1 import { Component, Input, OnInit, ViewChild } from '@angular/core';
2 import * as _ from 'lodash';
3 import { DistributionService } from '../../distribution.service';
5 // tslint:disable:no-string-literal
8 selector: 'app-distribution-component-artifact-table',
9 templateUrl: './distribution-component-artifact-table.component.html',
10 styleUrls: ['./distribution-component-artifact-table.component.less']
12 export class DistributionComponentArtifactTableComponent implements OnInit {
14 @ViewChild('statusTable', {}) table: any;
16 @Input() componentName: string;
17 @Input() rowDistributionID: string;
18 @Input() statusFilter: string;
20 public artifacts = [];
22 constructor(private distributionService: DistributionService) {
26 this.artifacts = this.distributionService.getArtifactstByDistributionIDAndComponentsName(this.rowDistributionID, this.componentName);
27 if (this.statusFilter) {
28 this.artifacts.forEach(
30 artifact.statuses = _.filter(artifact.statuses, {status: this.statusFilter});
35 public getLatestArtifact(artifactName: string) {
36 const selectedArtifact = this.artifacts.filter((artifact) => artifact.name === artifactName);
37 if (selectedArtifact && selectedArtifact[0] && selectedArtifact[0]['statuses'] && selectedArtifact[0]['statuses'][0]) {
38 return selectedArtifact[0]['statuses'][0];
44 private copyToClipboard(urlToCopy: any) {
46 const inputForCopyToClipboard = document.getElementById('inputForCopyToClipboard') as HTMLInputElement;
47 inputForCopyToClipboard.value = urlToCopy;
48 /* Select the text field */
49 inputForCopyToClipboard.select();
51 /* Copy the text inside the text field */
52 document.execCommand('copy');
56 private generateDataTestID(preFix: string, componentName: string, artifactName: string, status?: string) {
58 return preFix + componentName + '_' + artifactName;
60 return preFix + status + '_' + componentName + '_' + artifactName;
64 private expandRow(row: any) {
65 this.table.rowDetail.toggleExpandRow(row);