1
0
mirror of https://github.com/dkmstr/openuds-gui.git synced 2024-10-26 08:55:23 +03:00

small modal fix

This commit is contained in:
Adolfo Gómez García 2023-01-15 21:27:23 +01:00
parent f464c5c91e
commit 2d771484ff
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 13 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<h4 mat-dialog-title [innerHtml]="data.title | safeHtml"></h4>
<mat-dialog-content [innerHTML]="data.body | safeHtml"></mat-dialog-content>
<mat-dialog-actions>
<button *ngIf="data.type===0" mat-raised-button mat-dialog-close (click)="resolver(false); close()"> <uds-translate>Close</uds-translate>{{ extra }}</button>
<button *ngIf="data.type===1" mat-raised-button mat-dialog-close (click)="resolver(true); close()"><uds-translate>Yes</uds-translate></button>
<button *ngIf="data.type===1" mat-raised-button mat-dialog-close (click)="resolver(false); close()"><uds-translate>No</uds-translate></button>
<button *ngIf="data.type===0" mat-raised-button mat-dialog-close (click)="resolveAndClose(false)"> <uds-translate>Close</uds-translate>{{ extra }}</button>
<button *ngIf="data.type===1" mat-raised-button mat-dialog-close (click)="resolveAndClose(true)"><uds-translate>Yes</uds-translate></button>
<button *ngIf="data.type===1" mat-raised-button mat-dialog-close (click)="resolveAndClose(false)"><uds-translate>No</uds-translate></button>
</mat-dialog-actions>

View File

@ -23,18 +23,21 @@ export interface ModalData {
@Component({
selector: 'uds-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
styleUrls: ['./modal.component.css'],
})
export class ModalComponent implements OnInit {
extra = '';
subscription: Subscription | null = null;
yesno: Promise<boolean> = new Promise<boolean>((resolve) => this.resolver = resolve);
yesno: Promise<boolean> = new Promise<boolean>((resolve) => (this.resolver = resolve));
constructor(public dialogRef: MatDialogRef<ModalComponent>, @Inject(MAT_DIALOG_DATA) public data: ModalData) {
// Notifies on case of yes or not to subscriber
}
resolveAndClose(value: boolean): void {
this.resolver(value);
this.close();
}
resolver: (value: boolean) => void = () => {};
close() {
@ -51,13 +54,13 @@ export class ModalComponent implements OnInit {
}
async initAlert(): Promise<void> {
const autoclose = (this.data.autoclose || 0);
const autoclose = this.data.autoclose || 0;
if (autoclose > 0) {
this.dialogRef.afterClosed().subscribe(res => {
this.dialogRef.afterClosed().subscribe((res) => {
this.close();
});
this.setExtra(autoclose);
interval(1000).subscribe(n => {
interval(1000).subscribe((n) => {
const rem = autoclose - (n + 1) * 1000;
this.setExtra(rem);
if (rem <= 0) {
@ -68,11 +71,8 @@ export class ModalComponent implements OnInit {
}
ngOnInit() {
if ( this.data.type === DialogType.yesno ) {
;
} else {
if (this.data.type === DialogType.alert) {
this.initAlert();
}
}
}