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";
14 selector: 'tosca-artifact-page',
16 templateUrl: './tosca-artifact-page.component.html',
17 styleUrls: ['./tosca-artifact-page.component.less', '../../../../../assets/styles/table-style.less']
19 export class ToscaArtifactPageComponent implements OnInit {
21 @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean;
22 @ViewChild('toscaArtifactsTable') table: any;
23 public toscaArtifacts$: Observable<ArtifactModel[]>;
24 public componentId: string;
25 public componentType:string;
27 constructor(private serviceLoader: SdcUiServices.LoaderService, private workspaceService: WorkspaceService, private store: Store) {
32 this.componentId = this.workspaceService.metadata.uniqueId;
33 this.componentType = this.workspaceService.metadata.componentType;
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)));
40 if(event.type === 'click'){
41 this.table.rowDetail.toggleExpandRow(event.row);