mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
convert analytics and toaster to platform utils
This commit is contained in:
parent
d4dd962193
commit
68ed8e51bd
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit 45341ec408319cbf69a4772e503a3991ae770a49
|
Subproject commit 6b3dc2344f2db167cbc404d83fa4602a1ca93ef8
|
@ -1,11 +1,9 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.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';
|
import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hint.component';
|
||||||
|
|
||||||
@ -14,9 +12,8 @@ import { HintComponent as BaseHintComponent } from 'jslib/angular/components/hin
|
|||||||
templateUrl: 'hint.component.html',
|
templateUrl: 'hint.component.html',
|
||||||
})
|
})
|
||||||
export class HintComponent extends BaseHintComponent {
|
export class HintComponent extends BaseHintComponent {
|
||||||
constructor(router: Router, analytics: Angulartics2,
|
constructor(router: Router, i18nService: I18nService,
|
||||||
toasterService: ToasterService, i18nService: I18nService,
|
apiService: ApiService, platformUtilsService: PlatformUtilsService) {
|
||||||
apiService: ApiService) {
|
super(router, i18nService, apiService, platformUtilsService);
|
||||||
super(router, analytics, toasterService, i18nService, apiService);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,6 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
@ -22,13 +19,11 @@ import { LockComponent as BaseLockComponent } from 'jslib/angular/components/loc
|
|||||||
templateUrl: 'lock.component.html',
|
templateUrl: 'lock.component.html',
|
||||||
})
|
})
|
||||||
export class LockComponent extends BaseLockComponent implements OnInit {
|
export class LockComponent extends BaseLockComponent implements OnInit {
|
||||||
constructor(router: Router, analytics: Angulartics2,
|
constructor(router: Router, i18nService: I18nService,
|
||||||
toasterService: ToasterService, i18nService: I18nService,
|
|
||||||
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
||||||
userService: UserService, cryptoService: CryptoService,
|
userService: UserService, cryptoService: CryptoService,
|
||||||
private routerService: RouterService) {
|
private routerService: RouterService) {
|
||||||
super(router, analytics, toasterService, i18nService, platformUtilsService,
|
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService);
|
||||||
messagingService, userService, cryptoService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
@ -4,11 +4,9 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
import { StateService } from 'jslib/abstractions/state.service';
|
import { StateService } from 'jslib/abstractions/state.service';
|
||||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||||
|
|
||||||
@ -20,10 +18,10 @@ import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/l
|
|||||||
})
|
})
|
||||||
export class LoginComponent extends BaseLoginComponent {
|
export class LoginComponent extends BaseLoginComponent {
|
||||||
constructor(authService: AuthService, router: Router,
|
constructor(authService: AuthService, router: Router,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
i18nService: I18nService, private route: ActivatedRoute,
|
i18nService: I18nService, private route: ActivatedRoute,
|
||||||
storageService: StorageService, private stateService: StateService) {
|
storageService: StorageService, private stateService: StateService,
|
||||||
super(authService, router, analytics, toasterService, i18nService, storageService);
|
platformUtilsService: PlatformUtilsService) {
|
||||||
|
super(authService, router, platformUtilsService, i18nService, storageService);
|
||||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
@ -25,12 +22,10 @@ export class RegisterComponent extends BaseRegisterComponent {
|
|||||||
showTerms = true;
|
showTerms = true;
|
||||||
|
|
||||||
constructor(authService: AuthService, router: Router,
|
constructor(authService: AuthService, router: Router,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
i18nService: I18nService, cryptoService: CryptoService,
|
i18nService: I18nService, cryptoService: CryptoService,
|
||||||
apiService: ApiService, private route: ActivatedRoute,
|
apiService: ApiService, private route: ActivatedRoute,
|
||||||
stateService: StateService, platformUtilsService: PlatformUtilsService) {
|
stateService: StateService, platformUtilsService: PlatformUtilsService) {
|
||||||
super(authService, router, analytics, toasterService, i18nService, cryptoService, apiService, stateService,
|
super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService);
|
||||||
platformUtilsService);
|
|
||||||
this.showTerms = !platformUtilsService.isSelfHost();
|
this.showTerms = !platformUtilsService.isSelfHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
@ -18,8 +15,7 @@ import {
|
|||||||
})
|
})
|
||||||
export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent {
|
export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent {
|
||||||
constructor(authService: AuthService, router: Router,
|
constructor(authService: AuthService, router: Router,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
i18nService: I18nService, platformUtilsService: PlatformUtilsService) {
|
i18nService: I18nService, platformUtilsService: PlatformUtilsService) {
|
||||||
super(authService, router, analytics, toasterService, i18nService, platformUtilsService, window);
|
super(authService, router, i18nService, platformUtilsService, window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,6 @@ import {
|
|||||||
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { TwoFactorOptionsComponent } from './two-factor-options.component';
|
import { TwoFactorOptionsComponent } from './two-factor-options.component';
|
||||||
|
|
||||||
import { ModalComponent } from '../modal.component';
|
import { ModalComponent } from '../modal.component';
|
||||||
@ -33,12 +30,10 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
@ViewChild('twoFactorOptions', { read: ViewContainerRef }) twoFactorOptionsModal: ViewContainerRef;
|
@ViewChild('twoFactorOptions', { read: ViewContainerRef }) twoFactorOptionsModal: ViewContainerRef;
|
||||||
|
|
||||||
constructor(authService: AuthService, router: Router,
|
constructor(authService: AuthService, router: Router,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
i18nService: I18nService, apiService: ApiService,
|
i18nService: I18nService, apiService: ApiService,
|
||||||
platformUtilsService: PlatformUtilsService, private stateService: StateService,
|
platformUtilsService: PlatformUtilsService, private stateService: StateService,
|
||||||
environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) {
|
environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) {
|
||||||
super(authService, router, analytics, toasterService, i18nService, apiService,
|
super(authService, router, i18nService, apiService, platformUtilsService, window, environmentService);
|
||||||
platformUtilsService, window, environmentService);
|
|
||||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,10 @@ import * as _swal from 'sweetalert';
|
|||||||
import { SweetAlert } from 'sweetalert/typings/core';
|
import { SweetAlert } from 'sweetalert/typings/core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
BodyOutputType,
|
||||||
|
Toast,
|
||||||
ToasterConfig,
|
ToasterConfig,
|
||||||
|
ToasterContainerComponent,
|
||||||
ToasterService,
|
ToasterService,
|
||||||
} from 'angular2-toaster';
|
} from 'angular2-toaster';
|
||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
@ -14,7 +17,9 @@ import {
|
|||||||
NgZone,
|
NgZone,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
SecurityContext,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import {
|
import {
|
||||||
NavigationEnd,
|
NavigationEnd,
|
||||||
Router,
|
Router,
|
||||||
@ -75,7 +80,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
private platformUtilsService: PlatformUtilsService, private ngZone: NgZone,
|
private platformUtilsService: PlatformUtilsService, private ngZone: NgZone,
|
||||||
private lockService: LockService, private storageService: StorageService,
|
private lockService: LockService, private storageService: StorageService,
|
||||||
private cryptoService: CryptoService, private collectionService: CollectionService,
|
private cryptoService: CryptoService, private collectionService: CollectionService,
|
||||||
private routerService: RouterService, private searchService: SearchService,
|
private sanitizer: DomSanitizer, private searchService: SearchService,
|
||||||
private notificationsService: NotificationsService) { }
|
private notificationsService: NotificationsService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -126,6 +131,15 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
this.router.navigate(['settings/premium']);
|
this.router.navigate(['settings/premium']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'showToast':
|
||||||
|
this.showToast(message);
|
||||||
|
break;
|
||||||
|
case 'analyticsEventTrack':
|
||||||
|
this.analytics.eventTrack.next({
|
||||||
|
action: message.action,
|
||||||
|
properties: { label: message.label },
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -202,6 +216,33 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
}, IdleTimeout);
|
}, IdleTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private 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 += ('<p>' + this.sanitizer.sanitize(SecurityContext.HTML, t) + '</p>'));
|
||||||
|
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 idleStateChanged() {
|
private idleStateChanged() {
|
||||||
if (this.isIdle) {
|
if (this.isIdle) {
|
||||||
this.notificationsService.disconnectFromInactivity();
|
this.notificationsService.disconnectFromInactivity();
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
@ -18,11 +15,10 @@ import { ExportComponent as BaseExportComponent } from '../../tools/export.compo
|
|||||||
export class ExportComponent extends BaseExportComponent {
|
export class ExportComponent extends BaseExportComponent {
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
|
|
||||||
constructor(analytics: Angulartics2, toasterService: ToasterService,
|
constructor(cryptoService: CryptoService, i18nService: I18nService,
|
||||||
cryptoService: CryptoService, i18nService: I18nService,
|
|
||||||
platformUtilsService: PlatformUtilsService, exportService: ExportService,
|
platformUtilsService: PlatformUtilsService, exportService: ExportService,
|
||||||
private route: ActivatedRoute) {
|
private route: ActivatedRoute) {
|
||||||
super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, exportService);
|
super(cryptoService, i18nService, platformUtilsService, exportService);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -3,9 +3,6 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
@ -35,14 +32,12 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(cipherService: CipherService, folderService: FolderService,
|
constructor(cipherService: CipherService, folderService: FolderService,
|
||||||
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
auditService: AuditService, stateService: StateService,
|
auditService: AuditService, stateService: StateService,
|
||||||
userService: UserService, totpService: TotpService,
|
userService: UserService, totpService: TotpService,
|
||||||
passwordGenerationService: PasswordGenerationService, private apiService: ApiService,
|
passwordGenerationService: PasswordGenerationService, private apiService: ApiService,
|
||||||
messagingService: MessagingService) {
|
messagingService: MessagingService) {
|
||||||
super(cipherService, folderService, i18nService, platformUtilsService, analytics,
|
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
|
||||||
toasterService, auditService, stateService, userService, totpService, passwordGenerationService,
|
userService, totpService, passwordGenerationService, messagingService);
|
||||||
messagingService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async loadCipher() {
|
protected async loadCipher() {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
@ -23,12 +20,10 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from '../../vault/at
|
|||||||
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||||
organization: Organization;
|
organization: Organization;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, analytics: Angulartics2,
|
constructor(cipherService: CipherService, i18nService: I18nService,
|
||||||
toasterService: ToasterService, i18nService: I18nService,
|
|
||||||
cryptoService: CryptoService, userService: UserService,
|
cryptoService: CryptoService, userService: UserService,
|
||||||
platformUtilsService: PlatformUtilsService, private apiService: ApiService) {
|
platformUtilsService: PlatformUtilsService, private apiService: ApiService) {
|
||||||
super(cipherService, analytics, toasterService, i18nService, cryptoService, userService,
|
super(cipherService, i18nService, cryptoService, userService, platformUtilsService);
|
||||||
platformUtilsService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async loadCipher() {
|
protected async loadCipher() {
|
||||||
|
@ -83,7 +83,7 @@ const i18nService = new I18nService(window.navigator.language, 'locales');
|
|||||||
const stateService = new StateService();
|
const stateService = new StateService();
|
||||||
const broadcasterService = new BroadcasterService();
|
const broadcasterService = new BroadcasterService();
|
||||||
const messagingService = new BroadcasterMessagingService(broadcasterService);
|
const messagingService = new BroadcasterMessagingService(broadcasterService);
|
||||||
const platformUtilsService = new WebPlatformUtilsService(i18nService);
|
const platformUtilsService = new WebPlatformUtilsService(i18nService, messagingService);
|
||||||
const storageService: StorageServiceAbstraction = new HtmlStorageService(platformUtilsService);
|
const storageService: StorageServiceAbstraction = new HtmlStorageService(platformUtilsService);
|
||||||
const secureStorageService: StorageServiceAbstraction = new MemoryStorageService();
|
const secureStorageService: StorageServiceAbstraction = new MemoryStorageService();
|
||||||
const cryptoFunctionService: CryptoFunctionServiceAbstraction = new WebCryptoFunctionService(window,
|
const cryptoFunctionService: CryptoFunctionServiceAbstraction = new WebCryptoFunctionService(window,
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
@ -15,16 +12,14 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components
|
|||||||
templateUrl: 'export.component.html',
|
templateUrl: 'export.component.html',
|
||||||
})
|
})
|
||||||
export class ExportComponent extends BaseExportComponent {
|
export class ExportComponent extends BaseExportComponent {
|
||||||
constructor(analytics: Angulartics2, toasterService: ToasterService,
|
constructor(cryptoService: CryptoService, i18nService: I18nService,
|
||||||
cryptoService: CryptoService, i18nService: I18nService,
|
|
||||||
platformUtilsService: PlatformUtilsService, exportService: ExportService) {
|
platformUtilsService: PlatformUtilsService, exportService: ExportService) {
|
||||||
super(analytics, toasterService, cryptoService, i18nService, platformUtilsService,
|
super(cryptoService, i18nService, platformUtilsService, exportService, window);
|
||||||
exportService, window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected saved() {
|
protected saved() {
|
||||||
super.saved();
|
super.saved();
|
||||||
this.masterPassword = null;
|
this.masterPassword = null;
|
||||||
this.toasterService.popAsync('success', null, this.i18nService.t('exportSuccess'));
|
this.platformUtilsService.showToast('success', null, this.i18nService.t('exportSuccess'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ export class ImportComponent implements OnInit {
|
|||||||
reader.onload = (evt) => {
|
reader.onload = (evt) => {
|
||||||
if (this.format === 'lastpasscsv' && file.type === 'text/html') {
|
if (this.format === 'lastpasscsv' && file.type === 'text/html') {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(evt.target.result, 'text/html');
|
const doc = parser.parseFromString((evt.target as any).result, 'text/html');
|
||||||
const pre = doc.querySelector('pre');
|
const pre = doc.querySelector('pre');
|
||||||
if (pre != null) {
|
if (pre != null) {
|
||||||
resolve(pre.textContent);
|
resolve(pre.textContent);
|
||||||
@ -139,7 +139,7 @@ export class ImportComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(evt.target.result);
|
resolve((evt.target as any).result);
|
||||||
};
|
};
|
||||||
reader.onerror = () => {
|
reader.onerror = () => {
|
||||||
reject();
|
reject();
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
@ -16,9 +13,8 @@ import {
|
|||||||
templateUrl: 'password-generator-history.component.html',
|
templateUrl: 'password-generator-history.component.html',
|
||||||
})
|
})
|
||||||
export class PasswordGeneratorHistoryComponent extends BasePasswordGeneratorHistoryComponent {
|
export class PasswordGeneratorHistoryComponent extends BasePasswordGeneratorHistoryComponent {
|
||||||
constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2,
|
constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
|
||||||
platformUtilsService: PlatformUtilsService, i18nService: I18nService,
|
i18nService: I18nService) {
|
||||||
toasterService: ToasterService) {
|
super(passwordGenerationService, platformUtilsService, i18nService, window);
|
||||||
super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
ComponentFactoryResolver,
|
ComponentFactoryResolver,
|
||||||
@ -28,10 +25,9 @@ export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent {
|
|||||||
|
|
||||||
private modal: ModalComponent = null;
|
private modal: ModalComponent = null;
|
||||||
|
|
||||||
constructor(passwordGenerationService: PasswordGenerationService, analytics: Angulartics2,
|
constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
|
||||||
platformUtilsService: PlatformUtilsService, i18nService: I18nService,
|
i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver) {
|
||||||
toasterService: ToasterService, private componentFactoryResolver: ComponentFactoryResolver) {
|
super(passwordGenerationService, platformUtilsService, i18nService, window);
|
||||||
super(passwordGenerationService, analytics, platformUtilsService, i18nService, toasterService, window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
history() {
|
history() {
|
||||||
|
@ -3,9 +3,6 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { CipherType } from 'jslib/enums/cipherType';
|
import { CipherType } from 'jslib/enums/cipherType';
|
||||||
|
|
||||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||||
@ -41,12 +38,10 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(cipherService: CipherService, folderService: FolderService,
|
constructor(cipherService: CipherService, folderService: FolderService,
|
||||||
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
auditService: AuditService, stateService: StateService,
|
auditService: AuditService, stateService: StateService,
|
||||||
protected userService: UserService, protected totpService: TotpService,
|
protected userService: UserService, protected totpService: TotpService,
|
||||||
protected passwordGenerationService: PasswordGenerationService, protected messagingService: MessagingService) {
|
protected passwordGenerationService: PasswordGenerationService, protected messagingService: MessagingService) {
|
||||||
super(cipherService, folderService, i18nService, platformUtilsService, analytics,
|
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService);
|
||||||
toasterService, auditService, stateService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -77,7 +72,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.analytics.eventTrack.next({ action: 'Launched Login URI' });
|
this.platformUtilsService.eventTrack('Launched Login URI');
|
||||||
this.platformUtilsService.launchUri(uri.uri);
|
this.platformUtilsService.launchUri(uri.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +81,9 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.analytics.eventTrack.next({ action: 'Copied ' + aType });
|
this.platformUtilsService.eventTrack('Copied ' + aType);
|
||||||
this.platformUtilsService.copyToClipboard(value, { window: window });
|
this.platformUtilsService.copyToClipboard(value, { window: window });
|
||||||
this.toasterService.popAsync('info', null,
|
this.platformUtilsService.showToast('info', null,
|
||||||
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
|
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,5 +152,4 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
await this.totpUpdateCode();
|
await this.totpUpdateCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
@ -16,11 +13,9 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/
|
|||||||
templateUrl: 'attachments.component.html',
|
templateUrl: 'attachments.component.html',
|
||||||
})
|
})
|
||||||
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||||
constructor(cipherService: CipherService, analytics: Angulartics2,
|
constructor(cipherService: CipherService, i18nService: I18nService,
|
||||||
toasterService: ToasterService, i18nService: I18nService,
|
|
||||||
cryptoService: CryptoService, userService: UserService,
|
cryptoService: CryptoService, userService: UserService,
|
||||||
platformUtilsService: PlatformUtilsService) {
|
platformUtilsService: PlatformUtilsService) {
|
||||||
super(cipherService, analytics, toasterService, i18nService, cryptoService, userService,
|
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, window);
|
||||||
platformUtilsService, window);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { ToasterService } from 'angular2-toaster';
|
|
||||||
import { Angulartics2 } from 'angulartics2';
|
|
||||||
|
|
||||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
@ -17,8 +14,7 @@ import {
|
|||||||
})
|
})
|
||||||
export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
||||||
constructor(folderService: FolderService, i18nService: I18nService,
|
constructor(folderService: FolderService, i18nService: I18nService,
|
||||||
analytics: Angulartics2, toasterService: ToasterService,
|
|
||||||
platformUtilsService: PlatformUtilsService) {
|
platformUtilsService: PlatformUtilsService) {
|
||||||
super(folderService, i18nService, analytics, toasterService, platformUtilsService);
|
super(folderService, i18nService, platformUtilsService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { SweetAlert } from 'sweetalert/typings/core';
|
|||||||
import { DeviceType } from 'jslib/enums/deviceType';
|
import { DeviceType } from 'jslib/enums/deviceType';
|
||||||
|
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
|
||||||
import { Utils } from 'jslib/misc/utils';
|
import { Utils } from 'jslib/misc/utils';
|
||||||
@ -16,7 +17,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
|
|
||||||
private browserCache: DeviceType = null;
|
private browserCache: DeviceType = null;
|
||||||
|
|
||||||
constructor(private i18nService: I18nService) { }
|
constructor(private i18nService: I18nService, private messagingService: MessagingService) { }
|
||||||
|
|
||||||
getDevice(): DeviceType {
|
getDevice(): DeviceType {
|
||||||
if (this.browserCache != null) {
|
if (this.browserCache != null) {
|
||||||
@ -143,8 +144,14 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string, global?: any): void {
|
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string | string[],
|
||||||
throw new Error('showToast not implemented');
|
options?: any): void {
|
||||||
|
this.messagingService.send('showToast', {
|
||||||
|
text: text,
|
||||||
|
title: title,
|
||||||
|
type: type,
|
||||||
|
options: options,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string) {
|
async showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string) {
|
||||||
@ -199,6 +206,14 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
return confirmed;
|
return confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventTrack(action: string, label?: string, options?: any) {
|
||||||
|
this.messagingService.send('analyticsEventTrack', {
|
||||||
|
action: action,
|
||||||
|
label: label,
|
||||||
|
options: options,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isDev(): boolean {
|
isDev(): boolean {
|
||||||
return process.env.ENV === 'development';
|
return process.env.ENV === 'development';
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,6 @@
|
|||||||
"@angular/*": [
|
"@angular/*": [
|
||||||
"node_modules/@angular/*"
|
"node_modules/@angular/*"
|
||||||
],
|
],
|
||||||
"angular2-toaster": [
|
|
||||||
"node_modules/angular2-toaster"
|
|
||||||
],
|
|
||||||
"angulartics2": [
|
|
||||||
"node_modules/angulartics2"
|
|
||||||
],
|
|
||||||
"node": [
|
"node": [
|
||||||
"node_modules/@types/node"
|
"node_modules/@types/node"
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user