Add offline cachine for file group elements and contents (not files, though)
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
02d8505b05
commit
294b312641
@ -1,4 +1,11 @@
|
|||||||
div.database-wrapper {
|
div.database-wrapper {
|
||||||
border: 2px solid #8c8c8c;
|
border: 2px solid #8c8c8c;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&.not-available {
|
||||||
|
height: 600px;
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 100px;
|
||||||
|
color: #494949;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
import {Model} from './Model';
|
||||||
|
|
||||||
|
export interface IFileGroup {
|
||||||
|
id?: number;
|
||||||
|
NodeId: string;
|
||||||
|
PageId: string;
|
||||||
|
FileIds: string[];
|
||||||
|
filesJSON: string;
|
||||||
|
UUID: string;
|
||||||
|
needsServerUpdate?: boolean;
|
||||||
|
deleted?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FileGroup extends Model<IFileGroup> implements IFileGroup {
|
||||||
|
id?: number;
|
||||||
|
NodeId: string;
|
||||||
|
PageId: string;
|
||||||
|
FileIds: string[];
|
||||||
|
filesJSON: string;
|
||||||
|
UUID: string;
|
||||||
|
needsServerUpdate?: boolean;
|
||||||
|
deleted?: boolean;
|
||||||
|
|
||||||
|
public static getTableName() {
|
||||||
|
return 'fileGroups';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getSchema() {
|
||||||
|
return '++id, NodeId, PageId, FileIds, filesJSON, UUID, needsServerUpdate, deleted';
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
NodeId: string,
|
||||||
|
PageId: string,
|
||||||
|
FileIds: string[],
|
||||||
|
filesJSON: string,
|
||||||
|
UUID: string,
|
||||||
|
needsServerUpdate?: boolean,
|
||||||
|
deleted?: boolean,
|
||||||
|
id?: number
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.NodeId = NodeId;
|
||||||
|
this.PageId = PageId;
|
||||||
|
this.FileIds = FileIds;
|
||||||
|
this.filesJSON = filesJSON;
|
||||||
|
this.UUID = UUID;
|
||||||
|
|
||||||
|
if ( typeof needsServerUpdate !== 'undefined' ) {
|
||||||
|
this.needsServerUpdate = needsServerUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof deleted !== 'undefined' ) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( id ) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public fillFromRecord(record: any) {
|
||||||
|
this.NodeId = record.NodeId;
|
||||||
|
this.PageId = record.PageId;
|
||||||
|
this.FileIds = record.FileIds;
|
||||||
|
this.filesJSON = JSON.stringify(record.files);
|
||||||
|
this.UUID = record.UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public inflateToRecord() {
|
||||||
|
return {
|
||||||
|
NodeId: this.NodeId,
|
||||||
|
PageId: this.PageId,
|
||||||
|
FileIds: this.FileIds,
|
||||||
|
files: JSON.parse(this.filesJSON),
|
||||||
|
UUID: this.UUID,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSaveRecord(): any {
|
||||||
|
return {
|
||||||
|
...(this.id ? { id: this.id } : {}),
|
||||||
|
NodeId: this.NodeId,
|
||||||
|
PageId: this.PageId,
|
||||||
|
FileIds: this.FileIds,
|
||||||
|
filesJSON: this.filesJSON,
|
||||||
|
UUID: this.UUID,
|
||||||
|
...(typeof this.needsServerUpdate === 'undefined' ? {} : { needsServerUpdate: this.needsServerUpdate }),
|
||||||
|
...(typeof this.deleted === 'undefined' ? {} : { deleted: this.deleted }),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDatabase(): Dexie.Table<IFileGroup, number> {
|
||||||
|
return this.staticClass().dbService.table('fileGroups') as Dexie.Table<IFileGroup, number>;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue