Initial OpenECOMP SDC commit
[sdc.git] / catalog-ui / app / scripts / view-models / dashboard / cover / dashboard-cover-view-model.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 /// <reference path="../../../references"/>
21 module Sdc.ViewModels {
22
23     'use strict';
24
25     export interface IDashboardCoverViewModelScope extends ng.IScope {
26         showTutorial:boolean;
27         version:string;
28         modalInstance:ng.ui.bootstrap.IModalServiceInstance;
29     }
30
31     export class DashboardCoverViewModel {
32         static '$inject' = [
33             '$scope',
34             '$stateParams',
35             'Sdc.Services.CacheService',
36             '$templateCache',
37             '$state',
38             '$modal',
39             'sdcConfig'
40         ];
41
42         constructor(private $scope:IDashboardCoverViewModelScope,
43                     private $stateParams:any,
44                     private cacheService:Services.CacheService,
45                     private $templateCache:ng.ITemplateCacheService,
46                     private $state:any,
47                     private $modal:ng.ui.bootstrap.IModalService,
48                     private sdcConfig:Models.IAppConfigurtaion) {
49
50             // Show the tutorial if needed when the dashboard page is opened.<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script>
51             // This is called from the welcome page.
52             if (this.$stateParams.show === 'tutorial') {
53                 this.$scope.showTutorial = true;
54             } else if (this.$stateParams.show === 'whatsnew') {
55                 this.$scope.version = this.cacheService.get('version');
56                 this.openWhatsNewModal(this.$scope);
57             }
58
59             this.initScope();
60         }
61
62         private initScope = ():void => {
63
64         };
65
66         private openWhatsNewModal = (scope:IDashboardCoverViewModelScope):void => {
67
68             let onOk = ():void => {};
69
70             let onCancel = ():void => {
71                 this.$state.go('dashboard.welcome', {show: ''});
72             };
73
74             let modalOptions:ng.ui.bootstrap.IModalSettings = {
75                 template: this.$templateCache.get('/app/scripts/view-models/whats-new/whats-new-view.html'),
76                 controller: 'Sdc.ViewModels.WhatsNewViewModel',
77                 size: 'sdc-l',
78                 backdrop: 'static',
79                 scope: scope,
80                 resolve: {
81                     'version': scope.version
82                 }
83             };
84
85             scope.modalInstance = this.$modal.open(modalOptions);
86             scope.modalInstance.result.then(onOk, onCancel);
87         };
88
89     }
90
91 }