diff options
author | Idan Amit <ia096e@intl.att.com> | 2018-03-06 13:52:58 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-03-07 06:56:36 +0000 |
commit | f97bae33631c3f5ef06574e9d21620c8dfff8f62 (patch) | |
tree | 5d7e2682fd7db6646b5608a417ae7af40a5ebf56 /catalog-ui/src/app/view-models | |
parent | 2064106f298ac9683821e83acbfd87dac8b5b32f (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/view-models')
5 files changed, 69 insertions, 21 deletions
diff --git a/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts b/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts index 5e2a59925c..438cf4a60c 100644 --- a/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts +++ b/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts @@ -8,6 +8,9 @@ interface IPluginsTabViewModelScope extends ng.IScope { user: IUserProperties; version: string; queryParams: Object; + isLoading: boolean; + + onLoadingDone(plugin: Plugin): void; } export class PluginsTabViewModel { @@ -27,17 +30,23 @@ 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; + } }; } } diff --git a/catalog-ui/src/app/view-models/plugins/plugins-tab-view.html b/catalog-ui/src/app/view-models/plugins/plugins-tab-view.html index 3695434463..bc404b46d1 100644 --- a/catalog-ui/src/app/view-models/plugins/plugins-tab-view.html +++ b/catalog-ui/src/app/view-models/plugins/plugins-tab-view.html @@ -1,7 +1,5 @@ <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> diff --git a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts index 959aead3ae..550fb84c10 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts @@ -8,6 +8,9 @@ interface IPluginsContextViewModelScope extends IWorkspaceViewModelScope { plugin: Plugin; user:IUserProperties; queryParams: Object; + isLoading: boolean; + + onLoadingDone(plugin: Plugin): void; } export class PluginsContextViewModel { @@ -27,8 +30,8 @@ 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 = { @@ -40,7 +43,14 @@ export class PluginsContextViewModel { 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; + } }; } diff --git a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view.html b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view.html index e155370ddd..d70717a3ed 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view.html @@ -1,5 +1,4 @@ +<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> diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts index 0f9d7590c7..ca34d6fdc4 100644 --- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts @@ -35,6 +35,7 @@ import { 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 { @@ -115,7 +116,8 @@ export class WorkspaceViewModel { 'Sdc.Services.EntityService', 'Notification', '$stateParams', - 'Sdc.Services.ProgressService' + 'Sdc.Services.ProgressService', + 'EventBusService' ]; constructor(private $scope:IWorkspaceViewModelScope, @@ -134,7 +136,8 @@ export class WorkspaceViewModel { private EntityService:EntityService, private Notification:any, private $stateParams:any, - private progressService:ProgressService) { + private progressService:ProgressService, + private eventBusService:EventBusService) { this.initScope(); this.initAfterScope(); @@ -216,6 +219,10 @@ export class WorkspaceViewModel { } }; + 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 => { @@ -223,9 +230,7 @@ export class WorkspaceViewModel { 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()) { @@ -266,6 +271,14 @@ export class WorkspaceViewModel { }); } 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(), @@ -426,6 +439,22 @@ export class WorkspaceViewModel { 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; @@ -472,10 +501,12 @@ export class WorkspaceViewModel { }); 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': @@ -550,6 +581,7 @@ export class WorkspaceViewModel { } }; //this.$scope.isLoading = true; + this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess); }; |