mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
Add download latest version button
Add download button in chart list view to download latest chart Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
parent
2011e606fc
commit
b9697df44a
@ -25,10 +25,13 @@
|
||||
<clr-datagrid (clrDgRefresh)="refresh()" [clrDgLoading]="loading" [(clrDgSelected)]="selectedRows">
|
||||
<clr-dg-action-bar>
|
||||
<button type="button" class="btn btn-sm btn-secondary" [disabled]="!developerRoleOrAbove" (click)="onChartUpload()">
|
||||
<clr-icon shape="upload" size="16"></clr-icon> {{'HELM_CHART.UPLOAD' | translate}}
|
||||
<clr-icon shape="upload" size="16"></clr-icon>{{'HELM_CHART.UPLOAD' | translate}}
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" [disabled]="!hasProjectAdminRole" (click)="openChartDeleteModal(selectedRows)">
|
||||
<clr-icon shape="delete" size="16"></clr-icon> {{'BUTTON.DELETE' | translate}}
|
||||
<button type="button" class="btn btn-sm btn-secondary" [disabled]="!hasProjectAdminRole || selectedRows.length<1" (click)="openChartDeleteModal(selectedRows)">
|
||||
<clr-icon shape="trash" size="16"></clr-icon>{{'BUTTON.DELETE' | translate}}
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" [disabled]="selectedRows.length!==1" (click)="downloadLatestVersion()">
|
||||
<clr-icon shape="download" size="16"></clr-icon>{{'HELM_CHART.DOWNLOAD' | translate}}
|
||||
</button>
|
||||
</clr-dg-action-bar>
|
||||
<clr-dg-column >{{'HELM_CHART.NAME' | translate}}</clr-dg-column>
|
||||
|
@ -107,4 +107,10 @@ clr-modal {
|
||||
max-width: 25%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
clr-icon {
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
@ -11,11 +11,11 @@ import {
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { State } from "@clr/angular";
|
||||
import { forkJoin, throwError } from "rxjs";
|
||||
import { forkJoin, throwError, Observable } from "rxjs";
|
||||
import { finalize, map, catchError } from "rxjs/operators";
|
||||
import { SystemInfo, SystemInfoService, HelmChartItem } from "../service/index";
|
||||
import { ErrorHandler } from "../error-handler/error-handler";
|
||||
import { toPromise, DEFAULT_PAGE_SIZE } from "../utils";
|
||||
import { toPromise, DEFAULT_PAGE_SIZE, downloadFile } from "../utils";
|
||||
import { HelmChartService } from "../service/helm-chart.service";
|
||||
import { DefaultHelmIcon} from "../shared/shared.const";
|
||||
import { Roles } from './../shared/shared.const';
|
||||
@ -183,7 +183,7 @@ export class HelmChartComponent implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
deleteChart(chartName: string) {
|
||||
deleteChart(chartName: string): Observable<any> {
|
||||
let operateMsg = new OperateInfo();
|
||||
operateMsg.name = "OPERATION.DELETE_CHART";
|
||||
operateMsg.data.id = chartName;
|
||||
@ -211,6 +211,35 @@ export class HelmChartComponent implements OnInit {
|
||||
.subscribe(() => {});
|
||||
}
|
||||
|
||||
downloadLatestVersion(evt?: Event, item?: HelmChartItem) {
|
||||
if (evt) {
|
||||
evt.stopPropagation();
|
||||
}
|
||||
let selectedChart: HelmChartItem;
|
||||
|
||||
if (item) {
|
||||
selectedChart = item;
|
||||
} else {
|
||||
// return if selected version less then 1
|
||||
if (this.selectedRows.length < 1) {
|
||||
return;
|
||||
}
|
||||
selectedChart = this.selectedRows[0];
|
||||
}
|
||||
if (!selectedChart) {
|
||||
return;
|
||||
}
|
||||
let filename = `charts/${selectedChart.name}-${selectedChart.latest_version}.tgz`;
|
||||
this.helmChartService.downloadChart(this.projectName, filename).subscribe(
|
||||
res => {
|
||||
downloadFile(res);
|
||||
},
|
||||
error => {
|
||||
this.errorHandler.error(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
openChartDeleteModal(charts: HelmChartItem[]) {
|
||||
let chartNames = charts.map(chart => chart.name).join(",");
|
||||
let message = new ConfirmationMessage(
|
||||
|
@ -123,6 +123,7 @@ export class HelmChartDefaultService extends HelmChartService {
|
||||
return {
|
||||
name: chart.Name,
|
||||
total_versions: chart.total_versions,
|
||||
latest_version: chart.latest_version,
|
||||
created: chart.Created,
|
||||
icon: chart.Icon,
|
||||
home: chart.Home};
|
||||
|
@ -301,6 +301,7 @@ export interface ScrollPosition {
|
||||
export interface HelmChartItem {
|
||||
name: string;
|
||||
total_versions: number;
|
||||
latest_version: string;
|
||||
created: string;
|
||||
icon: string;
|
||||
home: string;
|
||||
|
Loading…
Reference in New Issue
Block a user