diff --git a/src/ui_ng/src/app/app.component.ts b/src/ui_ng/src/app/app.component.ts index 274d5881b..5273bcb36 100644 --- a/src/ui_ng/src/app/app.component.ts +++ b/src/ui_ng/src/app/app.component.ts @@ -1,10 +1,11 @@ -import { Component } from '@angular/core'; +import { Component, ReflectiveInjector, LOCALE_ID } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { CookieService } from 'angular2-cookie/core'; import { supportedLangs, enLang } from './shared/shared.const'; import { SessionService } from './shared/session.service'; + @Component({ selector: 'harbor-app', templateUrl: 'app.component.html' @@ -21,9 +22,9 @@ export class AppComponent { let langSetting = this.cookie.get("harbor-lang"); if (!langSetting || langSetting.trim() === "") { //Use browser lang - langSetting = translate.getBrowserLang(); + langSetting = translate.getBrowserCultureLang(); } - + let selectedLang = this.isLangMatch(langSetting, supportedLangs) ? langSetting : enLang; translate.use(selectedLang); //this.session.switchLanguage(selectedLang).catch(error => console.error(error)); diff --git a/src/ui_ng/src/app/app.module.ts b/src/ui_ng/src/app/app.module.ts index a46f17f50..3dde3002a 100644 --- a/src/ui_ng/src/app/app.module.ts +++ b/src/ui_ng/src/app/app.module.ts @@ -1,5 +1,5 @@ import { BrowserModule } from '@angular/platform-browser'; -import { NgModule, APP_INITIALIZER } from '@angular/core'; +import { NgModule, APP_INITIALIZER, LOCALE_ID } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { ClarityModule } from 'clarity-angular'; @@ -11,7 +11,7 @@ import { SharedModule } from './shared/shared.module'; import { AccountModule } from './account/account.module'; import { ConfigurationModule } from './config/config.module'; -import { TranslateModule, TranslateLoader, MissingTranslationHandler } from "@ngx-translate/core"; +import { TranslateModule, TranslateLoader, TranslateService, MissingTranslationHandler } from "@ngx-translate/core"; import { MyMissingTranslationHandler } from './i18n/missing-trans.handler'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { Http } from '@angular/http'; @@ -26,6 +26,10 @@ export function initConfig(configService: AppConfigService) { return () => configService.load(); } +function getCurrentLanguage(translateService: TranslateService) { + return translateService.currentLang; +} + @NgModule({ declarations: [ AppComponent, @@ -49,14 +53,19 @@ export function initConfig(configService: AppConfigService) { }) ], providers: [ - AppConfigService, - { - provide: APP_INITIALIZER, - useFactory: initConfig, - deps: [AppConfigService], + AppConfigService, + { + provide: APP_INITIALIZER, + useFactory: initConfig, + deps: [ AppConfigService ], multi: true - }], + }, + { + provide: LOCALE_ID, + useFactory: getCurrentLanguage, + deps:[ TranslateService ] + } + ], bootstrap: [AppComponent] }) -export class AppModule { -} +export class AppModule {} diff --git a/src/ui_ng/src/app/base/navigator/navigator.component.html b/src/ui_ng/src/app/base/navigator/navigator.component.html index 6db1970ed..a83279998 100644 --- a/src/ui_ng/src/app/base/navigator/navigator.component.html +++ b/src/ui_ng/src/app/base/navigator/navigator.component.html @@ -18,8 +18,8 @@ diff --git a/src/ui_ng/src/app/base/navigator/navigator.component.ts b/src/ui_ng/src/app/base/navigator/navigator.component.ts index 83aaf337f..7f33bebca 100644 --- a/src/ui_ng/src/app/base/navigator/navigator.component.ts +++ b/src/ui_ng/src/app/base/navigator/navigator.component.ts @@ -1,4 +1,4 @@ -import { Component, Output, EventEmitter, OnInit, Inject } from '@angular/core'; +import { Component, Output, EventEmitter, OnInit } from '@angular/core'; import { Router, NavigationExtras } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -27,7 +27,7 @@ export class NavigatorComponent implements OnInit { private selectedLang: string = enLang; private appTitle: string = 'APP_TITLE.HARBOR'; - + constructor( private session: SessionService, private router: Router, @@ -35,7 +35,9 @@ export class NavigatorComponent implements OnInit { private cookie: CookieService, private appConfigService: AppConfigService, private msgHandler: MessageHandlerService, - private searchTrigger: SearchTriggerService) { } + private searchTrigger: SearchTriggerService) { + + } ngOnInit(): void { this.selectedLang = this.translate.currentLang; @@ -118,10 +120,10 @@ export class NavigatorComponent implements OnInit { this.router.navigate([CommonRoutes.EMBEDDED_SIGN_IN]); }) .catch(error => { - this.msgHandler.handleError(error); + this.msgHandler.handleError(error); }); //Confirm search result panel is close - this.searchTrigger.closeSearch(true); + this.searchTrigger.closeSearch(true); } //Switch languages @@ -133,8 +135,7 @@ export class NavigatorComponent implements OnInit { //TODO: console.error('Language ' + lang.trim() + ' is not suppoted'); } - //Try to switch backend lang - //this.session.switchLanguage(lang).catch(error => console.error(error)); + window.location.reload(); } //Handle the home action diff --git a/src/ui_ng/src/app/log/audit-log.component.html b/src/ui_ng/src/app/log/audit-log.component.html index 621bffede..39e2b726e 100644 --- a/src/ui_ng/src/app/log/audit-log.component.html +++ b/src/ui_ng/src/app/log/audit-log.component.html @@ -35,7 +35,7 @@ {{l.repo_name}} {{l.repo_tag}} {{l.operation}} - {{l.op_time}} + {{l.op_time | date: 'short'}} {{totalRecordCount}} {{'AUDIT_LOG.ITEMS' | translate}} diff --git a/src/ui_ng/src/app/log/recent-log.component.html b/src/ui_ng/src/app/log/recent-log.component.html index 768f5ec45..492d900df 100644 --- a/src/ui_ng/src/app/log/recent-log.component.html +++ b/src/ui_ng/src/app/log/recent-log.component.html @@ -30,7 +30,7 @@ {{l.repo_name}} {{l.repo_tag}} {{l.operation}} - {{formatDateTime(l.op_time)}} + {{l.op_time | date: 'short'}} {{ (recentLogs ? recentLogs.length : 0) }} {{'AUDIT_LOG.ITEMS' | translate}} diff --git a/src/ui_ng/src/app/log/recent-log.component.ts b/src/ui_ng/src/app/log/recent-log.component.ts index 9144dc798..2546d4a26 100644 --- a/src/ui_ng/src/app/log/recent-log.component.ts +++ b/src/ui_ng/src/app/log/recent-log.component.ts @@ -65,11 +65,6 @@ export class RecentLogComponent implements OnInit { this.retrieveLogs(); } - public formatDateTime(dateTime: string) { - let dt: Date = new Date(dateTime); - return dt.toLocaleString(); - } - private retrieveLogs(): void { if (this.lines < 10) { this.lines = 10; diff --git a/src/ui_ng/src/app/project/list-project/list-project.component.html b/src/ui_ng/src/app/project/list-project/list-project.component.html index 2fb23f45a..c8f62fbb2 100644 --- a/src/ui_ng/src/app/project/list-project/list-project.component.html +++ b/src/ui_ng/src/app/project/list-project/list-project.component.html @@ -14,7 +14,7 @@ {{ (p.public === 1 ? 'PROJECT.PUBLIC' : 'PROJECT.PRIVATE') | translate}} {{roleInfo[p.current_user_role_id] | translate}} {{p.repo_count}} - {{p.creation_time}} + {{p.creation_time | date: 'short'}} {{totalRecordCount || (projects ? projects.length : 0)}} {{'PROJECT.ITEMS' | translate}} diff --git a/src/ui_ng/src/app/replication/destination/destination.component.html b/src/ui_ng/src/app/replication/destination/destination.component.html index b2ce12739..83117a541 100644 --- a/src/ui_ng/src/app/replication/destination/destination.component.html +++ b/src/ui_ng/src/app/replication/destination/destination.component.html @@ -25,7 +25,7 @@ {{t.name}} {{t.endpoint}} - {{t.creation_time}} + {{t.creation_time | date: 'short'}} {{ (targets ? targets.length : 0) }} {{'DESTINATION.ITEMS' | translate}} diff --git a/src/ui_ng/src/app/replication/list-job/list-job.component.html b/src/ui_ng/src/app/replication/list-job/list-job.component.html index a9e18ade6..04c3ae24f 100644 --- a/src/ui_ng/src/app/replication/list-job/list-job.component.html +++ b/src/ui_ng/src/app/replication/list-job/list-job.component.html @@ -9,8 +9,8 @@ {{j.repository}} {{j.status}} {{j.operation}} - {{j.creation_time}} - {{j.update_time}} + {{j.creation_time | date: 'short'}} + {{j.update_time | date: 'short'}} diff --git a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html index c2aaa20c9..76bbd83ed 100644 --- a/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html +++ b/src/ui_ng/src/app/repository/tag-repository/tag-repository.component.html @@ -37,7 +37,7 @@ {{t.author}} - {{t.created | date: 'yyyy/MM/dd'}} + {{t.created | date: 'short'}} {{t.dockerVersion}} {{t.architecture}} {{t.os}} diff --git a/src/ui_ng/src/app/shared/list-policy/list-policy.component.html b/src/ui_ng/src/app/shared/list-policy/list-policy.component.html index 785284f66..521f3d638 100644 --- a/src/ui_ng/src/app/shared/list-policy/list-policy.component.html +++ b/src/ui_ng/src/app/shared/list-policy/list-policy.component.html @@ -20,9 +20,12 @@ {{p.project_name}} - {{p.description}} + {{p.description ? p.description : '-'}} {{p.target_name}} - {{p.start_time}} + + + + {{ (p.enabled === 1 ? 'REPLICATION.ENABLED' : 'REPLICATION.DISABLED') | translate}} diff --git a/src/ui_ng/src/app/shared/list-policy/list-policy.component.ts b/src/ui_ng/src/app/shared/list-policy/list-policy.component.ts index 84d1e8871..ee235217c 100644 --- a/src/ui_ng/src/app/shared/list-policy/list-policy.component.ts +++ b/src/ui_ng/src/app/shared/list-policy/list-policy.component.ts @@ -18,6 +18,8 @@ import { Subscription } from 'rxjs/Subscription'; }) export class ListPolicyComponent implements OnDestroy { + nullTime: string = '0001-01-01T00:00:00Z'; + @Input() policies: Policy[]; @Input() projectless: boolean; @Input() selectedId: number; diff --git a/src/ui_ng/src/app/shared/list-project-ro/list-project-ro.component.html b/src/ui_ng/src/app/shared/list-project-ro/list-project-ro.component.html index 7d26d8920..591e39361 100644 --- a/src/ui_ng/src/app/shared/list-project-ro/list-project-ro.component.html +++ b/src/ui_ng/src/app/shared/list-project-ro/list-project-ro.component.html @@ -7,7 +7,7 @@ {{p.name}} {{ (p.public === 1 ? 'PROJECT.PUBLIC' : 'PROJECT.PRIVATE') | translate}} {{p.repo_count}} - {{p.creation_time}} + {{p.creation_time | date: 'short'}} {{totalRecordCount || (projects ? projects.length : 0)}} {{'PROJECT.ITEMS' | translate}} diff --git a/src/ui_ng/src/app/shared/session.service.ts b/src/ui_ng/src/app/shared/session.service.ts index 3d09652bf..10e53cc10 100644 --- a/src/ui_ng/src/app/shared/session.service.ts +++ b/src/ui_ng/src/app/shared/session.service.ts @@ -161,4 +161,5 @@ export class SessionService { getProjectMembers(): Member[] { return this.projectMembers; } + } \ No newline at end of file diff --git a/src/ui_ng/src/app/shared/shared.const.ts b/src/ui_ng/src/app/shared/shared.const.ts index 8454df101..d058f14e6 100644 --- a/src/ui_ng/src/app/shared/shared.const.ts +++ b/src/ui_ng/src/app/shared/shared.const.ts @@ -1,8 +1,8 @@ -export const supportedLangs = ['en', 'zh']; -export const enLang = "en"; +export const supportedLangs = ['en-US', 'zh-CN']; +export const enLang = "en-US"; export const languageNames = { - "en": "English", - "zh": "中文简体" + "en-US": "English", + "zh-CN": "中文简体" }; export const enum AlertType { DANGER, WARNING, INFO, SUCCESS diff --git a/src/ui_ng/src/app/shared/shared.utils.ts b/src/ui_ng/src/app/shared/shared.utils.ts index ddd53a606..dbe6ee351 100644 --- a/src/ui_ng/src/app/shared/shared.utils.ts +++ b/src/ui_ng/src/app/shared/shared.utils.ts @@ -11,8 +11,7 @@ export const errorHandler = function (error: any): string { if (!error) { return "UNKNOWN_ERROR"; } - console.log(JSON.stringify(error)); - + console.log(error); if (!(error.statusCode || error.status)) { //treat as string message return '' + error; diff --git a/src/ui_ng/src/app/user/user.component.html b/src/ui_ng/src/app/user/user.component.html index 0dff7b3b1..a2c1e1a3a 100644 --- a/src/ui_ng/src/app/user/user.component.html +++ b/src/ui_ng/src/app/user/user.component.html @@ -25,9 +25,7 @@ {{user.username}} {{isSystemAdmin(user)}} {{user.email}} - - {{user.creation_time}} - + {{user.creation_time | date: 'short'}} {{users.length}} {{'USER.ITEMS' | translate}} diff --git a/src/ui_ng/src/i18n/lang/en-lang.json b/src/ui_ng/src/i18n/lang/en-US-lang.json similarity index 100% rename from src/ui_ng/src/i18n/lang/en-lang.json rename to src/ui_ng/src/i18n/lang/en-US-lang.json diff --git a/src/ui_ng/src/i18n/lang/zh-lang.json b/src/ui_ng/src/i18n/lang/zh-CN-lang.json similarity index 100% rename from src/ui_ng/src/i18n/lang/zh-lang.json rename to src/ui_ng/src/i18n/lang/zh-CN-lang.json diff --git a/src/ui_ng/src/index.html b/src/ui_ng/src/index.html index 6f579cd88..0d977b6c1 100644 --- a/src/ui_ng/src/index.html +++ b/src/ui_ng/src/index.html @@ -7,7 +7,6 @@ - diff --git a/src/ui_ng/src/styles.css b/src/ui_ng/src/styles.css deleted file mode 100644 index 93d2409e4..000000000 --- a/src/ui_ng/src/styles.css +++ /dev/null @@ -1,9 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ -.datagrid-content-wrapper { - overflow: hidden; -} - -.form-group-label-override { - font-size: 14px; - font-weight: 400; -} \ No newline at end of file