import { Component, OnInit, ChangeDetectionStrategy, Input } from "@angular/core"; import { HelmChartMetaData, HelmChartSecurity } from "./../../service/interface"; import { downloadFile } from './../../utils'; import { HelmChartService } from "../../service/index"; import { ErrorHandler } from "./../../error-handler/error-handler"; @Component({ selector: "hbr-chart-detail-summary", templateUrl: "./chart-detail-summary.component.html", styleUrls: ["./chart-detail-summary.component.scss"], changeDetection: ChangeDetectionStrategy.OnPush }) export class ChartDetailSummaryComponent implements OnInit { @Input() summary: HelmChartMetaData; @Input() security: HelmChartSecurity; @Input() repoURL: string; @Input() projectName: string; @Input() chartName: string; @Input() chartVersion: string; @Input() readme: string; copiedCMD = ''; addCMD: string; installCMD: string; verifyCMD: string; constructor( private errorHandler: ErrorHandler, private helmChartService: HelmChartService ) {} ngOnInit(): void { this.addCMD = `helm repo add --ca-file --cert-file --key-file --username --password ${this.repoURL}/chartrepo/${this.projectName}`; this.installCMD = `helm install --ca-file --cert-file --key-file --username= --password= --version ${this.chartVersion} /${this.chartName}`; this.verifyCMD = `helm verify --keyring ${this.chartName}-${this.chartVersion}.tgz`; } isCopied(cmd: string) { return this.copiedCMD === cmd; } onCopySuccess(e: Event, cmd: string) { this.copiedCMD = cmd; } public get prov_ready() { return this.security && this.security.signature && this.security.signature.signed; } downloadChart() { if (!this.summary || !this.summary.urls || this.summary.urls.length < 1) { return; } let filename = `${this.summary.urls[0]}.prov`; this.helmChartService.downloadChart(this.projectName, filename).subscribe( res => { downloadFile(res); }, error => { this.errorHandler.error(error); }, ); } }