diff --git a/jslib b/jslib index 013bf20a35..d429cd2199 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 013bf20a35c74383389337ac2c5ae9ac19a0bba7 +Subproject commit d429cd2199e8a0880dfc0edbaea5fcad874eb424 diff --git a/src/app/accounts/two-factor.component.ts b/src/app/accounts/two-factor.component.ts index fd2d06f5f7..b509e26c30 100644 --- a/src/app/accounts/two-factor.component.ts +++ b/src/app/accounts/two-factor.component.ts @@ -20,7 +20,7 @@ import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType'; import { ApiService } from 'jslib/abstractions/api.service'; import { AuthService } from 'jslib/abstractions/auth.service'; -import { EnvironmentService } from 'jslib/services/environment.service'; +import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { SyncService } from 'jslib/abstractions/sync.service'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 28394a5409..6e5e2bd05f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -42,7 +42,7 @@ import { AttachmentsComponent } from './vault/attachments.component'; import { CiphersComponent } from './vault/ciphers.component'; import { FolderAddEditComponent } from './vault/folder-add-edit.component'; import { GroupingsComponent } from './vault/groupings.component'; -import { IconComponent } from './vault/icon.component'; +import { IconComponent } from 'jslib/angular/components/icon.component'; import { PasswordGeneratorHistoryComponent } from './vault/password-generator-history.component'; import { PasswordGeneratorComponent } from './vault/password-generator.component'; import { VaultComponent } from './vault/vault.component'; diff --git a/src/app/vault/icon.component.html b/src/app/vault/icon.component.html deleted file mode 100644 index fd42b99dde..0000000000 --- a/src/app/vault/icon.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/src/app/vault/icon.component.ts b/src/app/vault/icon.component.ts deleted file mode 100644 index c9e555e4f7..0000000000 --- a/src/app/vault/icon.component.ts +++ /dev/null @@ -1,91 +0,0 @@ -import * as template from './icon.component.html'; - -import { - Component, - Input, - OnChanges, -} from '@angular/core'; - -import { CipherType } from 'jslib/enums/cipherType'; - -import { EnvironmentService } from 'jslib/abstractions/environment.service'; -import { StateService } from 'jslib/abstractions/state.service'; - -import { ConstantsService } from 'jslib/services/constants.service'; - -@Component({ - selector: 'app-vault-icon', - template: template, -}) -export class IconComponent implements OnChanges { - @Input() cipher: any; - icon: string; - image: string; - fallbackImage: string; - imageEnabled: boolean; - - private iconsUrl: string; - - constructor(private environmentService: EnvironmentService, private stateService: StateService) { - this.iconsUrl = environmentService.iconsUrl; - if (!this.iconsUrl) { - if (environmentService.baseUrl) { - this.iconsUrl = environmentService.baseUrl + '/icons'; - } else { - this.iconsUrl = 'https://icons.bitwarden.com'; - } - } - } - - async ngOnChanges() { - this.imageEnabled = !(await this.stateService.get(ConstantsService.disableFaviconKey)); - - switch (this.cipher.type) { - case CipherType.Login: - this.icon = 'fa-globe'; - this.setLoginIcon(); - break; - case CipherType.SecureNote: - this.icon = 'fa-sticky-note-o'; - break; - case CipherType.Card: - this.icon = 'fa-credit-card'; - break; - case CipherType.Identity: - this.icon = 'fa-id-card-o'; - break; - default: - break; - } - } - - private setLoginIcon() { - if (this.cipher.login.uri) { - let hostnameUri = this.cipher.login.uri; - let isWebsite = false; - - if (hostnameUri.indexOf('androidapp://') === 0) { - this.icon = 'fa-android'; - this.image = null; - } else if (hostnameUri.indexOf('iosapp://') === 0) { - this.icon = 'fa-apple'; - this.image = null; - } else if (this.imageEnabled && hostnameUri.indexOf('://') === -1 && hostnameUri.indexOf('.') > -1) { - hostnameUri = 'http://' + hostnameUri; - isWebsite = true; - } else if (this.imageEnabled) { - isWebsite = hostnameUri.indexOf('http') === 0 && hostnameUri.indexOf('.') > -1; - } - - if (this.imageEnabled && isWebsite) { - try { - const url = new URL(hostnameUri); - this.image = this.iconsUrl + '/' + url.hostname + '/icon.png'; - this.fallbackImage = 'images/fa-globe.png'; - } catch (e) { } - } - } else { - this.image = null; - } - } -}