2018-02-18 04:37:43 +01:00
|
|
|
import * as template from './password-generator-history.component.html';
|
|
|
|
|
2018-02-23 22:31:52 +01:00
|
|
|
import { ToasterService } from 'angular2-toaster';
|
2018-02-18 04:37:43 +01:00
|
|
|
import { Angulartics2 } from 'angulartics2';
|
|
|
|
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
} from '@angular/core';
|
|
|
|
|
2018-02-23 22:31:52 +01:00
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
2018-02-23 22:32:32 +01:00
|
|
|
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
|
2018-02-18 04:37:43 +01:00
|
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
|
|
|
|
|
|
|
import { PasswordHistory } from 'jslib/models/domain/passwordHistory';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-password-generator-history',
|
|
|
|
template: template,
|
|
|
|
})
|
|
|
|
export class PasswordGeneratorHistoryComponent implements OnInit {
|
2018-02-23 22:31:52 +01:00
|
|
|
history: PasswordHistory[] = [];
|
2018-02-18 04:37:43 +01:00
|
|
|
|
|
|
|
constructor(private passwordGenerationService: PasswordGenerationService, private analytics: Angulartics2,
|
2018-02-23 22:31:52 +01:00
|
|
|
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
|
|
|
|
private toasterService: ToasterService) { }
|
2018-02-18 04:37:43 +01:00
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
this.history = await this.passwordGenerationService.getHistory();
|
|
|
|
}
|
|
|
|
|
|
|
|
clear() {
|
|
|
|
this.history = [];
|
|
|
|
this.passwordGenerationService.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
copy(password: string) {
|
|
|
|
this.analytics.eventTrack.next({ action: 'Copied Historical Password' });
|
|
|
|
this.platformUtilsService.copyToClipboard(password);
|
2018-02-23 22:31:52 +01:00
|
|
|
this.toasterService.popAsync('info', null, this.i18nService.t('valueCopied', this.i18nService.t('password')));
|
2018-02-18 04:37:43 +01:00
|
|
|
}
|
|
|
|
}
|