Add ui change

using api/chartreport for ui

Signed-off-by: DQ <dengq@vmware.com>
This commit is contained in:
DQ 2020-03-30 22:53:00 +08:00
parent 9ff7d46e8f
commit 6216073d2a
5 changed files with 21 additions and 9 deletions

View File

@ -46,7 +46,7 @@ import { ListChartVersionRoComponent } from "./list-chart-version-ro/list-chart-
import { IServiceConfig, SERVICE_CONFIG } from "../../lib/entities/service.config"; import { IServiceConfig, SERVICE_CONFIG } from "../../lib/entities/service.config";
import { ErrorHandler } from "../../lib/utils/error-handler"; import { ErrorHandler } from "../../lib/utils/error-handler";
import { HarborLibraryModule } from "../../lib/harbor-library.module"; import { HarborLibraryModule } from "../../lib/harbor-library.module";
import { CURRENT_BASE_HREF } from "../../lib/utils/utils"; import { CURRENT_BASE_HREF, V1_BASE_HREF } from "../../lib/utils/utils";
const uiLibConfig: IServiceConfig = { const uiLibConfig: IServiceConfig = {
enablei18Support: true, enablei18Support: true,
@ -67,8 +67,9 @@ const uiLibConfig: IServiceConfig = {
configurationEndpoint: CURRENT_BASE_HREF + "/configurations", configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan", scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
labelEndpoint: CURRENT_BASE_HREF + "/labels", labelEndpoint: CURRENT_BASE_HREF + "/labels",
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo", helmChartEndpoint: V1_BASE_HREF + "/chartrepo",
downloadChartEndpoint: "/chartrepo", downloadChartEndpoint: "/chartrepo",
helmChartLabelEndpoint: CURRENT_BASE_HREF + "/chartrepo",
gcEndpoint: CURRENT_BASE_HREF + "/system/gc", gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll", ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll",
quotaUrl: CURRENT_BASE_HREF + "/quotas" quotaUrl: CURRENT_BASE_HREF + "/quotas"

View File

@ -229,6 +229,8 @@ export interface IServiceConfig {
*/ */
downloadChartEndpoint?: string; downloadChartEndpoint?: string;
helmChartLabelEndpoint?: string;
gcEndpoint?: string; gcEndpoint?: string;
ScanAllEndpoint?: string; ScanAllEndpoint?: string;

View File

@ -34,7 +34,7 @@ import {
ErrorHandler, ErrorHandler,
DefaultErrorHandler DefaultErrorHandler
} from './utils/error-handler'; } from './utils/error-handler';
import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG, CURRENT_BASE_HREF } from './utils/utils'; import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG, CURRENT_BASE_HREF, V1_BASE_HREF } from './utils/utils';
import { OperationService } from './components/operation/operation.service'; import { OperationService } from './components/operation/operation.service';
import { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component"; import { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component";
import { GcComponent } from "./components/config/gc/gc.component"; import { GcComponent } from "./components/config/gc/gc.component";
@ -97,7 +97,8 @@ export const DefaultServiceConfig: IServiceConfig = {
configurationEndpoint: CURRENT_BASE_HREF + "/configurations", configurationEndpoint: CURRENT_BASE_HREF + "/configurations",
scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan", scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan",
labelEndpoint: CURRENT_BASE_HREF + "/labels", labelEndpoint: CURRENT_BASE_HREF + "/labels",
helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo", helmChartEndpoint: V1_BASE_HREF + "/chartrepo",
helmChartLabelEndpoint: CURRENT_BASE_HREF + "/chartrepo",
downloadChartEndpoint: "/chartrepo", downloadChartEndpoint: "/chartrepo",
gcEndpoint: CURRENT_BASE_HREF + "/system/gc", gcEndpoint: CURRENT_BASE_HREF + "/system/gc",
ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll" ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll"

View File

@ -6,7 +6,7 @@ import { RequestQueryParams } from "./RequestQueryParams";
import { Label } from "./interface"; import { Label } from "./interface";
import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config"; import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config";
import { buildHttpRequestOptions, CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils"; import { buildHttpRequestOptions, CURRENT_BASE_HREF, V1_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils";
import { Observable, throwError as observableThrowError } from "rxjs"; import { Observable, throwError as observableThrowError } from "rxjs";
export abstract class LabelService { export abstract class LabelService {
@ -72,6 +72,7 @@ export abstract class LabelService {
export class LabelDefaultService extends LabelService { export class LabelDefaultService extends LabelService {
labelUrl: string; labelUrl: string;
chartUrl: string; chartUrl: string;
chartLabelUrl: string;
constructor( constructor(
@Inject(SERVICE_CONFIG) config: IServiceConfig, @Inject(SERVICE_CONFIG) config: IServiceConfig,
@ -79,7 +80,8 @@ export class LabelDefaultService extends LabelService {
) { ) {
super(); super();
this.labelUrl = config.labelEndpoint ? config.labelEndpoint : CURRENT_BASE_HREF + "/labels"; this.labelUrl = config.labelEndpoint ? config.labelEndpoint : CURRENT_BASE_HREF + "/labels";
this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : CURRENT_BASE_HREF + "/chartrepo"; this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : V1_BASE_HREF + "/chartrepo";
this.chartLabelUrl = config.helmChartLabelEndpoint ? config.helmChartLabelEndpoint : CURRENT_BASE_HREF + "/chartrepo";
} }
@ -208,7 +210,7 @@ export class LabelDefaultService extends LabelService {
chartName: string, chartName: string,
version: string version: string
): Observable<Label[]> { ): Observable<Label[]> {
return this.http.get<Label[]>(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels`); return this.http.get<Label[]>(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels`);
} }
markChartLabel( markChartLabel(
@ -217,7 +219,7 @@ export class LabelDefaultService extends LabelService {
version: string, version: string,
label: Label, label: Label,
): Observable<any> { ): Observable<any> {
return this.http.post(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels`, return this.http.post(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels`,
JSON.stringify(label), HTTP_JSON_OPTIONS); JSON.stringify(label), HTTP_JSON_OPTIONS);
} }
@ -227,7 +229,7 @@ export class LabelDefaultService extends LabelService {
version: string, version: string,
label: Label, label: Label,
): Observable<any> { ): Observable<any> {
return this.http.delete(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels/${label.id}`, HTTP_JSON_OPTIONS); return this.http.delete(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels/${label.id}`, HTTP_JSON_OPTIONS);
} }
} }

View File

@ -13,6 +13,12 @@ enum APILevels {
V1 = '', V1 = '',
V2 = '/v2.0' V2 = '/v2.0'
} }
/**
* v1 base href
*/
export const V1_BASE_HREF = '/api' + APILevels.V1;
/** /**
* Current base href * Current base href
*/ */