diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index b78823a0..309c94ba 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { AccountComponent } from './settings/account.component'; +import { OptionsComponent } from './settings/options.component'; import { SettingsComponent } from './settings/settings.component'; import { ExportComponent } from './tools/export.component'; @@ -51,6 +52,7 @@ const routes: Routes = [ children: [ { path: '', pathMatch: 'full', redirectTo: 'account' }, { path: 'account', component: AccountComponent, canActivate: [AuthGuardService] }, + { path: 'options', component: OptionsComponent, canActivate: [AuthGuardService] }, ], }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cdeb8d50..18bcc86b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -36,6 +36,7 @@ import { ChangeEmailComponent } from './settings/change-email.component'; import { ChangePasswordComponent } from './settings/change-password.component'; import { DeauthorizeSessionsComponent } from './settings/deauthorize-sessions.component'; import { DeleteAccountComponent } from './settings/delete-account.component'; +import { OptionsComponent } from './settings/options.component'; import { ProfileComponent } from './settings/profile.component'; import { PurgeVaultComponent } from './settings/purge-vault.component'; import { SettingsComponent } from './settings/settings.component'; @@ -122,6 +123,7 @@ import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; LoginComponent, ModalComponent, NavbarComponent, + OptionsComponent, OrganizationsComponent, OrganizationLayoutComponent, PasswordGeneratorComponent, diff --git a/src/app/settings/options.component.html b/src/app/settings/options.component.html new file mode 100644 index 00000000..6d35a48f --- /dev/null +++ b/src/app/settings/options.component.html @@ -0,0 +1,23 @@ + +
+
+
+ + + {{'languageDesc' | i18n}} +
+
+
+
+
+ + +
+ {{'disableIconsDesc' | i18n}} +
diff --git a/src/app/settings/options.component.ts b/src/app/settings/options.component.ts new file mode 100644 index 00000000..b7ac6388 --- /dev/null +++ b/src/app/settings/options.component.ts @@ -0,0 +1,53 @@ +import { + Component, + OnInit, +} from '@angular/core'; + +import { Angulartics2 } from 'angulartics2'; + +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { StateService } from 'jslib/abstractions/state.service'; +import { StorageService } from 'jslib/abstractions/storage.service'; + +import { ConstantsService } from 'jslib/services/constants.service'; + +@Component({ + selector: 'app-options', + templateUrl: 'options.component.html', +}) +export class OptionsComponent implements OnInit { + disableIcons: boolean; + locale: string; + localeOptions: any[]; + + constructor(private storageService: StorageService, private stateService: StateService, + private analytics: Angulartics2, i18nService: I18nService) { + this.localeOptions = [{ name: i18nService.t('default'), value: null }]; + i18nService.supportedTranslationLocales.forEach((locale) => { + this.localeOptions.push({ name: locale, value: locale }); + }); + } + + async ngOnInit() { + this.disableIcons = await this.storageService.get(ConstantsService.disableFaviconKey); + this.locale = await this.storageService.get(ConstantsService.localeKey); + } + + async saveIcons() { + await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons); + await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons); + this.callAnalytics('Website Icons', !this.disableIcons); + } + + async saveLocale() { + await this.storageService.save(ConstantsService.localeKey, this.locale); + this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale }); + window.location.reload(); + } + + private callAnalytics(name: string, enabled: boolean) { + const status = enabled ? 'Enabled' : 'Disabled'; + this.analytics.eventTrack.next({ action: `${status} ${name}` }); + } + +} diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 2a08cd0a..42d383e3 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -2,13 +2,13 @@