2018-10-23 15:25:44 +02:00
|
|
|
import { Location } from '@angular/common';
|
2018-10-23 16:29:05 +02:00
|
|
|
import { Component } from '@angular/core';
|
2018-10-23 22:17:30 +02:00
|
|
|
import {
|
|
|
|
ActivatedRoute,
|
|
|
|
Router,
|
|
|
|
} from '@angular/router';
|
2018-10-23 15:25:44 +02:00
|
|
|
|
|
|
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
|
|
|
import { CollectionService } from 'jslib/abstractions/collection.service';
|
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
|
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
2018-10-23 16:29:05 +02:00
|
|
|
import { UserService } from 'jslib/abstractions/user.service';
|
2018-10-23 15:25:44 +02:00
|
|
|
|
2018-10-23 16:29:05 +02:00
|
|
|
import { ShareComponent as BaseShareComponent } from 'jslib/angular/components/share.component';
|
2018-10-23 15:25:44 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-vault-share',
|
|
|
|
templateUrl: 'share.component.html',
|
|
|
|
})
|
2018-10-23 16:29:05 +02:00
|
|
|
export class ShareComponent extends BaseShareComponent {
|
|
|
|
constructor(collectionService: CollectionService, platformUtilsService: PlatformUtilsService,
|
|
|
|
i18nService: I18nService, userService: UserService,
|
|
|
|
cipherService: CipherService, private route: ActivatedRoute,
|
2018-10-23 22:17:30 +02:00
|
|
|
private location: Location, private router: Router) {
|
2018-10-23 16:29:05 +02:00
|
|
|
super(collectionService, platformUtilsService, i18nService, userService, cipherService);
|
2018-10-23 15:25:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
2018-10-23 22:17:30 +02:00
|
|
|
this.onSharedCipher.subscribe(() => {
|
|
|
|
this.router.navigate(['view-cipher', { cipherId: this.cipherId }]);
|
|
|
|
});
|
2021-03-02 19:31:52 +01:00
|
|
|
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
2018-10-23 16:29:05 +02:00
|
|
|
this.cipherId = params.cipherId;
|
2019-03-06 20:31:50 +01:00
|
|
|
await this.load();
|
2019-01-17 05:30:39 +01:00
|
|
|
if (queryParamsSub != null) {
|
|
|
|
queryParamsSub.unsubscribe();
|
|
|
|
}
|
2018-10-23 15:25:44 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-10 20:10:40 +02:00
|
|
|
async submit(): Promise<boolean> {
|
|
|
|
const success = await super.submit();
|
|
|
|
if (success) {
|
2020-12-17 18:06:31 +01:00
|
|
|
this.cancel();
|
2019-05-10 20:10:40 +02:00
|
|
|
}
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2018-10-23 15:25:44 +02:00
|
|
|
cancel() {
|
2020-12-17 18:06:31 +01:00
|
|
|
this.router.navigate(['/view-cipher'], { replaceUrl: true, queryParams: { cipherId: this.cipher.id } });
|
2018-10-23 15:25:44 +02:00
|
|
|
}
|
|
|
|
}
|