2018-04-05 21:35:56 +02:00
|
|
|
import * as template from './ciphers.component.html';
|
|
|
|
|
2018-04-06 05:49:04 +02:00
|
|
|
import { Location } from '@angular/common';
|
2018-04-05 21:35:56 +02:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
} from '@angular/core';
|
|
|
|
import {
|
|
|
|
ActivatedRoute,
|
|
|
|
Router,
|
|
|
|
} from '@angular/router';
|
|
|
|
|
|
|
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
|
|
|
|
|
|
|
import { CipherView } from 'jslib/models/view/cipherView';
|
|
|
|
|
|
|
|
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-vault-ciphers',
|
|
|
|
template: template,
|
|
|
|
})
|
|
|
|
export class CiphersComponent extends BaseCiphersComponent implements OnInit {
|
2018-04-06 05:09:49 +02:00
|
|
|
constructor(cipherService: CipherService, private route: ActivatedRoute,
|
2018-04-06 05:49:04 +02:00
|
|
|
private router: Router, private location: Location) {
|
2018-04-05 21:35:56 +02:00
|
|
|
super(cipherService);
|
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
this.route.queryParams.subscribe(async (params) => {
|
|
|
|
if (params.type) {
|
|
|
|
const t = parseInt(params.type, null);
|
|
|
|
await super.load((c) => c.type === t);
|
|
|
|
} else if (params.folderId) {
|
|
|
|
await super.load((c) => c.folderId === params.folderId);
|
|
|
|
} else if (params.collectionId) {
|
|
|
|
await super.load((c) => c.collectionIds.indexOf(params.collectionId) > -1);
|
|
|
|
} else {
|
|
|
|
await super.load();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
selectCipher(cipher: CipherView) {
|
|
|
|
super.selectCipher(cipher);
|
2018-04-06 05:09:49 +02:00
|
|
|
this.router.navigate(['/view-cipher'], { queryParams: { cipherId: cipher.id } });
|
2018-04-05 21:35:56 +02:00
|
|
|
}
|
2018-04-06 05:49:04 +02:00
|
|
|
|
|
|
|
addCipher() {
|
|
|
|
super.addCipher();
|
|
|
|
this.router.navigate(['/add-cipher']);
|
|
|
|
}
|
|
|
|
|
|
|
|
back() {
|
|
|
|
this.location.back();
|
|
|
|
}
|
2018-04-05 21:35:56 +02:00
|
|
|
}
|