diff options
Diffstat (limited to 'catalog-ui/src/app/ng2')
4 files changed, 53 insertions, 9 deletions
diff --git a/catalog-ui/src/app/ng2/app.module.ts b/catalog-ui/src/app/ng2/app.module.ts index 0346b10915..ffeb1fd89f 100644 --- a/catalog-ui/src/app/ng2/app.module.ts +++ b/catalog-ui/src/app/ng2/app.module.ts @@ -28,7 +28,7 @@ import {UpgradeModule} from '@angular/upgrade/static'; import {PropertiesAssignmentModule} from './pages/properties-assignment/properties-assignment.module'; import { DataTypesServiceProvider, SharingServiceProvider, CookieServiceProvider, StateServiceFactory, - StateParamsServiceFactory, CacheServiceProvider, EventListenerServiceProvider + StateParamsServiceFactory, CacheServiceProvider, EventListenerServiceProvider, ScopeServiceFactory } from "./utils/ng1-upgraded-provider"; import {ConfigService} from "./services/config.service"; import {HttpModule} from '@angular/http'; @@ -85,6 +85,7 @@ export function configServiceFactory(config:ConfigService) { SharingServiceProvider, CookieServiceProvider, StateServiceFactory, + ScopeServiceFactory, StateParamsServiceFactory, CacheServiceProvider, EventListenerServiceProvider, 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: [ diff --git a/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts b/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts index c21817c001..51314c04bd 100644 --- a/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts +++ b/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,6 +46,10 @@ export function stateServiceFactory(cacheObj: ICacheObject) { return cacheObj.get('$state'); } +export function scopeServiceFactory(cacheObj: ICacheObject) { + return cacheObj.get('$scope'); +} + export function stateParamsServiceFactory(cacheObj: ICacheObject) { return cacheObj.get('$stateParams'); } @@ -84,6 +88,12 @@ export const StateServiceFactory = { deps: ['$injector'] }; +export const ScopeServiceFactory= { + provide: '$scope', + useFactory: scopeServiceFactory, + deps: ['$injector'] +}; + export const StateParamsServiceFactory = { provide: '$stateParams', useFactory: stateParamsServiceFactory, |