Catalog alignment
[sdc.git] / catalog-ui / src / app / ng2 / pages / plugins / plugin-context-view / plugin-context-view.page.component.ts
1 import {Component, Inject} from "@angular/core";
2 import {Component as ComponentData, IUserProperties, Plugin} from "app/models";
3 import {CacheService, PluginsService} from "app/services-ng2";
4
5
6 @Component({
7     selector: 'plugin-context-view',
8     templateUrl: './plugin-context-view.page.component.html',
9     styleUrls: ['./plugin-context-view.page.component.less']
10 })
11
12 export class PluginContextViewPageComponent {
13     plugin: Plugin;
14     user: IUserProperties;
15     queryParams: Object;
16     isLoading: boolean;
17     show: boolean;
18     component: ComponentData;
19
20     constructor(@Inject("$stateParams") private _stateParams,
21                 private cacheService: CacheService,
22                 private pluginsService: PluginsService) {
23
24         this.show = false;
25         this.component = this._stateParams.component;
26         this.plugin = this.pluginsService.getPluginByStateUrl(_stateParams.path);
27         this.user = this.cacheService.get('user');
28     }
29
30     ngOnInit() {
31         this.isLoading = true;
32
33         this.queryParams = {
34             userId: this.user.userId,
35             userRole: this.user.role,
36             displayType: "context",
37             contextType: this.component.getComponentSubType(),
38             uuid: this.component.uuid,
39             lifecycleState: this.component.lifecycleState,
40             isOwner: this.component.lastUpdaterUserId === this.user.userId,
41             version: this.component.version,
42             parentUrl: window.location.origin,
43             eventsClientId: this.plugin.pluginId
44         };
45
46         if (this._stateParams.queryParams) {
47             _.assign(this.queryParams, this._stateParams.queryParams);
48         }
49     }
50
51     onLoadingDone(plugin: Plugin) {
52         if (plugin.pluginId == this.plugin.pluginId) {
53             this.isLoading = false;
54         }
55     }
56
57
58 }