aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/workspace/tosca-artifacts/tosca-artifact-page.component.ts
blob: e74e5db6680255a60702751afd2b8e62334396a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {Component, OnInit, ViewChild} from "@angular/core";
import {WorkspaceService} from "../workspace.service";
import {SdcUiServices} from "onap-ui-angular";
import {ArtifactModel} from "../../../../models";
import {Select, Store} from "@ngxs/store";
import {WorkspaceState} from "../../../store/states/workspace.state";
import * as _ from "lodash";
import {ArtifactGroupType, COMPONENT_FIELDS} from "../../../../utils";
import {GetArtifactsByTypeAction} from "../../../store/actions/artifacts.action";
import {Observable} from "rxjs/index";
import {ArtifactsState} from "../../../store/states/artifacts.state";
import {ArtifactType} from "../../../../utils/constants";
import {map} from "rxjs/operators";

@Component({
    selector: 'tosca-artifact-page',

    templateUrl: './tosca-artifact-page.component.html',
    styleUrls: ['./tosca-artifact-page.component.less', '../../../../../assets/styles/table-style.less']
})
export class ToscaArtifactPageComponent implements OnInit {

    @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean;
    @ViewChild('toscaArtifactsTable') table: any;
    public toscaArtifacts$: Observable<ArtifactModel[]>;
    public componentId: string;
    public componentType:string;

    constructor(private serviceLoader: SdcUiServices.LoaderService, private workspaceService: WorkspaceService, private store: Store) {
    }


    ngOnInit(): void {
        this.componentId = this.workspaceService.metadata.uniqueId;
        this.componentType = this.workspaceService.metadata.componentType;

        this.store.dispatch(new GetArtifactsByTypeAction({componentType:this.componentType, componentId:this.componentId, artifactType:ArtifactGroupType.TOSCA}));
        this.toscaArtifacts$ = this.store.select(ArtifactsState.getArtifactsByType).pipe(map(filterFn => filterFn(ArtifactGroupType.TOSCA)));
    }

    onActivate(event) {
        if(event.type === 'click'){
            this.table.rowDetail.toggleExpandRow(event.row);
        }
    }
}