2018-01-24 04:21:14 +01:00
|
|
|
import {
|
2018-08-20 23:01:25 +02:00
|
|
|
ChangeDetectorRef,
|
2018-01-24 04:21:14 +01:00
|
|
|
Component,
|
2018-07-30 17:00:06 +02:00
|
|
|
EventEmitter,
|
2018-08-20 23:01:25 +02:00
|
|
|
NgZone,
|
2018-01-24 04:21:14 +01:00
|
|
|
OnChanges,
|
2018-07-30 17:00:06 +02:00
|
|
|
Output,
|
2018-01-24 04:21:14 +01:00
|
|
|
} from '@angular/core';
|
|
|
|
|
2021-06-07 19:26:36 +02:00
|
|
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
|
|
|
import { AuditService } from 'jslib-common/abstractions/audit.service';
|
2021-12-06 12:03:02 +01:00
|
|
|
import { BroadcasterService } from 'jslib-common/abstractions/broadcaster.service';
|
2021-06-07 19:26:36 +02:00
|
|
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
|
|
|
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
|
|
|
|
import { EventService } from 'jslib-common/abstractions/event.service';
|
|
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
2021-10-21 11:10:36 +02:00
|
|
|
import { LogService } from 'jslib-common/abstractions/log.service';
|
2021-06-07 19:26:36 +02:00
|
|
|
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
|
|
|
|
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
|
|
|
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
2021-12-15 23:32:00 +01:00
|
|
|
import { StateService } from 'jslib-common/abstractions/state.service';
|
2021-06-07 19:26:36 +02:00
|
|
|
import { TokenService } from 'jslib-common/abstractions/token.service';
|
|
|
|
import { TotpService } from 'jslib-common/abstractions/totp.service';
|
2018-01-24 06:06:05 +01:00
|
|
|
|
2021-06-07 19:26:36 +02:00
|
|
|
import { ViewComponent as BaseViewComponent } from 'jslib-angular/components/view.component';
|
2018-01-24 18:20:01 +01:00
|
|
|
|
2021-06-07 19:26:36 +02:00
|
|
|
import { CipherView } from 'jslib-common/models/view/cipherView';
|
2018-07-30 17:00:06 +02:00
|
|
|
|
2020-11-04 18:09:21 +01:00
|
|
|
const BroadcasterSubscriptionId = 'ViewComponent';
|
|
|
|
|
2018-01-24 04:21:14 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'app-vault-view',
|
2018-04-06 18:25:22 +02:00
|
|
|
templateUrl: 'view.component.html',
|
2018-01-24 04:21:14 +01:00
|
|
|
})
|
2018-04-06 05:50:06 +02:00
|
|
|
export class ViewComponent extends BaseViewComponent implements OnChanges {
|
2018-07-30 17:00:06 +02:00
|
|
|
@Output() onViewCipherPasswordHistory = new EventEmitter<CipherView>();
|
|
|
|
|
2018-04-06 05:50:06 +02:00
|
|
|
constructor(cipherService: CipherService, totpService: TotpService,
|
2018-10-03 15:42:11 +02:00
|
|
|
tokenService: TokenService, i18nService: I18nService,
|
2018-04-06 05:50:06 +02:00
|
|
|
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
|
2018-08-20 23:01:25 +02:00
|
|
|
auditService: AuditService, broadcasterService: BroadcasterService,
|
2018-08-29 05:17:34 +02:00
|
|
|
ngZone: NgZone, changeDetectorRef: ChangeDetectorRef,
|
2021-12-15 23:32:00 +01:00
|
|
|
eventService: EventService, apiService: ApiService,
|
2021-10-21 11:10:36 +02:00
|
|
|
private messagingService: MessagingService, passwordRepromptService: PasswordRepromptService,
|
2021-12-15 23:32:00 +01:00
|
|
|
logService: LogService, stateService: StateService) {
|
2018-10-03 15:42:11 +02:00
|
|
|
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
|
2021-12-15 23:32:00 +01:00
|
|
|
auditService, window, broadcasterService, ngZone, changeDetectorRef, eventService,
|
|
|
|
apiService, passwordRepromptService, logService, stateService);
|
2018-01-25 17:28:52 +01:00
|
|
|
}
|
2020-11-04 18:09:21 +01:00
|
|
|
ngOnInit() {
|
|
|
|
super.ngOnInit();
|
|
|
|
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
|
|
|
this.ngZone.run(() => {
|
|
|
|
switch (message.command) {
|
|
|
|
case 'windowHidden':
|
|
|
|
this.onWindowHidden();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-01-25 17:28:52 +01:00
|
|
|
|
2020-11-04 20:00:44 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
super.ngOnDestroy();
|
|
|
|
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
|
|
|
}
|
|
|
|
|
2018-04-06 05:50:06 +02:00
|
|
|
async ngOnChanges() {
|
|
|
|
await super.load();
|
2018-01-25 05:26:40 +01:00
|
|
|
}
|
2018-07-30 17:00:06 +02:00
|
|
|
|
|
|
|
viewHistory() {
|
|
|
|
this.onViewCipherPasswordHistory.emit(this.cipher);
|
|
|
|
}
|
2020-04-14 22:11:41 +02:00
|
|
|
|
2021-05-04 21:32:03 +02:00
|
|
|
async copy(value: string, typeI18nKey: string, aType: string) {
|
2020-04-14 22:11:41 +02:00
|
|
|
super.copy(value, typeI18nKey, aType);
|
2020-04-14 22:52:03 +02:00
|
|
|
this.messagingService.send('minimizeOnCopy');
|
2020-04-14 22:11:41 +02:00
|
|
|
}
|
2020-11-04 18:09:21 +01:00
|
|
|
|
|
|
|
onWindowHidden() {
|
|
|
|
this.showPassword = false;
|
2021-05-28 20:08:44 +02:00
|
|
|
this.showCardNumber = false;
|
2020-11-04 18:09:21 +01:00
|
|
|
this.showCardCode = false;
|
|
|
|
if (this.cipher !== null && this.cipher.hasFields) {
|
|
|
|
this.cipher.fields.forEach(field => {
|
|
|
|
field.showValue = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-01-24 04:21:14 +01:00
|
|
|
}
|