2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 import {CacheService} from "app/services-ng2";
23 import {IAppConfigurtaion} from "app/models";
25 interface IAdminDashboardViewModelScope extends ng.IScope {
27 sdcConfig:IAppConfigurtaion;
32 moveToTab(tab:string):void;
33 isSelected(tab:string):boolean;
37 export class AdminDashboardViewModel {
41 'Sdc.Services.CacheService',
45 constructor(private $scope:IAdminDashboardViewModelScope,
46 private $templateCache:ng.ITemplateCacheService,
47 private cacheService:CacheService,
48 private sdcConfig:IAppConfigurtaion) {
53 private initScope = ():void => {
55 this.$scope.version = this.cacheService.get('version');
56 this.$scope.sdcConfig = this.sdcConfig;
57 this.$scope.monitorUrl = this.$scope.sdcConfig.api.kibana;
58 this.$scope.isSelected = (tab:string):boolean => {
59 return tab === this.$scope.currentTab;
62 this.$scope.moveToTab = (tab:string):void => {
63 if (tab === this.$scope.currentTab) {
66 else if (tab === 'USER_MANAGEMENT') {
67 this.$scope.templateUrl="user-management-view.html";
68 this.$templateCache.put("user-management-view.html", require('app/view-models/admin-dashboard/user-management/user-management-view.html'));
70 else if (tab === 'CATEGORY_MANAGEMENT') {
71 this.$scope.templateUrl="category-management-view.html";
72 this.$templateCache.put("category-management-view.html", require('app/view-models/admin-dashboard/category-management/category-management-view.html'));
74 this.$scope.currentTab = tab;
77 this.$scope.moveToTab('USER_MANAGEMENT');