diff --git a/package-lock.json b/package-lock.json
index 2a81204..5119fb4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10197,6 +10197,11 @@
"tslib": "^1.9.0"
}
},
+ "rxjs-compat": {
+ "version": "6.5.5",
+ "resolved": "https://registry.npmjs.org/rxjs-compat/-/rxjs-compat-6.5.5.tgz",
+ "integrity": "sha512-F42sssVbUyWH4vJswEo6m+Eh02xHv3q93n8S7nUJO58R7sbc3CvJIOts605zdaBhWa1xMB9aVSyqPqhQ5q3eXg=="
+ },
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
diff --git a/package.json b/package.json
index 23d4d96..4cb687b 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"@angular/router": "~9.1.6",
"bootstrap": "^3.3.7",
"rxjs": "~6.5.4",
+ "rxjs-compat": "^6.5.5",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
diff --git a/src/app/app.component.html b/src/app/app.component.html
index 474e8aa..5bd872a 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,20 +1,17 @@
+
-
Mes appareils
-
Mis à jour le : {{ lastUpdate | async | date: 'd MMMM y' | uppercase }}
-
-
-
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 846136d..6576cce 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,5 +1,4 @@
import {Component, OnInit} from '@angular/core';
-import { AppareilService } from './services/appareil.service';
@Component({
selector: 'app-root',
@@ -8,38 +7,9 @@ import { AppareilService } from './services/appareil.service';
})
export class AppComponent implements OnInit {
- isAuth = false;
- lastUpdate = new Promise((resolve, reject) => {
- const date = new Date();
- setTimeout(
- () => {
- resolve(date);
- }, 2000
- );
- });
- appareils: any[];
-
- constructor(private appareilService: AppareilService) {
- setTimeout(
- () => {
- this.isAuth = true;
- }, 4000
- );
- }
-
- ngOnInit() {
- this.appareils = this.appareilService.appareils;
- }
-
- onAllumer() {
- this.appareilService.switchOnAll();
- }
+ constructor() {
+ }
- onEteindre() {
- if (confirm('Etes-vous sûr de vouloir éteindre tous vos appareils ?')) {
- this.appareilService.switchOffAll();
- } else {
- return null;
+ ngOnInit() {
}
- }
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c9d2ca3..5d529b9 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -4,18 +4,41 @@ import { AppComponent } from './app.component';
import { AppareilComponent } from './appareil/appareil.component';
import { FormsModule } from '@angular/forms';
import { AppareilService } from './services/appareil.service';
+import { AuthComponent } from './auth/auth.component';
+import { AppareilViewComponent } from './appareil-view/appareil-view.component';
+import { RouterModule, Routes } from '@angular/router';
+import { AuthService } from './services/auth.service';
+import { SingleAppareilComponent } from './single-appareil/single-appareil.component';
+import { FourOhFourComponent } from './four-oh-four/four-oh-four.component';
+import { AuthGuard } from './services/auth-guard.service';
+
+const appRoutes: Routes = [
+ { path: 'appareils', canActivate: [AuthGuard], component: AppareilViewComponent },
+ { path: 'appareils/:id', canActivate: [AuthGuard], component: SingleAppareilComponent },
+ { path: 'auth', component: AuthComponent },
+ { path: '', component: AuthComponent },
+ { path: 'not-found', component: FourOhFourComponent },
+ { path: '**', redirectTo: 'not-found' }
+];
@NgModule({
declarations: [
AppComponent,
- AppareilComponent
+ AppareilComponent,
+ AuthComponent,
+ AppareilViewComponent,
+ SingleAppareilComponent,
+ FourOhFourComponent
],
imports: [
BrowserModule,
- FormsModule
+ FormsModule,
+ RouterModule.forRoot(appRoutes)
],
providers: [
- AppareilService
+ AppareilService,
+ AuthService,
+ AuthGuard
],
bootstrap: [AppComponent]
})
diff --git a/src/app/appareil-view/appareil-view.component.html b/src/app/appareil-view/appareil-view.component.html
new file mode 100644
index 0000000..11dfa70
--- /dev/null
+++ b/src/app/appareil-view/appareil-view.component.html
@@ -0,0 +1,19 @@
+
+
+
+
Mes appareils
+
Mis à jour le : {{ lastUpdate | async | date: 'd MMMM y' | uppercase }}
+
+
+
+
+
+
diff --git a/src/app/appareil-view/appareil-view.component.scss b/src/app/appareil-view/appareil-view.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/appareil-view/appareil-view.component.ts b/src/app/appareil-view/appareil-view.component.ts
new file mode 100644
index 0000000..9c9867c
--- /dev/null
+++ b/src/app/appareil-view/appareil-view.component.ts
@@ -0,0 +1,45 @@
+import { Component, OnInit } from '@angular/core';
+import { AppareilService } from '../services/appareil.service';
+
+@Component({
+ selector: 'app-appareil-view',
+ templateUrl: './appareil-view.component.html',
+ styleUrls: ['./appareil-view.component.scss']
+})
+export class AppareilViewComponent implements OnInit {
+
+ isAuth = false;
+ appareils: any[];
+
+ lastUpdate = new Promise((resolve, reject) => {
+ const date = new Date();
+ setTimeout(
+ () => {
+ resolve(date);
+ }, 2000
+ );
+ });
+
+ constructor(private appareilService: AppareilService) {
+ setTimeout(() => {
+ this.isAuth = true;
+ }, 3000);
+ }
+
+ ngOnInit() {
+ this.appareils = this.appareilService.appareils;
+ }
+
+ onAllumer() {
+ this.appareilService.switchOnAll();
+ }
+
+ onEteindre() {
+ if (confirm('Etes-vous sûr de vouloir éteindre tous vos appareils ?')) {
+ this.appareilService.switchOffAll();
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/src/app/appareil/appareil.component.html b/src/app/appareil/appareil.component.html
index de0a6c0..6463b62 100644
--- a/src/app/appareil/appareil.component.html
+++ b/src/app/appareil/appareil.component.html
@@ -3,6 +3,7 @@
'list-group-item-danger': appareilStatus === 'éteint'}">
Appareil : {{ appareilName }} -- Statut : {{ appareilStatus }}
+ Détail