' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '
')); - toast.body = message; - toast.bodyOutputType = BodyOutputType.TrustedHtml; + options.enableHtml = true; } if (msg.options != null) { if (msg.options.trustedHtml === true) { - toast.bodyOutputType = BodyOutputType.TrustedHtml; + options.enableHtml = true; } if (msg.options.timeout != null && msg.options.timeout > 0) { - toast.timeout = msg.options.timeout; + options.timeOut = msg.options.timeout; } } - this.toasterService.popAsync(toast); + + this.toastrService.show(message, msg.title, options, 'toast-' + msg.type); } private async showDialog(msg: any) { diff --git a/src/popup/app.module.ts b/src/popup/app.module.ts index 61ba5b1cd8..8b7f1258d7 100644 --- a/src/popup/app.module.ts +++ b/src/popup/app.module.ts @@ -1,7 +1,6 @@ import { A11yModule } from '@angular/cdk/a11y'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { ScrollingModule } from '@angular/cdk/scrolling'; -import { ToasterModule } from 'angular2-toaster'; import { AppRoutingModule } from './app-routing.module'; import { ServicesModule } from './services/services.module'; @@ -85,6 +84,7 @@ import { VerifyMasterPasswordComponent } from './components/verify-master-passwo import { CalloutComponent } from 'jslib-angular/components/callout.component'; import { IconComponent } from 'jslib-angular/components/icon.component'; +import { BitwardenToastModule } from 'jslib-angular/components/toastr.component'; import { CurrencyPipe, @@ -188,7 +188,12 @@ registerLocaleData(localeZhTw, 'zh-TW'); ReactiveFormsModule, ScrollingModule, ServicesModule, - ToasterModule.forRoot(), + BitwardenToastModule.forRoot({ + maxOpened: 2, + autoDismiss: true, + closeButton: true, + positionClass: 'toast-bottom-full-width', + }), ], declarations: [ A11yTitleDirective, diff --git a/src/popup/components/action-buttons.component.ts b/src/popup/components/action-buttons.component.ts index 9c0f273fb0..b7cc088ddf 100644 --- a/src/popup/components/action-buttons.component.ts +++ b/src/popup/components/action-buttons.component.ts @@ -5,8 +5,6 @@ import { Output, } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; - import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType'; import { CipherType } from 'jslib-common/enums/cipherType'; import { EventType } from 'jslib-common/enums/eventType'; @@ -33,7 +31,7 @@ export class ActionButtonsComponent { cipherType = CipherType; userHasPremiumAccess = false; - constructor(private toasterService: ToasterService, private i18nService: I18nService, + constructor(private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private eventService: EventService, private totpService: TotpService, private userService: UserService, private passwordRepromptService: PasswordRepromptService) { } @@ -63,7 +61,7 @@ export class ActionButtonsComponent { } this.platformUtilsService.copyToClipboard(value, { window: window }); - this.toasterService.popAsync('info', null, + this.platformUtilsService.showToast('info', null, this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); if (typeI18nKey === 'password' || typeI18nKey === 'verificationCodeTotp') { diff --git a/src/popup/scss/plugins.scss b/src/popup/scss/plugins.scss index 9ccb3ee5f0..9062e4cbdb 100644 --- a/src/popup/scss/plugins.scss +++ b/src/popup/scss/plugins.scss @@ -1,6 +1,6 @@ $fa-font-path: "~font-awesome/fonts"; @import "~font-awesome/scss/font-awesome.scss"; -@import "~angular2-toaster/toaster"; +@import '~ngx-toastr/toastr'; @import "~sweetalert2/src/sweetalert2.scss"; @import "variables.scss"; @@ -9,32 +9,36 @@ $fa-font-path: "~font-awesome/fonts"; // Toaster .toast-container { - &.toast-bottom-full-width div.toast { - margin: 0 10px 10px; - width: calc(100% - 20px); - box-shadow: 0 0 8px rgba(0, 0, 0, 0.35); - - &:hover { - box-shadow: 0 0 10px rgba(0, 0, 0, 0.6); - } + .toast-close-button { + font-size: 18px; + margin-right: 4px; } - .toast { - &:before { + .ngx-toastr { + align-items: center; + background-image: none !important; + border-radius: $border-radius; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.35); + display: flex; + padding: 15px; + + .toast-close-button { + position: absolute; + right: 5px; + top: 0; + } + + &:hover { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.6); + } + + .icon i::before { + float: left; + font-style: normal; font-family: FontAwesome; font-size: 25px; line-height: 20px; - float: left; - color: #ffffff; - margin: auto 0 auto 15px; - } - - .toast-content { - padding: 15px; - } - - .toaster-icon { - display: none; + padding-right: 15px; } .toast-message { @@ -48,49 +52,41 @@ $fa-font-path: "~font-awesome/fonts"; } &.toast-danger, &.toast-error { - background-image: none !important; - @include themify($themes) { background-color: themed('dangerColor'); } - &:before { + .icon i::before { content: "\f0e7"; } } &.toast-warning { - background-image: none !important; - @include themify($themes) { background-color: themed('warningColor'); } - &:before { + .icon i::before { content: "\f071"; } } &.toast-info { - background-image: none !important; - @include themify($themes) { background-color: themed('infoColor'); } - &:before { + .icon i:before { content: "\f05a"; } } &.toast-success { - background-image: none !important; - @include themify($themes) { background-color: themed('successColor'); } - &:before { + .icon i:before { content: "\f00C"; } } diff --git a/src/popup/settings/settings.component.ts b/src/popup/settings/settings.component.ts index 94fb371272..aa0c6dcc83 100644 --- a/src/popup/settings/settings.component.ts +++ b/src/popup/settings/settings.component.ts @@ -6,7 +6,6 @@ import { } from '@angular/core'; import { FormControl } from '@angular/forms'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import Swal from 'sweetalert2/src/sweetalert2.js'; import { BrowserApi } from '../../browser/browserApi'; @@ -68,7 +67,7 @@ export class SettingsComponent implements OnInit { public messagingService: MessagingService, private router: Router, private environmentService: EnvironmentService, private cryptoService: CryptoService, private userService: UserService, private popupUtilsService: PopupUtilsService, - private modalService: ModalService, private toasterService: ToasterService, + private modalService: ModalService, private keyConnectorService: KeyConnectorService) { } @@ -136,7 +135,7 @@ export class SettingsComponent implements OnInit { } if (!this.vaultTimeout.valid) { - this.toasterService.popAsync('error', null, this.i18nService.t('vaultTimeoutToLarge')); + this.platformUtilsService.showToast('error', null, this.i18nService.t('vaultTimeoutToLarge')); return; } @@ -165,7 +164,7 @@ export class SettingsComponent implements OnInit { } if (!this.vaultTimeout.valid) { - this.toasterService.popAsync('error', null, this.i18nService.t('vaultTimeoutToLarge')); + this.platformUtilsService.showToast('error', null, this.i18nService.t('vaultTimeoutToLarge')); return; } diff --git a/src/popup/settings/sync.component.ts b/src/popup/settings/sync.component.ts index fd720a520c..9ec6b5fffd 100644 --- a/src/popup/settings/sync.component.ts +++ b/src/popup/settings/sync.component.ts @@ -1,11 +1,10 @@ -import { ToasterService } from 'angular2-toaster'; - import { Component, OnInit, } from '@angular/core'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { SyncService } from 'jslib-common/abstractions/sync.service'; @Component({ @@ -16,7 +15,7 @@ export class SyncComponent implements OnInit { lastSync = '--'; syncPromise: Promise