aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2018-03-06 13:52:58 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 06:56:36 +0000
commitf97bae33631c3f5ef06574e9d21620c8dfff8f62 (patch)
tree5d7e2682fd7db6646b5608a417ae7af40a5ebf56 /catalog-ui/src/app/ng2/components
parent2064106f298ac9683821e83acbfd87dac8b5b32f (diff)
Add events hub notify calls
Added events hub notify calls. Fixed issues raised by development across the publish subscribe mechanism development Change-Id: I0768bdcb2d89f99634cdb6bc7cb75e20263f5c00 Issue-ID: SDC-1029 Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/components')
-rw-r--r--catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts41
-rw-r--r--catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.module.ts4
2 files changed, 39 insertions, 6 deletions
diff --git a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
index 801dfa98fe..eb7d138232 100644
--- a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
+++ b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
@@ -1,27 +1,32 @@
-import {Component, OnInit, Input} from "@angular/core";
-import { URLSearchParams } from '@angular/http';
+import {Component, Inject, Input, Output, OnInit, EventEmitter, ViewChild, ElementRef} from "@angular/core";
+import {URLSearchParams} from '@angular/http';
import {Plugin} from "app/models";
+import {EventBusService} from "../../../services/event-bus.service";
@Component({
selector: 'plugin-frame',
templateUrl: './plugin-frame.component.html',
- styleUrls:['plugin-frame.component.less']
+ styleUrls: ['plugin-frame.component.less']
})
export class PluginFrameComponent implements OnInit {
@Input() plugin: Plugin;
@Input() queryParams: Object;
+ @Output() onLoadingDone: EventEmitter<void> = new EventEmitter<void>();
pluginUrl: string;
private urlSearchParams: URLSearchParams;
+ private isClosed: boolean;
- constructor() {
+ constructor(private eventBusService: EventBusService,
+ @Inject('$scope') private $scope: ng.IScope,
+ @Inject('$state') private $state: ng.ui.IStateService) {
this.urlSearchParams = new URLSearchParams();
}
ngOnInit(): void {
-
this.pluginUrl = this.plugin.pluginSourceUrl;
+ this.isClosed = false;
if (this.queryParams && !_.isEmpty(this.queryParams)) {
_.forOwn(this.queryParams, (value, key) => {
@@ -31,5 +36,31 @@ export class PluginFrameComponent implements OnInit {
this.pluginUrl += '?';
this.pluginUrl += this.urlSearchParams.toString();
}
+
+ this.eventBusService.on((eventData) => {
+ if (eventData.originId === this.plugin.pluginId) {
+ if (eventData.type == "READY") {
+ this.onLoadingDone.emit();
+ }
+ }
+ });
+
+ // Listening to the stateChangeStart event in order to notify the plugin about it being closed
+ // before moving to a new state
+ this.$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
+ if (fromState.name !== toState.name) {
+ if (!this.isClosed) {
+ event.preventDefault();
+
+ this.eventBusService.notify("WINDOW_OUT");
+
+ this.isClosed = true;
+
+ setTimeout(() => {
+ this.$state.go(toState.name, toParams);
+ });
+ }
+ }
+ });
}
}
diff --git a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.module.ts b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.module.ts
index 81b99cc2d8..9eebd5c47f 100644
--- a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.module.ts
+++ b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.module.ts
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import {PluginFrameComponent} from "./plugin-frame.component";
import {LayoutModule} from "../../layout/layout.module";
import {GlobalPipesModule} from "../../../pipes/global-pipes.module";
+import {UiElementsModule} from "../ui-elements.module";
@NgModule({
@@ -12,7 +13,8 @@ import {GlobalPipesModule} from "../../../pipes/global-pipes.module";
imports: [
CommonModule,
LayoutModule,
- GlobalPipesModule
+ GlobalPipesModule,
+ UiElementsModule
],
entryComponents: [PluginFrameComponent],
exports: [