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:
parent
f464c5c91e
commit
2d771484ff
@ -1,7 +1,7 @@
|
|||||||
<h4 mat-dialog-title [innerHtml]="data.title | safeHtml"></h4>
|
<h4 mat-dialog-title [innerHtml]="data.title | safeHtml"></h4>
|
||||||
<mat-dialog-content [innerHTML]="data.body | safeHtml"></mat-dialog-content>
|
<mat-dialog-content [innerHTML]="data.body | safeHtml"></mat-dialog-content>
|
||||||
<mat-dialog-actions>
|
<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===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)="resolver(true); close()"><uds-translate>Yes</uds-translate></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)="resolver(false); close()"><uds-translate>No</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>
|
</mat-dialog-actions>
|
||||||
|
@ -23,18 +23,21 @@ export interface ModalData {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'uds-modal',
|
selector: 'uds-modal',
|
||||||
templateUrl: './modal.component.html',
|
templateUrl: './modal.component.html',
|
||||||
styleUrls: ['./modal.component.css']
|
styleUrls: ['./modal.component.css'],
|
||||||
})
|
})
|
||||||
|
|
||||||
export class ModalComponent implements OnInit {
|
export class ModalComponent implements OnInit {
|
||||||
extra = '';
|
extra = '';
|
||||||
subscription: Subscription | null = null;
|
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) {
|
constructor(public dialogRef: MatDialogRef<ModalComponent>, @Inject(MAT_DIALOG_DATA) public data: ModalData) {
|
||||||
// Notifies on case of yes or not to subscriber
|
// Notifies on case of yes or not to subscriber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolveAndClose(value: boolean): void {
|
||||||
|
this.resolver(value);
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
resolver: (value: boolean) => void = () => {};
|
resolver: (value: boolean) => void = () => {};
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
@ -51,13 +54,13 @@ export class ModalComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initAlert(): Promise<void> {
|
async initAlert(): Promise<void> {
|
||||||
const autoclose = (this.data.autoclose || 0);
|
const autoclose = this.data.autoclose || 0;
|
||||||
if (autoclose > 0) {
|
if (autoclose > 0) {
|
||||||
this.dialogRef.afterClosed().subscribe(res => {
|
this.dialogRef.afterClosed().subscribe((res) => {
|
||||||
this.close();
|
this.close();
|
||||||
});
|
});
|
||||||
this.setExtra(autoclose);
|
this.setExtra(autoclose);
|
||||||
interval(1000).subscribe(n => {
|
interval(1000).subscribe((n) => {
|
||||||
const rem = autoclose - (n + 1) * 1000;
|
const rem = autoclose - (n + 1) * 1000;
|
||||||
this.setExtra(rem);
|
this.setExtra(rem);
|
||||||
if (rem <= 0) {
|
if (rem <= 0) {
|
||||||
@ -68,11 +71,8 @@ export class ModalComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if ( this.data.type === DialogType.yesno ) {
|
if (this.data.type === DialogType.alert) {
|
||||||
;
|
|
||||||
} else {
|
|
||||||
this.initAlert();
|
this.initAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user