Catalog alignment
[sdc.git] / catalog-ui / src / app / ng2 / pages / workspace / deployment / deployment-page.component.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
21 import {Component} from "@angular/core";
22 import {HierarchyTabComponent} from "./panel/panel-tabs/hierarchy-tab/hierarchy-tab.component";
23 import {ComponentGenericResponse} from "../../../services/responses/component-generic-response";
24 import {TopologyTemplateService} from "../../../services/component-services/topology-template.service";
25 import {WorkspaceService} from "../workspace.service";
26 import {Module} from "app/models";
27 import {SdcUiServices} from "onap-ui-angular";
28 import {Select} from "@ngxs/store";
29 import {WorkspaceState} from "../../../store/states/workspace.state";
30 import {DeploymentGraphService} from "../../composition/deployment/deployment-graph.service";
31
32 const tabs =
33     {
34         hierarchyTab: {
35             titleIcon: 'composition-o',
36             component: HierarchyTabComponent,
37             input: {},
38             isActive: true,
39             tooltipText: 'Hierarchy'
40         }
41     };
42
43 @Component({
44     selector: 'deployment-page',
45     templateUrl: './deployment-page.component.html',
46     styleUrls: ['deployment-page.component.less']
47 })
48
49 export class DeploymentPageComponent {
50     public tabs: Array<any>;
51     public resourceType: string;
52     public modules: Array<Module>;
53     public isDataAvailable: boolean;
54
55     @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean;
56
57     constructor(private topologyTemplateService: TopologyTemplateService,
58                 private workspaceService: WorkspaceService,
59                 private deploymentService: DeploymentGraphService,
60                 private loaderService: SdcUiServices.LoaderService) {
61         this.tabs = [];
62         this.isDataAvailable = false;
63     }
64
65     ngOnInit(): void {
66         this.topologyTemplateService.getDeploymentGraphData(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId).subscribe((response: ComponentGenericResponse) => {
67             this.deploymentService.componentInstances = response.componentInstances;
68             this.deploymentService.componentInstancesRelations = response.componentInstancesRelations;
69             this.deploymentService.modules = response.modules;
70             this.isDataAvailable = true;
71             this.loaderService.deactivate();
72         });
73
74         this.loaderService.activate();
75         this.resourceType = this.workspaceService.getMetadataType();
76         this.tabs.push(tabs.hierarchyTab);
77     }
78 }