From 3171e43e66e876cdb180c80584405cbefb0095d5 Mon Sep 17 00:00:00 2001 From: Steven Zou Date: Wed, 12 Apr 2017 08:34:00 +0800 Subject: [PATCH] override page title and search placeholder when in VIC mode --- src/ui_ng/src/app/app.component.ts | 17 +++++++++++++++-- .../global-search/global-search.component.html | 2 +- .../global-search/global-search.component.ts | 12 +++++++++++- src/ui_ng/src/i18n/lang/en-us-lang.json | 3 ++- src/ui_ng/src/i18n/lang/zh-cn-lang.json | 3 ++- src/ui_ng/src/index.html | 2 +- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/ui_ng/src/app/app.component.ts b/src/ui_ng/src/app/app.component.ts index 917980eca..5639ba1e8 100644 --- a/src/ui_ng/src/app/app.component.ts +++ b/src/ui_ng/src/app/app.component.ts @@ -4,7 +4,8 @@ import { CookieService } from 'angular2-cookie/core'; import { supportedLangs, enLang } from './shared/shared.const'; import { SessionService } from './shared/session.service'; - +import { AppConfigService } from './app-config.service'; +import { Title } from '@angular/platform-browser'; @Component({ selector: 'harbor-app', @@ -14,7 +15,9 @@ export class AppComponent { constructor( private translate: TranslateService, private cookie: CookieService, - private session: SessionService) { + private session: SessionService, + private appConfigService: AppConfigService, + private titleService: Title) { translate.addLangs(supportedLangs); translate.setDefaultLang(enLang); @@ -29,6 +32,16 @@ export class AppComponent { let selectedLang = this.isLangMatch(langSetting, supportedLangs) ? langSetting : enLang; translate.use(selectedLang); //this.session.switchLanguage(selectedLang).catch(error => console.error(error)); + + //Override page title + let key: string = "APP_TITLE.HARBOR"; + if (this.appConfigService.isIntegrationMode()) { + key = "APP_TITLE.REG"; + } + + translate.get(key).subscribe((res: string) => { + this.titleService.setTitle(res); + }); } private isLangMatch(browserLang: string, supportedLangs: string[]) { diff --git a/src/ui_ng/src/app/base/global-search/global-search.component.html b/src/ui_ng/src/app/base/global-search/global-search.component.html index 77fb5e03b..d6848dd47 100644 --- a/src/ui_ng/src/app/base/global-search/global-search.component.html +++ b/src/ui_ng/src/app/base/global-search/global-search.component.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/src/ui_ng/src/app/base/global-search/global-search.component.ts b/src/ui_ng/src/app/base/global-search/global-search.component.ts index 75bb4be18..af47a445c 100644 --- a/src/ui_ng/src/app/base/global-search/global-search.component.ts +++ b/src/ui_ng/src/app/base/global-search/global-search.component.ts @@ -6,6 +6,8 @@ import { Subscription } from 'rxjs/Subscription'; import { SearchTriggerService } from './search-trigger.service'; +import { AppConfigService } from '../../app-config.service'; + import 'rxjs/add/operator/debounceTime'; import 'rxjs/add/operator/distinctUntilChanged'; @@ -27,9 +29,13 @@ export class GlobalSearchComponent implements OnInit, OnDestroy { private isResPanelOpened: boolean = false; private searchTerm: string = ""; + //Placeholder text + placeholderText: string = "GLOBAL_SEARCH.PLACEHOLDER"; + constructor( private searchTrigger: SearchTriggerService, - private router: Router) { } + private router: Router, + private appConfigService: AppConfigService) { } //Implement ngOnIni ngOnInit(): void { @@ -42,6 +48,10 @@ export class GlobalSearchComponent implements OnInit, OnDestroy { this.closeSub = this.searchTrigger.searchClearChan$.subscribe(clear => { this.searchTerm = ""; }); + + if(this.appConfigService.isIntegrationMode()){ + this.placeholderText = "GLOBAL_SEARCH.PLACEHOLDER_VIC"; + } } ngOnDestroy(): void { diff --git a/src/ui_ng/src/i18n/lang/en-us-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json index 621423749..96cc9d25f 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -86,7 +86,8 @@ "ROOT_CERT": "Download Root Cert" }, "GLOBAL_SEARCH": { - "PLACEHOLDER": "Search Harbor..." + "PLACEHOLDER": "Search Harbor...", + "PLACEHOLDER_VIC": "Search Registry..." }, "SIDE_NAV": { "DASHBOARD": "Dashboard", diff --git a/src/ui_ng/src/i18n/lang/zh-cn-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json index a3a505e3d..57aba1bcf 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -86,7 +86,8 @@ "ROOT_CERT": "下载根证书" }, "GLOBAL_SEARCH": { - "PLACEHOLDER": "搜索 Harbor..." + "PLACEHOLDER": "搜索 Harbor...", + "PLACEHOLDER_VIC": "搜索 Registry..." }, "SIDE_NAV": { "DASHBOARD": "仪表板", diff --git a/src/ui_ng/src/index.html b/src/ui_ng/src/index.html index fe95d0fe7..2a3bf2fe3 100644 --- a/src/ui_ng/src/index.html +++ b/src/ui_ng/src/index.html @@ -3,7 +3,7 @@ - Harbor + VMware