From 8332e52a7bf73f218a17dbbc52e3339673a0b88d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Nov 2017 23:46:03 -0500 Subject: [PATCH] cleanup and formatting --- src/popup/app/config.js | 2 +- src/popup/app/global/main.controller.ts | 2 +- .../app/global/private-mode.controller.ts | 2 +- .../{privateMode.html => private-mode.html} | 0 src/popup/app/global/tabs.controller.ts | 2 +- src/popup/app/settings/about.component.ts | 2 +- src/popup/app/settings/credits.component.html | 2 +- src/popup/app/settings/credits.component.ts | 2 +- .../app/settings/environment.component.ts | 6 +- src/popup/app/settings/features.component.ts | 58 +++++++------------ .../settings/folders/add-folder.component.ts | 21 +++---- .../settings/folders/edit-folder.component.ts | 50 +++++++--------- .../app/settings/folders/folders.component.ts | 23 ++++---- src/popup/app/settings/help.component.ts | 2 +- src/popup/app/settings/premium.component.html | 2 +- src/popup/app/settings/premium.component.ts | 18 +++--- src/popup/app/settings/settings.component.ts | 15 ++--- src/popup/app/settings/settings.module.ts | 2 +- src/popup/app/settings/sync.component.ts | 39 ++++++------- 19 files changed, 104 insertions(+), 146 deletions(-) rename src/popup/app/global/{privateMode.html => private-mode.html} (100%) diff --git a/src/popup/app/config.js b/src/popup/app/config.js index aa2cd10350..213cbf8c7f 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -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 } }) diff --git a/src/popup/app/global/main.controller.ts b/src/popup/app/global/main.controller.ts index 4bd4f26b4e..ab33925012 100644 --- a/src/popup/app/global/main.controller.ts +++ b/src/popup/app/global/main.controller.ts @@ -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; diff --git a/src/popup/app/global/private-mode.controller.ts b/src/popup/app/global/private-mode.controller.ts index fe7186c398..23a0c60fd2 100644 --- a/src/popup/app/global/private-mode.controller.ts +++ b/src/popup/app/global/private-mode.controller.ts @@ -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'); diff --git a/src/popup/app/global/privateMode.html b/src/popup/app/global/private-mode.html similarity index 100% rename from src/popup/app/global/privateMode.html rename to src/popup/app/global/private-mode.html diff --git a/src/popup/app/global/tabs.controller.ts b/src/popup/app/global/tabs.controller.ts index 729c569d10..a910240f41 100644 --- a/src/popup/app/global/tabs.controller.ts +++ b/src/popup/app/global/tabs.controller.ts @@ -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; diff --git a/src/popup/app/settings/about.component.ts b/src/popup/app/settings/about.component.ts index 1d94f70fa9..76c0698d04 100644 --- a/src/popup/app/settings/about.component.ts +++ b/src/popup/app/settings/about.component.ts @@ -1,4 +1,4 @@ -import * as template from './about.component.html'; +import * as template from './about.component.html'; class AboutController { version: string; diff --git a/src/popup/app/settings/credits.component.html b/src/popup/app/settings/credits.component.html index d5ab6f0bc1..9ed29865a5 100644 --- a/src/popup/app/settings/credits.component.html +++ b/src/popup/app/settings/credits.component.html @@ -27,7 +27,7 @@ diff --git a/src/popup/app/settings/credits.component.ts b/src/popup/app/settings/credits.component.ts index 90c83743a6..68e0b48754 100644 --- a/src/popup/app/settings/credits.component.ts +++ b/src/popup/app/settings/credits.component.ts @@ -1,4 +1,4 @@ -import * as template from './credits.component.html'; +import * as template from './credits.component.html'; class CreditsController { i18n: any; diff --git a/src/popup/app/settings/environment.component.ts b/src/popup/app/settings/environment.component.ts index 646a959d1c..f76bcd1356 100644 --- a/src/popup/app/settings/environment.component.ts +++ b/src/popup/app/settings/environment.component.ts @@ -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; diff --git a/src/popup/app/settings/features.component.ts b/src/popup/app/settings/features.component.ts index 697b12da91..37216a3c2d 100644 --- a/src/popup/app/settings/features.component.ts +++ b/src/popup/app/settings/features.component.ts @@ -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(this.constantsService.enableAutoFillOnPageLoadKey); + this.enableAutoFillOnPageLoad = await this.utilsService.getObjFromStorage( + this.constantsService.enableAutoFillOnPageLoadKey); - const disableGa = await this.utilsService.getObjFromStorage(this.constantsService.disableGaKey); + const disableGa = await this.utilsService.getObjFromStorage( + this.constantsService.disableGaKey); this.disableGa = disableGa || (this.utilsService.isFirefox() && disableGa === undefined); - this.disableAddLoginNotification = await this.utilsService - .getObjFromStorage(this.constantsService.disableAddLoginNotificationKey); + this.disableAddLoginNotification = await this.utilsService.getObjFromStorage( + this.constantsService.disableAddLoginNotificationKey); - this.disableContextMenuItem = await this.utilsService - .getObjFromStorage(this.constantsService.disableContextMenuItemKey); + this.disableContextMenuItem = await this.utilsService.getObjFromStorage( + this.constantsService.disableContextMenuItemKey); this.disableAutoTotpCopy = !await this.totpService.isAutoCopyEnabled(); - this.disableFavicon = await this.utilsService - .getObjFromStorage(this.constantsService.disableFaviconKey); + this.disableFavicon = await this.utilsService.getObjFromStorage( + 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); } diff --git a/src/popup/app/settings/folders/add-folder.component.ts b/src/popup/app/settings/folders/add-folder.component.ts index bdee42980d..5cea454911 100644 --- a/src/popup/app/settings/folders/add-folder.component.ts +++ b/src/popup/app/settings/folders/add-folder.component.ts @@ -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' }); + }); } } diff --git a/src/popup/app/settings/folders/edit-folder.component.ts b/src/popup/app/settings/folders/edit-folder.component.ts index 4563775cc6..9ece9d017e 100644 --- a/src/popup/app/settings/folders/edit-folder.component.ts +++ b/src/popup/app/settings/folders/edit-folder.component.ts @@ -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', }); + }); } }); } diff --git a/src/popup/app/settings/folders/folders.component.ts b/src/popup/app/settings/folders/folders.component.ts index 04d3f617c3..a1b1a873da 100644 --- a/src/popup/app/settings/folders/folders.component.ts +++ b/src/popup/app/settings/folders/folders.component.ts @@ -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) { diff --git a/src/popup/app/settings/help.component.ts b/src/popup/app/settings/help.component.ts index 36ae275b5f..41fbcc7295 100644 --- a/src/popup/app/settings/help.component.ts +++ b/src/popup/app/settings/help.component.ts @@ -1,4 +1,4 @@ -import * as template from './help.component.html'; +import * as template from './help.component.html'; class HelpController { i18n: any; diff --git a/src/popup/app/settings/premium.component.html b/src/popup/app/settings/premium.component.html index 05c8b7af2b..a53055e029 100644 --- a/src/popup/app/settings/premium.component.html +++ b/src/popup/app/settings/premium.component.html @@ -41,7 +41,7 @@ -
+

