Commit c52cb4fc authored by Yogi_Wang's avatar Yogi_Wang
Browse files

Remove the Deplicate utils in lib an app , fix #6365, #7807


1.remove the Deplicate utils in lib an app ,fix #6365
2.edit style fix #7807
Signed-off-by: default avatarYogi_Wang <yawang@vmware.com>
parent fbec3ee7
export * from './harbor-library.module';
export * from './service.config';
export * from './service/index';
export * from './error-handler/index';
export * from './utils';
export * from './log/index';
export * from './filter/index';
export * from './endpoint/index';
export * from './repository/index';
export * from './create-edit-endpoint/index';
export * from './create-edit-rule/index';
export * from './tag/index';
export * from './list-replication-rule/index';
export * from './replication/index';
export * from './vulnerability-scanning/index';
export * from './i18n/index';
export * from './push-image/index';
export * from './third-party/index';
export * from './config/index';
export * from './channel/index';
export * from './project-policy-config/index';
export * from './label/index';
export * from './create-edit-label/index';
export * from './gridview/index';
export * from './repository-gridview/index';
export * from './operation/index';
export * from './_animations/index';
export * from "./harbor-library.module";
export * from "./service.config";
export * from "./service/index";
export * from "./error-handler/index";
export * from "./shared/shared.const";
export * from "./shared/shared.utils";
export * from "./utils";
export * from "./log/index";
export * from "./filter/index";
export * from "./endpoint/index";
export * from "./repository/index";
export * from "./create-edit-endpoint/index";
export * from "./create-edit-rule/index";
export * from "./tag/index";
export * from "./list-replication-rule/index";
export * from "./replication/index";
export * from "./vulnerability-scanning/index";
export * from "./i18n/index";
export * from "./push-image/index";
export * from "./third-party/index";
export * from "./config/index";
export * from "./channel/index";
export * from "./project-policy-config/index";
export * from "./label/index";
export * from "./create-edit-label/index";
export * from "./gridview/index";
export * from "./repository-gridview/index";
export * from "./operation/index";
export * from "./_animations/index";
import {throwError as observableThrowError, Observable } from "rxjs";
import { Injectable, Inject } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { HttpClient, HttpParams, HttpResponse } from "@angular/common/http";
import { map , catchError } from "rxjs/operators";
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
......@@ -10,7 +10,7 @@ import { ProjectPolicy } from "../project-policy-config/project-policy-config.co
import {
HTTP_JSON_OPTIONS,
HTTP_GET_OPTIONS,
buildHttpRequestOptions
buildHttpRequestOptionsWithObserveResponse
} from "../utils";
import { RequestQueryParams } from "./RequestQueryParams";
......@@ -64,10 +64,15 @@ export abstract class ProjectService {
*/
abstract listProjects(
name: string,
isPublic: number,
isPublic?: number,
page?: number,
pageSize?: number
): Observable<Project[]>;
): Observable<HttpResponse<Project[]>>;
abstract createProject(name: string, metadata: any): Observable<any>;
abstract toggleProjectPublic(projectId: number, isPublic: string): Observable<any>;
abstract deleteProject(projectId: number): Observable<any>;
abstract checkProjectExists(projectName: string): Observable<any>;
abstract checkProjectMember(projectId: number): Observable<any>;
}
/**
......@@ -100,32 +105,6 @@ export class ProjectDefaultService extends ProjectService {
.pipe(catchError(error => observableThrowError(error)));
}
public listProjects(
name: string,
isPublic: number,
page?: number,
pageSize?: number
): Observable<Project[]> {
let baseUrl: string = this.config.projectBaseEndpoint
? this.config.projectBaseEndpoint
: "/api/projects";
let params = new RequestQueryParams();
if (page && pageSize) {
params = params.set("page", page + "").set("page_size", pageSize + "");
}
if (name && name.trim() !== "") {
params = params.set("name", name);
}
if (isPublic !== undefined) {
params = params.set("public", "" + isPublic);
}
// let options = new RequestOptions({ headers: this.getHeaders, search: params });
return this.http
.get<Project[]>(baseUrl, buildHttpRequestOptions(params))
.pipe(catchError(error => observableThrowError(error)));
}
public updateProjectPolicy(
projectId: number | string,
projectPolicy: ProjectPolicy
......@@ -149,4 +128,53 @@ export class ProjectDefaultService extends ProjectService {
)
.pipe(catchError(error => observableThrowError(error)));
}
public listProjects(name: string, isPublic?: number, page?: number, pageSize?: number): Observable<HttpResponse<Project[]>> {
let params = new HttpParams();
if (page && pageSize) {
params = params.set('page', page + '').set('page_size', pageSize + '');
}
if (name && name.trim() !== "") {
params = params.set('name', name);
}
if (isPublic !== undefined) {
params = params.set('public', '' + isPublic);
}
return this.http
.get<HttpResponse<Project[]>>(`/api/projects`, buildHttpRequestOptionsWithObserveResponse(params)).pipe(
catchError(error => observableThrowError(error)), );
}
public createProject(name: string, metadata: any): Observable<any> {
return this.http
.post(`/api/projects`,
JSON.stringify({'project_name': name, 'metadata': {
public: metadata.public ? 'true' : 'false',
}})
, HTTP_JSON_OPTIONS).pipe(
catchError(error => observableThrowError(error)), );
}
public toggleProjectPublic(projectId: number, isPublic: string): Observable<any> {
return this.http
.put(`/api/projects/${projectId}`, { 'metadata': {'public': isPublic} }, HTTP_JSON_OPTIONS).pipe(
catchError(error => observableThrowError(error)), );
}
public deleteProject(projectId: number): Observable<any> {
return this.http
.delete(`/api/projects/${projectId}`)
.pipe(catchError(error => observableThrowError(error)));
}
public checkProjectExists(projectName: string): Observable<any> {
return this.http
.head(`/api/projects/?project_name=${projectName}`).pipe(
catchError(error => observableThrowError(error)), );
}
public checkProjectMember(projectId: number): Observable<any> {
return this.http
.get(`/api/projects/${projectId}/members`, HTTP_GET_OPTIONS).pipe(
catchError(error => observableThrowError(error)), );
}
}
......@@ -11,14 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export const supportedLangs = ['en-us', 'zh-cn', 'es-es', 'fr-fr'];
export const enLang = "en-us";
export const languageNames = {
"en-us": "English",
"zh-cn": "中文简体",
"es-es": "Español",
"fr-fr": "Français"
};
export const enum AlertType {
DANGER, WARNING, INFO, SUCCESS
}
......@@ -91,21 +84,3 @@ export const LabelColor = [
{ 'color': '#F52F52', 'textColor': 'black' }, { 'color': '#FF5501', 'textColor': 'black' },
{ 'color': '#F57600', 'textColor': 'black' }, { 'color': '#FFDC0B', 'textColor': 'black' },
];
export const RoleMapping = { 'projectAdmin': 'MEMBER.PROJECT_ADMIN', 'master': 'MEMBER.PROJECT_MASTER',
'developer': 'MEMBER.DEVELOPER', 'guest': 'MEMBER.GUEST' };
export enum Roles {
PROJECT_ADMIN = 1,
PROJECT_MASTER = 4,
DEVELOPER = 2,
GUEST = 3,
OTHER = 0,
}
export enum ResourceType {
REPOSITORY = 1,
CHART_VERSION = 2,
REPOSITORY_TAG = 3,
}
......@@ -32,7 +32,7 @@ import { ChannelService } from "../channel/index";
import {
ConfirmationTargets,
ConfirmationState,
ConfirmationButtons, Roles
ConfirmationButtons
} from "../shared/shared.const";
import { ConfirmationDialogComponent } from "../confirmation-dialog/confirmation-dialog.component";
......
......@@ -185,8 +185,23 @@ export class CustomComparator<T> implements Comparator<T> {
compare(a: { [key: string]: any | any[] }, b: { [key: string]: any | any[] }) {
let comp = 0;
if (a && b) {
let fieldA = a[this.fieldName];
let fieldB = b[this.fieldName];
let fieldA, fieldB;
for (let key of Object.keys(a)) {
if (key === this.fieldName) {
fieldA = a[key];
fieldB = b[key];
break;
} else if (typeof a[key] === 'object') {
let insideObject = a[key];
for (let insideKey in insideObject) {
if (insideKey === this.fieldName) {
fieldA = insideObject[insideKey];
fieldB = b[key][insideKey];
break;
}
}
}
}
switch (this.type) {
case "number":
comp = fieldB - fieldA;
......@@ -194,6 +209,9 @@ export class CustomComparator<T> implements Comparator<T> {
case "date":
comp = new Date(fieldB).getTime() - new Date(fieldA).getTime();
break;
case "string":
comp = fieldB.localeCompare(fieldA);
break;
}
}
return comp;
......
......@@ -22,8 +22,7 @@ import { SessionService } from "../../shared/session.service";
import { InlineAlertComponent } from "../../shared/inline-alert/inline-alert.component";
import { MessageHandlerService } from "../../shared/message-handler/message-handler.service";
import { SearchTriggerService } from "../../base/global-search/search-trigger.service";
import { CommonRoutes } from "../../shared/shared.const";
import { CopyInputComponent } from "@harbor/ui";
import { CopyInputComponent, CommonRoutes } from "@harbor/ui";
import { AccountSettingsModalService } from './account-settings-modal-service.service';
import { ConfirmationDialogComponent } from "../../shared/confirmation-dialog/confirmation-dialog.component";
import {
......
......@@ -18,7 +18,7 @@ import { NgForm } from '@angular/forms';
import { PasswordSettingService } from '../password-setting.service';
import { InlineAlertComponent } from '../../../shared/inline-alert/inline-alert.component';
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
import { CommonRoutes } from '../../../shared/shared.const';
import { CommonRoutes } from '@harbor/ui';
@Component({
selector: 'reset-password',
......
......@@ -26,7 +26,7 @@ import { SessionService } from '../../shared/session.service';
import { AboutDialogComponent } from '../../shared/about-dialog/about-dialog.component';
import { SearchTriggerService } from '../global-search/search-trigger.service';
import { CommonRoutes } from '../../shared/shared.const';
import { CommonRoutes } from '@harbor/ui';
@Component({
selector: 'harbor-shell',
......
......@@ -22,7 +22,8 @@ import { modalEvents } from '../modal-events.const';
import { SessionService } from '../../shared/session.service';
import { CookieService, CookieOptions } from 'ngx-cookie';
import { supportedLangs, enLang, languageNames, CommonRoutes } from '../../shared/shared.const';
import { supportedLangs, enLang, languageNames } from '../../shared/shared.const';
import { CommonRoutes } from '@harbor/ui';
import { AppConfigService } from '../../app-config.service';
import { SearchTriggerService } from '../global-search/search-trigger.service';
import { MessageHandlerService } from '../../shared/message-handler/message-handler.service';
......
......@@ -15,8 +15,7 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Subscription } from "rxjs";
import {
Configuration, StringValueItem, SystemSettingsComponent,
isEmpty, clone, getChanges, GcRepoService } from '@harbor/ui';
isEmpty, clone } from '@harbor/ui';
import { ConfirmationTargets, ConfirmationState } from '../shared/shared.const';
import { SessionService } from '../shared/session.service';
import { ConfirmationDialogService } from '../shared/confirmation-dialog/confirmation-dialog.service';
......
......@@ -16,9 +16,8 @@ import { HttpClient } from '@angular/common/http';
import { map, catchError } from "rxjs/operators";
import { Observable, throwError as observableThrowError } from "rxjs";
import { Configuration } from '@harbor/ui';
import { Configuration, HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS } from '@harbor/ui';
import {HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS} from "@harbor/ui";
const configEndpoint = "/api/configurations";
const emailEndpoint = "/api/email/ping";
......
......@@ -19,7 +19,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Message } from './message';
import { MessageService } from './message.service';
import { dismissInterval, httpStatusCode, CommonRoutes } from '../shared/shared.const';
import { dismissInterval, httpStatusCode, CommonRoutes } from '@harbor/ui';
@Component({
selector: 'global-message',
......
......@@ -4,21 +4,21 @@ import { flatMap, catchError } from "rxjs/operators";
import { SessionService } from "./../shared/session.service";
import { TranslateService } from "@ngx-translate/core";
import { Component, OnInit, ViewChild, OnDestroy } from "@angular/core";
import { operateChanges, OperateInfo, OperationService, OperationState } from "@harbor/ui";
import { operateChanges, OperateInfo, OperationService, OperationState, errorHandler as errorHandFn } from "@harbor/ui";
import {
ConfirmationTargets,
ConfirmationState,
ConfirmationButtons
} from "../shared/shared.const";
import { ConfirmationMessage } from "../shared/confirmation-dialog/confirmation-message";
import { ConfirmationDialogService } from "./../shared/confirmation-dialog/confirmation-dialog.service";
import { AddGroupModalComponent } from "./add-group-modal/add-group-modal.component";
import { UserGroup } from "./group";
import { GroupService } from "./group.service";
import { MessageHandlerService } from "../shared/message-handler/message-handler.service";
import { errorHandler as errorHandFn } from "../shared/shared.utils";
import { Observable, throwError as observableThrowError } from "rxjs";
import { throwError as observableThrowError } from "rxjs";
@Component({
selector: "app-group",
templateUrl: "./group.component.html",
......
......@@ -2,8 +2,7 @@ import { Router, ActivatedRoute } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { OidcOnboardService } from './oidc-onboard.service';
import { FormControl } from '@angular/forms';
import { errorHandler } from "../shared/shared.utils";
import { CommonRoutes } from '../shared/shared.const';
import { errorHandler, CommonRoutes } from "@harbor/ui";
@Component({
selector: 'app-oidc-onboard',
......
......@@ -30,7 +30,7 @@ import { MessageHandlerService } from "../../shared/message-handler/message-hand
import { InlineAlertComponent } from "../../shared/inline-alert/inline-alert.component";
import { Project } from "../project";
import { ProjectService } from "../project.service";
import { ProjectService } from "@harbor/ui";
import { errorHandler } from '@angular/platform-browser/src/browser';
......
......@@ -25,7 +25,8 @@ import { State,
operateChanges,
OperationService,
UserPermissionService,
USERSTATICPERMISSION } from "@harbor/ui";
USERSTATICPERMISSION,
errorHandler as errorHandFn } from "@harbor/ui";
import { HelmChartVersion, HelmChartMaintainer } from "../../helm-chart.interface.service";
import { HelmChartService } from "../../helm-chart.service";
......@@ -39,9 +40,7 @@ import {
ConfirmationState,
DefaultHelmIcon,
ResourceType,
Roles
} from "../../../../shared/shared.const";
import { errorHandler as errorHandFn } from "../../../../shared/shared.utils";
@Component({
selector: "hbr-helm-chart-version",
......
......@@ -10,10 +10,9 @@ import {
} from "@angular/core";
import { NgForm } from '@angular/forms';
import { TranslateService } from "@ngx-translate/core";
import {
State, ErrorHandler, SystemInfo, SystemInfoService, DEFAULT_PAGE_SIZE, downloadFile
import { State, ErrorHandler, SystemInfo, SystemInfoService, DEFAULT_PAGE_SIZE, downloadFile
, OperationService, UserPermissionService, USERSTATICPERMISSION, OperateInfo, OperationState, operateChanges
} from "@harbor/ui";
, errorHandler as errorHandFn } from "@harbor/ui";
import { forkJoin, throwError as observableThrowError, Observable } from "rxjs";
import { finalize, map, catchError } from "rxjs/operators";
import { HelmChartItem } from "../helm-chart.interface.service";
......@@ -28,7 +27,6 @@ import {
ConfirmationTargets,
ConfirmationState,
} from "../../../shared/shared.const";
import { errorHandler as errorHandFn } from "../../../shared/shared.utils";
@Component({
selector: "hbr-helm-chart",
......
......@@ -24,9 +24,10 @@ import { Router } from "@angular/router";
import { Comparator, State } from "../../../../lib/src/service/interface";
import {TranslateService} from "@ngx-translate/core";
import { RoleInfo, ConfirmationTargets, ConfirmationState, ConfirmationButtons } from "../../shared/shared.const";
import { CustomComparator, doFiltering, doSorting, calculatePage } from "../../shared/shared.utils";
import { errorHandler as errorHandFn, calculatePage , operateChanges, OperateInfo, OperationService
, OperationState, CustomComparator, doFiltering, doSorting, ProjectService } from "@harbor/ui";
import { SessionService } from "../../shared/session.service";
import { StatisticHandler } from "../../shared/statictics/statistic-handler.service";
......@@ -34,14 +35,11 @@ import { ConfirmationDialogService } from "../../shared/confirmation-dialog/conf
import { MessageHandlerService } from "../../shared/message-handler/message-handler.service";
import { ConfirmationMessage } from "../../shared/confirmation-dialog/confirmation-message";
import { SearchTriggerService } from "../../base/global-search/search-trigger.service";
import {AppConfigService} from "../../app-config.service";
import {operateChanges, OperateInfo, OperationService, OperationState} from "@harbor/ui";
import { AppConfigService } from "../../app-config.service";
import { Project } from "../project";
import { ProjectService } from "../project.service";
import { map, catchError } from "rxjs/operators";
import { throwError as observableThrowError } from "rxjs";
import { errorHandler as errorHandFn } from "../../shared/shared.utils";
@Component({
selector: "list-project",
......
......@@ -7,7 +7,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
import { NgForm } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import {operateChanges, OperateInfo, OperationService, OperationState} from "@harbor/ui";
import { operateChanges, OperateInfo, OperationService, OperationState, errorHandler as errorHandFn } from "@harbor/ui";
import { UserGroup } from "./../../../group/group";
import { MemberService } from "./../member.service";
......@@ -16,7 +16,6 @@ import { ProjectRoles } from "../../../shared/shared.const";
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
import { Member } from "../member";
import { throwError as observableThrowError } from "rxjs";
import { errorHandler as errorHandFn } from "../../../shared/shared.utils";
@Component({
selector: "add-group",
templateUrl: "./add-group.component.html",
......
......@@ -39,7 +39,7 @@ import {User} from "../../../user/user";
import {Project} from "../../project";
import { Member } from '../member';
import { errorHandler as errorHandFn } from "../../../shared/shared.utils";
import { errorHandler as errorHandFn } from "@harbor/ui";
import { MemberService } from '../member.service';
import { HttpResponseBase } from '@angular/common/http';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment