blob: 866c14e56faa744238fa186337b97788971fc1f0 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import * as _ from 'lodash';
import { DistributionService } from '../../distribution.service';
// tslint:disable:no-string-literal
@Component({
selector: 'app-distribution-component-artifact-table',
templateUrl: './distribution-component-artifact-table.component.html',
styleUrls: ['./distribution-component-artifact-table.component.less']
})
export class DistributionComponentArtifactTableComponent implements OnInit {
@ViewChild('statusTable', {}) table: any;
@Input() componentName: string;
@Input() rowDistributionID: string;
@Input() statusFilter: string;
public artifacts = [];
constructor(private distributionService: DistributionService) {
}
ngOnInit() {
const artifacts = this.distributionService.getArtifactstByDistributionIDAndComponentsName(this.rowDistributionID, this.componentName);
this.artifacts = this.prepareArtifacts(artifacts);
if (this.statusFilter) {
this.artifacts.forEach(
(artifact) => {
artifact.statuses = _.filter(artifact.statuses, {status: this.statusFilter});
});
}
}
public getLatestArtifact(artifactName: string) {
const selectedArtifact = this.artifacts.filter((artifact) => artifact.name === artifactName);
if (selectedArtifact && selectedArtifact[0] && selectedArtifact[0]['statuses'] && selectedArtifact[0]['statuses'][0]) {
return selectedArtifact[0]['statuses'][0];
} else {
return null;
}
}
private prepareArtifacts(artifacts: any[]) {
if (artifacts) {
artifacts.forEach((artifact) => {
if (artifact && artifact['statuses']) {
artifact['statuses'].forEach((status) => {
if (!status.errorReason || status.errorReason === 'null') {
status.errorReason = ''
}
})
}
});
}
return artifacts
}
private copyToClipboard(urlToCopy: any) {
const inputForCopyToClipboard = document.getElementById('inputForCopyToClipboard') as HTMLInputElement;
inputForCopyToClipboard.value = urlToCopy;
/* Select the text field */
inputForCopyToClipboard.select();
/* Copy the text inside the text field */
document.execCommand('copy');
}
private generateDataTestID(preFix: string, componentName: string, artifactName: string, status?: string) {
if (!status) {
return preFix + componentName + '_' + artifactName;
} else {
return preFix + status + '_' + componentName + '_' + artifactName;
}
}
private expandRow(row: any) {
this.table.rowDetail.toggleExpandRow(row);
}
}
|