mirror of
https://github.com/bitwarden/browser.git
synced 2024-08-25 23:03:07 +02:00
init view properties
This commit is contained in:
parent
62b074ae22
commit
b01709240e
|
@ -4,12 +4,12 @@ import { Attachment } from '../domain/attachment';
|
||||||
import { SymmetricCryptoKey } from '../domain/symmetricCryptoKey';
|
import { SymmetricCryptoKey } from '../domain/symmetricCryptoKey';
|
||||||
|
|
||||||
export class AttachmentView implements View {
|
export class AttachmentView implements View {
|
||||||
id: string;
|
id: string = null;
|
||||||
url: string;
|
url: string = null;
|
||||||
size: number;
|
size: number = null;
|
||||||
sizeName: string;
|
sizeName: string = null;
|
||||||
fileName: string;
|
fileName: string = null;
|
||||||
key: SymmetricCryptoKey;
|
key: SymmetricCryptoKey = null;
|
||||||
|
|
||||||
constructor(a?: Attachment) {
|
constructor(a?: Attachment) {
|
||||||
if (!a) {
|
if (!a) {
|
||||||
|
|
|
@ -3,15 +3,15 @@ import { View } from './view';
|
||||||
import { Card } from '../domain/card';
|
import { Card } from '../domain/card';
|
||||||
|
|
||||||
export class CardView implements View {
|
export class CardView implements View {
|
||||||
cardholderName: string;
|
cardholderName: string = null;
|
||||||
expMonth: string = null;
|
expMonth: string = null;
|
||||||
expYear: string;
|
expYear: string = null;
|
||||||
code: string;
|
code: string = null;
|
||||||
|
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
private _brand: string = null;
|
private _brand: string = null;
|
||||||
private _number: string;
|
private _number: string = null;
|
||||||
private _subTitle: string;
|
private _subTitle: string = null;
|
||||||
// tslint:enable
|
// tslint:enable
|
||||||
|
|
||||||
constructor(c?: Card) {
|
constructor(c?: Card) {
|
||||||
|
|
|
@ -12,25 +12,25 @@ import { SecureNoteView } from './secureNoteView';
|
||||||
import { View } from './view';
|
import { View } from './view';
|
||||||
|
|
||||||
export class CipherView implements View {
|
export class CipherView implements View {
|
||||||
id: string;
|
id: string = null;
|
||||||
organizationId: string;
|
organizationId: string = null;
|
||||||
folderId: string;
|
folderId: string = null;
|
||||||
name: string;
|
name: string = null;
|
||||||
notes: string;
|
notes: string = null;
|
||||||
type: CipherType;
|
type: CipherType = null;
|
||||||
favorite = false;
|
favorite = false;
|
||||||
organizationUseTotp = false;
|
organizationUseTotp = false;
|
||||||
edit = false;
|
edit = false;
|
||||||
localData: any;
|
localData: any;
|
||||||
login: LoginView;
|
login = new LoginView();
|
||||||
identity: IdentityView;
|
identity = new IdentityView();
|
||||||
card: CardView;
|
card = new CardView();
|
||||||
secureNote: SecureNoteView;
|
secureNote = new SecureNoteView();
|
||||||
attachments: AttachmentView[];
|
attachments: AttachmentView[] = null;
|
||||||
fields: FieldView[];
|
fields: FieldView[] = null;
|
||||||
passwordHistory: PasswordHistoryView[];
|
passwordHistory: PasswordHistoryView[] = null;
|
||||||
collectionIds: string[];
|
collectionIds: string[] = null;
|
||||||
revisionDate: Date;
|
revisionDate: Date = null;
|
||||||
|
|
||||||
constructor(c?: Cipher) {
|
constructor(c?: Cipher) {
|
||||||
if (!c) {
|
if (!c) {
|
||||||
|
@ -90,7 +90,7 @@ export class CipherView implements View {
|
||||||
}
|
}
|
||||||
|
|
||||||
get passwordRevisionDisplayDate(): Date {
|
get passwordRevisionDisplayDate(): Date {
|
||||||
if (this.login == null) {
|
if (this.type !== CipherType.Login || this.login == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (this.login.password == null || this.login.password === '') {
|
} else if (this.login.password == null || this.login.password === '') {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -4,10 +4,10 @@ import { Collection } from '../domain/collection';
|
||||||
import { ITreeNodeObject } from '../domain/treeNode';
|
import { ITreeNodeObject } from '../domain/treeNode';
|
||||||
|
|
||||||
export class CollectionView implements View, ITreeNodeObject {
|
export class CollectionView implements View, ITreeNodeObject {
|
||||||
id: string;
|
id: string = null;
|
||||||
organizationId: string;
|
organizationId: string = null;
|
||||||
name: string;
|
name: string = null;
|
||||||
readOnly: boolean;
|
readOnly: boolean = null;
|
||||||
|
|
||||||
constructor(c?: Collection) {
|
constructor(c?: Collection) {
|
||||||
if (!c) {
|
if (!c) {
|
||||||
|
|
|
@ -5,9 +5,9 @@ import { View } from './view';
|
||||||
import { Field } from '../domain/field';
|
import { Field } from '../domain/field';
|
||||||
|
|
||||||
export class FieldView implements View {
|
export class FieldView implements View {
|
||||||
name: string;
|
name: string = null;
|
||||||
value: string;
|
value: string = null;
|
||||||
type: FieldType;
|
type: FieldType = null;
|
||||||
|
|
||||||
constructor(f?: Field) {
|
constructor(f?: Field) {
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import { ITreeNodeObject } from '../domain/treeNode';
|
||||||
|
|
||||||
export class FolderView implements View, ITreeNodeObject {
|
export class FolderView implements View, ITreeNodeObject {
|
||||||
id: string = null;
|
id: string = null;
|
||||||
name: string;
|
name: string = null;
|
||||||
revisionDate: Date;
|
revisionDate: Date = null;
|
||||||
|
|
||||||
constructor(f?: Folder) {
|
constructor(f?: Folder) {
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
|
|
@ -6,26 +6,26 @@ import { Utils } from '../../misc/utils';
|
||||||
|
|
||||||
export class IdentityView implements View {
|
export class IdentityView implements View {
|
||||||
title: string = null;
|
title: string = null;
|
||||||
middleName: string;
|
middleName: string = null;
|
||||||
address1: string;
|
address1: string = null;
|
||||||
address2: string;
|
address2: string = null;
|
||||||
address3: string;
|
address3: string = null;
|
||||||
city: string;
|
city: string = null;
|
||||||
state: string;
|
state: string = null;
|
||||||
postalCode: string;
|
postalCode: string = null;
|
||||||
country: string;
|
country: string = null;
|
||||||
company: string;
|
company: string = null;
|
||||||
email: string;
|
email: string = null;
|
||||||
phone: string;
|
phone: string = null;
|
||||||
ssn: string;
|
ssn: string = null;
|
||||||
username: string;
|
username: string = null;
|
||||||
passportNumber: string;
|
passportNumber: string = null;
|
||||||
licenseNumber: string;
|
licenseNumber: string = null;
|
||||||
|
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
private _firstName: string;
|
private _firstName: string = null;
|
||||||
private _lastName: string;
|
private _lastName: string = null;
|
||||||
private _subTitle: string;
|
private _subTitle: string = null;
|
||||||
// tslint:enable
|
// tslint:enable
|
||||||
|
|
||||||
constructor(i?: Identity) {
|
constructor(i?: Identity) {
|
||||||
|
|
|
@ -20,10 +20,10 @@ export class LoginUriView implements View {
|
||||||
match: UriMatchType = null;
|
match: UriMatchType = null;
|
||||||
|
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
private _uri: string;
|
private _uri: string = null;
|
||||||
private _domain: string;
|
private _domain: string = null;
|
||||||
private _hostname: string;
|
private _hostname: string = null;
|
||||||
private _canLaunch: boolean;
|
private _canLaunch: boolean = null;
|
||||||
// tslint:enable
|
// tslint:enable
|
||||||
|
|
||||||
constructor(u?: LoginUri) {
|
constructor(u?: LoginUri) {
|
||||||
|
|
|
@ -4,11 +4,11 @@ import { View } from './view';
|
||||||
import { Login } from '../domain/login';
|
import { Login } from '../domain/login';
|
||||||
|
|
||||||
export class LoginView implements View {
|
export class LoginView implements View {
|
||||||
username: string;
|
username: string = null;
|
||||||
password: string;
|
password: string = null;
|
||||||
passwordRevisionDate?: Date;
|
passwordRevisionDate?: Date = null;
|
||||||
totp: string;
|
totp: string = null;
|
||||||
uris: LoginUriView[];
|
uris: LoginUriView[] = null;
|
||||||
|
|
||||||
constructor(l?: Login) {
|
constructor(l?: Login) {
|
||||||
if (!l) {
|
if (!l) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { View } from './view';
|
||||||
import { Password } from '../domain/password';
|
import { Password } from '../domain/password';
|
||||||
|
|
||||||
export class PasswordHistoryView implements View {
|
export class PasswordHistoryView implements View {
|
||||||
password: string;
|
password: string = null;
|
||||||
lastUsedDate: Date;
|
lastUsedDate: Date = null;
|
||||||
|
|
||||||
constructor(ph?: Password) {
|
constructor(ph?: Password) {
|
||||||
if (!ph) {
|
if (!ph) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { View } from './view';
|
||||||
import { SecureNote } from '../domain/secureNote';
|
import { SecureNote } from '../domain/secureNote';
|
||||||
|
|
||||||
export class SecureNoteView implements View {
|
export class SecureNoteView implements View {
|
||||||
type: SecureNoteType;
|
type: SecureNoteType = null;
|
||||||
|
|
||||||
constructor(n?: SecureNote) {
|
constructor(n?: SecureNote) {
|
||||||
if (!n) {
|
if (!n) {
|
||||||
|
|
|
@ -10,6 +10,10 @@ import {
|
||||||
|
|
||||||
import { ImportResult } from '../models/domain/importResult';
|
import { ImportResult } from '../models/domain/importResult';
|
||||||
|
|
||||||
|
import { CipherType } from '../enums/cipherType';
|
||||||
|
|
||||||
|
import { Utils } from '../misc/utils';
|
||||||
|
|
||||||
import { CipherRequest } from '../models/request/cipherRequest';
|
import { CipherRequest } from '../models/request/cipherRequest';
|
||||||
import { CollectionRequest } from '../models/request/collectionRequest';
|
import { CollectionRequest } from '../models/request/collectionRequest';
|
||||||
import { FolderRequest } from '../models/request/folderRequest';
|
import { FolderRequest } from '../models/request/folderRequest';
|
||||||
|
@ -278,6 +282,6 @@ export class ImportService implements ImportServiceAbstraction {
|
||||||
|
|
||||||
private badData(c: CipherView) {
|
private badData(c: CipherView) {
|
||||||
return (c.name == null || c.name === '--') &&
|
return (c.name == null || c.name === '--') &&
|
||||||
(c.login != null && (c.login.password == null || c.login.password === ''));
|
(c.type === CipherType.Login && c.login != null && Utils.isNullOrWhitespace(c.login.password));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||||
});
|
});
|
||||||
builder.field('notes');
|
builder.field('notes');
|
||||||
(builder as any).field('login.username', {
|
(builder as any).field('login.username', {
|
||||||
extractor: (c: CipherView) => c.login != null ? c.login.username : null,
|
extractor: (c: CipherView) => c.type === CipherType.Login && c.login != null ? c.login.username : null,
|
||||||
});
|
});
|
||||||
(builder as any).field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
|
(builder as any).field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
|
||||||
(builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
|
(builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
|
||||||
|
@ -198,7 +198,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||||
}
|
}
|
||||||
|
|
||||||
private uriExtractor(c: CipherView) {
|
private uriExtractor(c: CipherView) {
|
||||||
if (c.login == null || !c.login.hasUris) {
|
if (c.type !== CipherType.Login || c.login == null || !c.login.hasUris) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const uris: string[] = [];
|
const uris: string[] = [];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user