CSIT Fix for SDC-2585
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / panel / panel-tabs / groups / group-tabs.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 * as _ from "lodash";
22 import { Component, Inject, Input, Output, EventEmitter, SimpleChanges, OnChanges } from "@angular/core";
23 import { TranslateService } from './../../../../../shared/translator/translate.service';
24 import { Component as TopologyTemplate, ComponentInstance, IAppMenu } from "app/models";
25 import { GroupsService } from '../../../../../services/groups.service';
26 import { GroupInstance } from "app/models/graph/zones/group-instance";
27
28 @Component({
29     selector: 'group-tabs',
30     templateUrl: './group-tabs.component.html'
31 })
32 export class GroupTabsComponent implements OnChanges {
33  
34     @Input() topologyTemplate:TopologyTemplate;
35     @Input() selectedZoneInstanceType:string;
36     @Input() selectedZoneInstanceId:string;
37     @Input() isViewOnly: boolean;
38     @Output() isLoading: EventEmitter<boolean> = new EventEmitter<boolean>();
39
40     private group:GroupInstance;
41
42     constructor(private translateService:TranslateService,
43                 private groupsService:GroupsService
44         ) {
45     }
46
47     ngOnChanges(changes: SimpleChanges): void {
48         this.initGroup();
49     }
50
51     private initGroup = ():void => {
52         this.isLoading.emit(true);
53         this.groupsService.getSpecificGroup(this.topologyTemplate.componentType, this.topologyTemplate.uniqueId, this.selectedZoneInstanceId).subscribe(
54             group => {
55                 this.group = group;
56                 console.log(JSON.stringify(group));
57             },
58             error => console.log("Error getting group!"),
59             () => this.isLoading.emit(false)
60         );
61     }
62
63     private setIsLoading = (value) :void => {
64         this.isLoading.emit(value);
65     }
66
67 }