Team crud Ok connection Back Ok
This commit is contained in:
parent
ae1fc13951
commit
e53a9a062d
9 changed files with 60 additions and 133 deletions
|
@ -15,7 +15,6 @@ import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.com
|
||||||
import { PageRepertoireComponent } from './pages/page-repertoire/page-repertoire.component';
|
import { PageRepertoireComponent } from './pages/page-repertoire/page-repertoire.component';
|
||||||
import { PageResetPasswordComponent } from './pages/page-reset-password/page-reset-password.component';
|
import { PageResetPasswordComponent } from './pages/page-reset-password/page-reset-password.component';
|
||||||
import { PageSignupComponent } from './pages/page-signup/page-signup.component';
|
import { PageSignupComponent } from './pages/page-signup/page-signup.component';
|
||||||
import { PageTestFormComponent } from './pages/page-test-form/page-test-form.component';
|
|
||||||
import { PageToDoListComponent } from './pages/page-to-do-list/page-to-do-list.component';
|
import { PageToDoListComponent } from './pages/page-to-do-list/page-to-do-list.component';
|
||||||
import { PageUpdateMemberComponent } from './pages/page-update-member/page-update-member.component';
|
import { PageUpdateMemberComponent } from './pages/page-update-member/page-update-member.component';
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,10 @@ import { HttpClientModule } from '@angular/common/http';
|
||||||
import { PageAjoutContactComponent } from './pages/page-ajout-contact/page-ajout-contact.component';
|
import { PageAjoutContactComponent } from './pages/page-ajout-contact/page-ajout-contact.component';
|
||||||
import { PageModifierContactComponent } from './pages/page-modifier-contact/page-modifier-contact.component';
|
import { PageModifierContactComponent } from './pages/page-modifier-contact/page-modifier-contact.component';
|
||||||
import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component';
|
import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component';
|
||||||
<<<<<<< HEAD
|
|
||||||
import { PageTestFormComponent } from './pages/page-test-form/page-test-form.component';
|
|
||||||
=======
|
|
||||||
import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
>>>>>>> 5c7e4662b2e3c8af6778c79d1b56aa66a0fdf0a1
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -79,11 +75,6 @@ import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
||||||
PageAjoutContactComponent,
|
PageAjoutContactComponent,
|
||||||
PageModifierContactComponent,
|
PageModifierContactComponent,
|
||||||
PageCreationTeamComponent,
|
PageCreationTeamComponent,
|
||||||
<<<<<<< HEAD
|
|
||||||
PageTestFormComponent,
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> 5c7e4662b2e3c8af6778c79d1b56aa66a0fdf0a1
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Team } from 'src/app/models/team';
|
import { Team } from 'src/app/models/team';
|
||||||
import { AuthService } from '../../services/auth.service';
|
import { TeamService } from 'src/app/services/team.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-creation-team',
|
selector: 'app-page-creation-team',
|
||||||
|
@ -17,7 +17,7 @@ import { AuthService } from '../../services/auth.service';
|
||||||
export class PageCreationTeamComponent implements OnInit {
|
export class PageCreationTeamComponent implements OnInit {
|
||||||
public teamForm: FormGroup;
|
public teamForm: FormGroup;
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private teamService: TeamService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private fb: FormBuilder
|
private fb: FormBuilder
|
||||||
) {
|
) {
|
||||||
|
@ -43,7 +43,7 @@ export class PageCreationTeamComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
if (team.nom !== '' ) {
|
if (team.nom !== '' ) {
|
||||||
this.authService.creationTeam(team).subscribe((resp) => {
|
this.teamService.addTeam(team).subscribe((resp) => {
|
||||||
this.router.navigate(['compte']);
|
this.router.navigate(['compte']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
<p>page-test-form works!</p>
|
|
||||||
<app-header></app-header>
|
|
||||||
<div class="signup-form text-center">
|
|
||||||
<main class="form-signup">
|
|
||||||
<form (ngSubmit)="onSubmit()" [formGroup]="signupForm">
|
|
||||||
<h1>Incrivez-vous !</h1>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="text"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInputlastName"
|
|
||||||
placeholder=""
|
|
||||||
name="lastName"
|
|
||||||
formControlName="lastNameFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['lastNameFc'].touched && signupForm.controls['lastNameFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['lastNameFc'].touched && !signupForm.controls['lastNameFc'].valid}">
|
|
||||||
<label for="floatingInputlastName">Nom</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="text"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInputfirstName"
|
|
||||||
placeholder=""
|
|
||||||
name="firstName"
|
|
||||||
formControlName="firstNameFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['firstNameFc'].touched && signupForm.controls['firstNameFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['firstNameFc'].touched && !signupForm.controls['firstNameFc'].valid}">
|
|
||||||
<label for="floatingInputfirstName">Prénom</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="date"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInputdateNaissance"
|
|
||||||
placeholder=""
|
|
||||||
name="dateNaissance"
|
|
||||||
formControlName="dateNaissanceFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['dateNaissanceFc'].touched && signupForm.controls['dateNaissanceFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['dateNaissanceFc'].touched && !signupForm.controls['dateNaissanceFc'].valid}">
|
|
||||||
<label for="floatingInputfirstName">Date de naissance</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="email"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingInput"
|
|
||||||
placeholder=""
|
|
||||||
name="email"
|
|
||||||
formControlName="emailFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['emailFc'].touched && signupForm.controls['emailFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['emailFc'].touched && !signupForm.controls['emailFc'].valid}">
|
|
||||||
<label for="floatingInput">Adresse email</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="password"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingPassword"
|
|
||||||
placeholder=""
|
|
||||||
name="password"
|
|
||||||
formControlName="passwordFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['passwordFc'].touched && signupForm.controls['passwordFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['passwordFc'].touched && !signupForm.controls['passwordFc'].valid}">
|
|
||||||
<label for="floatingPassword">Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="passwordConfirm"
|
|
||||||
class="form-control"
|
|
||||||
id="floatingpasswordConfirm"
|
|
||||||
placeholder=""
|
|
||||||
name="passwordConfirm"
|
|
||||||
formControlName="passwordConfirmFc"
|
|
||||||
[ngClass]="{'is-valid' : signupForm.controls['passwordConfirmFc'].touched && signupForm.controls['passwordConfirmFc'].valid,
|
|
||||||
'is-invalid': signupForm.controls['passwordConfirmFc'].touched && !signupForm.controls['passwordConfirmFc'].valid}">
|
|
||||||
<label for="floatingPassword">Confirmer mot de passe</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="w-100 btn btn-lg btn-success"
|
|
||||||
type="submit"
|
|
||||||
[disabled]="signupForm.invalid">Je m'inscris !</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { PageTestFormComponent } from './page-test-form.component';
|
|
||||||
|
|
||||||
describe('PageTestFormComponent', () => {
|
|
||||||
let component: PageTestFormComponent;
|
|
||||||
let fixture: ComponentFixture<PageTestFormComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ PageTestFormComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(PageTestFormComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-page-test-form',
|
|
||||||
templateUrl: './page-test-form.component.html',
|
|
||||||
styleUrls: ['./page-test-form.component.scss']
|
|
||||||
})
|
|
||||||
export class PageTestFormComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
16
src/app/services/team.service.spec.ts
Normal file
16
src/app/services/team.service.spec.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { TeamService } from '../services/team.service';
|
||||||
|
|
||||||
|
describe('TeamService', () => {
|
||||||
|
let service: TeamService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(TeamService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
41
src/app/services/team.service.ts
Normal file
41
src/app/services/team.service.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
import { Team } from '../models/team';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class TeamService {
|
||||||
|
apiUrl: string;
|
||||||
|
tokenKey: string;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) {
|
||||||
|
this.apiUrl = environment.apiUrl;
|
||||||
|
this.tokenKey = environment.tokenKey;
|
||||||
|
}
|
||||||
|
getTeams(): Observable<any> {
|
||||||
|
return this.http.get(`${this.apiUrl}/teams/all`);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTeamById(id: any): Observable<any> {
|
||||||
|
return this.http.get(`${this.apiUrl}/teams/1` + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
addTeam(team: Team): Observable<any> {
|
||||||
|
console.log(team);
|
||||||
|
|
||||||
|
return this.http.post(`${this.apiUrl}/teams/add`, team);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteTeam(team: Team): Observable<any> {
|
||||||
|
return this.http.delete(`${this.apiUrl}/teams/delete/1`);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTeam(team: Team): Observable<any> {
|
||||||
|
return this.http.put(`${this.apiUrl}/teams/update/1`, team);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue