Add Console Settings -> Security front-end (#2079)

This commit is contained in:
Pavlo Tkach 2023-07-26 12:50:31 -04:00 committed by GitHub
parent 9873772150
commit 9b17adcb28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 545 additions and 21 deletions

View file

@ -13,10 +13,79 @@
// limitations under the License.
import { Component } from '@angular/core';
import { SecurityService, SecuritySettings } from './security.service';
import { HttpErrorResponse } from '@angular/common/http';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-security',
templateUrl: './security.component.html',
styleUrls: ['./security.component.less'],
providers: [SecurityService],
})
export default class SecurityComponent {}
export default class SecurityComponent {
loading: boolean = false;
inEdit: boolean = false;
dataSource: SecuritySettings = {};
constructor(
public securityService: SecurityService,
private _snackBar: MatSnackBar
) {
this.loading = true;
this.securityService.fetchSecurityDetails().subscribe({
complete: () => {
this.dataSource = this.securityService.securitySettings;
this.loading = false;
},
error: (err: HttpErrorResponse) => {
this._snackBar.open(err.error, undefined, {
duration: 1500,
});
this.loading = false;
},
});
}
enableEdit() {
this.inEdit = true;
this.dataSource = JSON.parse(
JSON.stringify(this.securityService.securitySettings)
);
}
disableEdit() {
this.inEdit = false;
this.dataSource = this.securityService.securitySettings;
}
createIpEntry() {
this.dataSource.ipAddressAllowList?.push({ value: '' });
}
save() {
this.loading = true;
this.securityService.saveChanges(this.dataSource).subscribe({
complete: () => {
this.loading = false;
this.dataSource = this.securityService.securitySettings;
},
error: (err: HttpErrorResponse) => {
this._snackBar.open(err.error, undefined, {
duration: 1500,
});
},
});
this.disableEdit();
}
cancel() {
this.dataSource = this.securityService.securitySettings;
this.inEdit = false;
}
removeIpEntry(index: number) {
this.dataSource.ipAddressAllowList =
this.dataSource.ipAddressAllowList?.filter((_, i) => i != index);
}
}