mirror of
https://github.com/google/nomulus.git
synced 2025-08-21 00:34:42 +02:00
Add settings to console home page, update settings->security styles (#2144)
This commit is contained in:
parent
6c18ea9cff
commit
5eb44c165c
14 changed files with 156 additions and 77 deletions
|
@ -13,9 +13,14 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { SecurityService, SecuritySettings } from './security.service';
|
||||
import {
|
||||
SecurityService,
|
||||
SecuritySettings,
|
||||
apiToUiConverter,
|
||||
} from './security.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { RegistrarService } from 'src/app/registrar/registrar.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-security',
|
||||
|
@ -30,33 +35,19 @@ export default class SecurityComponent {
|
|||
|
||||
constructor(
|
||||
public securityService: SecurityService,
|
||||
private _snackBar: MatSnackBar
|
||||
private _snackBar: MatSnackBar,
|
||||
public registrarService: RegistrarService
|
||||
) {
|
||||
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;
|
||||
},
|
||||
});
|
||||
this.dataSource = apiToUiConverter(this.registrarService.registrar);
|
||||
}
|
||||
|
||||
enableEdit() {
|
||||
this.inEdit = true;
|
||||
this.dataSource = JSON.parse(
|
||||
JSON.stringify(this.securityService.securitySettings)
|
||||
);
|
||||
}
|
||||
|
||||
disableEdit() {
|
||||
cancel() {
|
||||
this.inEdit = false;
|
||||
this.dataSource = this.securityService.securitySettings;
|
||||
this.resetDataSource();
|
||||
}
|
||||
|
||||
createIpEntry() {
|
||||
|
@ -68,7 +59,7 @@ export default class SecurityComponent {
|
|||
this.securityService.saveChanges(this.dataSource).subscribe({
|
||||
complete: () => {
|
||||
this.loading = false;
|
||||
this.dataSource = this.securityService.securitySettings;
|
||||
this.resetDataSource();
|
||||
},
|
||||
error: (err: HttpErrorResponse) => {
|
||||
this._snackBar.open(err.error, undefined, {
|
||||
|
@ -76,16 +67,15 @@ export default class SecurityComponent {
|
|||
});
|
||||
},
|
||||
});
|
||||
this.disableEdit();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.dataSource = this.securityService.securitySettings;
|
||||
this.inEdit = false;
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
removeIpEntry(index: number) {
|
||||
this.dataSource.ipAddressAllowList =
|
||||
this.dataSource.ipAddressAllowList?.filter((_, i) => i != index);
|
||||
}
|
||||
|
||||
resetDataSource() {
|
||||
this.dataSource = apiToUiConverter(this.registrarService.registrar);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue