2022-12-16 08:59:48 +01:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
ViewEncapsulation,
|
|
|
|
ComponentRef,
|
|
|
|
ElementRef,
|
|
|
|
Input,
|
|
|
|
EventEmitter,
|
|
|
|
Output,
|
|
|
|
ViewChild
|
|
|
|
} from '@angular/core';
|
|
|
|
declare var UIkit: any;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'modal-loading',
|
|
|
|
template: `
|
2023-07-28 10:16:30 +02:00
|
|
|
<div #loading_element [class.uk-modal]="!isMobile" [class.uk-modal-full]="isMobile" [id]="id" uk-modal="container: #modal-container; bg-close:false; ">
|
|
|
|
<div class="uk-modal-dialog">
|
|
|
|
<div *ngIf="isMobile" #header class="uk-modal-header uk-flex uk-flex-middle" [ngClass]="classTitle">
|
|
|
|
<div [class.uk-invisible]="!title"
|
|
|
|
class="uk-width-expand uk-padding-small uk-padding-remove-vertical uk-flex uk-flex-center">
|
|
|
|
<h4 class="uk-margin-remove">{{title}}</h4>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div #body class="uk-modal-body" [class.uk-overflow-auto]="isMobile">
|
|
|
|
<div [class.uk-container]="isMobile" [class.uk-height-1-1]="isMobile">
|
2019-07-23 14:23:12 +02:00
|
|
|
<h4 class="text-center" >{{message}}</h4>
|
2023-02-21 23:09:12 +01:00
|
|
|
<loading></loading>
|
2020-03-24 16:40:51 +01:00
|
|
|
<ng-content></ng-content>
|
2017-12-19 13:53:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2023-02-21 23:09:12 +01:00
|
|
|
</div>
|
2023-07-28 10:16:30 +02:00
|
|
|
`,
|
2017-12-19 13:53:46 +01:00
|
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
})
|
|
|
|
/**
|
|
|
|
* API to an open alert window.
|
|
|
|
*/
|
|
|
|
export class ModalLoading{
|
2022-12-16 08:59:48 +01:00
|
|
|
private static MODAL_LOADING_COUNTER: number = 0;
|
|
|
|
|
|
|
|
id: string = "modal-loading";
|
2023-02-21 23:09:12 +01:00
|
|
|
title: string;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2023-02-21 23:09:12 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
|
|
|
@Input() classTitle: string = "uk-background-primary uk-light";
|
|
|
|
@Input() public message:string ="Loading";
|
2022-12-16 08:59:48 +01:00
|
|
|
@ViewChild('loading_element') element: ElementRef;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* if the value is true alert will be visible or else it will be hidden.
|
|
|
|
*/
|
2022-12-16 08:59:48 +01:00
|
|
|
// public isOpen:boolean=false;
|
2017-12-19 13:53:46 +01:00
|
|
|
/**
|
|
|
|
* Emitted when a ok button was clicked
|
|
|
|
* or when Ok method is called.
|
|
|
|
*/
|
|
|
|
@Output() public alertOutput:EventEmitter<any> = new EventEmitter();
|
2022-12-16 08:59:48 +01:00
|
|
|
constructor( public _elementRef: ElementRef){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ModalLoading.MODAL_LOADING_COUNTER++;
|
|
|
|
this.id = 'modal-loading-' + ModalLoading.MODAL_LOADING_COUNTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
if(typeof document !== "undefined") {
|
2022-12-16 16:21:37 +01:00
|
|
|
const element = document.getElementById("modal-container");
|
2022-12-16 08:59:48 +01:00
|
|
|
for (let i = element.childNodes.length - 1; i >= 0; --i) {
|
|
|
|
let child: ChildNode = element.childNodes[i];
|
|
|
|
if (child['id'] == this.id) {
|
|
|
|
child.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
/**
|
|
|
|
* Opens a alert window creating backdrop.
|
|
|
|
*/
|
|
|
|
open(){
|
2022-12-16 08:59:48 +01:00
|
|
|
// this.isOpen= true;
|
|
|
|
UIkit.modal(this.element.nativeElement).show();
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
close(){
|
2022-12-16 08:59:48 +01:00
|
|
|
// this.isOpen = false;
|
|
|
|
UIkit.modal(this.element.nativeElement).hide();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|