diff --git a/src/ui_ng/src/app/account/sign-in/sign-in.component.ts b/src/ui_ng/src/app/account/sign-in/sign-in.component.ts index d0c9eff73..c4c1a72c8 100644 --- a/src/ui_ng/src/app/account/sign-in/sign-in.component.ts +++ b/src/ui_ng/src/app/account/sign-in/sign-in.component.ts @@ -131,6 +131,7 @@ export class SignInComponent implements AfterViewChecked, OnInit { let expires: number = expireDays * 3600 * 24 * 1000; let date = new Date(Date.now() + expires); let cookieptions = new CookieOptions({ + path: "/", expires: date }); this.cookie.put(remCookieKey, this.signInCredential.principal, cookieptions); 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/app/base/navigator/navigator.component.ts b/src/ui_ng/src/app/base/navigator/navigator.component.ts index 420cdca55..de793a1bb 100644 --- a/src/ui_ng/src/app/base/navigator/navigator.component.ts +++ b/src/ui_ng/src/app/base/navigator/navigator.component.ts @@ -7,7 +7,7 @@ import { modalEvents } from '../modal-events.const'; import { SessionUser } from '../../shared/session-user'; import { SessionService } from '../../shared/session.service'; -import { CookieService } from 'angular2-cookie/core'; +import { CookieService, CookieOptions } from 'angular2-cookie/core'; import { supportedLangs, enLang, languageNames, CommonRoutes } from '../../shared/shared.const'; import { AppConfigService } from '../../app-config.service'; @@ -44,7 +44,8 @@ export class NavigatorComponent implements OnInit { this.translate.onLangChange.subscribe(langChange => { this.selectedLang = langChange.lang; //Keep in cookie for next use - this.cookie.put("harbor-lang", langChange.lang); + let opt = new CookieOptions({path: '/', expires: new Date(Date.now() + 3600*1000*24*31)}); + this.cookie.put("harbor-lang", langChange.lang, opt); }); if (this.appConfigService.isIntegrationMode()) { this.appTitle = 'APP_TITLE.VIC'; @@ -126,16 +127,14 @@ export class NavigatorComponent implements OnInit { //Switch languages switchLanguage(lang: string): void { + let selectedLang: string = enLang;//Default if (supportedLangs.find(supportedLang => supportedLang === lang.trim())) { - this.translate.use(lang); + selectedLang = lang; } else { - this.translate.use(enLang);//Use default - //TODO: - console.error('Language ' + lang.trim() + ' is not suppoted'); + console.error('Language ' + lang.trim() + ' is not suppoted yet'); } - setTimeout(() => { - window.location.reload(); - }, 500); + + this.translate.use(selectedLang).subscribe(() => window.location.reload()); } //Handle the home action 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