bitwarden-estensione-browser/src/popup/vault/view.component.ts

69 lines
2.4 KiB
TypeScript
Raw Normal View History

2018-04-06 05:09:49 +02:00
import { Location } from '@angular/common';
import {
2018-08-20 23:40:39 +02:00
ChangeDetectorRef,
2018-04-06 05:09:49 +02:00
Component,
2018-08-20 23:40:39 +02:00
NgZone,
2018-04-06 05:09:49 +02:00
} from '@angular/core';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { TokenService } from 'jslib/abstractions/token.service';
import { TotpService } from 'jslib/abstractions/totp.service';
2018-08-29 05:17:39 +02:00
import { UserService } from 'jslib/abstractions/user.service';
2018-04-06 05:09:49 +02:00
2018-08-20 23:40:39 +02:00
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
2018-04-06 05:09:49 +02:00
import { ViewComponent as BaseViewComponent } from 'jslib/angular/components/view.component';
@Component({
selector: 'app-vault-view',
2018-04-06 17:48:45 +02:00
templateUrl: 'view.component.html',
2018-04-06 05:09:49 +02:00
})
2018-08-20 23:40:39 +02:00
export class ViewComponent extends BaseViewComponent {
2018-07-25 05:23:44 +02:00
showAttachments = true;
2018-04-14 20:56:30 +02:00
2018-04-06 05:09:49 +02:00
constructor(cipherService: CipherService, totpService: TotpService,
tokenService: TokenService, i18nService: I18nService,
2018-04-06 05:09:49 +02:00
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, private route: ActivatedRoute,
2018-08-20 23:40:39 +02:00
private router: Router, private location: Location,
broadcasterService: BroadcasterService, ngZone: NgZone,
2018-08-29 05:17:39 +02:00
changeDetectorRef: ChangeDetectorRef, userService: UserService) {
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService);
2018-04-06 05:09:49 +02:00
}
ngOnInit() {
2018-07-25 05:23:44 +02:00
this.showAttachments = !this.platformUtilsService.isEdge();
2018-12-20 16:20:57 +01:00
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
2018-04-06 05:09:49 +02:00
if (params.cipherId) {
this.cipherId = params.cipherId;
} else {
this.close();
}
await this.load();
2019-01-17 05:30:39 +01:00
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
2018-04-06 05:09:49 +02:00
});
2018-08-20 23:40:39 +02:00
super.ngOnInit();
2018-04-06 05:09:49 +02:00
}
edit() {
super.edit();
this.router.navigate(['/edit-cipher'], { queryParams: { cipherId: this.cipher.id } });
}
close() {
this.location.back();
}
}