1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-04 18:37:45 +01:00

set page titles

This commit is contained in:
Kyle Spearrin 2018-07-05 22:37:35 -04:00
parent 7baf72d3db
commit 6193bf431d
8 changed files with 86 additions and 27 deletions

2
jslib

@ -1 +1 @@
Subproject commit 91081d92327da22ab3be88a60f8b71be26933370 Subproject commit ed93fa9ea3c486d78ba2591b3057245ead147a15

View File

@ -52,8 +52,16 @@ const routes: Routes = [
children: [ children: [
{ path: '', pathMatch: 'full', component: LoginComponent, canActivate: [UnauthGuardService] }, { path: '', pathMatch: 'full', component: LoginComponent, canActivate: [UnauthGuardService] },
{ path: '2fa', component: TwoFactorComponent, canActivate: [UnauthGuardService] }, { path: '2fa', component: TwoFactorComponent, canActivate: [UnauthGuardService] },
{ path: 'register', component: RegisterComponent, canActivate: [UnauthGuardService] }, {
{ path: 'hint', component: HintComponent, canActivate: [UnauthGuardService] }, path: 'register', component: RegisterComponent,
canActivate: [UnauthGuardService],
data: { titleId: 'createAccount' },
},
{
path: 'hint', component: HintComponent,
canActivate: [UnauthGuardService],
data: { titleId: 'passwordHint' },
},
{ path: 'lock', component: LockComponent }, { path: 'lock', component: LockComponent },
], ],
}, },
@ -62,20 +70,24 @@ const routes: Routes = [
component: UserLayoutComponent, component: UserLayoutComponent,
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
children: [ children: [
{ path: 'vault', component: VaultComponent }, { path: 'vault', component: VaultComponent, data: { titleId: 'myVault' } },
{ {
path: 'settings', path: 'settings',
component: SettingsComponent, component: SettingsComponent,
children: [ children: [
{ path: '', pathMatch: 'full', redirectTo: 'account' }, { path: '', pathMatch: 'full', redirectTo: 'account' },
{ path: 'account', component: AccountComponent }, { path: 'account', component: AccountComponent, data: { titleId: 'myAccount' } },
{ path: 'options', component: OptionsComponent }, { path: 'options', component: OptionsComponent, data: { titleId: 'options' } },
{ path: 'domain-rules', component: DomainRulesComponent }, { path: 'domain-rules', component: DomainRulesComponent, data: { titleId: 'domainRules' } },
{ path: 'two-factor', component: TwoFactorSetupComponent }, { path: 'two-factor', component: TwoFactorSetupComponent, data: { titleId: 'twoStepLogin' } },
{ path: 'premium', component: PremiumComponent }, { path: 'premium', component: PremiumComponent, data: { titleId: 'goPremium' } },
{ path: 'billing', component: UserBillingComponent }, { path: 'billing', component: UserBillingComponent, data: { titleId: 'billingAndLicensing' } },
{ path: 'organizations', component: OrganizationsComponent }, { path: 'organizations', component: OrganizationsComponent, data: { titleId: 'organizations' } },
{ path: 'create-organization', component: CreateOrganizationComponent }, {
path: 'create-organization',
component: CreateOrganizationComponent,
data: { titleId: 'newOrganization' },
},
], ],
}, },
{ {
@ -84,10 +96,14 @@ const routes: Routes = [
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
children: [ children: [
{ path: '', pathMatch: 'full', redirectTo: 'generator' }, { path: '', pathMatch: 'full', redirectTo: 'generator' },
{ path: 'import', component: ImportComponent }, { path: 'import', component: ImportComponent, data: { titleId: 'importData' } },
{ path: 'export', component: ExportComponent }, { path: 'export', component: ExportComponent, data: { titleId: 'exportVault' } },
{ path: 'generator', component: PasswordGeneratorComponent }, {
{ path: 'breach-report', component: BreachReportComponent }, path: 'generator',
component: PasswordGeneratorComponent,
data: { titleId: 'passwordGenerator' },
},
{ path: 'breach-report', component: BreachReportComponent, data: { titleId: 'dataBreachReport' } },
], ],
}, },
], ],
@ -98,7 +114,7 @@ const routes: Routes = [
canActivate: [AuthGuardService, OrganizationGuardService], canActivate: [AuthGuardService, OrganizationGuardService],
children: [ children: [
{ path: '', pathMatch: 'full', redirectTo: 'vault' }, { path: '', pathMatch: 'full', redirectTo: 'vault' },
{ path: 'vault', component: OrgVaultComponent }, { path: 'vault', component: OrgVaultComponent, data: { titleId: 'vault' } },
{ {
path: 'tools', path: 'tools',
component: OrgToolsComponent, component: OrgToolsComponent,
@ -106,8 +122,8 @@ const routes: Routes = [
data: { allowedTypes: [OrganizationUserType.Owner, OrganizationUserType.Admin] }, data: { allowedTypes: [OrganizationUserType.Owner, OrganizationUserType.Admin] },
children: [ children: [
{ path: '', pathMatch: 'full', redirectTo: 'export' }, { path: '', pathMatch: 'full', redirectTo: 'export' },
// { path: 'import', component: ImportComponent }, // { path: 'import', component: ImportComponent, data: { titleId: 'importData' } },
{ path: 'export', component: OrgExportComponent }, { path: 'export', component: OrgExportComponent, data: { titleId: 'exportVault' } },
], ],
}, },
], ],

View File

@ -5,7 +5,7 @@
<div class="card-header">{{'tools' | i18n}}</div> <div class="card-header">{{'tools' | i18n}}</div>
<div class="list-group list-group-flush"> <div class="list-group list-group-flush">
<a routerLink="import" class="list-group-item" routerLinkActive="active"> <a routerLink="import" class="list-group-item" routerLinkActive="active">
{{'import' | i18n}} {{'importData' | i18n}}
</a> </a>
<a routerLink="export" class="list-group-item" routerLinkActive="active"> <a routerLink="export" class="list-group-item" routerLinkActive="active">
{{'exportVault' | i18n}} {{'exportVault' | i18n}}

View File

@ -15,7 +15,7 @@ export class OrganizationTypeGuardService implements CanActivate {
async canActivate(route: ActivatedRouteSnapshot) { async canActivate(route: ActivatedRouteSnapshot) {
const org = await this.userService.getOrganization(route.parent.params.organizationId); const org = await this.userService.getOrganization(route.parent.params.organizationId);
const allowedTypes = route.data['allowedTypes'] as OrganizationUserType[]; const allowedTypes = route.data == null ? null : route.data.allowedTypes as OrganizationUserType[];
if (allowedTypes == null || allowedTypes.indexOf(org.type) === -1) { if (allowedTypes == null || allowedTypes.indexOf(org.type) === -1) {
this.router.navigate(['/organizations', org.id]); this.router.navigate(['/organizations', org.id]);
return false; return false;

View File

@ -1,20 +1,53 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { import {
ActivatedRoute,
NavigationEnd, NavigationEnd,
Router, Router,
} from '@angular/router'; } from '@angular/router';
import { I18nService } from 'jslib/abstractions/i18n.service';
@Injectable() @Injectable()
export class RouterService { export class RouterService {
private previousUrl: string = undefined; private previousUrl: string = undefined;
private currentUrl: string = undefined; private currentUrl: string = undefined;
constructor(private router: Router) { constructor(private router: Router, private activatedRoute: ActivatedRoute,
private titleService: Title, private i18nService: I18nService) {
this.currentUrl = this.router.url; this.currentUrl = this.router.url;
router.events.subscribe((event) => { router.events.subscribe((event) => {
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
this.previousUrl = this.currentUrl; this.previousUrl = this.currentUrl;
this.currentUrl = event.url; this.currentUrl = event.url;
let title = i18nService.t('pageTitle', 'Bitwarden');
let titleId: string = null;
let rawTitle: string = null;
let child = this.activatedRoute.firstChild;
while (child != null) {
if (child.firstChild != null) {
child = child.firstChild;
} else if (child.snapshot.data != null && child.snapshot.data.title != null) {
rawTitle = child.snapshot.data.title;
break;
} else if (child.snapshot.data != null && child.snapshot.data.titleId != null) {
titleId = child.snapshot.data.titleId;
break;
} else {
titleId = null;
rawTitle = null;
break;
}
}
if (titleId != null || rawTitle != null) {
const newTitle = rawTitle != null ? rawTitle : i18nService.t(titleId);
if (newTitle != null && newTitle !== '') {
title = (newTitle + ' | ' + title);
}
}
this.titleService.setTitle(title);
} }
}); });
} }

View File

@ -1,5 +1,5 @@
<div class="page-header"> <div class="page-header">
<h1>Import</h1> <h1>{{'importData' | i18n}}</h1>
</div> </div>
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
<div class="row"> <div class="row">
@ -48,6 +48,6 @@
</div> </div>
<button appBlurClick type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button appBlurClick type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<span>{{'import' | i18n}}</span> <span>{{'importData' | i18n}}</span>
</button> </button>
</form> </form>

View File

@ -8,7 +8,7 @@
{{'passwordGenerator' | i18n}} {{'passwordGenerator' | i18n}}
</a> </a>
<a routerLink="import" class="list-group-item" routerLinkActive="active"> <a routerLink="import" class="list-group-item" routerLinkActive="active">
{{'import' | i18n}} {{'importData' | i18n}}
</a> </a>
<a routerLink="export" class="list-group-item" routerLinkActive="active"> <a routerLink="export" class="list-group-item" routerLinkActive="active">
{{'exportVault' | i18n}} {{'exportVault' | i18n}}

View File

@ -1,4 +1,14 @@
{ {
"pageTitle": {
"message": "$APP_NAME$ Web Vault",
"description": "The title of the website in the browser window.",
"placeholders": {
"app_name": {
"content": "$1",
"example": "Bitwarden"
}
}
},
"whatTypeOfItem": { "whatTypeOfItem": {
"message": "What type of item is this?" "message": "What type of item is this?"
}, },
@ -884,8 +894,8 @@
"tools": { "tools": {
"message": "Tools" "message": "Tools"
}, },
"import": { "importData": {
"message": "Import" "message": "Import Data"
}, },
"importSuccess": { "importSuccess": {
"message": "Data has been successfully imported into your vault." "message": "Data has been successfully imported into your vault."