c0d6aba915e6b8794f46fdf547f54965227907d1
[sdc.git] /
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     'use strict';
23
24     interface IDistributionStatusModalViewModelScope {
25         distribution:Models.Distribution;
26         status:string;
27         getStatusCount(distributionComponent:Array<Models.DistributionComponent>):any;
28         getUrlName(url:string):string;
29         modalDitributionStatus:ng.ui.bootstrap.IModalServiceInstance;
30         footerButtons: Array<any>;
31         close(): void;
32     }
33
34     export class DistributionStatusModalViewModel {
35
36         static '$inject' = ['$scope','$modalInstance', 'data'];
37
38         constructor(private $scope:IDistributionStatusModalViewModelScope,
39                     private $modalInstance:ng.ui.bootstrap.IModalServiceInstance,
40                     private data:any
41                     ) {
42             this.initScope();
43         }
44
45         private initScope = ():void => {
46             this.$scope.distribution = this.data.distribution;
47             this.$scope.status = this.data.status;
48             this.$scope.modalDitributionStatus = this.$modalInstance;
49
50             this.$scope.getUrlName = (url:string):string =>{
51                 let urlName:string = _.last(url.split('/'));
52                 return urlName;
53             };
54
55             this.$scope.close = ():void => {
56                 this.$modalInstance.close();
57             };
58
59             this.$scope.footerButtons = [
60                 {'name': 'Close', 'css': 'blue', 'callback': this.$scope.close }
61             ];
62
63         };
64
65
66     }
67 }