ef4112c30cdb90eb851d17576797407b46ecfa54
[sdc.git] / catalog-ui / src / app / ng2 / pages / workspace / tosca-artifacts / tosca-artifact-page.component.ts
1 import {Component, OnInit, ViewChild} from "@angular/core";
2 import {WorkspaceService} from "../workspace.service";
3 import {SdcUiServices} from "onap-ui-angular";
4 import {ArtifactModel} from "../../../../models";
5 import {Select, Store} from "@ngxs/store";
6 import {WorkspaceState} from "../../../store/states/workspace.state";
7 import {ArtifactGroupType} from "../../../../utils";
8 import {GetArtifactsByTypeAction} from "../../../store/actions/artifacts.action";
9 import {Observable} from "rxjs/index";
10 import {ArtifactsState} from "../../../store/states/artifacts.state";
11 import {map} from "rxjs/operators";
12
13 @Component({
14     selector: 'tosca-artifact-page',
15
16     templateUrl: './tosca-artifact-page.component.html',
17     styleUrls: ['./tosca-artifact-page.component.less', '../../../../../assets/styles/table-style.less']
18 })
19 export class ToscaArtifactPageComponent implements OnInit {
20
21     @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean;
22     @ViewChild('toscaArtifactsTable') table: any;
23     public toscaArtifacts$: Observable<ArtifactModel[]>;
24     public componentId: string;
25     public componentType:string;
26
27     constructor(private serviceLoader: SdcUiServices.LoaderService, private workspaceService: WorkspaceService, private store: Store) {
28     }
29
30
31     ngOnInit(): void {
32         this.componentId = this.workspaceService.metadata.uniqueId;
33         this.componentType = this.workspaceService.metadata.componentType;
34
35         this.store.dispatch(new GetArtifactsByTypeAction({componentType:this.componentType, componentId:this.componentId, artifactType:ArtifactGroupType.TOSCA}));
36         this.toscaArtifacts$ = this.store.select(ArtifactsState.getArtifactsByType).pipe(map(filterFn => filterFn(ArtifactGroupType.TOSCA)));
37     }
38
39     onActivate(event) {
40         if(event.type === 'click'){
41             this.table.rowDetail.toggleExpandRow(event.row);
42         }
43     }
44 }