feat: Added menu items and account security to settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<mat-accordion>
|
||||
<!-- #region Rooms-->
|
||||
<mat-expansion-panel>
|
||||
<!-- TODO: Make more ergonomic -->
|
||||
<mat-expansion-panel-header>
|
||||
@@ -8,6 +9,8 @@
|
||||
<p>Kliknij listę aby edytować</p>
|
||||
<app-list-editor [converter]="usettings.rooms" (edit)="saveRoom($event)"></app-list-editor>
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
<!-- #region Room grade reasons-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Powody nieczystości</mat-panel-title>
|
||||
@@ -16,6 +19,8 @@
|
||||
<p>Kliknij listę aby edytować</p>
|
||||
<app-list-editor [list]="usettings.cleanThings" (edit)="saveCleanThings($event)"></app-list-editor>
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
<!-- #region Key rooms-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Sale z kluczami</mat-panel-title>
|
||||
@@ -23,6 +28,68 @@
|
||||
</mat-expansion-panel-header>
|
||||
<app-list-editor [list]="usettings.keyrooms" (edit)="saveKeyrooms($event)"></app-list-editor>
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
<!-- #region Default menu items-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Domyślne wpisy jadłospisu</mat-panel-title>
|
||||
<mat-panel-description></mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<table>
|
||||
<caption>Domyślne wpisy w jadłospisie dla danych pozycji</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Śniadanie</th>
|
||||
<th>Kolacja</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<app-list-editor [list]="usettings.menu.defaultItems.sn" (edit)="saveSn($event)"/>
|
||||
</td>
|
||||
<td>
|
||||
<app-list-editor [list]="usettings.menu.defaultItems.kol" (edit)="saveKol($event)"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
<!-- #region Security-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Bezpieczeństwo</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<mat-tab-group color="accent">
|
||||
<mat-tab label="Konta">
|
||||
<p>
|
||||
Domyślne hasło użytkownika po wygenerowaniu konto to <code>pierwszelogowanie</code><br>
|
||||
Reset hasła powoduje zmianę na <code>reset</code>
|
||||
</p>
|
||||
<form [formGroup]="accSec" (submit)="saveAccSecTimeouts()">
|
||||
<p>Ograniczenia logowania</p>
|
||||
<mat-form-field color="accent">
|
||||
<mat-label>Dozwolone próby logowania</mat-label>
|
||||
<input matInput type="number" formControlName="attempts">
|
||||
</mat-form-field><br>
|
||||
<mat-form-field color="accent">
|
||||
<mat-label>Okres liczenia prób</mat-label>
|
||||
<input matInput type="number" formControlName="time">
|
||||
<mat-hint>Podaj w minutach</mat-hint>
|
||||
</mat-form-field><br>
|
||||
<mat-form-field color="accent">
|
||||
<mat-label>Czas blokady konta</mat-label>
|
||||
<input matInput type="number" formControlName="lockout">
|
||||
<mat-hint>Podaj w minutach</mat-hint>
|
||||
</mat-form-field><br>
|
||||
<button mat-flat-button color="accent">Zapisz</button>
|
||||
</form>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
<!-- #region Program control-->
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Sterowanie programem</mat-panel-title>
|
||||
@@ -41,4 +108,5 @@
|
||||
Wyloguj wszystkich użytkowników
|
||||
</button> -->
|
||||
</mat-expansion-panel>
|
||||
<!-- #endregion -->
|
||||
</mat-accordion>
|
||||
@@ -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,6 +40,35 @@ 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) {
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<StartComponent>;
|
||||
let component: StartAdminComponent;
|
||||
let fixture: ComponentFixture<StartAdminComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [StartComponent]
|
||||
declarations: [StartAdminComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(StartComponent);
|
||||
fixture = TestBed.createComponent(StartAdminComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user