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>
inputs: ['searchPlaceholder', 'searchBarClass', 'autoCompleteValues'],
outputs: ['searchChanged', 'searchButtonClicked']
}) as angular.IDirectiveFactory);
-angular.module('sdcApp').directive('pluginFrame', downgradeComponent( {component: PluginFrameComponent, inputs: ['plugin', 'queryParams']} ) as angular.IDirectiveFactory);
+angular.module('sdcApp').directive('pluginFrame', downgradeComponent( {component: PluginFrameComponent, inputs: ['plugin', 'queryParams'], outputs: ['onLoadingDone']} ) as angular.IDirectiveFactory);
ng1appModule.config([
'$stateProvider',
this.eventsCallbacks.splice(index, 1)
}
- public notify(eventType:string, eventData:any) {
+ public notify(eventType:string, eventData?:any) {
let eventObj = {
type: eventType,
data: eventData,
export class PluginPubSub extends BasePubSub {
- constructor(pluginId: string, subscriberUrl: string) {
+ constructor(pluginId: string, parentUrl: string) {
super(pluginId);
- this.register('sdc-hub', window.parent, subscriberUrl);
+ this.register('sdc-hub', window.parent, parentUrl);
this.subscribe();
}
import {ComponentInstanceServiceNg2} from "../ng2/services/component-instance-services/component-instance.service";
import {UserService as UserServiceNg2} from "../ng2/services/user.service";
import {PluginsService} from "../ng2/services/plugins.service";
+import {EventBusService} from "../ng2/services/event-bus.service";
let moduleName:string = 'Sdc.Services';
let serviceModule:ng.IModule = angular.module(moduleName, []);
serviceModule.factory('ComponentInstanceServiceNg2', downgradeInjectable(ComponentInstanceServiceNg2));
serviceModule.factory('UserServiceNg2', downgradeInjectable(UserServiceNg2));
serviceModule.factory('PluginsService', downgradeInjectable(PluginsService));
+serviceModule.factory('EventBusService', downgradeInjectable(EventBusService));
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';
SharingServiceProvider,
CookieServiceProvider,
StateServiceFactory,
+ ScopeServiceFactory,
StateParamsServiceFactory,
CacheServiceProvider,
EventListenerServiceProvider,
-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) => {
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);
+ });
+ }
+ }
+ });
}
}
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({
imports: [
CommonModule,
LayoutModule,
- GlobalPipesModule
+ GlobalPipesModule,
+ UiElementsModule
],
entryComponents: [PluginFrameComponent],
exports: [
* 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.
return cacheObj.get('$state');
}
+export function scopeServiceFactory(cacheObj: ICacheObject) {
+ return cacheObj.get('$scope');
+}
+
export function stateParamsServiceFactory(cacheObj: ICacheObject) {
return cacheObj.get('$stateParams');
}
deps: ['$injector']
};
+export const ScopeServiceFactory= {
+ provide: '$scope',
+ useFactory: scopeServiceFactory,
+ deps: ['$injector']
+};
+
export const StateParamsServiceFactory = {
provide: '$stateParams',
useFactory: stateParamsServiceFactory,
* 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.
import {ComponentInstanceFactory, CommonUtils} from "app/utils";
import {SharingService} from "../sharing-service";
import {ComponentMetadata} from "../../models/component-metadata";
+import {EventBusService} from "../../ng2/services/event-bus.service";
export interface IComponentService {
'sdcConfig',
'Sdc.Services.SharingService',
'$q',
- '$base64'
+ '$base64',
+ 'EventBusService'
];
constructor(protected restangular:restangular.IElement,
protected sdcConfig:IAppConfigurtaion,
protected sharingService:SharingService,
protected $q:ng.IQService,
- protected $base64:any
+ protected $base64:any,
+ protected eventBusService:EventBusService
) {
this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root);
}, (err)=> {
deferred.reject(err);
});
+
+ // Notifying about events before executing the actual actions
+ switch (state) {
+ case "checkIn":
+ this.eventBusService.notify("CHECK_IN");
+ break;
+ case "submitForTesting":
+ this.eventBusService.notify("SUBMIT_FOR_TESTING");
+ break;
+ }
+
return deferred.promise;
};
* 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.
import {IComponentService, ComponentService} from "./component-service";
import {PropertyModel, IAppConfigurtaion, Resource, Component} from "../../models";
import {SharingService} from "../sharing-service";
+import {EventBusService} from "../../ng2/services/event-bus.service";
export interface IResourceService extends IComponentService {
updateResourceGroupProperties(uniqueId:string, groupId:string, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>>
'sdcConfig',
'Sdc.Services.SharingService',
'$q',
- '$base64'
+ '$base64',
+ 'EventBusService'
];
constructor(protected restangular:restangular.IElement,
protected sdcConfig:IAppConfigurtaion,
protected sharingService:SharingService,
protected $q:ng.IQService,
- protected $base64:any
+ protected $base64:any,
+ protected eventBusService:EventBusService
) {
- super(restangular, sdcConfig, sharingService, $q, $base64);
+ super(restangular, sdcConfig, sharingService, $q, $base64, eventBusService);
this.restangular = restangular.one("resources");
}
* 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.
import {IComponentService, ComponentService} from "./component-service";
import {Distribution, DistributionComponent, Service, PropertyModel, Component, IAppConfigurtaion} from "app/models";
import {SharingService} from "../sharing-service";
+import {EventBusService} from "../../ng2/services/event-bus.service";
export interface IServiceService extends IComponentService {
getDistributionsList(uuid:string):ng.IPromise<Array<Distribution>>;
protected sdcConfig:IAppConfigurtaion,
protected sharingService:SharingService,
protected $q:ng.IQService,
- protected $base64:any) {
- super(restangular, sdcConfig, sharingService, $q, $base64);
+ protected $base64:any,
+ protected eventBusService:EventBusService) {
+ super(restangular, sdcConfig, sharingService, $q, $base64, eventBusService);
this.restangular = restangular.one("services");
}
user: IUserProperties;
version: string;
queryParams: Object;
+ isLoading: boolean;
+
+ onLoadingDone(plugin: Plugin): void;
}
export class PluginsTabViewModel {
}
private initScope = ():void => {
+ this.$scope.isLoading = true;
this.$scope.plugin = this.pluginsService.getPluginByStateUrl(this.$stateParams.path);
-
this.$scope.version = this.cacheService.get('version');
-
this.$scope.user = this.cacheService.get('user');
this.$scope.queryParams = {
userId: this.$scope.user.userId,
userRole: this.$scope.user.role,
displayType: "tab",
- parentUrl: window.location.origin
+ parentUrl: window.location.origin,
+ eventsClientId: this.$scope.plugin.pluginId
+ };
+
+ this.$scope.onLoadingDone = (plugin: Plugin) => {
+ if (plugin.pluginId == this.$scope.plugin.pluginId) {
+ this.$scope.isLoading = false;
+ }
};
}
}
<div class="sdc-catalog-container">
-
+ <loader display="isLoading"></loader>
<top-nav [version]="version" [hide-search]="true"></top-nav>
-
- <plugin-frame [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
-
+ <plugin-frame (on-loading-done)="onLoadingDone(plugin)" [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
</div>
plugin: Plugin;
user:IUserProperties;
queryParams: Object;
+ isLoading: boolean;
+
+ onLoadingDone(plugin: Plugin): void;
}
export class PluginsContextViewModel {
}
private initScope = ():void => {
+ this.$scope.isLoading = true;
this.$scope.plugin = this.pluginsService.getPluginByStateUrl(this.$stateParams.path);
-
this.$scope.user = this.cacheService.get('user');
this.$scope.queryParams = {
lifecycleState: this.$scope.component.lifecycleState,
isOwner: this.$scope.component.lastUpdaterUserId === this.$scope.user.userId,
version: this.$scope.component.version ,
- parentUrl: window.location.origin
+ parentUrl: window.location.origin,
+ eventsClientId: this.$scope.plugin.pluginId
+ };
+
+ this.$scope.onLoadingDone = (plugin: Plugin) => {
+ if (plugin.pluginId == this.$scope.plugin.pluginId) {
+ this.$scope.isLoading = false;
+ }
};
}
+<loader display="isLoading"></loader>
<div class="workspace-plugins">
-
- <plugin-frame [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
-
+ <plugin-frame (on-loading-done)="onLoadingDone(plugin)" [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
</div>
LeftPaletteLoaderService
} from "app/services";
import {FileUploadModel} from "../../directives/file-upload/file-upload";
+import {EventBusService} from "../../ng2/services/event-bus.service";
export interface IWorkspaceViewModelScope extends ng.IScope {
'Sdc.Services.EntityService',
'Notification',
'$stateParams',
- 'Sdc.Services.ProgressService'
+ 'Sdc.Services.ProgressService',
+ 'EventBusService'
];
constructor(private $scope:IWorkspaceViewModelScope,
private EntityService:EntityService,
private Notification:any,
private $stateParams:any,
- private progressService:ProgressService) {
+ private progressService:ProgressService,
+ private eventBusService:EventBusService) {
this.initScope();
this.initAfterScope();
}
};
+ this.$scope.$on('$stateChangeSuccess', (event, toState) => {
+ this.$scope.updateSelectedMenuItem(this.$state.current.name);
+ });
+
this.$scope.onMenuItemPressed = (state:string, params:any):ng.IPromise<boolean> => {
let deferred = this.$q.defer();
let goToState = ():void => {
id: this.$scope.component.uniqueId,
type: this.$scope.component.componentType.toLowerCase(),
components: this.components
- }, params)).then(() => {
- this.$scope.updateSelectedMenuItem(state);
- });
+ }, params));
deferred.resolve(true);
};
if (this.isNeedSave()) {
});
}
this.$scope.isLoading = true;
+
+ let eventData = {
+ uuid: this.$scope.component.uuid,
+ version: this.$scope.changeVersion.selectedVersion.versionNumber
+ };
+
+ this.eventBusService.notify("VERSION_CHANGED", eventData);
+
this.$state.go(this.$state.current.name, {
id: selectedId,
type: this.$scope.componentType.toLowerCase(),
let onSuccess = (component:Component, url:string):void => {
//Updating the component from server response
+ // Creating the data object to notify the plugins with
+ let eventData: any = {
+ uuid: this.$scope.component.uuid,
+ version: this.$scope.component.version
+ };
+
+ // Notifying about events after successfully executing the actions
+ switch (state) {
+ case "checkOut":
+ this.eventBusService.notify("CHECK_OUT", eventData);
+ break;
+ case "deleteVersion":
+ this.eventBusService.notify("UNDO_CHECK_OUT", eventData);
+ break;
+ }
+
//the server returns only metaData (small component) except checkout (Full component) ,so we update only the statuses of distribution & lifecycle
this.$scope.component.lifecycleState = component.lifecycleState;
this.$scope.component.distributionStatus = component.distributionStatus;
});
break;
case 'lifecycleState/UNDOCHECKOUT':
- defaultActionAfterChangeLifecycleState();
- this.Notification.success({
- message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
- title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE")
+ setTimeout(() => {
+ defaultActionAfterChangeLifecycleState();
+ this.Notification.success({
+ message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
+ title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE")
+ });
});
break;
case 'lifecycleState/certificationRequest':
}
};
//this.$scope.isLoading = true;
+
this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess);
};