mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-23 16:11:24 +01:00
commit
fceedb9976
@ -1,47 +1,62 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { throwError as observableThrowError, Observable } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from "../../service.config";
|
||||
|
||||
export abstract class GcApiRepository {
|
||||
abstract postSchedule(param): Observable<any>;
|
||||
|
||||
abstract putSchedule(param): Observable<any>;
|
||||
|
||||
abstract getSchedule(): Observable<any>;
|
||||
|
||||
abstract getLog(id): Observable<any>;
|
||||
|
||||
abstract getStatus(id): Observable<any>;
|
||||
|
||||
abstract getJobs(): Observable<any>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class GcApiRepository {
|
||||
|
||||
export class GcApiDefaultRepository extends GcApiRepository {
|
||||
constructor(
|
||||
private http: Http,
|
||||
@Inject(SERVICE_CONFIG) private config: IServiceConfig
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public postSchedule(param): Observable<any> {
|
||||
return this.http.post("/api/system/gc/schedule", param)
|
||||
return this.http.post(`${this.config.gcEndpoint}/schedule`, param)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public putSchedule(param): Observable<any> {
|
||||
return this.http.put("/api/system/gc/schedule", param)
|
||||
return this.http.put(`${this.config.gcEndpoint}/schedule`, param)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getSchedule(): Observable<any> {
|
||||
return this.http.get("/api/system/gc/schedule")
|
||||
return this.http.get(`${this.config.gcEndpoint}/schedule`)
|
||||
.pipe(catchError(error => observableThrowError(error)))
|
||||
.pipe(map(response => response.json()));
|
||||
}
|
||||
|
||||
public getLog(id): Observable<any> {
|
||||
return this.http.get("/api/system/gc/" + id + "/log")
|
||||
return this.http.get(`${this.config.gcEndpoint}/${id}/log`)
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
public getStatus(id): Observable<any> {
|
||||
return this.http.get("/api/system/gc/" + id)
|
||||
return this.http.get(`${this.config.gcEndpoint}/id`)
|
||||
.pipe(catchError(error => observableThrowError(error)))
|
||||
.pipe(map(response => response.json()));
|
||||
}
|
||||
|
||||
public getJobs(): Observable<any> {
|
||||
return this.http.get("/api/system/gc")
|
||||
return this.http.get(`${this.config.gcEndpoint}`)
|
||||
.pipe(catchError(error => observableThrowError(error)))
|
||||
.pipe(map(response => response.json()));
|
||||
}
|
44
src/portal/lib/src/config/gc/gc.component.spec.ts
Normal file
44
src/portal/lib/src/config/gc/gc.component.spec.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { GcComponent } from './gc.component';
|
||||
import { SERVICE_CONFIG, IServiceConfig } from '../../service.config';
|
||||
import { GcApiRepository, GcApiDefaultRepository} from './gc.api.repository';
|
||||
import { GcRepoService } from './gc.service';
|
||||
import { SharedModule } from "../../shared/shared.module";
|
||||
import { ErrorHandler } from '../../error-handler/error-handler';
|
||||
import { GcViewModelFactory } from './gc.viewmodel.factory';
|
||||
import { GcUtility } from './gc.utility';
|
||||
|
||||
describe('GcComponent', () => {
|
||||
let component: GcComponent;
|
||||
let fixture: ComponentFixture<GcComponent>;
|
||||
let config: IServiceConfig = {
|
||||
systemInfoEndpoint: "/api/system/gc"
|
||||
};
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
SharedModule
|
||||
],
|
||||
declarations: [ GcComponent ],
|
||||
providers: [
|
||||
{ provide: GcApiRepository, useClass: GcApiDefaultRepository },
|
||||
{ provide: SERVICE_CONFIG, useValue: config },
|
||||
GcRepoService,
|
||||
ErrorHandler,
|
||||
GcViewModelFactory,
|
||||
GcUtility
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GcComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -5,7 +5,7 @@ import { GcViewModelFactory } from "./gc.viewmodel.factory";
|
||||
import { GcRepoService } from "./gc.service";
|
||||
import { WEEKDAYS, SCHEDULE_TYPE, ONE_MINITUE, THREE_SECONDS} from './gc.const';
|
||||
import { GcUtility } from './gc.utility';
|
||||
import { ErrorHandler } from '@harbor/ui';
|
||||
import { ErrorHandler } from '../../error-handler/index';
|
||||
|
||||
@Component({
|
||||
selector: 'gc-config',
|
@ -3,9 +3,10 @@ import { Http } from '@angular/http';
|
||||
import { Observable, Subscription, Subject, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { GcApiRepository } from './gc.api.repository';
|
||||
import { ErrorHandler } from '@harbor/ui';
|
||||
import { ErrorHandler } from '../../error-handler/index';
|
||||
import { GcJobData } from './gcLog';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class GcRepoService {
|
||||
|
7
src/portal/lib/src/config/gc/index.ts
Normal file
7
src/portal/lib/src/config/gc/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export * from "./gc.component";
|
||||
export * from "./gc.const";
|
||||
export * from "./gc.api.repository";
|
||||
export * from "./gc.service";
|
||||
export * from "./gc.utility";
|
||||
export * from "./gc.viewmodel.factory";
|
||||
export * from "./gcLog";
|
@ -4,15 +4,19 @@ import { ReplicationConfigComponent } from './replication/replication-config.com
|
||||
import { SystemSettingsComponent } from './system/system-settings.component';
|
||||
import { VulnerabilityConfigComponent } from './vulnerability/vulnerability-config.component';
|
||||
import { RegistryConfigComponent } from './registry-config.component';
|
||||
import { GcComponent } from './gc/gc.component';
|
||||
|
||||
|
||||
export * from './config';
|
||||
export * from './replication/replication-config.component';
|
||||
export * from './system/system-settings.component';
|
||||
export * from './vulnerability/vulnerability-config.component';
|
||||
export * from './registry-config.component';
|
||||
export * from './gc/index';
|
||||
|
||||
export const CONFIGURATION_DIRECTIVES: Type<any>[] = [
|
||||
ReplicationConfigComponent,
|
||||
GcComponent,
|
||||
SystemSettingsComponent,
|
||||
VulnerabilityConfigComponent,
|
||||
RegistryConfigComponent
|
||||
|
@ -13,5 +13,11 @@
|
||||
<vulnerability-config *ngIf="withClair" #vulnerabilityConfig [(vulnerabilityConfig)]="config" [showSubTitle]="true"></vulnerability-config>
|
||||
</clr-tab-content>
|
||||
</clr-tab>
|
||||
<clr-tab>
|
||||
<button id="config-gc" clrTabLink>{{'CONFIG.GC' | translate}}</button>
|
||||
<clr-tab-content id="gc" *clrIfActive>
|
||||
<gc-config #gcConfig></gc-config>
|
||||
</clr-tab-content>
|
||||
</clr-tab>
|
||||
</clr-tabs>
|
||||
<confirmation-dialog #cfgConfirmationDialog (confirmAction)="confirmCancel($event)"></confirmation-dialog>
|
@ -8,6 +8,7 @@ import { SystemSettingsComponent } from './system/system-settings.component';
|
||||
import { VulnerabilityConfigComponent } from './vulnerability/vulnerability-config.component';
|
||||
import { RegistryConfigComponent } from './registry-config.component';
|
||||
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
|
||||
import { GcComponent } from './gc/gc.component';
|
||||
|
||||
import {
|
||||
ConfigurationService,
|
||||
@ -62,7 +63,8 @@ describe('RegistryConfigComponent (inline template)', () => {
|
||||
SystemSettingsComponent,
|
||||
VulnerabilityConfigComponent,
|
||||
RegistryConfigComponent,
|
||||
ConfirmationDialogComponent
|
||||
ConfirmationDialogComponent,
|
||||
GcComponent
|
||||
],
|
||||
providers: [
|
||||
ErrorHandler,
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
clone
|
||||
} from '../utils';
|
||||
import { ErrorHandler } from '../error-handler/index';
|
||||
import { SystemSettingsComponent, VulnerabilityConfigComponent} from './index';
|
||||
import { SystemSettingsComponent, VulnerabilityConfigComponent, GcComponent} from './index';
|
||||
import { Configuration } from './config';
|
||||
|
||||
@Component({
|
||||
@ -30,6 +30,7 @@ export class RegistryConfigComponent implements OnInit {
|
||||
|
||||
@ViewChild("systemSettings") systemSettings: SystemSettingsComponent;
|
||||
@ViewChild("vulnerabilityConfig") vulnerabilityCfg: VulnerabilityConfigComponent;
|
||||
@ViewChild("gc") gc: GcComponent;
|
||||
@ViewChild("cfgConfirmationDialog") confirmationDlg: ConfirmationDialogComponent;
|
||||
|
||||
constructor(
|
||||
|
@ -59,6 +59,10 @@ import {
|
||||
UserPermissionService,
|
||||
UserPermissionDefaultService
|
||||
} from './service/index';
|
||||
import { GcRepoService } from './config/gc/gc.service';
|
||||
import { GcUtility } from './config/gc/gc.utility';
|
||||
import {GcViewModelFactory} from './config/gc/gc.viewmodel.factory';
|
||||
import {GcApiRepository, GcApiDefaultRepository} from './config/gc/gc.api.repository';
|
||||
import {
|
||||
ErrorHandler,
|
||||
DefaultErrorHandler
|
||||
@ -98,7 +102,8 @@ export const DefaultServiceConfig: IServiceConfig = {
|
||||
scanJobEndpoint: "/api/jobs/scan",
|
||||
labelEndpoint: "/api/labels",
|
||||
helmChartEndpoint: "/api/chartrepo",
|
||||
downloadChartEndpoint: "/chartrepo"
|
||||
downloadChartEndpoint: "/chartrepo",
|
||||
gcEndpoint: "/api/system/gc"
|
||||
};
|
||||
|
||||
/**
|
||||
@ -154,6 +159,10 @@ export interface HarborModuleConfig {
|
||||
helmChartService?: Provider;
|
||||
// Service implementation for userPermission
|
||||
userPermissionService?: Provider;
|
||||
|
||||
// Service implementation for gc
|
||||
gcApiRepository?: Provider;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,6 +263,7 @@ export class HarborLibraryModule {
|
||||
config.labelService || { provide: LabelService, useClass: LabelDefaultService },
|
||||
config.helmChartService || { provide: HelmChartService, useClass: HelmChartDefaultService },
|
||||
config.userPermissionService || { provide: UserPermissionService, useClass: UserPermissionDefaultService },
|
||||
config.gcApiRepository || {provide: GcApiRepository, useClass: GcApiDefaultRepository},
|
||||
// Do initializing
|
||||
TranslateServiceInitializer,
|
||||
{
|
||||
@ -263,7 +273,10 @@ export class HarborLibraryModule {
|
||||
multi: true
|
||||
},
|
||||
ChannelService,
|
||||
OperationService
|
||||
OperationService,
|
||||
GcRepoService,
|
||||
GcViewModelFactory,
|
||||
GcUtility
|
||||
]
|
||||
};
|
||||
}
|
||||
@ -288,8 +301,12 @@ export class HarborLibraryModule {
|
||||
config.labelService || { provide: LabelService, useClass: LabelDefaultService },
|
||||
config.helmChartService || { provide: HelmChartService, useClass: HelmChartDefaultService },
|
||||
config.userPermissionService || { provide: UserPermissionService, useClass: UserPermissionDefaultService },
|
||||
config.gcApiRepository || {provide: GcApiRepository, useClass: GcApiDefaultRepository},
|
||||
ChannelService,
|
||||
OperationService
|
||||
OperationService,
|
||||
GcRepoService,
|
||||
GcViewModelFactory,
|
||||
GcUtility
|
||||
]
|
||||
};
|
||||
}
|
||||
|
@ -26,3 +26,4 @@ export * from './repository-gridview/index';
|
||||
export * from './operation/index';
|
||||
export * from './_animations/index';
|
||||
export * from './helm-chart/index';
|
||||
|
||||
|
@ -237,4 +237,6 @@ export interface IServiceConfig {
|
||||
* * {string}
|
||||
*/
|
||||
downloadChartEndpoint?: string;
|
||||
|
||||
gcEndpoint?: string;
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { Subscription } from "rxjs";
|
||||
import {
|
||||
Configuration, StringValueItem, SystemSettingsComponent, VulnerabilityConfigComponent,
|
||||
isEmpty, clone, getChanges
|
||||
} from '@harbor/ui';
|
||||
isEmpty, clone, getChanges, GcComponent, GcRepoService } from '@harbor/ui';
|
||||
|
||||
import { ConfirmationTargets, ConfirmationState } from '../shared/shared.const';
|
||||
import { SessionService } from '../shared/session.service';
|
||||
@ -26,7 +25,6 @@ import { MessageHandlerService } from '../shared/message-handler/message-handler
|
||||
import { AppConfigService } from '../app-config.service';
|
||||
import { ConfigurationAuthComponent } from './auth/config-auth.component';
|
||||
import { ConfigurationEmailComponent } from './email/config-email.component';
|
||||
import { GcComponent } from './gc/gc.component';
|
||||
import { ConfigurationService } from './config.service';
|
||||
|
||||
|
||||
|
@ -11,6 +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.
|
||||
|
||||
import { NgModule } from "@angular/core";
|
||||
import { CoreModule } from "../core/core.module";
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
@ -20,28 +21,19 @@ import { ConfigurationService } from "./config.service";
|
||||
import { ConfirmMessageHandler } from "./config.msg.utils";
|
||||
import { ConfigurationAuthComponent } from "./auth/config-auth.component";
|
||||
import { ConfigurationEmailComponent } from "./email/config-email.component";
|
||||
import { GcComponent } from "./gc/gc.component";
|
||||
import { GcRepoService } from "./gc/gc.service";
|
||||
import { GcApiRepository } from "./gc/gc.api.repository";
|
||||
import { RobotApiRepository } from "../project/robot-account/robot.api.repository";
|
||||
import { GcViewModelFactory } from "./gc/gc.viewmodel.factory";
|
||||
import { GcUtility } from "./gc/gc.utility";
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [CoreModule, SharedModule],
|
||||
declarations: [
|
||||
ConfigurationComponent,
|
||||
ConfigurationAuthComponent,
|
||||
ConfigurationEmailComponent,
|
||||
GcComponent
|
||||
ConfigurationEmailComponent
|
||||
],
|
||||
exports: [ConfigurationComponent],
|
||||
providers: [
|
||||
ConfigurationService,
|
||||
GcRepoService,
|
||||
GcApiRepository,
|
||||
GcViewModelFactory,
|
||||
GcUtility,
|
||||
ConfirmMessageHandler,
|
||||
RobotApiRepository
|
||||
]
|
||||
|
@ -1,25 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { GcComponent } from './gc.component';
|
||||
|
||||
describe('GcComponent', () => {
|
||||
let component: GcComponent;
|
||||
let fixture: ComponentFixture<GcComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ GcComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GcComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -74,7 +74,8 @@ const uiLibConfig: IServiceConfig = {
|
||||
scanJobEndpoint: "/api/jobs/scan",
|
||||
labelEndpoint: "/api/labels",
|
||||
helmChartEndpoint: "/api/chartrepo",
|
||||
downloadChartEndpoint: "/chartrepo"
|
||||
downloadChartEndpoint: "/chartrepo",
|
||||
gcEndpoint: "/api/system/gc"
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
|
Loading…
Reference in New Issue
Block a user