mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
save cipher
This commit is contained in:
parent
b083b03050
commit
5b92d9d31f
@ -13,6 +13,7 @@ import { SecureNoteType } from 'jslib/enums/secureNoteType';
|
|||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
|
||||||
import { CardView } from 'jslib/models/view/cardView';
|
import { CardView } from 'jslib/models/view/cardView';
|
||||||
import { CipherView } from 'jslib/models/view/cipherView';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
@ -40,7 +41,7 @@ export class AddComponent implements OnChanges {
|
|||||||
addFieldTypeOptions: any[];
|
addFieldTypeOptions: any[];
|
||||||
|
|
||||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||||
private i18nService: I18nService) {
|
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService) {
|
||||||
this.typeOptions = [
|
this.typeOptions = [
|
||||||
{ name: i18nService.t('typeLogin'), value: CipherType.Login },
|
{ name: i18nService.t('typeLogin'), value: CipherType.Login },
|
||||||
{ name: i18nService.t('typeCard'), value: CipherType.Card },
|
{ name: i18nService.t('typeCard'), value: CipherType.Card },
|
||||||
@ -101,6 +102,19 @@ export class AddComponent implements OnChanges {
|
|||||||
this.folders = await this.folderService.getAllDecrypted();
|
this.folders = await this.folderService.getAllDecrypted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async save() {
|
||||||
|
if (this.cipher.name == null || this.cipher.name === '') {
|
||||||
|
this.platformUtilsService.alertError(this.i18nService.t('errorOccurred'),
|
||||||
|
this.i18nService.t('nameRequired'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cipher = await this.cipherService.encrypt(this.cipher);
|
||||||
|
await this.cipherService.saveWithServer(cipher);
|
||||||
|
//$analytics.eventTrack('Added Cipher');
|
||||||
|
// TODO: success message
|
||||||
|
};
|
||||||
|
|
||||||
addField() {
|
addField() {
|
||||||
if (this.cipher.fields == null) {
|
if (this.cipher.fields == null) {
|
||||||
this.cipher.fields = [];
|
this.cipher.fields = [];
|
||||||
|
@ -283,5 +283,8 @@
|
|||||||
},
|
},
|
||||||
"remove": {
|
"remove": {
|
||||||
"message": "Remove"
|
"message": "Remove"
|
||||||
|
},
|
||||||
|
"nameRequired": {
|
||||||
|
"message": "Name is required."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user