diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 7f11fe7..63323c0 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -46,6 +46,7 @@ import { ParametresComponent } from './components/home/workspace/parametres/para
import { InfosComponent } from './components/home/workspace/infos/infos.component';
import { HoursComponent } from './components/home/workspace/hours/hours.component';
import { LogsComponent } from './components/home/workspace/logs/logs.component';
+import { ConfirmComponent } from './components/dialog/confirm/confirm.component';
@NgModule({
declarations: [
@@ -58,7 +59,8 @@ import { LogsComponent } from './components/home/workspace/logs/logs.component';
ParametresComponent,
InfosComponent,
HoursComponent,
- LogsComponent
+ LogsComponent,
+ ConfirmComponent
],
imports: [
BrowserModule,
diff --git a/src/app/components/dialog/confirm/confirm.component.css b/src/app/components/dialog/confirm/confirm.component.css
new file mode 100644
index 0000000..c4e5987
--- /dev/null
+++ b/src/app/components/dialog/confirm/confirm.component.css
@@ -0,0 +1,8 @@
+.mat-dialog-container {
+ background-color: lightblue;
+}
+
+.mat-raised-button {
+ margin-left: 1rem;
+ margin-right: 1rem;
+}
diff --git a/src/app/components/dialog/confirm/confirm.component.html b/src/app/components/dialog/confirm/confirm.component.html
new file mode 100644
index 0000000..ec8605c
--- /dev/null
+++ b/src/app/components/dialog/confirm/confirm.component.html
@@ -0,0 +1,8 @@
+
{{title}}
+
+ {{text}}
+
+
+
+
+
diff --git a/src/app/components/dialog/confirm/confirm.component.spec.ts b/src/app/components/dialog/confirm/confirm.component.spec.ts
new file mode 100644
index 0000000..eb385ba
--- /dev/null
+++ b/src/app/components/dialog/confirm/confirm.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ConfirmComponent } from './confirm.component';
+
+describe('ConfirmComponent', () => {
+ let component: ConfirmComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ConfirmComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ConfirmComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/components/dialog/confirm/confirm.component.ts b/src/app/components/dialog/confirm/confirm.component.ts
new file mode 100644
index 0000000..e783ffd
--- /dev/null
+++ b/src/app/components/dialog/confirm/confirm.component.ts
@@ -0,0 +1,31 @@
+import { Component, OnInit, Inject } from '@angular/core';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
+
+@Component({
+ selector: 'app-confirm',
+ templateUrl: './confirm.component.html',
+ styleUrls: ['./confirm.component.css']
+})
+export class ConfirmComponent implements OnInit {
+ title:string;
+ text:string;
+ labelOK: string;
+ labelNOK: string;
+
+ constructor(
+ @Inject(MAT_DIALOG_DATA) public data:any,
+ public dialogRef: MatDialogRef
+ ) {
+ this.title = data.title;
+ this.text = data.text;
+ this.labelOK = data.labelOK;
+ this.labelNOK = data.labelNOK;
+ }
+
+ ngOnInit(): void {
+ }
+
+ sendAnswer(val:boolean): void {
+ this.dialogRef.close(val);
+ }
+}
diff --git a/src/app/components/home/home.component.css b/src/app/components/home/home.component.css
index 4cffce0..45ce1f7 100644
--- a/src/app/components/home/home.component.css
+++ b/src/app/components/home/home.component.css
@@ -4,4 +4,6 @@
.menu-button {
padding: 0.5rem 1.5rem 0.2rem 0.5rem;
+ width: 100%;
+ text-align: start;
}
diff --git a/src/app/components/home/home.component.html b/src/app/components/home/home.component.html
index 0216a92..93f075a 100644
--- a/src/app/components/home/home.component.html
+++ b/src/app/components/home/home.component.html
@@ -20,27 +20,27 @@
-
-
+
+
diff --git a/src/app/components/home/workspace/infos/infos.component.ts b/src/app/components/home/workspace/infos/infos.component.ts
index 6c7b447..71f0f44 100644
--- a/src/app/components/home/workspace/infos/infos.component.ts
+++ b/src/app/components/home/workspace/infos/infos.component.ts
@@ -1,5 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
+import { MatDialog } from '@angular/material/dialog';
+import { ConfirmComponent } from '../../../dialog/confirm/confirm.component';
import { BackendService } from '../../../../services/backend/backend.service';
import { Info } from '../../../../models/info.model';
import { ToastrService } from 'ngx-toastr';
@@ -20,6 +22,7 @@ export class InfosComponent implements OnInit {
constructor( private bs:BackendService,
private router:Router,
+ public dialog: MatDialog,
private toast:ToastrService ) { }
ngOnInit(): void {
@@ -90,4 +93,37 @@ export class InfosComponent implements OnInit {
}
)
}
+
+ onShutdown():void {
+ var title:string = "Confirmation";
+ let text:string = "Voulez-vous arrêter le système ?";
+ const myDialog = this.dialog.open(ConfirmComponent, {
+ disableClose: true,
+ data: {
+ title: title,
+ text: text,
+ labelOK: 'Confirmer',
+ labelNOK: 'Annuler'
+ }
+ });
+
+ myDialog.afterClosed().subscribe(
+ data => {
+ if(data) {
+ this.bs.shutdownSys().subscribe(
+ data => {
+ this.toast.info("Arrêt du système ...");
+ this.router.navigateByUrl("/login");
+ }, err => {
+ if(err.status == 401) {
+ this.router.navigateByUrl("/login");
+ } else {
+ this.toast.error(err.error.description);
+ }
+ }
+ )
+ }
+ }
+ );
+ }
}
diff --git a/src/app/services/backend/backend.service.ts b/src/app/services/backend/backend.service.ts
index 05b0966..279bd3e 100644
--- a/src/app/services/backend/backend.service.ts
+++ b/src/app/services/backend/backend.service.ts
@@ -171,4 +171,15 @@ export class BackendService {
};
return this.http.post(host+"/api/configurateur/reboot", {}, options);
}
+
+ shutdownSys():Observable {
+ let host=environment.host;
+ const options = {
+ headers: new HttpHeaders({
+ 'Content-Type' : 'application/json',
+ }),
+ withCredentials: true
+ };
+ return this.http.post(host+"/api/configurateur/shutdown", {}, options);
+ }
}