diff --git a/src/app/admin-view/settings/settings.component.html b/src/app/admin-view/settings/settings.component.html index 65b3708..9c4f03e 100644 --- a/src/app/admin-view/settings/settings.component.html +++ b/src/app/admin-view/settings/settings.component.html @@ -1,4 +1,5 @@ + @@ -8,6 +9,8 @@

Kliknij listę aby edytować

+ + Powody nieczystości @@ -16,6 +19,8 @@

Kliknij listę aby edytować

+ + Sale z kluczami @@ -23,6 +28,68 @@ + + + + + Domyślne wpisy jadłospisu + + + + + + + + + + + + + + + + +
Domyślne wpisy w jadłospisie dla danych pozycji
ŚniadanieKolacja
+ + + +
+
+ + + + + Bezpieczeństwo + + + +

+ Domyślne hasło użytkownika po wygenerowaniu konto to pierwszelogowanie
+ Reset hasła powoduje zmianę na reset +

+
+

Ograniczenia logowania

+ + Dozwolone próby logowania + +
+ + Okres liczenia prób + + Podaj w minutach +
+ + Czas blokady konta + + Podaj w minutach +
+ +
+
+
+
+ + Sterowanie programem @@ -41,4 +108,5 @@ Wyloguj wszystkich użytkowników --> +
\ No newline at end of file diff --git a/src/app/admin-view/settings/settings.component.ts b/src/app/admin-view/settings/settings.component.ts index c16c921..11b2d36 100644 --- a/src/app/admin-view/settings/settings.component.ts +++ b/src/app/admin-view/settings/settings.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { AdminCommService } from '../admin-comm.service'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { FormBuilder } from '@angular/forms'; @Component({ selector: 'app-settings', @@ -11,10 +12,18 @@ export class SettingsComponent implements OnInit { usettings!: IUSettings reloadTimeout: boolean = false; - constructor (private readonly acu: AdminCommService, private readonly sb: MatSnackBar) { } + constructor (private readonly acu: AdminCommService, private readonly sb: MatSnackBar, private readonly fb: FormBuilder) { } + + accSec = this.fb.nonNullable.group({ + attempts: this.fb.nonNullable.control(1), + time: this.fb.nonNullable.control(1), + lockout: this.fb.nonNullable.control(1), + }) + ngOnInit(): void { this.acu.settings.getAll().subscribe((r) => { this.usettings = r + this.accSecTimeouts = r.security.loginTimeout }) } @@ -31,10 +40,39 @@ export class SettingsComponent implements OnInit { this.send() } + saveSn(event: string[]) { + this.usettings.menu.defaultItems.sn = event + this.send() + } + saveKol(event: string[]) { + this.usettings.menu.defaultItems.kol = event + this.send() + } + + saveAccSecTimeouts() { + this.usettings.security.loginTimeout = this.accSecTimeouts + this.send() + } + + set accSecTimeouts(value: IUSettings['security']['loginTimeout']) { + this.accSec.setValue({ + attempts: value.attempts, + lockout: value.lockout / 60, + time: value.time / 60 + }) + } + get accSecTimeouts(): IUSettings['security']['loginTimeout'] { + return { + attempts: this.accSec.controls['attempts'].value, + lockout: this.accSec.controls['lockout'].value * 60, + time: this.accSec.controls['time'].value * 60 + } + } + send() { this.acu.settings.post(this.usettings).subscribe((s) => { if (s.status == 200) { - this.sb.open("Zapisano!", undefined, {duration: 1000}) + this.sb.open("Zapisano!", undefined, { duration: 1000 }) } else { console.error(s); } @@ -51,7 +89,7 @@ export class SettingsComponent implements OnInit { }, 5000); this.acu.settings.reload().subscribe((s) => { if (s.status == 200) { - this.sb.open("Przeładowano ustawienia!", undefined, {duration: 3000}) + this.sb.open("Przeładowano ustawienia!", undefined, { duration: 3000 }) } else { console.error(s); } @@ -63,4 +101,17 @@ export interface IUSettings { keyrooms: string[]; rooms: string[]; cleanThings: string[]; + menu: { + defaultItems: { + sn: string[]; + kol: string[]; + } + }; + security: { + loginTimeout: { + attempts: number; + time: number; + lockout: number; + } + } } \ No newline at end of file diff --git a/src/app/admin-view/start/start.component.spec.ts b/src/app/admin-view/start/start.component.spec.ts index 32701e4..2865fd0 100644 --- a/src/app/admin-view/start/start.component.spec.ts +++ b/src/app/admin-view/start/start.component.spec.ts @@ -1,18 +1,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { StartComponent } from './start.component'; +import { StartAdminComponent } from './start.component'; describe('StartComponent', () => { - let component: StartComponent; - let fixture: ComponentFixture; + let component: StartAdminComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [StartComponent] + declarations: [StartAdminComponent] }) .compileComponents(); - fixture = TestBed.createComponent(StartComponent); + fixture = TestBed.createComponent(StartAdminComponent); component = fixture.componentInstance; fixture.detectChanges(); });