{{$ctrl.i18n.premiumCurrentMember}}

{{$ctrl.i18n.premiumCurrentMemberThanks}}

diff --git a/src/popup/app/settings/premium.component.ts b/src/popup/app/settings/premium.component.ts index 8d71daad9c..44f908c2c9 100644 --- a/src/popup/app/settings/premium.component.ts +++ b/src/popup/app/settings/premium.component.ts @@ -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() { diff --git a/src/popup/app/settings/settings.component.ts b/src/popup/app/settings/settings.component.ts index 1e9a67012f..4fb1ce9bce 100644 --- a/src/popup/app/settings/settings.component.ts +++ b/src/popup/app/settings/settings.component.ts @@ -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()], }); diff --git a/src/popup/app/settings/settings.module.ts b/src/popup/app/settings/settings.module.ts index c075c57d4b..37fbad3f87 100644 --- a/src/popup/app/settings/settings.module.ts +++ b/src/popup/app/settings/settings.module.ts @@ -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'; diff --git a/src/popup/app/settings/sync.component.ts b/src/popup/app/settings/sync.component.ts index 47d5d8938a..a1a989291a 100644 --- a/src/popup/app/settings/sync.component.ts +++ b/src/popup/app/settings/sync.component.ts @@ -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; + } + }); } }