2018-04-13 20:19:33 +02:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
2023-11-27 21:59:44 +01:00
|
|
|
import { AbstractThemingService } from "@bitwarden/angular/platform/services/theming/theming.service.abstraction";
|
2023-04-28 21:07:26 +02:00
|
|
|
import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
|
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
|
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
2023-11-27 21:59:44 +01:00
|
|
|
import { ThemeType } from "@bitwarden/common/platform/enums";
|
|
|
|
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
|
|
|
import { UriMatchType } from "@bitwarden/common/vault/enums";
|
2018-04-13 20:19:33 +02:00
|
|
|
|
2023-11-21 02:53:03 +01:00
|
|
|
import { flagEnabled } from "../../platform/flags";
|
|
|
|
|
2018-04-13 20:19:33 +02:00
|
|
|
@Component({
|
|
|
|
selector: "app-options",
|
|
|
|
templateUrl: "options.component.html",
|
|
|
|
})
|
|
|
|
export class OptionsComponent implements OnInit {
|
2022-06-23 09:53:42 +02:00
|
|
|
enableFavicon = false;
|
|
|
|
enableBadgeCounter = false;
|
2018-04-13 20:19:33 +02:00
|
|
|
enableAutoFillOnPageLoad = false;
|
2021-04-07 02:45:12 +02:00
|
|
|
autoFillOnPageLoadDefault = false;
|
|
|
|
autoFillOnPageLoadOptions: any[];
|
2022-06-23 09:53:42 +02:00
|
|
|
enableAutoTotpCopy = false; // TODO: Does it matter if this is set to false or true?
|
|
|
|
enableContextMenuItem = false;
|
|
|
|
enableAddLoginNotification = false;
|
|
|
|
enableChangedPasswordNotification = false;
|
2023-11-23 17:09:27 +01:00
|
|
|
enablePasskeys = true;
|
2022-06-23 09:53:42 +02:00
|
|
|
showCardsCurrentTab = false;
|
|
|
|
showIdentitiesCurrentTab = false;
|
2019-03-05 15:26:57 +01:00
|
|
|
showClearClipboard = true;
|
2022-01-28 15:24:04 +01:00
|
|
|
theme: ThemeType;
|
2018-05-30 23:26:43 +02:00
|
|
|
themeOptions: any[];
|
2019-01-09 17:59:14 +01:00
|
|
|
defaultUriMatch = UriMatchType.Domain;
|
|
|
|
uriMatchOptions: any[];
|
2019-02-27 17:07:54 +01:00
|
|
|
clearClipboard: number;
|
|
|
|
clearClipboardOptions: any[];
|
2022-02-24 18:14:04 +01:00
|
|
|
showGeneral = true;
|
|
|
|
showAutofill = true;
|
|
|
|
showDisplay = true;
|
2023-11-21 02:53:03 +01:00
|
|
|
accountSwitcherEnabled = false;
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2021-04-14 23:43:09 +02:00
|
|
|
constructor(
|
|
|
|
private messagingService: MessagingService,
|
|
|
|
private stateService: StateService,
|
|
|
|
private totpService: TotpService,
|
2022-06-23 13:36:05 +02:00
|
|
|
i18nService: I18nService,
|
2023-04-28 21:07:26 +02:00
|
|
|
private themingService: AbstractThemingService,
|
|
|
|
private settingsService: SettingsService,
|
2021-04-14 23:43:09 +02:00
|
|
|
) {
|
2018-05-30 23:26:43 +02:00
|
|
|
this.themeOptions = [
|
2022-01-28 15:24:04 +01:00
|
|
|
{ name: i18nService.t("default"), value: ThemeType.System },
|
2021-10-04 22:30:31 +02:00
|
|
|
{ name: i18nService.t("light"), value: ThemeType.Light },
|
|
|
|
{ name: i18nService.t("dark"), value: ThemeType.Dark },
|
|
|
|
{ name: "Nord", value: ThemeType.Nord },
|
|
|
|
{ name: i18nService.t("solarizedDark"), value: ThemeType.SolarizedDark },
|
2018-05-30 23:26:43 +02:00
|
|
|
];
|
2019-01-09 17:59:14 +01:00
|
|
|
this.uriMatchOptions = [
|
|
|
|
{ name: i18nService.t("baseDomain"), value: UriMatchType.Domain },
|
|
|
|
{ name: i18nService.t("host"), value: UriMatchType.Host },
|
|
|
|
{ name: i18nService.t("startsWith"), value: UriMatchType.StartsWith },
|
|
|
|
{ name: i18nService.t("regEx"), value: UriMatchType.RegularExpression },
|
|
|
|
{ name: i18nService.t("exact"), value: UriMatchType.Exact },
|
|
|
|
{ name: i18nService.t("never"), value: UriMatchType.Never },
|
|
|
|
];
|
2019-02-27 17:07:54 +01:00
|
|
|
this.clearClipboardOptions = [
|
|
|
|
{ name: i18nService.t("never"), value: null },
|
|
|
|
{ name: i18nService.t("tenSeconds"), value: 10 },
|
|
|
|
{ name: i18nService.t("twentySeconds"), value: 20 },
|
|
|
|
{ name: i18nService.t("thirtySeconds"), value: 30 },
|
|
|
|
{ name: i18nService.t("oneMinute"), value: 60 },
|
|
|
|
{ name: i18nService.t("twoMinutes"), value: 120 },
|
|
|
|
{ name: i18nService.t("fiveMinutes"), value: 300 },
|
|
|
|
];
|
2021-04-07 02:45:12 +02:00
|
|
|
this.autoFillOnPageLoadOptions = [
|
2021-04-16 05:46:56 +02:00
|
|
|
{ name: i18nService.t("autoFillOnPageLoadYes"), value: true },
|
|
|
|
{ name: i18nService.t("autoFillOnPageLoadNo"), value: false },
|
2021-06-07 19:25:37 +02:00
|
|
|
];
|
2023-11-21 02:53:03 +01:00
|
|
|
|
|
|
|
this.accountSwitcherEnabled = flagEnabled("accountSwitching");
|
2018-05-30 23:26:43 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-13 20:19:33 +02:00
|
|
|
async ngOnInit() {
|
2022-01-27 22:22:51 +01:00
|
|
|
this.enableAutoFillOnPageLoad = await this.stateService.getEnableAutoFillOnPageLoad();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2021-04-16 05:46:56 +02:00
|
|
|
this.autoFillOnPageLoadDefault =
|
2022-01-27 22:22:51 +01:00
|
|
|
(await this.stateService.getAutoFillOnPageLoadDefault()) ?? true;
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.enableAddLoginNotification = !(await this.stateService.getDisableAddLoginNotification());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.enableChangedPasswordNotification =
|
|
|
|
!(await this.stateService.getDisableChangedPasswordNotification());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.enableContextMenuItem = !(await this.stateService.getDisableContextMenuItem());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.showCardsCurrentTab = !(await this.stateService.getDontShowCardsCurrentTab());
|
|
|
|
this.showIdentitiesCurrentTab = !(await this.stateService.getDontShowIdentitiesCurrentTab());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.enableAutoTotpCopy = !(await this.stateService.getDisableAutoTotpCopy());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-04-28 21:07:26 +02:00
|
|
|
this.enableFavicon = !this.settingsService.getDisableFavicon();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
this.enableBadgeCounter = !(await this.stateService.getDisableBadgeCounter());
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-11-23 17:09:27 +01:00
|
|
|
this.enablePasskeys = await this.stateService.getEnablePasskeys();
|
|
|
|
|
2022-01-27 22:22:51 +01:00
|
|
|
this.theme = await this.stateService.getTheme();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-01-27 22:22:51 +01:00
|
|
|
const defaultUriMatch = await this.stateService.getDefaultUriMatch();
|
2019-01-09 17:59:14 +01:00
|
|
|
this.defaultUriMatch = defaultUriMatch == null ? UriMatchType.Domain : defaultUriMatch;
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-01-27 22:22:51 +01:00
|
|
|
this.clearClipboard = await this.stateService.getClearClipboard();
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-13 20:19:33 +02:00
|
|
|
async updateAddLoginNotification() {
|
2022-06-23 09:53:42 +02:00
|
|
|
await this.stateService.setDisableAddLoginNotification(!this.enableAddLoginNotification);
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-08-01 05:48:11 +02:00
|
|
|
async updateChangedPasswordNotification() {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setDisableChangedPasswordNotification(
|
2022-06-23 09:53:42 +02:00
|
|
|
!this.enableChangedPasswordNotification,
|
2018-08-01 05:48:11 +02:00
|
|
|
);
|
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-11-23 17:09:27 +01:00
|
|
|
async updateEnablePasskeys() {
|
|
|
|
await this.stateService.setEnablePasskeys(this.enablePasskeys);
|
|
|
|
}
|
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
async updateContextMenuItem() {
|
|
|
|
await this.stateService.setDisableContextMenuItem(!this.enableContextMenuItem);
|
2018-04-13 20:19:33 +02:00
|
|
|
this.messagingService.send("bgUpdateContextMenu");
|
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-13 20:19:33 +02:00
|
|
|
async updateAutoTotpCopy() {
|
2022-06-23 09:53:42 +02:00
|
|
|
await this.stateService.setDisableAutoTotpCopy(!this.enableAutoTotpCopy);
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-13 20:19:33 +02:00
|
|
|
async updateAutoFillOnPageLoad() {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setEnableAutoFillOnPageLoad(this.enableAutoFillOnPageLoad);
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2021-04-16 05:46:56 +02:00
|
|
|
async updateAutoFillOnPageLoadDefault() {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setAutoFillOnPageLoadDefault(this.autoFillOnPageLoadDefault);
|
2021-04-16 05:46:56 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
async updateFavicon() {
|
2023-04-28 21:07:26 +02:00
|
|
|
await this.settingsService.setDisableFavicon(!this.enableFavicon);
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
async updateBadgeCounter() {
|
|
|
|
await this.stateService.setDisableBadgeCounter(!this.enableBadgeCounter);
|
2021-03-06 17:18:11 +01:00
|
|
|
this.messagingService.send("bgUpdateContextMenu");
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
async updateShowCardsCurrentTab() {
|
|
|
|
await this.stateService.setDontShowCardsCurrentTab(!this.showCardsCurrentTab);
|
2018-11-21 20:31:34 +01:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2022-06-23 09:53:42 +02:00
|
|
|
async updateShowIdentitiesCurrentTab() {
|
|
|
|
await this.stateService.setDontShowIdentitiesCurrentTab(!this.showIdentitiesCurrentTab);
|
2018-11-21 20:31:34 +01:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-05-30 23:26:43 +02:00
|
|
|
async saveTheme() {
|
2022-06-23 13:36:05 +02:00
|
|
|
await this.themingService.updateConfiguredTheme(this.theme);
|
2018-05-30 23:26:43 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2019-01-09 17:59:14 +01:00
|
|
|
async saveDefaultUriMatch() {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setDefaultUriMatch(this.defaultUriMatch);
|
2019-01-09 17:59:14 +01:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2019-02-27 17:07:54 +01:00
|
|
|
async saveClearClipboard() {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setClearClipboard(this.clearClipboard);
|
2018-04-13 20:19:33 +02:00
|
|
|
}
|
|
|
|
}
|