mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
cleanup and formatting
This commit is contained in:
parent
78c4ea7ecb
commit
8332e52a7b
@ -53,7 +53,7 @@ angular
|
||||
.state('privateMode', {
|
||||
url: '/private-mode',
|
||||
controller: 'privateModeController',
|
||||
template: require('./global/privateMode.html'),
|
||||
template: require('./global/private-mode.html'),
|
||||
data: { authorize: false },
|
||||
params: { animation: null }
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ export class MainController implements ng.IController {
|
||||
animation: string;
|
||||
|
||||
constructor($scope: any, $transitions: any, $state: any, authService: any, toastr: any,
|
||||
i18nService: any, $analytics: any, utilsService: UtilsService, $window: any) {
|
||||
i18nService: any, $analytics: any, utilsService: UtilsService, $window: any) {
|
||||
this.animation = '';
|
||||
this.xsBody = $window.screen.availHeight < 600;
|
||||
this.smBody = !this.xsBody && $window.screen.availHeight <= 800;
|
||||
|
@ -1,4 +1,4 @@
|
||||
export class PrivateModeController implements ng.IController {
|
||||
export class PrivateModeController implements ng.IController {
|
||||
constructor($scope: any) {
|
||||
$scope.privateModeMessage = chrome.i18n.getMessage('privateModeMessage');
|
||||
$scope.learnMoreMessage = chrome.i18n.getMessage('learnMore');
|
||||
|
@ -1,4 +1,4 @@
|
||||
export class TabsController implements ng.IController {
|
||||
export class TabsController implements ng.IController {
|
||||
constructor($scope: any, $state: any, i18nService: any) {
|
||||
$scope.$state = $state;
|
||||
$scope.i18n = i18nService;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as template from './about.component.html';
|
||||
import * as template from './about.component.html';
|
||||
|
||||
class AboutController {
|
||||
version: string;
|
||||
|
@ -27,7 +27,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-section-footer">
|
||||
{{$ctrl.i18n.contribute}} <a href="" ng-click="learnMore()">{{$ctrl.i18n.learnMore}}</a>
|
||||
{{$ctrl.i18n.contribute}} <a href="" ng-click="$ctrl.learnMore()">{{$ctrl.i18n.learnMore}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as template from './credits.component.html';
|
||||
import * as template from './credits.component.html';
|
||||
|
||||
class CreditsController {
|
||||
i18n: any;
|
||||
|
@ -26,15 +26,13 @@ class EnvironmentController {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.environmentService
|
||||
.setUrls({
|
||||
this.environmentService.setUrls({
|
||||
base: this.baseUrl,
|
||||
api: this.apiUrl,
|
||||
identity: this.identityUrl,
|
||||
webVault: this.webVaultUrl,
|
||||
icons: this.iconsUrl,
|
||||
})
|
||||
.then((resUrls: any) => {
|
||||
}).then((resUrls: any) => {
|
||||
this.$timeout(() => {
|
||||
// re-set urls since service can change them, ex: prefixing https://
|
||||
this.baseUrl = resUrls.base;
|
||||
|
@ -13,8 +13,8 @@ class FeaturesController {
|
||||
i18n: any;
|
||||
|
||||
constructor(private i18nService: any, private $analytics: any, private constantsService: any,
|
||||
private utilsService: UtilsService, private totpService: any, private stateService: StateService,
|
||||
private $timeout: ng.ITimeoutService) {
|
||||
private utilsService: UtilsService, private totpService: any, private stateService: StateService,
|
||||
private $timeout: ng.ITimeoutService) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
$timeout(() => {
|
||||
@ -25,22 +25,23 @@ class FeaturesController {
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.enableAutoFillOnPageLoad = await this.utilsService
|
||||
.getObjFromStorage<boolean>(this.constantsService.enableAutoFillOnPageLoadKey);
|
||||
this.enableAutoFillOnPageLoad = await this.utilsService.getObjFromStorage<boolean>(
|
||||
this.constantsService.enableAutoFillOnPageLoadKey);
|
||||
|
||||
const disableGa = await this.utilsService.getObjFromStorage<boolean>(this.constantsService.disableGaKey);
|
||||
const disableGa = await this.utilsService.getObjFromStorage<boolean>(
|
||||
this.constantsService.disableGaKey);
|
||||
this.disableGa = disableGa || (this.utilsService.isFirefox() && disableGa === undefined);
|
||||
|
||||
this.disableAddLoginNotification = await this.utilsService
|
||||
.getObjFromStorage<boolean>(this.constantsService.disableAddLoginNotificationKey);
|
||||
this.disableAddLoginNotification = await this.utilsService.getObjFromStorage<boolean>(
|
||||
this.constantsService.disableAddLoginNotificationKey);
|
||||
|
||||
this.disableContextMenuItem = await this.utilsService
|
||||
.getObjFromStorage<boolean>(this.constantsService.disableContextMenuItemKey);
|
||||
this.disableContextMenuItem = await this.utilsService.getObjFromStorage<boolean>(
|
||||
this.constantsService.disableContextMenuItemKey);
|
||||
|
||||
this.disableAutoTotpCopy = !await this.totpService.isAutoCopyEnabled();
|
||||
|
||||
this.disableFavicon = await this.utilsService
|
||||
.getObjFromStorage<boolean>(this.constantsService.disableFaviconKey);
|
||||
this.disableFavicon = await this.utilsService.getObjFromStorage<boolean>(
|
||||
this.constantsService.disableFaviconKey);
|
||||
}
|
||||
|
||||
callAnalytics(name: string, enabled: boolean) {
|
||||
@ -49,28 +50,19 @@ class FeaturesController {
|
||||
}
|
||||
|
||||
updateGa() {
|
||||
this.utilsService.saveObjToStorage(
|
||||
this.constantsService.disableGaKey,
|
||||
this.disableGa,
|
||||
);
|
||||
this.utilsService.saveObjToStorage(this.constantsService.disableGaKey, this.disableGa);
|
||||
this.callAnalytics('Analytics', !this.disableGa);
|
||||
}
|
||||
|
||||
updateAddLoginNotification() {
|
||||
this.utilsService.saveObjToStorage(
|
||||
this.constantsService.disableAddLoginNotificationKey,
|
||||
this.disableAddLoginNotification,
|
||||
);
|
||||
this.utilsService.saveObjToStorage(this.constantsService.disableAddLoginNotificationKey,
|
||||
this.disableAddLoginNotification);
|
||||
this.callAnalytics('Add Login Notification', !this.disableAddLoginNotification);
|
||||
}
|
||||
|
||||
updateDisableContextMenuItem() {
|
||||
this.utilsService
|
||||
.saveObjToStorage(
|
||||
this.constantsService.disableContextMenuItemKey,
|
||||
this.disableContextMenuItem,
|
||||
)
|
||||
.then(() => {
|
||||
this.utilsService.saveObjToStorage(this.constantsService.disableContextMenuItemKey,
|
||||
this.disableContextMenuItem).then(() => {
|
||||
chrome.runtime.sendMessage({
|
||||
command: 'bgUpdateContextMenu',
|
||||
});
|
||||
@ -79,26 +71,18 @@ class FeaturesController {
|
||||
}
|
||||
|
||||
updateAutoTotpCopy() {
|
||||
this.utilsService.saveObjToStorage(
|
||||
this.constantsService.disableAutoTotpCopyKey,
|
||||
this.disableAutoTotpCopy,
|
||||
);
|
||||
this.utilsService.saveObjToStorage(this.constantsService.disableAutoTotpCopyKey, this.disableAutoTotpCopy);
|
||||
this.callAnalytics('Auto Copy TOTP', !this.disableAutoTotpCopy);
|
||||
}
|
||||
|
||||
updateAutoFillOnPageLoad() {
|
||||
this.utilsService.saveObjToStorage(
|
||||
this.constantsService.enableAutoFillOnPageLoadKey,
|
||||
this.enableAutoFillOnPageLoad,
|
||||
);
|
||||
this.utilsService.saveObjToStorage(this.constantsService.enableAutoFillOnPageLoadKey,
|
||||
this.enableAutoFillOnPageLoad);
|
||||
this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad);
|
||||
}
|
||||
|
||||
updateDisableFavicon() {
|
||||
this.utilsService.saveObjToStorage(
|
||||
this.constantsService.disableFaviconKey,
|
||||
this.disableFavicon,
|
||||
);
|
||||
this.utilsService.saveObjToStorage(this.constantsService.disableFaviconKey, this.disableFavicon);
|
||||
this.stateService.saveState('faviconEnabled', !this.disableFavicon);
|
||||
this.callAnalytics('Favicon', !this.disableFavicon);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class AddFolderController {
|
||||
i18n: any;
|
||||
|
||||
constructor(private folderService: any, private $state: any, private toastr: any, utilsService: UtilsService,
|
||||
private $analytics: any, private i18nService: any, $timeout: any) {
|
||||
private $analytics: any, private i18nService: any, $timeout: any) {
|
||||
$timeout(() => {
|
||||
utilsService.initListSectionItemListeners(document, angular);
|
||||
document.getElementById('name').focus();
|
||||
@ -26,17 +26,14 @@ class AddFolderController {
|
||||
return;
|
||||
}
|
||||
|
||||
this.savePromise = this.folderService
|
||||
.encrypt(model)
|
||||
.then((folderModel: any) => {
|
||||
const folder = new Folder(folderModel, true);
|
||||
return this.folderService.saveWithServer(folder);
|
||||
})
|
||||
.then((folder: any) => {
|
||||
this.$analytics.eventTrack('Added Folder');
|
||||
this.toastr.success(this.i18nService.addedFolder);
|
||||
this.$state.go('^.list', { animation: 'out-slide-down' });
|
||||
});
|
||||
this.savePromise = this.folderService.encrypt(model).then((folderModel: any) => {
|
||||
const folder = new Folder(folderModel, true);
|
||||
return this.folderService.saveWithServer(folder);
|
||||
}).then((folder: any) => {
|
||||
this.$analytics.eventTrack('Added Folder');
|
||||
this.toastr.success(this.i18nService.addedFolder);
|
||||
this.$state.go('^.list', { animation: 'out-slide-down' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@ class EditFolderController {
|
||||
folder: Folder;
|
||||
|
||||
constructor($scope: any, $stateParams: any, private folderService: any, private toastr: any, private $state: any,
|
||||
private SweetAlert: any, utilsService: UtilsService, private $analytics: any, private i18nService: any,
|
||||
$timeout: any) {
|
||||
private SweetAlert: any, utilsService: UtilsService, private $analytics: any, private i18nService: any,
|
||||
$timeout: any) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
$timeout(() => {
|
||||
@ -25,14 +25,11 @@ class EditFolderController {
|
||||
|
||||
$onInit() {
|
||||
this.folderId = this.$transition$.params('to').folderId;
|
||||
|
||||
this.folderService
|
||||
.get(this.folderId)
|
||||
.then((folder: any) => {
|
||||
return folder.decrypt();
|
||||
}).then((model: Folder) => {
|
||||
this.folder = model;
|
||||
});
|
||||
this.folderService.get(this.folderId).then((folder: any) => {
|
||||
return folder.decrypt();
|
||||
}).then((model: Folder) => {
|
||||
this.folder = model;
|
||||
});
|
||||
}
|
||||
|
||||
save(model: any) {
|
||||
@ -41,17 +38,14 @@ class EditFolderController {
|
||||
return;
|
||||
}
|
||||
|
||||
this.savePromise = this.folderService
|
||||
.encrypt(model)
|
||||
.then((folderModel: any) => {
|
||||
const folder = new Folder(folderModel, true);
|
||||
return this.folderService.saveWithServer(folder);
|
||||
})
|
||||
.then((folder: any) => {
|
||||
this.$analytics.eventTrack('Edited Folder');
|
||||
this.toastr.success(this.i18nService.editedFolder);
|
||||
this.$state.go('^.list', { animation: 'out-slide-down' });
|
||||
});
|
||||
this.savePromise = this.folderService.encrypt(model).then((folderModel: any) => {
|
||||
const folder = new Folder(folderModel, true);
|
||||
return this.folderService.saveWithServer(folder);
|
||||
}).then((folder: any) => {
|
||||
this.$analytics.eventTrack('Edited Folder');
|
||||
this.toastr.success(this.i18nService.editedFolder);
|
||||
this.$state.go('^.list', { animation: 'out-slide-down' });
|
||||
});
|
||||
}
|
||||
|
||||
delete() {
|
||||
@ -63,15 +57,13 @@ class EditFolderController {
|
||||
cancelButtonText: this.i18nService.no,
|
||||
}, (confirmed: boolean) => {
|
||||
if (confirmed) {
|
||||
this.folderService
|
||||
.deleteWithServer(this.folderId)
|
||||
.then(() => {
|
||||
this.$analytics.eventTrack('Deleted Folder');
|
||||
this.toastr.success(this.i18nService.deletedFolder);
|
||||
this.$state.go('^.list', {
|
||||
animation: 'out-slide-down',
|
||||
});
|
||||
this.folderService.deleteWithServer(this.folderId).then(() => {
|
||||
this.$analytics.eventTrack('Deleted Folder');
|
||||
this.toastr.success(this.i18nService.deletedFolder);
|
||||
this.$state.go('^.list', {
|
||||
animation: 'out-slide-down',
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Folder } from '../../../../models/domain/folder';
|
||||
import { Folder } from '../../../../models/domain/folder';
|
||||
import * as template from './folders.component.html';
|
||||
|
||||
class FoldersController {
|
||||
@ -8,23 +8,20 @@ class FoldersController {
|
||||
|
||||
constructor(private folderService: any, private $state: any, i18nService: any) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
this.load();
|
||||
}
|
||||
|
||||
load() {
|
||||
this.folderService
|
||||
.getAllDecrypted()
|
||||
.then((folders: any) => {
|
||||
if (folders.length > 0 && folders[0].id === null) {
|
||||
// remove the "none" folder
|
||||
this.folders = folders.slice(1);
|
||||
} else {
|
||||
this.folders = folders;
|
||||
}
|
||||
this.folderService.getAllDecrypted().then((folders: any) => {
|
||||
if (folders.length > 0 && folders[0].id === null) {
|
||||
// remove the "none" folder
|
||||
this.folders = folders.slice(1);
|
||||
} else {
|
||||
this.folders = folders;
|
||||
}
|
||||
|
||||
this.loaded = true;
|
||||
});
|
||||
this.loaded = true;
|
||||
});
|
||||
}
|
||||
|
||||
editFolder(folder: any) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as template from './help.component.html';
|
||||
import * as template from './help.component.html';
|
||||
|
||||
class HelpController {
|
||||
i18n: any;
|
||||
|
@ -41,7 +41,7 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="isPremium">
|
||||
<div ng-if="$ctrl.isPremium">
|
||||
<p class="text-center lead">{{$ctrl.i18n.premiumCurrentMember}}</p>
|
||||
<p class="text-center">{{$ctrl.i18n.premiumCurrentMemberThanks}}</p>
|
||||
<div class="bottom-buttons">
|
||||
|
@ -6,22 +6,20 @@ class PremiumController {
|
||||
price = '$10';
|
||||
|
||||
constructor(private i18nService: any, private tokenService: any, private apiService: any, private toastr: any,
|
||||
private SweetAlert: any, private $analytics: any, private $timeout: any) {
|
||||
private SweetAlert: any, private $analytics: any, private $timeout: any) {
|
||||
this.i18n = i18nService;
|
||||
this.isPremium = tokenService.getPremium();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.apiService
|
||||
.refreshIdentityToken()
|
||||
.then(() => {
|
||||
this.toastr.success(this.i18nService.refreshComplete);
|
||||
this.$timeout(() => {
|
||||
this.isPremium = this.tokenService.getPremium();
|
||||
});
|
||||
}, (err: any) => {
|
||||
this.toastr.error(this.i18nService.errorsOccurred);
|
||||
this.apiService.refreshIdentityToken().then(() => {
|
||||
this.toastr.success(this.i18nService.refreshComplete);
|
||||
this.$timeout(() => {
|
||||
this.isPremium = this.tokenService.getPremium();
|
||||
});
|
||||
}, (err: any) => {
|
||||
this.toastr.error(this.i18nService.errorsOccurred);
|
||||
});
|
||||
}
|
||||
|
||||
purchase() {
|
||||
|
@ -23,8 +23,8 @@ class SettingsController {
|
||||
showOnLocked: boolean;
|
||||
|
||||
constructor(private $state: any, private SweetAlert: any, private utilsService: UtilsService,
|
||||
private $analytics: any, private i18nService: any, private constantsService: ConstantsService,
|
||||
private cryptoService: CryptoService, private lockService: any, private $timeout: ng.ITimeoutService) {
|
||||
private $analytics: any, private i18nService: any, private constantsService: ConstantsService,
|
||||
private cryptoService: CryptoService, private lockService: any, private $timeout: ng.ITimeoutService) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
$timeout(() => {
|
||||
@ -77,13 +77,11 @@ class SettingsController {
|
||||
|
||||
lock() {
|
||||
this.$analytics.eventTrack('Lock Now');
|
||||
this.lockService
|
||||
.lock()
|
||||
.then(() => {
|
||||
return this.$state.go('lock', {
|
||||
animation: 'in-slide-down',
|
||||
});
|
||||
this.lockService.lock().then(() => {
|
||||
return this.$state.go('lock', {
|
||||
animation: 'in-slide-down',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
logOut() {
|
||||
@ -147,7 +145,6 @@ class SettingsController {
|
||||
|
||||
rate() {
|
||||
this.$analytics.eventTrack('Rate Extension');
|
||||
|
||||
chrome.tabs.create({
|
||||
url: RateUrls[this.utilsService.getBrowser()],
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as angular from 'angular';
|
||||
import * as angular from 'angular';
|
||||
import { AboutComponent } from './about.component';
|
||||
import { CreditsComponent } from './credits.component';
|
||||
import { EnvironmentComponent } from './environment.component';
|
||||
|
@ -7,36 +7,31 @@ class SyncController {
|
||||
|
||||
constructor(private syncService: any, private toastr: any, private $analytics: any, private i18nService: any) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
this.setLastSync();
|
||||
}
|
||||
|
||||
sync() {
|
||||
this.loading = true;
|
||||
this.syncService
|
||||
.fullSync(true)
|
||||
.then((success: boolean) => {
|
||||
this.loading = false;
|
||||
if (success) {
|
||||
this.setLastSync();
|
||||
this.$analytics.eventTrack('Synced Full');
|
||||
this.toastr.success(this.i18nService.syncingComplete);
|
||||
} else {
|
||||
this.toastr.error(this.i18nService.syncingFailed);
|
||||
}
|
||||
});
|
||||
this.syncService.fullSync(true).then((success: boolean) => {
|
||||
this.loading = false;
|
||||
if (success) {
|
||||
this.setLastSync();
|
||||
this.$analytics.eventTrack('Synced Full');
|
||||
this.toastr.success(this.i18nService.syncingComplete);
|
||||
} else {
|
||||
this.toastr.error(this.i18nService.syncingFailed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setLastSync() {
|
||||
this.syncService
|
||||
.getLastSync()
|
||||
.then((lastSync: any) => {
|
||||
if (lastSync) {
|
||||
this.lastSync = lastSync.toLocaleDateString() + ' ' + lastSync.toLocaleTimeString();
|
||||
} else {
|
||||
this.lastSync = this.i18nService.never;
|
||||
}
|
||||
});
|
||||
this.syncService.getLastSync().then((lastSync: any) => {
|
||||
if (lastSync) {
|
||||
this.lastSync = lastSync.toLocaleDateString() + ' ' + lastSync.toLocaleTimeString();
|
||||
} else {
|
||||
this.lastSync = this.i18nService.never;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user