1 import {Plugin, IUserProperties} from "app/models";
2 import {CacheService} from "app/services";
3 import {PluginsService} from "../../../../ng2/services/plugins.service";
4 import {IWorkspaceViewModelScope} from "../../workspace-view-model";
7 interface IPluginsContextViewModelScope extends IWorkspaceViewModelScope {
13 onLoadingDone(plugin: Plugin): void;
16 export class PluginsContextViewModel {
20 'Sdc.Services.CacheService',
24 constructor(private $scope:IPluginsContextViewModelScope,
25 private $stateParams:any,
26 private cacheService:CacheService,
27 private pluginsService:PluginsService) {
32 private initScope = ():void => {
33 this.$scope.isLoading = true;
34 this.$scope.plugin = this.pluginsService.getPluginByStateUrl(this.$stateParams.path);
35 this.$scope.user = this.cacheService.get('user');
37 this.$scope.queryParams = {
38 userId: this.$scope.user.userId,
39 userRole: this.$scope.user.role,
40 displayType: "context",
41 contextType: this.$scope.component.getComponentSubType(),
42 uuid: this.$scope.component.uuid,
43 lifecycleState: this.$scope.component.lifecycleState,
44 isOwner: this.$scope.component.lastUpdaterUserId === this.$scope.user.userId,
45 version: this.$scope.component.version ,
46 parentUrl: window.location.origin,
47 eventsClientId: this.$scope.plugin.pluginId
50 this.$scope.onLoadingDone = (plugin: Plugin) => {
51 if (plugin.pluginId == this.$scope.plugin.pluginId) {
52 this.$scope.isLoading = false;