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=========================================================
20 /// <reference path="../../../../references"/>
21 module Sdc.ViewModels {
23 import ArtifactModel = Sdc.Models.ArtifactModel;
25 export interface IToscaArtifactsScope extends IWorkspaceViewModelScope {
26 artifacts: Array<Models.ArtifactModel>;
27 tableHeadersList: Array<any>;
29 downloadFile:Models.IFileDownload;
35 download(artifact:Models.ArtifactModel): void;
36 sort(sortBy:string): void;
37 showNoArtifactMessage():boolean;
40 export class ToscaArtifactsViewModel {
47 constructor(private $scope:IToscaArtifactsScope,
48 private $filter:ng.IFilterService) {
50 this.$scope.updateSelectedMenuItem();
53 private initScope = ():void => {
55 this.$scope.isLoading = false;
56 this.$scope.sortBy = 'artifactDisplayName';
57 this.$scope.reverse = false;
58 this.$scope.setValidState(true);
59 this.$scope.artifactType = 'normal';
60 this.$scope.getTitle = ():string => {
61 return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts';
65 this.$scope.tableHeadersList = [
66 {title: 'Name', property: 'artifactDisplayName'},
67 {title: 'Type', property: 'artifactType'}
70 this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.toscaArtifacts);
71 this.$scope.sort = (sortBy:string):void => {
72 this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false;
73 this.$scope.sortBy = sortBy;
78 this.$scope.showNoArtifactMessage = ():boolean => {
79 if (this.$scope.artifacts.length === 0) {