mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
Fix Api cennter
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
e3f73a3efd
commit
d41c5496a2
@ -15,6 +15,7 @@ COPY ./api/v2.0/legacy_swagger.yaml /build_dir/swagger.yaml
|
||||
COPY ./api/v2.0/swagger.yaml /build_dir/swagger2.yaml
|
||||
|
||||
RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger.yaml > swagger.json
|
||||
RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger2.yaml > swagger2.json
|
||||
|
||||
COPY ./LICENSE /build_dir
|
||||
COPY src/portal /build_dir
|
||||
@ -28,6 +29,7 @@ FROM goharbor/harbor-portal-base:${harbor_base_image_version}
|
||||
COPY --from=nodeportal /build_dir/dist /usr/share/nginx/html
|
||||
COPY --from=nodeportal /build_dir/swagger.yaml /usr/share/nginx/html
|
||||
COPY --from=nodeportal /build_dir/swagger.json /usr/share/nginx/html
|
||||
COPY --from=nodeportal /build_dir/swagger2.json /usr/share/nginx/html
|
||||
COPY --from=nodeportal /build_dir/LICENSE /usr/share/nginx/html
|
||||
|
||||
COPY make/photon/portal/nginx.conf /etc/nginx/nginx.conf
|
||||
|
@ -1,12 +1,18 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { throwError as observableThrowError, Observable } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { throwError as observableThrowError, forkJoin } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CookieService } from "ngx-cookie";
|
||||
import * as SwaggerUI from 'swagger-ui';
|
||||
import { mergeDeep } from "../../lib/utils/utils";
|
||||
|
||||
enum SwaggerJsonUrls {
|
||||
SWAGGER1 = '/swagger.json',
|
||||
SWAGGER2 = '/swagger2.json'
|
||||
}
|
||||
|
||||
const SwaggerUI = require('swagger-ui');
|
||||
@Component({
|
||||
selector: 'dev-center',
|
||||
templateUrl: 'dev-center.component.html',
|
||||
@ -15,8 +21,6 @@ const SwaggerUI = require('swagger-ui');
|
||||
})
|
||||
export class DevCenterComponent implements AfterViewInit, OnInit {
|
||||
private ui: any;
|
||||
private host: any;
|
||||
private json: any;
|
||||
constructor(
|
||||
private el: ElementRef,
|
||||
private http: HttpClient,
|
||||
@ -48,13 +52,15 @@ export class DevCenterComponent implements AfterViewInit, OnInit {
|
||||
}
|
||||
}
|
||||
};
|
||||
this.http.get("/swagger.json")
|
||||
forkJoin([this.http.get(SwaggerJsonUrls.SWAGGER1), this.http.get(SwaggerJsonUrls.SWAGGER2)])
|
||||
.pipe(catchError(error => observableThrowError(error)))
|
||||
.subscribe(json => {
|
||||
.subscribe(jsonArr => {
|
||||
const json: object = {};
|
||||
mergeDeep(json, jsonArr[0], jsonArr[1]);
|
||||
json['host'] = window.location.host;
|
||||
const protocal = window.location.protocol;
|
||||
json['schemes'] = [protocal.replace(":", "")];
|
||||
let ui = SwaggerUI({
|
||||
this.ui = SwaggerUI({
|
||||
spec: json,
|
||||
domNode: this.el.nativeElement.querySelector('.swagger-container'),
|
||||
deepLinking: true,
|
||||
|
@ -8,6 +8,7 @@ import { AdditionLink } from "../../../../../../../ng-swagger-gen/models/additio
|
||||
import { ErrorHandler } from "../../../../../../lib/utils/error-handler";
|
||||
import * as yaml from "js-yaml";
|
||||
import { finalize } from "rxjs/operators";
|
||||
import { isObject } from "../../../../../../lib/utils/utils";
|
||||
|
||||
@Component({
|
||||
selector: "hbr-artifact-values",
|
||||
@ -84,7 +85,7 @@ export class ValuesComponent implements OnInit {
|
||||
format(obj: object) {
|
||||
for (let name in obj) {
|
||||
if (obj.hasOwnProperty(name)) {
|
||||
if (obj[name] instanceof Object) {
|
||||
if (isObject(obj[name])) {
|
||||
for (let key in obj[name]) {
|
||||
if (obj[name].hasOwnProperty(key)) {
|
||||
obj[`${name}.${key}`] = obj[name][key];
|
||||
|
@ -2,7 +2,7 @@ import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/cor
|
||||
import { DatePipe } from "@angular/common";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { Artifact } from "../../../../../../ng-swagger-gen/models/artifact";
|
||||
import { formatSize } from "../../../../../lib/utils/utils";
|
||||
import { isObject } from "../../../../../lib/utils/utils";
|
||||
|
||||
enum Types {
|
||||
CREATED = 'created',
|
||||
@ -36,7 +36,7 @@ export class ArtifactCommonPropertiesComponent implements OnInit, OnChanges {
|
||||
Object.assign(this.commonProperties, this.artifactDetails.extra_attrs);
|
||||
for (let name in this.commonProperties) {
|
||||
if (this.commonProperties.hasOwnProperty(name)) {
|
||||
if (this.commonProperties[name] && this.commonProperties[name] instanceof Object) {
|
||||
if (isObject(this.commonProperties[name])) {
|
||||
this.commonProperties[name] = JSON.stringify(this.commonProperties[name]);
|
||||
}
|
||||
if (name === Types.CREATED) {
|
||||
|
@ -51,7 +51,6 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
if ((this.status === VULNERABILITY_SCAN_STATUS.RUNNING ||
|
||||
this.status === VULNERABILITY_SCAN_STATUS.PENDING) &&
|
||||
!this.stateCheckTimer) {
|
||||
@ -188,7 +187,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
this.summary = clone(newVal);
|
||||
}
|
||||
viewLog(): string {
|
||||
return `${ CURRENT_BASE_HREF }/projects/${this.projectName}/repositories/${this.repoName}
|
||||
/artifacts/${this.artifactDigest}/scan/${this.summary.report_id}/log`;
|
||||
return `${ CURRENT_BASE_HREF }/projects/${this.projectName
|
||||
}/repositories/${this.repoName}/artifacts/${this.artifactDigest}/scan/${this.summary.report_id}/log`;
|
||||
}
|
||||
}
|
||||
|
@ -597,3 +597,34 @@ export function formatSize(tagSize: string): string {
|
||||
return size + "B";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple object check.
|
||||
* @param item
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isObject(item): boolean {
|
||||
return (item && typeof item === 'object' && !Array.isArray(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deep merge two objects.
|
||||
* @param target
|
||||
* @param ...sources
|
||||
*/
|
||||
export function mergeDeep(target, ...sources) {
|
||||
if (!sources.length) { return target; }
|
||||
const source = sources.shift();
|
||||
|
||||
if (isObject(target) && isObject(source)) {
|
||||
for (const key in source) {
|
||||
if (isObject(source[key])) {
|
||||
if (!target[key]) { Object.assign(target, { [key]: {} }); }
|
||||
mergeDeep(target[key], source[key]);
|
||||
} else {
|
||||
Object.assign(target, { [key]: source[key] });
|
||||
}
|
||||
}
|
||||
}
|
||||
return mergeDeep(target, ...sources);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user