set icons server environment url

This commit is contained in:
Kyle Spearrin 2017-10-23 23:05:24 -04:00
parent a6d56975fb
commit 0c90d9dba2
5 changed files with 30 additions and 4 deletions

View File

@ -747,6 +747,9 @@
"identityUrl": {
"message": "Identity Server URL"
},
"iconsUrl": {
"message": "Icons Server URL"
},
"environmentSaved": {
"message": "The environment URLs have been saved."
},

View File

@ -6,10 +6,20 @@ angular
cipher: '<'
},
templateUrl: 'app/components/views/icon.html',
controller: function (stateService, constantsService) {
controller: function (stateService, constantsService, environmentService) {
var ctrl = this;
ctrl.imageEnabled = stateService.getState('faviconEnabled');
var iconsUrl = environmentService.iconsUrl;
if (!iconsUrl) {
if (environmentService.baseUrl) {
iconsUrl = environmentService.baseUrl = '/icons';
}
else {
iconsUrl = 'https://icons.bitwarden.com';
}
}
ctrl.$onChanges = function () {
switch (ctrl.cipher.type) {
case constantsService.cipherType.login:
@ -54,7 +64,7 @@ angular
if (ctrl.imageEnabled && isWebsite) {
try {
var url = new URL(hostnameUri);
ctrl.image = 'https://icons.bitwarden.com/' + url.hostname + '/icon.png';
ctrl.image = iconsUrl + '/' + url.hostname + '/icon.png';
ctrl.fallbackImage = chrome.extension.getURL('images/fa-globe.png');
}
catch (e) { }

View File

@ -11,13 +11,15 @@
$scope.webVaultUrl = environmentService.webVaultUrl || '';
$scope.apiUrl = environmentService.apiUrl || '';
$scope.identityUrl = environmentService.identityUrl || '';
$scope.iconsUrl = environmentService.iconsUrl || '';
$scope.save = function () {
environmentService.setUrls({
base: $scope.baseUrl,
api: $scope.apiUrl,
identity: $scope.identityUrl,
webVault: $scope.webVaultUrl
webVault: $scope.webVaultUrl,
icons: $scope.iconsUrl
}, function (resUrls) {
$timeout(function () {
// re-set urls since service can change them, ex: prefixing https://
@ -25,6 +27,7 @@
$scope.apiUrl = resUrls.api;
$scope.identityUrl = resUrls.identity;
$scope.webVaultUrl = resUrls.webVault;
$scope.iconsUrl = resUrls.icons;
$analytics.eventTrack('Set Environment URLs');
toastr.success(i18nService.environmentSaved);

View File

@ -42,6 +42,10 @@
<label for="identityUrl" class="item-label">{{i18n.identityUrl}}</label>
<input id="identityUrl" type="text" name="IdentityUrl" ng-model="identityUrl">
</div>
<div class="list-section-item">
<label for="iconsUrl" class="item-label">{{i18n.iconsUrl}}</label>
<input id="iconsUrl" type="text" name="IconsUrl" ng-model="iconsUrl">
</div>
</div>
<div class="list-section-footer">
{{i18n.customEnvironmentFooter}}

View File

@ -6,6 +6,7 @@ function EnvironmentService(constantsService, apiService) {
this.webVaultUrl = null;
this.apiUrl = null;
this.identityUrl = null;
this.iconsUrl = null;
initEnvironmentService();
}
@ -19,6 +20,7 @@ function initEnvironmentService() {
base: null,
api: null,
identity: null,
icons: null,
webVault: null
};
@ -34,6 +36,7 @@ function initEnvironmentService() {
self.webVaultUrl = urls.webVault;
self.apiUrl = urls.api;
self.identityUrl = urls.identity;
self.iconsUrl = urls.icons;
self.apiService.setUrls({
api: self.apiUrl,
@ -51,13 +54,15 @@ function initEnvironmentService() {
urls.webVault = formatUrl(urls.webVault);
urls.api = formatUrl(urls.api);
urls.identity = formatUrl(urls.identity);
urls.icons = formatUrl(urls.icons);
var urlsObj = {};
urlsObj[self.constantsService.environmentUrlsKey] = {
base: urls.base,
api: urls.api,
identity: urls.identity,
webVault: urls.webVault
webVault: urls.webVault,
icons: urls.icons
};
chrome.storage.local.set(urlsObj, function () {
@ -65,6 +70,7 @@ function initEnvironmentService() {
self.webVaultUrl = urls.webVault;
self.apiUrl = urls.api;
self.identityUrl = urls.identity;
self.iconsUrl = urls.icons;
if (self.baseUrl) {
self.apiService.setUrls({