2018-04-13 20:19:33 +02:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
2022-06-23 13:36:05 +02:00
|
|
|
import { AbstractThemingService } from "@bitwarden/angular/services/theming/theming.service.abstraction";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
2023-04-28 21:07:26 +02:00
|
|
|
import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
|
|
|
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
[AC-1266] Enums filename conventions (#5140)
* refactor: update clientType enum
* refactor: update deviceType filename
* refactor: update encryptedExportType filename
* refactor: update encryptionType filename
* refactor: update eventType filename
* refactor: update fieldType filename
* refactor: update fileUploadType filename
* refactor: update hashPurpose filename
* refactor: update htmlStorageLocation filename
* refactor: update kdfType filename
* refactor: update keySuffixOptions filename
* refactor: update linkedIdType filename
* refactor: update logLevelType filename
* refactor: update nativeMessagingVersion filename
* refactor: update notificationType filename
* refactor: update productType filename
* refactor: update secureNoteType filename
* refactor: update stateVersion filename
* refactor: update storageLocation filename
* refactor: update themeType filename
* refactor: update uriMatchType filename
* fix: update kdfType classes missed in initial pass, refs AC-1266
* fix: missing import update for device-type
* refactor: add barrel file for enums and update pathed import statements, refs AC-1266
* fix: incorrect import statements for web, refs AC-1266
* fix: missed import statement updates (browser), refs AC-1266
* fix: missed import statement changes (cli), refs AC-1266
* fix: missed import statement changes (desktop), refs AC-1266
* fix: prettier, refs AC-1266
* refactor: (libs) update relative paths to use barrel file, refs AC-1266
* fix: missed find/replace import statements for SecureNoteType, refs AC-1266
* refactor: apply .enum suffix to enums folder and modify leftover relative paths, refs AC-1266
* fix: find/replace errors for native-messaging-version, refs AC-1266
2023-04-05 05:42:21 +02:00
|
|
|
import { ThemeType, UriMatchType } from "@bitwarden/common/enums";
|
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;
|
|
|
|
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;
|
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
|
|
|
];
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|