3 * Copyright (c) 2018 AT&T Intellectual Property.
7 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
27 * limitations under the License.
31 import {IUserProperties, Plugin} from "app/models";
32 import {CacheService} from "app/services";
33 import {PluginsService} from "../../ng2/services/plugins.service";
36 interface IPluginsTabViewModelScope extends ng.IScope {
38 user: IUserProperties;
43 onLoadingDone(plugin: Plugin): void;
46 export class PluginsTabViewModel {
50 'Sdc.Services.CacheService',
54 constructor(private $scope: IPluginsTabViewModelScope,
55 private $stateParams: any,
56 private cacheService: CacheService,
57 private pluginsService: PluginsService) {
62 private initScope = (): void => {
63 this.$scope.plugin = this.pluginsService.getPluginByStateUrl(this.$stateParams.path);
64 this.$scope.version = this.cacheService.get('version');
65 this.$scope.user = this.cacheService.get('user');
67 this.$scope.isLoading = true;
69 this.$scope.queryParams = {
70 userId: this.$scope.user.userId,
71 userRole: this.$scope.user.role,
73 parentUrl: window.location.origin,
74 eventsClientId: this.$scope.plugin.pluginId
77 this.$scope.onLoadingDone = (plugin: Plugin) => {
78 if (plugin.pluginId == this.$scope.plugin.pluginId) {
79 this.$scope.isLoading = false;