Skip to content

Commit 7a47929

Browse files
author
majid noureddine
committed
create form to add new appareils
1 parent aef2b5d commit 7a47929

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<ul class="nav navbar-nav">
55
<li routerLinkActive="active"><a routerLink="auth">Authentification</a></li>
66
<li routerLinkActive="active"><a routerLink="appareils">Appareils</a></li>
7+
<li routerLinkActive="active"><a routerLink="edit">Nouvel appareil</a></li>
78
</ul>
89
<div class="navbar-right">
910
<p>Vous êtes connecté depuis {{ secondes }} secondes !</p>

src/app/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import { AuthService } from './services/auth.service';
1111
import { SingleAppareilComponent } from './single-appareil/single-appareil.component';
1212
import { FourOhFourComponent } from './four-oh-four/four-oh-four.component';
1313
import { AuthGuard } from './services/auth-guard.service';
14+
import { EditAppareilComponent } from './edit-appareil/edit-appareil.component';
1415

1516
const appRoutes: Routes = [
1617
{ path: 'appareils', canActivate: [AuthGuard], component: AppareilViewComponent },
1718
{ path: 'appareils/:id', canActivate: [AuthGuard], component: SingleAppareilComponent },
19+
{ path: 'edit', canActivate: [AuthGuard], component: EditAppareilComponent },
1820
{ path: 'auth', component: AuthComponent },
1921
{ path: '', component: AuthComponent },
2022
{ path: 'not-found', component: FourOhFourComponent },
@@ -28,7 +30,8 @@ const appRoutes: Routes = [
2830
AuthComponent,
2931
AppareilViewComponent,
3032
SingleAppareilComponent,
31-
FourOhFourComponent
33+
FourOhFourComponent,
34+
EditAppareilComponent
3235
],
3336
imports: [
3437
BrowserModule,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="row">
2+
<div class="col-sm-8 col-sm-offset-2">
3+
<form (ngSubmit)="onSubmit(f)" #f="ngForm">
4+
<div class="form-group">
5+
<label for="name">
6+
Nom de l'appareil
7+
</label>
8+
<input type="text" id="name" class="form-control" name="name" ngModel>
9+
</div>
10+
<div class="form-group">
11+
<label for="status">
12+
État de l'appareil
13+
</label>
14+
<select id="status" class="form-control" name="status" ngModel>
15+
<option value="allumé">Allumé</option>
16+
<option value="éteint">Éteint</option>
17+
</select>
18+
</div>
19+
<button class="btn btn-primary" type="submit">Enregistrer</button>
20+
</form>
21+
</div>
22+
</div>

src/app/edit-appareil/edit-appareil.component.scss

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { NgForm } from '@angular/forms';
3+
4+
@Component({
5+
selector: 'app-edit-appareil',
6+
templateUrl: './edit-appareil.component.html',
7+
styleUrls: ['./edit-appareil.component.scss']
8+
})
9+
export class EditAppareilComponent implements OnInit {
10+
11+
constructor() { }
12+
13+
ngOnInit(): void {
14+
}
15+
16+
onSubmit(form: NgForm) {
17+
console.log(form.value);
18+
}
19+
}

0 commit comments

Comments
 (0)