mirror of
https://github.com/bitwarden/browser
synced 2026-01-21 03:43:41 +00:00
added toaster
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
||||
import { ToasterContainerComponent, ToasterConfig } from 'angular2-toaster';
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
styles: [],
|
||||
template: '<router-outlet></router-outlet>',
|
||||
template: `
|
||||
<toaster-container [toasterconfig]="toasterConfig"></toaster-container>
|
||||
<router-outlet></router-outlet>`,
|
||||
})
|
||||
export class AppComponent {
|
||||
toasterConfig: ToasterConfig = new ToasterConfig({
|
||||
showCloseButton: true,
|
||||
mouseoverTimerStop: true,
|
||||
animation: 'flyRight',
|
||||
limit: 5,
|
||||
});
|
||||
|
||||
constructor(angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import 'zone.js/dist/zone';
|
||||
import { Angulartics2Module } from 'angulartics2';
|
||||
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ServicesModule } from './services/services.module';
|
||||
import { ToasterModule } from 'angular2-toaster';
|
||||
|
||||
import { AddComponent } from './vault/add.component';
|
||||
import { AppComponent } from './app.component';
|
||||
@@ -25,7 +26,7 @@ import { ViewComponent } from './vault/view.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
FormsModule,
|
||||
AppRoutingModule,
|
||||
ServicesModule,
|
||||
@@ -34,6 +35,7 @@ import { ViewComponent } from './vault/view.component';
|
||||
clearQueryParams: true,
|
||||
},
|
||||
}),
|
||||
ToasterModule,
|
||||
],
|
||||
declarations: [
|
||||
AddComponent,
|
||||
|
||||
@@ -77,7 +77,7 @@ const settingsService = new SettingsService(userService, storageService);
|
||||
const cipherService = new CipherService(cryptoService, userService, settingsService,
|
||||
apiService, storageService);
|
||||
const folderService = new FolderService(cryptoService, userService,
|
||||
() => i18nService.t('noFolder'), apiService, storageService);
|
||||
() => i18nService.t('noneFolder'), apiService, storageService);
|
||||
const collectionService = new CollectionService(cryptoService, userService, storageService);
|
||||
const lockService = new LockService(cipherService, folderService, collectionService,
|
||||
cryptoService, platformUtilsService, storageService,
|
||||
|
||||
@@ -6,6 +6,9 @@ import {
|
||||
OnChanges,
|
||||
} from '@angular/core';
|
||||
|
||||
import { Angulartics2 } from 'angulartics2';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { CipherType } from 'jslib/enums/cipherType';
|
||||
import { FieldType } from 'jslib/enums/fieldType';
|
||||
import { SecureNoteType } from 'jslib/enums/secureNoteType';
|
||||
@@ -41,7 +44,8 @@ export class AddComponent implements OnChanges {
|
||||
addFieldTypeOptions: any[];
|
||||
|
||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService) {
|
||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||
private analytics: Angulartics2, private toasterService: ToasterService) {
|
||||
this.typeOptions = [
|
||||
{ name: i18nService.t('typeLogin'), value: CipherType.Login },
|
||||
{ name: i18nService.t('typeCard'), value: CipherType.Card },
|
||||
@@ -104,15 +108,15 @@ export class AddComponent implements OnChanges {
|
||||
|
||||
async save() {
|
||||
if (this.cipher.name == null || this.cipher.name === '') {
|
||||
this.platformUtilsService.alertError(this.i18nService.t('errorOccurred'),
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('nameRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
const cipher = await this.cipherService.encrypt(this.cipher);
|
||||
await this.cipherService.saveWithServer(cipher);
|
||||
//$analytics.eventTrack('Added Cipher');
|
||||
// TODO: success message
|
||||
this.analytics.eventTrack.next({ action: 'Added Cipher' });
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('addedItem'));
|
||||
};
|
||||
|
||||
addField() {
|
||||
|
||||
Reference in New Issue
Block a user