Merge pull request #6478 from zhoumeina/fix_chart_label

fix helm chart did not get global label
This commit is contained in:
Mia ZHOU 2018-12-07 14:37:16 +08:00 committed by GitHub
commit 0b476b859f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 20 deletions

View File

@ -54,7 +54,7 @@
</button>
<clr-dropdown-menu clrPosition="bottom-left" *clrIfOpen>
<hbr-resource-label-marker
[labels]="projectLabels"
[labels]="labels"
[projectName]="projectName"
[resource]="selectedRows[0]"
[resourceType]="resourceType"
@ -74,7 +74,7 @@
{{'REPOSITORY.LABELS' | translate}}
<clr-dg-filter [clrDgFilter]="labelFilter">
<hbr-chart-version-label-filter #labelFilter class="label-filter"
[labels]="projectLabels"
[labels]="labels"
[resourceType]="resourceType">
</hbr-chart-version-label-filter>
</clr-dg-filter>

View File

@ -9,7 +9,7 @@ import {
EventEmitter
} from "@angular/core";
import { Observable, forkJoin } from "rxjs";
import {finalize, map} from "rxjs/operators";
import { finalize, map } from "rxjs/operators";
import { TranslateService } from "@ngx-translate/core";
import { State } from "@clr/angular";
@ -65,7 +65,7 @@ export class ChartVersionComponent implements OnInit {
chartVersions: HelmChartVersion[] = [];
systemInfo: SystemInfo;
selectedRows: HelmChartVersion[] = [];
projectLabels: Label[] = [];
labels: Label[] = [];
loading = true;
resourceType = ResourceType.CHART_VERSION;
@ -93,7 +93,7 @@ export class ChartVersionComponent implements OnInit {
private resrouceLabelService: LabelService,
private cdr: ChangeDetectorRef,
private operationService: OperationService,
) {}
) { }
public get registryUrl(): string {
return this.systemInfo ? this.systemInfo.registry_url : "";
@ -105,7 +105,7 @@ export class ChartVersionComponent implements OnInit {
.then(systemInfo => (this.systemInfo = systemInfo))
.catch(error => this.errorHandler.error(error));
this.refresh();
this.getProjectLabels();
this.getLabels();
this.lastFilteredVersionName = "";
}
@ -114,12 +114,12 @@ export class ChartVersionComponent implements OnInit {
this.refresh();
}
getProjectLabels() {
this.resrouceLabelService.getProjectLabels(this.projectId).subscribe(
(labels: Label[]) => {
this.projectLabels = labels;
}
);
getLabels() {
forkJoin(this.resrouceLabelService.getLabels("g"), this.resrouceLabelService.getProjectLabels(this.projectId))
.subscribe(
(labels) => {
this.labels = [].concat(...labels);
});
}
refresh() {
@ -318,12 +318,12 @@ export class ChartVersionComponent implements OnInit {
onLabelChange(version: HelmChartVersion) {
this.resrouceLabelService.getChartVersionLabels(this.projectName, this.chartName, version.version)
.subscribe(labels => {
.subscribe(labels => {
let versionIdx = this.chartVersions.findIndex(v => v.name === version.name);
this.chartVersions[versionIdx].labels = labels;
let hnd = setInterval(() => this.cdr.markForCheck(), 200);
setTimeout(() => clearInterval(hnd), 5000);
});
});
}
public get developerRoleOrAbove(): boolean {

View File

@ -1,7 +1,7 @@
import { Inject, Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { Observable} from "rxjs";
import { map } from "rxjs/operators";
import { map, catchError} from "rxjs/operators";
import { RequestQueryParams } from "./RequestQueryParams";
import { Label } from "./interface";
@ -33,7 +33,7 @@ export abstract class LabelService {
projectId?: number,
name?: string,
queryParams?: RequestQueryParams
): Observable<Label[]> | Promise<Label[]>;
): Observable<Label[]>;
abstract createLabel(
label: Label
@ -149,7 +149,7 @@ export class LabelDefaultService extends LabelService {
projectId?: number,
name?: string,
queryParams?: RequestQueryParams
): Observable<Label[]> | Promise<Label[]> {
): Observable<Label[]> {
if (!queryParams) {
queryParams = new RequestQueryParams();
}
@ -164,9 +164,8 @@ export class LabelDefaultService extends LabelService {
}
return this.http
.get(this.labelUrl, buildHttpRequestOptions(queryParams))
.toPromise()
.then(response => response.json())
.catch(error => Promise.reject(error));
.pipe(map(response => response.json()))
.pipe(catchError(error => Promise.reject(error)));
}
createLabel(label: Label): Observable<any> | Promise<any> | any {