- {{i18n.loginOrCreateNewAccount}}
- + diff --git a/src/popup/app/settings/settingsEnvironmentController.js b/src/popup/app/settings/settingsEnvironmentController.js new file mode 100644 index 00000000000..ac9c2f6aed9 --- /dev/null +++ b/src/popup/app/settings/settingsEnvironmentController.js @@ -0,0 +1,51 @@ +angular + .module('bit.settings') + + .controller('settingsEnvironmentController', function ($scope, i18nService, $analytics, constantsService, utilsService, + $window, apiService, toastr) { + $scope.i18n = i18nService; + + utilsService.initListSectionItemListeners($(document), angular); + + $scope.baseUrl = $window.localStorage.getItem(constantsService.baseUrlKey) || ''; + $scope.apiUrl = $window.localStorage.getItem(constantsService.apiUrlKey) || ''; + $scope.identityUrl = $window.localStorage.getItem(constantsService.identityUrlKey) || ''; + + $scope.save = function () { + if ($scope.baseUrl && $scope.baseUrl !== '') { + $scope.baseUrl = formatUrl($scope.baseUrl); + $window.localStorage.setItem(constantsService.baseUrlKey, $scope.baseUrl); + } + else { + $window.localStorage.removeItem(constantsService.baseUrlKey); + } + + if ($scope.apiUrl && $scope.apiUrl !== '') { + $scope.apiUrl = formatUrl($scope.apiUrl); + $window.localStorage.setItem(constantsService.apiUrlKey, $scope.apiUrl); + } + else { + $window.localStorage.removeItem(constantsService.apiUrlKey); + } + + if ($scope.identityUrl && $scope.identityUrl !== '') { + $scope.identityUrl = formatUrl($scope.identityUrl); + $window.localStorage.setItem(constantsService.identityUrlKey, $scope.identityUrl); + } + else { + $window.localStorage.removeItem(constantsService.identityUrlKey); + } + + apiService.setUrls(); + $analytics.eventTrack('Set Environment URLs'); + toastr.success(i18nService.environmentSaved); + }; + + function formatUrl(url) { + url = url.replace(/\/+$/g, ''); + if (!url.startsWith("http://") && !url.startsWith('https://')) { + url = 'https://' + url; + } + return url; + } + }); diff --git a/src/popup/app/settings/views/settingsEnvironment.html b/src/popup/app/settings/views/settingsEnvironment.html new file mode 100644 index 00000000000..7af6f5c71a6 --- /dev/null +++ b/src/popup/app/settings/views/settingsEnvironment.html @@ -0,0 +1,48 @@ + diff --git a/src/popup/index.html b/src/popup/index.html index 46c44cc3c85..8b10dc9c866 100644 --- a/src/popup/index.html +++ b/src/popup/index.html @@ -85,6 +85,7 @@ + diff --git a/src/popup/less/components.less b/src/popup/less/components.less index c16ebd6a8a4..92a2b980378 100644 --- a/src/popup/less/components.less +++ b/src/popup/less/components.less @@ -375,6 +375,7 @@ border: none; width: 100%; background-color: transparent; + .placeholder-color(#bbbbbb); &:focus { outline: none; diff --git a/src/popup/less/pages.less b/src/popup/less/pages.less index 8aa0dde267b..a72936d0102 100644 --- a/src/popup/less/pages.less +++ b/src/popup/less/pages.less @@ -17,13 +17,13 @@ img { margin: 0 auto 20px; - width: 220px; + width: 270px; display: block; } } .home-page { - padding: 100px 20px 20px; + padding: 150px 20px 20px; text-align: center; position: relative; height: 100%; @@ -37,6 +37,26 @@ p { font-size: 18px; } + + a.settings-icon { + color: #bbbbbb; + position: absolute; + top: 10px; + left: 10px; + + span { + visibility: hidden; + } + + &:hover { + color: @link-hover-color; + text-decoration: none; + + span { + visibility: visible; + } + } + } } .splash-page { diff --git a/src/services/apiService.js b/src/services/apiService.js index 46ef73b58ac..9b072ac606f 100644 --- a/src/services/apiService.js +++ b/src/services/apiService.js @@ -1,33 +1,53 @@ -function ApiService(tokenService, appIdService, utilsService, logoutCallback) { - // Desktop - //this.baseUrl = 'http://localhost:4000'; - //this.identityBaseUrl = 'http://localhost:33656'; - - // Desktop HTTPS - //this.baseUrl = 'https://localhost:44377'; - //this.identityBaseUrl = 'https://localhost:44392'; - - // Desktop external - //this.baseUrl = 'http://192.168.1.4:4000'; - //this.identityBaseUrl = 'http://192.168.1.4:33656'; - - // Preview - //this.baseUrl = 'https://preview-api.bitwarden.com'; - //this.identityBaseUrl = 'https://preview-identity.bitwarden.com'; - - // Production - this.baseUrl = 'https://api.bitwarden.com'; - this.identityBaseUrl = 'https://identity.bitwarden.com'; - +function ApiService(tokenService, appIdService, utilsService, constantsService, logoutCallback) { this.tokenService = tokenService; this.logoutCallback = logoutCallback; this.appIdService = appIdService; this.utilsService = utilsService; + this.constantsService = constantsService; initApiService(); + this.setUrls(); } function initApiService() { + ApiService.prototype.setUrls = function () { + var storedBaseUrl = window.localStorage.getItem(this.constantsService.baseUrlKey); + + if (storedBaseUrl) { + this.baseUrl = storedBaseUrl + '/api'; + this.identityBaseUrl = storedBaseUrl + '/identity'; + return; + } + + var storedApiUrl = window.localStorage.getItem(this.constantsService.apiUrlKey); + var storedIdentityUrl = window.localStorage.getItem(this.constantsService.identityUrlKey); + if (storedApiUrl && storedIdentityUrl) { + this.baseUrl = storedApiUrl; + this.identityBaseUrl = storedIdentityUrl; + return; + } + + // Desktop + //this.baseUrl = 'http://localhost:4000'; + //this.identityBaseUrl = 'http://localhost:33656'; + + // Desktop HTTPS + //this.baseUrl = 'https://localhost:44377'; + //this.identityBaseUrl = 'https://localhost:44392'; + + // Desktop external + //this.baseUrl = 'http://192.168.1.4:4000'; + //this.identityBaseUrl = 'http://192.168.1.4:33656'; + + // Preview + //this.baseUrl = 'https://preview-api.bitwarden.com'; + //this.identityBaseUrl = 'https://preview-identity.bitwarden.com'; + + // Production + this.baseUrl = 'https://api.bitwarden.com'; + this.identityBaseUrl = 'https://identity.bitwarden.com'; + }; + // Auth APIs ApiService.prototype.postIdentityToken = function (tokenRequest, success, successWithTwoFactor, error) { diff --git a/src/services/constantsService.js b/src/services/constantsService.js index f2701b3cb01..69524e386fd 100644 --- a/src/services/constantsService.js +++ b/src/services/constantsService.js @@ -1,5 +1,8 @@ function ConstantsService(i18nService) { return { + baseUrlKey: 'baseUrl', + apiUrlKey: 'apiUrl', + identityUrlKey: 'identityUrl', disableGaKey: 'disableGa', disableAddLoginNotificationKey: 'disableAddLoginNotification', disableContextMenuItemKey: 'disableContextMenuItem',
+