mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
Convert global module to TypeScript. (#397)
This commit is contained in:
parent
f5ccc22076
commit
7c525d3f3a
@ -26,6 +26,7 @@ import ToolsModule from './tools/tools.module';
|
||||
import ServicesModule from './services/services.module';
|
||||
import LockModule from './lock/lock.module';
|
||||
import CurrentModule from './current/current.module';
|
||||
import GlobalModule from './global/global.module';
|
||||
|
||||
// Model imports
|
||||
import { Attachment } from '../../models/domain/attachment';
|
||||
@ -83,7 +84,7 @@ angular
|
||||
ComponentsModule,
|
||||
ServicesModule,
|
||||
|
||||
'bit.global',
|
||||
GlobalModule,
|
||||
'bit.accounts',
|
||||
CurrentModule,
|
||||
'bit.vault',
|
||||
@ -93,11 +94,6 @@ angular
|
||||
]);
|
||||
|
||||
require('./config');
|
||||
require('./global/globalModule.js');
|
||||
require('./global/mainController.js');
|
||||
require('./global/tabsController.js');
|
||||
require('./global/baseController.js');
|
||||
require('./global/privateModeController.js');
|
||||
require('./accounts/accountsModule.js');
|
||||
require('./accounts/accountsLoginController.js');
|
||||
require('./accounts/accountsLoginTwoFactorController.js');
|
||||
|
5
src/popup/app/global/base.controller.ts
Normal file
5
src/popup/app/global/base.controller.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class BaseController implements ng.IController {
|
||||
constructor($scope: any, i18nService: any) {
|
||||
$scope.i18n = i18nService;
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
angular
|
||||
.module('bit.global')
|
||||
|
||||
.controller('baseController', function ($scope, i18nService) {
|
||||
$scope.i18n = i18nService;
|
||||
});
|
15
src/popup/app/global/global.module.ts
Normal file
15
src/popup/app/global/global.module.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as angular from 'angular';
|
||||
import { BaseController } from './base.controller';
|
||||
import { MainController } from './main.controller';
|
||||
import { PrivateModeController } from './private-mode.controller';
|
||||
import { TabsController } from './tabs.controller';
|
||||
|
||||
export default angular
|
||||
.module('bit.global', ['ngAnimate'])
|
||||
|
||||
.controller('mainController', MainController)
|
||||
.controller('baseController', BaseController)
|
||||
.controller('tabsController', TabsController)
|
||||
.controller('privateModeController', PrivateModeController)
|
||||
|
||||
.name;
|
@ -1,2 +0,0 @@
|
||||
angular
|
||||
.module('bit.global', ['ngAnimate']);
|
46
src/popup/app/global/main.controller.ts
Normal file
46
src/popup/app/global/main.controller.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { UtilsService } from '../../../services/abstractions/utils.service';
|
||||
|
||||
export class MainController implements ng.IController {
|
||||
smBody: boolean;
|
||||
xsBody: boolean;
|
||||
animation: string;
|
||||
|
||||
constructor($scope: any, $transitions: any, $state: any, authService: any, toastr: 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;
|
||||
|
||||
$transitions.onSuccess({}, (transition: any) => {
|
||||
const toParams = transition.params('to');
|
||||
|
||||
if (toParams.animation) {
|
||||
this.animation = toParams.animation;
|
||||
} else {
|
||||
this.animation = '';
|
||||
}
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: any) => {
|
||||
if (msg.command === 'syncCompleted') {
|
||||
$scope.$broadcast('syncCompleted', msg.successfully);
|
||||
} else if (msg.command === 'syncStarted') {
|
||||
$scope.$broadcast('syncStarted');
|
||||
} else if (msg.command === 'doneLoggingOut') {
|
||||
authService.logOut(() => {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
if (msg.expired) {
|
||||
toastr.warning(i18nService.loginExpired, i18nService.loggedOut);
|
||||
}
|
||||
$state.go('home');
|
||||
});
|
||||
} else if (msg.command === 'collectPageDetailsResponse' && msg.sender === 'currentController') {
|
||||
$scope.$broadcast('collectPageDetailsResponse', {
|
||||
frameId: sender.frameId,
|
||||
tab: msg.tab,
|
||||
details: msg.details,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
angular
|
||||
.module('bit.global')
|
||||
|
||||
.controller('mainController', function ($scope, $transitions, $state, authService, toastr, i18nService, $analytics, utilsService,
|
||||
$window) {
|
||||
var self = this;
|
||||
self.animation = '';
|
||||
self.xsBody = $window.screen.availHeight < 600;
|
||||
self.smBody = !self.xsBody && $window.screen.availHeight <= 800;
|
||||
|
||||
$transitions.onSuccess({}, function(transition) {
|
||||
const toParams = transition.params("to");
|
||||
|
||||
if (toParams.animation) {
|
||||
self.animation = toParams.animation;
|
||||
return;
|
||||
} else {
|
||||
self.animation = '';
|
||||
}
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
if (msg.command === 'syncCompleted') {
|
||||
$scope.$broadcast('syncCompleted', msg.successfully);
|
||||
}
|
||||
else if (msg.command === 'syncStarted') {
|
||||
$scope.$broadcast('syncStarted');
|
||||
}
|
||||
else if (msg.command === 'doneLoggingOut') {
|
||||
authService.logOut(function () {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
if (msg.expired) {
|
||||
toastr.warning(i18nService.loginExpired, i18nService.loggedOut);
|
||||
}
|
||||
$state.go('home');
|
||||
});
|
||||
}
|
||||
else if (msg.command === 'collectPageDetailsResponse' && msg.sender === 'currentController') {
|
||||
$scope.$broadcast('collectPageDetailsResponse', {
|
||||
frameId: sender.frameId,
|
||||
tab: msg.tab,
|
||||
details: msg.details
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
9
src/popup/app/global/private-mode.controller.ts
Normal file
9
src/popup/app/global/private-mode.controller.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export class PrivateModeController implements ng.IController {
|
||||
constructor($scope: any) {
|
||||
$scope.privateModeMessage = chrome.i18n.getMessage('privateModeMessage');
|
||||
$scope.learnMoreMessage = chrome.i18n.getMessage('learnMore');
|
||||
$scope.learnMore = () => {
|
||||
chrome.tabs.create({ url: 'https://help.bitwarden.com/article/extension-wont-load-in-private-mode/' });
|
||||
};
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
angular
|
||||
.module('bit.global')
|
||||
|
||||
.controller('privateModeController', function ($scope) {
|
||||
$scope.privateModeMessage = chrome.i18n.getMessage("privateModeMessage");
|
||||
$scope.learnMoreMessage = chrome.i18n.getMessage("learnMore");
|
||||
$scope.learnMore = function () {
|
||||
chrome.tabs.create({ url: 'https://help.bitwarden.com/article/extension-wont-load-in-private-mode/' });
|
||||
};
|
||||
});
|
6
src/popup/app/global/tabs.controller.ts
Normal file
6
src/popup/app/global/tabs.controller.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export class TabsController implements ng.IController {
|
||||
constructor($scope: any, $state: any, i18nService: any) {
|
||||
$scope.$state = $state;
|
||||
$scope.i18n = i18nService;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
angular
|
||||
.module('bit.global')
|
||||
|
||||
.controller('tabsController', function ($scope, $state, i18nService) {
|
||||
$scope.$state = $state;
|
||||
$scope.i18n = i18nService;
|
||||
});
|
Loading…
Reference in New Issue
Block a user