diff --git a/src/app/directives/fallbackSrcDirective.js b/src/app/directives/fallbackSrcDirective.js new file mode 100644 index 00000000..1df1015e --- /dev/null +++ b/src/app/directives/fallbackSrcDirective.js @@ -0,0 +1,11 @@ +angular + .module('bit.directives') + + .directive('fallbackSrc', function () { + return function (scope, element, attrs) { + var el = $(element); + el.bind('error', function (event) { + el.attr('src', attrs.fallbackSrc); + }); + }; + }); diff --git a/src/app/services/cipherService.js b/src/app/services/cipherService.js index d99b4c6a..2d42e608 100644 --- a/src/app/services/cipherService.js +++ b/src/app/services/cipherService.js @@ -220,7 +220,36 @@ angular case constants.cipherType.login: cipher.subTitle = _service.decryptProperty(cipherData.Username, key, true, true); cipher.meta.password = _service.decryptProperty(cipherData.Password, key, true, true); - cipher.icon = 'fa-globe'; + cipher.meta.uri = _service.decryptProperty(cipherData.Uri, key, true, true); + + if (cipher.meta.uri) { + var hostnameUri = cipher.meta.uri; + + if (hostnameUri.indexOf('androidapp://') === 0) { + cipher.icon = 'fa-android'; + } + else if (hostnameUri.indexOf('iosapp://') === 0) { + cipher.icon = 'fa-apple'; + } + else if (hostnameUri.indexOf('://') === -1 && hostnameUri.indexOf('http://') !== 0 && + hostnameUri.indexOf('https://') !== 0) { + hostnameUri = "http://" + hostnameUri; + } + + if (!cipher.icon && hostnameUri.indexOf('.') > 0) { + try { + var url = new URL(hostnameUri); + if (url && url.hostname) { + cipher.meta.image = 'https://icons.bitwarden.com?url=' + url.hostname; + } + } + catch (e) { } + } + } + + if (!cipher.icon) { + cipher.icon = 'fa-globe'; + } break; case constants.cipherType.secureNote: cipher.subTitle = null; diff --git a/src/app/vault/views/vault.html b/src/app/vault/views/vault.html index c9c8e668..8778d851 100644 --- a/src/app/vault/views/vault.html +++ b/src/app/vault/views/vault.html @@ -119,7 +119,9 @@ - + + {{cipher.name}} @@ -186,7 +188,7 @@
- +
@@ -232,7 +234,9 @@
- + + {{cipher.name}} diff --git a/src/app/vault/views/vaultShared.html b/src/app/vault/views/vaultShared.html index b543d9e3..5969acf7 100644 --- a/src/app/vault/views/vaultShared.html +++ b/src/app/vault/views/vaultShared.html @@ -87,6 +87,11 @@ + + + {{cipher.name}} diff --git a/src/images/fa-globe.png b/src/images/fa-globe.png new file mode 100644 index 00000000..7ba709fd Binary files /dev/null and b/src/images/fa-globe.png differ diff --git a/src/index.html b/src/index.html index 70bf6187..710d5ac8 100644 --- a/src/index.html +++ b/src/index.html @@ -25,6 +25,7 @@ img-src 'self' data: + https://icons.bitwarden.com https://*.paypal.com https://www.paypalobjects.com https://q.stripe.com @@ -173,6 +174,7 @@ + diff --git a/src/less/vault.less b/src/less/vault.less index e88335ca..b965e400 100644 --- a/src/less/vault.less +++ b/src/less/vault.less @@ -432,6 +432,7 @@ form .btn .loading-icon { .table td.action-select { text-align: center; width: 30px; + max-width: 30px; @media (max-width: @screen-sm-max) { display: none; @@ -441,8 +442,14 @@ form .btn .loading-icon { .table td.vault-icon { text-align: center; width: 41px; + max-width: 41px; color: @text-muted; + img { + max-width: 24px; + height: auto; + } + @media (max-width: @screen-sm-max) { display: none; }