k15t-aui-ng2
Version:
aui-ng2 is a set of angular 2 components, directives and services to simplify the integration with Atlassian products based on AUI/ADG. The library is still under development and is considered in an experimental state. So be aware that things will change
41 lines (34 loc) • 1.5 kB
text/typescript
import {Injectable, DynamicComponentLoader, ComponentRef, ViewContainerRef} from '@angular/core';
import {Observable} from 'rxjs/Rx';
import {AuiNgMessageDialogComponent} from './message-dialog.component';
import {LogService} from '../common/services/log.service.ts';
()
export class AuiNgDialogService {
constructor(
private componentLoader: DynamicComponentLoader,
private logService: LogService
) {}
closeDialog() {
}
openDialog(componentType, viewContainerRef: ViewContainerRef, opts?: any): Observable<any> {
let observable = Observable.fromPromise(this.componentLoader.loadNextToLocation(componentType, viewContainerRef));
observable.subscribe((containerRef: ComponentRef<AuiNgMessageDialogComponent>) => {
if (containerRef.instance.hidden === undefined || !!containerRef.instance.hidden) {
containerRef.instance.init(opts).subscribe(() => {
containerRef.destroy();
});
containerRef.instance.open();
}
},
err => this.logService.logError('Error' + err)
);
return observable;
}
openMessageDialog(title: string, msg: string, type: string, viewContainerRef: ViewContainerRef): Observable<any> {
return this.openDialog(AuiNgMessageDialogComponent, viewContainerRef, {
title: title,
message: msg,
type: type
});
}
}