1 import {Component, OnInit, ViewChild} from "@angular/core";
2 import {WorkspaceService} from "../workspace.service";
3 import {SdcUiCommon, SdcUiComponents, SdcUiServices} from "onap-ui-angular";
4 import {TopologyTemplateService} from "../../../services/component-services/topology-template.service";
5 import * as _ from "lodash";
6 import {ArtifactGroupType, ArtifactType} from "../../../../utils/constants";
7 import {ArtifactsService} from "../../../components/forms/artifacts-form/artifacts.service";
8 import {DeleteArtifactAction, GetArtifactsByTypeAction} from "../../../store/actions/artifacts.action";
9 import {Select, Store} from "@ngxs/store";
10 import {Observable} from "rxjs/index";
11 import {ArtifactsState} from "../../../store/states/artifacts.state";
12 import {map} from "rxjs/operators";
13 import {WorkspaceState} from "../../../store/states/workspace.state";
14 import {ArtifactModel} from "../../../../models/artifacts";
17 selector: 'information-artifact-page',
18 templateUrl: './information-artifact-page.component.html',
19 styleUrls: ['./information-artifact-page.component.less', '../../../../../assets/styles/table-style.less']
21 export class InformationArtifactPageComponent implements OnInit {
23 public componentId: string;
24 public componentType: string;
25 public informationArtifacts$: Observable<ArtifactModel[]>;
26 public informationArtifactsAsButtons$: Observable<ArtifactModel[]>;
27 @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean;
28 @ViewChild('informationArtifactsTable') table: any;
30 constructor(private workspaceService: WorkspaceService,
31 private artifactsService: ArtifactsService,
32 private store: Store) {
36 this.componentId = this.workspaceService.metadata.uniqueId;
37 this.componentType = this.workspaceService.metadata.componentType;
39 this.store.dispatch(new GetArtifactsByTypeAction({
40 componentType: this.componentType,
41 componentId: this.componentId,
42 artifactType: ArtifactGroupType.INFORMATION
45 let artifacts = this.store.select(ArtifactsState.getArtifactsByType).pipe(map(filterFn => filterFn(ArtifactType.INFORMATION)));
46 this.informationArtifacts$ = artifacts.pipe(map(artifacts => _.filter(artifacts, (artifact) => {
50 this.informationArtifactsAsButtons$ = artifacts.pipe(map(artifacts => _.filter(artifacts, (artifact) => {
51 return !artifact.esId;
56 if (event.type === 'click') {
57 this.table.rowDetail.toggleExpandRow(event.row);
61 public addOrUpdateArtifact = (artifact: ArtifactModel, isViewOnly?: boolean) => {
62 this.artifactsService.openArtifactModal(this.componentId, this.componentType, artifact, ArtifactGroupType.INFORMATION, isViewOnly);
65 public deleteArtifact = (artifactToDelete) => {
66 this.artifactsService.deleteArtifact(this.componentType, this.componentId, artifactToDelete)