From 89a448b12f16f7d17c338d43a7f3e1ff70716453 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 2 Oct 2018 23:33:56 -0400 Subject: [PATCH] platform utils for toasting --- jslib | 2 +- src/popup/accounts/environment.component.ts | 6 +-- src/popup/accounts/hint.component.ts | 6 +-- src/popup/accounts/home.component.ts | 11 +---- src/popup/accounts/lock.component.ts | 6 +-- src/popup/accounts/login.component.ts | 8 ++-- src/popup/accounts/register.component.ts | 5 +- .../accounts/two-factor-options.component.ts | 5 +- src/popup/accounts/two-factor.component.ts | 9 ++-- src/popup/app.component.ts | 48 +++++++++++++++++-- .../components/ciphers-list.component.ts | 10 ---- .../password-generator-history.component.ts | 5 +- .../generator/password-generator.component.ts | 6 +-- src/popup/settings/export.component.ts | 6 +-- .../settings/folder-add-edit.component.ts | 5 +- src/popup/settings/premium.component.ts | 5 +- src/popup/vault/add-edit.component.ts | 7 +-- src/popup/vault/attachments.component.ts | 6 +-- src/popup/vault/password-history.component.ts | 6 +-- src/popup/vault/view.component.ts | 5 +- src/services/browserPlatformUtils.service.ts | 10 +++- 21 files changed, 91 insertions(+), 86 deletions(-) diff --git a/jslib b/jslib index 45341ec408..f793ff0aa5 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 45341ec408319cbf69a4772e503a3991ae770a49 +Subproject commit f793ff0aa57ef9ffcf09323d1f557c7c24509c1e diff --git a/src/popup/accounts/environment.component.ts b/src/popup/accounts/environment.component.ts index b42415f6ce..a22b4dc240 100644 --- a/src/popup/accounts/environment.component.ts +++ b/src/popup/accounts/environment.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { EnvironmentComponent as BaseEnvironmentComponent } from 'jslib/angular/components/environment.component'; @@ -14,10 +14,10 @@ import { EnvironmentComponent as BaseEnvironmentComponent } from 'jslib/angular/ templateUrl: 'environment.component.html', }) export class EnvironmentComponent extends BaseEnvironmentComponent { - constructor(analytics: Angulartics2, toasterService: ToasterService, + constructor(analytics: Angulartics2, platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService, i18nService: I18nService, private router: Router) { - super(analytics, toasterService, environmentService, i18nService); + super(analytics, platformUtilsService, environmentService, i18nService); this.showCustom = true; } diff --git a/src/popup/accounts/hint.component.ts b/src/popup/accounts/hint.component.ts index bb84ff02f9..3c476b1ddd 100644 --- a/src/popup/accounts/hint.component.ts +++ b/src/popup/accounts/hint.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hint.component'; @@ -15,8 +15,8 @@ import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hin }) export class HintComponent extends BaseHintComponent { constructor(router: Router, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, i18nService: I18nService, apiService: ApiService) { - super(router, analytics, toasterService, i18nService, apiService); + super(router, analytics, i18nService, apiService, platformUtilsService); } } diff --git a/src/popup/accounts/home.component.ts b/src/popup/accounts/home.component.ts index 583c7eb398..2780e2b5bc 100644 --- a/src/popup/accounts/home.component.ts +++ b/src/popup/accounts/home.component.ts @@ -1,16 +1,7 @@ import { Component } from '@angular/core'; -import { Router } from '@angular/router'; - -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - -import { I18nService } from 'jslib/abstractions/i18n.service'; @Component({ selector: 'app-home', templateUrl: 'home.component.html', }) -export class HomeComponent { - constructor(private router: Router, i18nService: I18nService, - analytics: Angulartics2, toasterService: ToasterService) { } -} +export class HomeComponent { } diff --git a/src/popup/accounts/lock.component.ts b/src/popup/accounts/lock.component.ts index 8079dd6378..73ad779119 100644 --- a/src/popup/accounts/lock.component.ts +++ b/src/popup/accounts/lock.component.ts @@ -4,7 +4,6 @@ import { } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { CryptoService } from 'jslib/abstractions/crypto.service'; @@ -21,11 +20,10 @@ import { LockComponent as BaseLockComponent } from 'jslib/angular/components/loc }) export class LockComponent extends BaseLockComponent implements OnInit { constructor(router: Router, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, + i18nService: I18nService, platformUtilsService: PlatformUtilsService, messagingService: MessagingService, userService: UserService, cryptoService: CryptoService) { - super(router, analytics, toasterService, i18nService, platformUtilsService, - messagingService, userService, cryptoService); + super(router, analytics, i18nService, platformUtilsService, messagingService, userService, cryptoService); this.successRoute = '/tabs/current'; } diff --git a/src/popup/accounts/login.component.ts b/src/popup/accounts/login.component.ts index 3ddd1c6228..e5856968bc 100644 --- a/src/popup/accounts/login.component.ts +++ b/src/popup/accounts/login.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { AuthService } from 'jslib/abstractions/auth.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { StorageService } from 'jslib/abstractions/storage.service'; import { SyncService } from 'jslib/abstractions/sync.service'; @@ -17,9 +17,9 @@ import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/l }) export class LoginComponent extends BaseLoginComponent { constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, - i18nService: I18nService, private syncService: SyncService, storageService: StorageService) { - super(authService, router, analytics, toasterService, i18nService, storageService); + analytics: Angulartics2, platformUtilsService: PlatformUtilsService, + i18nService: I18nService, syncService: SyncService, storageService: StorageService) { + super(authService, router, analytics, platformUtilsService, i18nService, storageService); super.onSuccessfulLogin = () => { return syncService.fullSync(true); }; diff --git a/src/popup/accounts/register.component.ts b/src/popup/accounts/register.component.ts index c49cdb9254..a305598fc0 100644 --- a/src/popup/accounts/register.component.ts +++ b/src/popup/accounts/register.component.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; @@ -19,11 +18,11 @@ import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/compon }) export class RegisterComponent extends BaseRegisterComponent { constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, + analytics: Angulartics2, i18nService: I18nService, cryptoService: CryptoService, apiService: ApiService, stateService: StateService, platformUtilsService: PlatformUtilsService) { - super(authService, router, analytics, toasterService, i18nService, cryptoService, apiService, stateService, + super(authService, router, analytics, i18nService, cryptoService, apiService, stateService, platformUtilsService); } } diff --git a/src/popup/accounts/two-factor-options.component.ts b/src/popup/accounts/two-factor-options.component.ts index 779d4813c1..b7be50bc0d 100644 --- a/src/popup/accounts/two-factor-options.component.ts +++ b/src/popup/accounts/two-factor-options.component.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { AuthService } from 'jslib/abstractions/auth.service'; @@ -18,9 +17,9 @@ import { }) export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent { constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, + analytics: Angulartics2, i18nService: I18nService, platformUtilsService: PlatformUtilsService) { - super(authService, router, analytics, toasterService, i18nService, platformUtilsService, window); + super(authService, router, analytics, i18nService, platformUtilsService, window); } choose(p: any) { diff --git a/src/popup/accounts/two-factor.component.ts b/src/popup/accounts/two-factor.component.ts index 2054d55832..a58dfaf597 100644 --- a/src/popup/accounts/two-factor.component.ts +++ b/src/popup/accounts/two-factor.component.ts @@ -2,13 +2,10 @@ import { ChangeDetectorRef, Component, NgZone, - OnDestroy, - OnInit, } from '@angular/core'; import { Router } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { BrowserApi } from '../../browser/browserApi'; @@ -36,13 +33,13 @@ export class TwoFactorComponent extends BaseTwoFactorComponent { showNewWindowMessage = false; constructor(authService: AuthService, router: Router, - analytics: Angulartics2, toasterService: ToasterService, + analytics: Angulartics2, i18nService: I18nService, apiService: ApiService, platformUtilsService: PlatformUtilsService, syncService: SyncService, environmentService: EnvironmentService, private ngZone: NgZone, private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef) { - super(authService, router, analytics, toasterService, i18nService, apiService, - platformUtilsService, window, environmentService); + super(authService, router, analytics, i18nService, apiService, platformUtilsService, window, + environmentService); super.onSuccessfulLogin = () => { return syncService.fullSync(true); }; diff --git a/src/popup/app.component.ts b/src/popup/app.component.ts index 7ae6ff0359..c009b443c5 100644 --- a/src/popup/app.component.ts +++ b/src/popup/app.component.ts @@ -1,8 +1,11 @@ import { BrowserApi } from '../browser/browserApi'; import { + BodyOutputType, + Toast, ToasterConfig, ToasterContainerComponent, + ToasterService, } from 'angular2-toaster'; import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; import swal from 'sweetalert'; @@ -12,14 +15,15 @@ import { Component, NgZone, OnInit, + SecurityContext, } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; import { NavigationEnd, Router, RouterOutlet, } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; @@ -62,7 +66,8 @@ export class AppComponent implements OnInit { private broadcasterService: BroadcasterService, private authService: AuthService, private i18nService: I18nService, private router: Router, private stateService: StateService, private messagingService: MessagingService, - private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { } + private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone, + private sanitizer: DomSanitizer) { } ngOnInit() { if (BrowserApi.getBackgroundPage() == null) { @@ -84,8 +89,11 @@ export class AppComponent implements OnInit { this.authService.logOut(() => { this.analytics.eventTrack.next({ action: 'Logged Out' }); if (msg.expired) { - this.toasterService.popAsync('warning', this.i18nService.t('loggedOut'), - this.i18nService.t('loginExpired')); + this.showToast({ + type: 'warning', + title: this.i18nService.t('loggedOut'), + text: this.i18nService.t('loginExpired'), + }); } this.router.navigate(['home']); this.stateService.purge(); @@ -96,6 +104,11 @@ export class AppComponent implements OnInit { this.stateService.purge(); } else if (msg.command === 'showDialog') { await this.showDialog(msg); + } else if (msg.command === 'showToast') { + this.ngZone.run(async () => { + await this.showToast(msg); + this.changeDetectorRef.detectChanges(); + }); } else { msg.webExtSender = sender; this.broadcasterService.send(msg); @@ -133,6 +146,33 @@ export class AppComponent implements OnInit { this.storageService.save(ConstantsService.lastActiveKey, now); } + private async showToast(msg: any) { + const toast: Toast = { + type: msg.type, + title: msg.title, + }; + if (typeof (msg.text) === 'string') { + toast.body = msg.text; + } else if (msg.text.length === 1) { + toast.body = msg.text[0]; + } else { + let message = ''; + msg.text.forEach((t: string) => + message += ('

' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '

')); + toast.body = message; + toast.bodyOutputType = BodyOutputType.TrustedHtml; + } + if (msg.options != null) { + if (msg.options.trustedHtml === true) { + toast.bodyOutputType = BodyOutputType.TrustedHtml; + } + if (msg.options.timeout != null && msg.options.timeout > 0) { + toast.timeout = msg.options.timeout; + } + } + this.toasterService.popAsync(toast); + } + private async showDialog(msg: any) { const buttons = [msg.confirmText == null ? this.i18nService.t('ok') : msg.confirmText]; if (msg.cancelText != null) { diff --git a/src/popup/components/ciphers-list.component.ts b/src/popup/components/ciphers-list.component.ts index 9ba7b4ac5f..81b477af3d 100644 --- a/src/popup/components/ciphers-list.component.ts +++ b/src/popup/components/ciphers-list.component.ts @@ -5,20 +5,10 @@ import { Output, } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; -import { Angulartics2 } from 'angulartics2'; - -import { BrowserApi } from '../../browser/browserApi'; - import { CipherType } from 'jslib/enums/cipherType'; import { CipherView } from 'jslib/models/view/cipherView'; -import { I18nService } from 'jslib/abstractions/i18n.service'; -import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; - -import { PopupUtilsService } from '../services/popup-utils.service'; - @Component({ selector: 'app-ciphers-list', templateUrl: 'ciphers-list.component.html', diff --git a/src/popup/generator/password-generator-history.component.ts b/src/popup/generator/password-generator-history.component.ts index 0d74c08720..6b4b4e9ec2 100644 --- a/src/popup/generator/password-generator-history.component.ts +++ b/src/popup/generator/password-generator-history.component.ts @@ -1,4 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { Location } from '@angular/common'; @@ -19,8 +18,8 @@ import { export class PasswordGeneratorHistoryComponent extends BasePasswordGeneratorHistoryComponent { constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2, platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService, private location: Location) { - super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window); + private location: Location) { + super(passwordGenerationService, analytics, platformUtilsService, i18nService, window); } close() { diff --git a/src/popup/generator/password-generator.component.ts b/src/popup/generator/password-generator.component.ts index 6085265dca..bdcf1e1919 100644 --- a/src/popup/generator/password-generator.component.ts +++ b/src/popup/generator/password-generator.component.ts @@ -1,4 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { Location } from '@angular/common'; @@ -24,9 +23,8 @@ export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent { constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2, platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService, private stateService: StateService, - private location: Location) { - super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window); + private stateService: StateService, private location: Location) { + super(passwordGenerationService, analytics, platformUtilsService, i18nService, window); } async ngOnInit() { diff --git a/src/popup/settings/export.component.ts b/src/popup/settings/export.component.ts index 6478734c22..7fefd942a5 100644 --- a/src/popup/settings/export.component.ts +++ b/src/popup/settings/export.component.ts @@ -1,4 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { Component } from '@angular/core'; @@ -16,12 +15,11 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components templateUrl: 'export.component.html', }) export class ExportComponent extends BaseExportComponent { - constructor(analytics: Angulartics2, toasterService: ToasterService, + constructor(analytics: Angulartics2, cryptoService: CryptoService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, exportService: ExportService, private router: Router) { - super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, - exportService, window); + super(analytics, cryptoService, i18nService, platformUtilsService, exportService, window); } protected saved() { diff --git a/src/popup/settings/folder-add-edit.component.ts b/src/popup/settings/folder-add-edit.component.ts index 428ae500c2..fba1a8d546 100644 --- a/src/popup/settings/folder-add-edit.component.ts +++ b/src/popup/settings/folder-add-edit.component.ts @@ -4,7 +4,6 @@ import { Router, } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { FolderService } from 'jslib/abstractions/folder.service'; @@ -21,10 +20,10 @@ import { }) export class FolderAddEditComponent extends BaseFolderAddEditComponent { constructor(folderService: FolderService, i18nService: I18nService, - analytics: Angulartics2, toasterService: ToasterService, + analytics: Angulartics2, platformUtilsService: PlatformUtilsService, private router: Router, private route: ActivatedRoute) { - super(folderService, i18nService, analytics, toasterService, platformUtilsService); + super(folderService, i18nService, analytics, platformUtilsService); } async ngOnInit() { diff --git a/src/popup/settings/premium.component.ts b/src/popup/settings/premium.component.ts index f2f959a815..69a1766979 100644 --- a/src/popup/settings/premium.component.ts +++ b/src/popup/settings/premium.component.ts @@ -1,7 +1,6 @@ import { CurrencyPipe } from '@angular/common'; import { Component } from '@angular/core'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; @@ -18,11 +17,11 @@ import { PremiumComponent as BasePremiumComponent } from 'jslib/angular/componen export class PremiumComponent extends BasePremiumComponent { priceString: string; - constructor(analytics: Angulartics2, toasterService: ToasterService, + constructor(analytics: Angulartics2, i18nService: I18nService, platformUtilsService: PlatformUtilsService, tokenService: TokenService, apiService: ApiService, private currencyPipe: CurrencyPipe) { - super(analytics, toasterService, i18nService, platformUtilsService, tokenService, apiService); + super(analytics, i18nService, platformUtilsService, tokenService, apiService); // Support old price string. Can be removed in future once all translations are properly updated. const thePrice = this.currencyPipe.transform(this.price, '$'); diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index a226ec4909..07967a12bd 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -8,11 +8,8 @@ import { Router, } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; -import { CipherType } from 'jslib/enums/cipherType'; - import { AuditService } from 'jslib/abstractions/audit.service'; import { CipherService } from 'jslib/abstractions/cipher.service'; import { FolderService } from 'jslib/abstractions/folder.service'; @@ -31,12 +28,12 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit { constructor(cipherService: CipherService, folderService: FolderService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, - analytics: Angulartics2, toasterService: ToasterService, + analytics: Angulartics2, auditService: AuditService, stateService: StateService, private route: ActivatedRoute, private router: Router, private location: Location) { super(cipherService, folderService, i18nService, platformUtilsService, analytics, - toasterService, auditService, stateService); + auditService, stateService); } ngOnInit() { diff --git a/src/popup/vault/attachments.component.ts b/src/popup/vault/attachments.component.ts index 5d0f854199..6abe53e9ef 100644 --- a/src/popup/vault/attachments.component.ts +++ b/src/popup/vault/attachments.component.ts @@ -2,7 +2,6 @@ import { Location } from '@angular/common'; import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { CipherService } from 'jslib/abstractions/cipher.service'; @@ -19,12 +18,11 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/ }) export class AttachmentsComponent extends BaseAttachmentsComponent { constructor(cipherService: CipherService, analytics: Angulartics2, - toasterService: ToasterService, i18nService: I18nService, + i18nService: I18nService, cryptoService: CryptoService, userService: UserService, platformUtilsService: PlatformUtilsService, private location: Location, private route: ActivatedRoute) { - super(cipherService, analytics, toasterService, i18nService, cryptoService, userService, - platformUtilsService, window); + super(cipherService, analytics, i18nService, cryptoService, userService, platformUtilsService, window); } async ngOnInit() { diff --git a/src/popup/vault/password-history.component.ts b/src/popup/vault/password-history.component.ts index b33af3f5e3..553b18ff86 100644 --- a/src/popup/vault/password-history.component.ts +++ b/src/popup/vault/password-history.component.ts @@ -1,4 +1,3 @@ -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { Location } from '@angular/common'; @@ -20,9 +19,8 @@ import { export class PasswordHistoryComponent extends BasePasswordHistoryComponent { constructor(cipherService: CipherService, analytics: Angulartics2, platformUtilsService: PlatformUtilsService, i18nService: I18nService, - toasterService: ToasterService, private location: Location, - private route: ActivatedRoute) { - super(cipherService, analytics, platformUtilsService, i18nService, toasterService, window); + private location: Location, private route: ActivatedRoute) { + super(cipherService, analytics, platformUtilsService, i18nService, window); } async ngOnInit() { diff --git a/src/popup/vault/view.component.ts b/src/popup/vault/view.component.ts index 6ee19d4ffc..dbfbcbb859 100644 --- a/src/popup/vault/view.component.ts +++ b/src/popup/vault/view.component.ts @@ -9,7 +9,6 @@ import { Router, } from '@angular/router'; -import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { AuditService } from 'jslib/abstractions/audit.service'; @@ -33,14 +32,14 @@ export class ViewComponent extends BaseViewComponent { showAttachments = true; constructor(cipherService: CipherService, totpService: TotpService, - tokenService: TokenService, toasterService: ToasterService, + tokenService: TokenService, cryptoService: CryptoService, platformUtilsService: PlatformUtilsService, i18nService: I18nService, analytics: Angulartics2, auditService: AuditService, private route: ActivatedRoute, private router: Router, private location: Location, broadcasterService: BroadcasterService, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, userService: UserService) { - super(cipherService, totpService, tokenService, toasterService, cryptoService, platformUtilsService, + super(cipherService, totpService, tokenService, cryptoService, platformUtilsService, i18nService, analytics, auditService, window, broadcasterService, ngZone, changeDetectorRef, userService); } diff --git a/src/services/browserPlatformUtils.service.ts b/src/services/browserPlatformUtils.service.ts index b4d6f47946..2a2af1e70a 100644 --- a/src/services/browserPlatformUtils.service.ts +++ b/src/services/browserPlatformUtils.service.ts @@ -1,3 +1,4 @@ +import { ToasterService } from 'angular2-toaster'; import * as tldjs from 'tldjs'; import { BrowserApi } from '../browser/browserApi'; @@ -178,8 +179,13 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService return true; } - showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string, global?: any): void { - throw new Error('showToast not implemented'); + showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string, options?: any): void { + this.messagingService.send('showToast', { + text: text, + title: title, + type: type, + options: options, + }); } showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string) {