Enhance the module configuration of harbor ui

This commit is contained in:
Steven Zou 2017-05-02 15:12:39 +08:00
parent e8e7f66e91
commit 25004bbd1f
3 changed files with 54 additions and 5 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ src/ui_ng/aot/**/*.json
**/*ngsummary.json
**/*ngfactory.ts
**/aot
**/dist

View File

@ -35,7 +35,8 @@
"core-js": "^2.4.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.8.4"
"zone.js": "^0.8.4",
"mutationobserver-shim": "^0.3.2"
},
"devDependencies": {
"@angular/cli": "^1.0.0",

View File

@ -2,18 +2,55 @@ import { NgModule, ModuleWithProviders, Provider } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SYSTEMINFO_DIRECTIVES } from './system/index';
import { SERVICE_CONFIG, IServiceConfig } from './service.config';
import {
AccessLogService,
AccessLogDefaultService,
EndpointService,
EndpointDefaultService,
ReplicationService,
ReplicationDefaultService,
RepositoryService,
RepositoryDefaultService,
TagService,
TagDefaultService
} from './service/index';
/**
* Declare default service configuration
*/
export const DefaultServiceConfig: IServiceConfig = {
systemInfoEndpoint: "/api/system",
repositoryBaseEndpoint: "",
logBaseEndpoint: "",
targetBaseEndpoint: "",
replicationRuleEndpoint:"",
replicationRuleEndpoint: "",
replicationJobEndpoint: ""
};
/**
* Define the configuration for harbor shareable module
*
* @export
* @interface HarborModuleConfig
*/
export interface HarborModuleConfig {
config?: Provider
//Service endpoints
config?: Provider,
//Service implementation for log
logService?: Provider,
//Service implementation for endpoint
endpointService?: Provider,
//Service implementation for replication
replicationService?: Provider,
//Service implementation for repository
repositoryService?: Provider,
//Service implementation for tag
tagService?: Provider
}
@NgModule({
@ -29,7 +66,12 @@ export class HarborLibraryModule {
return {
ngModule: HarborLibraryModule,
providers: [
config.config || { provide: SERVICE_CONFIG, useValue: DefaultServiceConfig }
config.config || { provide: SERVICE_CONFIG, useValue: DefaultServiceConfig },
config.logService || { provide: AccessLogService, useClass: AccessLogDefaultService },
config.endpointService || { provide: EndpointService, useClass: EndpointDefaultService },
config.replicationService || { provide: ReplicationService, useClass: ReplicationDefaultService },
config.repositoryService || { provide: RepositoryService, useClass: RepositoryDefaultService },
config.tagService || { provide: TagService, useClass: TagDefaultService }
]
};
}
@ -38,7 +80,12 @@ export class HarborLibraryModule {
return {
ngModule: HarborLibraryModule,
providers: [
config.config || { provide: SERVICE_CONFIG, useValue: DefaultServiceConfig }
config.config || { provide: SERVICE_CONFIG, useValue: DefaultServiceConfig },
config.logService || { provide: AccessLogService, useClass: AccessLogDefaultService },
config.endpointService || { provide: EndpointService, useClass: EndpointDefaultService },
config.replicationService || { provide: ReplicationService, useClass: ReplicationDefaultService },
config.repositoryService || { provide: RepositoryService, useClass: RepositoryDefaultService },
config.tagService || { provide: TagService, useClass: TagDefaultService }
]
};
}