Improve version modal previews and remove debugging logging
This commit is contained in:
parent
aa27fefef4
commit
94c6a66dff
@ -57,7 +57,6 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
|
|||||||
useValue: {
|
useValue: {
|
||||||
highlight(code: string, lang: string, callback?: (error: any, code: string) => void): string {
|
highlight(code: string, lang: string, callback?: (error: any, code: string) => void): string {
|
||||||
const highlighted = hljs.highlight(lang, code, true);
|
const highlighted = hljs.highlight(lang, code, true);
|
||||||
console.log('highlighed', highlighted);
|
|
||||||
|
|
||||||
if ( callback ) {
|
if ( callback ) {
|
||||||
callback(null, highlighted.value);
|
callback(null, highlighted.value);
|
||||||
|
@ -152,7 +152,7 @@ export class CodeComponent extends EditorNodeContract implements OnInit {
|
|||||||
res();
|
res();
|
||||||
}).catch(rej);
|
}).catch(rej);
|
||||||
} else {
|
} else {
|
||||||
this.api.getCodium(this.page.UUID, this.node.UUID, this.node.Value.Value).then(data => {
|
this.api.getCodium(this.page.UUID, this.node.UUID, this.node.Value.Value, this.node.associatedTypeVersionNum).then(data => {
|
||||||
this.dbRecord = data;
|
this.dbRecord = data;
|
||||||
this.initialValue = this.dbRecord.code;
|
this.initialValue = this.dbRecord.code;
|
||||||
this.editorValue = this.dbRecord.code;
|
this.editorValue = this.dbRecord.code;
|
||||||
|
@ -139,7 +139,6 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onRowDragEnd($event) {
|
onRowDragEnd($event) {
|
||||||
console.log($event, this);
|
|
||||||
if ( !this.isInitialLoad && this.editorService.canEdit() ) {
|
if ( !this.isInitialLoad && this.editorService.canEdit() ) {
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.triggerSaveDebounce();
|
this.triggerSaveDebounce();
|
||||||
@ -369,7 +368,8 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
|
|||||||
this.node.value = this.dbRecord.UUID;
|
this.node.value = this.dbRecord.UUID;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.dbRecord = await this.api.getDatabase(this.page.UUID, this.node.UUID, this.node.Value.Value);
|
this.dbRecord = await this.api.getDatabase(
|
||||||
|
this.page.UUID, this.node.UUID, this.node.Value.Value, this.node.associatedTypeVersionNum);
|
||||||
this.dbName = this.dbRecord.Name;
|
this.dbName = this.dbRecord.Name;
|
||||||
this.notAvailableOffline = false;
|
this.notAvailableOffline = false;
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
@ -382,7 +382,8 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the columns
|
// Load the columns
|
||||||
const columns = await this.api.getDatabaseColumns(this.page.UUID, this.node.UUID, this.node.Value.Value);
|
const columns = await this.api.getDatabaseColumns(
|
||||||
|
this.page.UUID, this.node.UUID, this.node.Value.Value, this.node.associatedTypeVersionNum);
|
||||||
this.setColumns(columns, false);
|
this.setColumns(columns, false);
|
||||||
|
|
||||||
const rows = await this.api.getDatabaseEntries(this.page.UUID, this.node.UUID, this.node.Value.Value);
|
const rows = await this.api.getDatabaseEntries(this.page.UUID, this.node.UUID, this.node.Value.Value);
|
||||||
|
@ -39,7 +39,6 @@ export class BooleanEditorComponent implements ICellEditorAngularComp, AfterView
|
|||||||
agInit(params: ICellEditorParams): void {
|
agInit(params: ICellEditorParams): void {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.value = this.params.value;
|
this.value = this.params.value;
|
||||||
console.log('bool params', {params});
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const values = params.colDef.additionalData.labelType.split('_');
|
const values = params.colDef.additionalData.labelType.split('_');
|
||||||
|
@ -25,8 +25,6 @@ export class PageLinkEditorComponent implements OnInit {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.pages = params._pagesData || [];
|
this.pages = params._pagesData || [];
|
||||||
|
|
||||||
console.log('page link editor comp', this);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.selectable.open();
|
this.selectable.open();
|
||||||
});
|
});
|
||||||
|
@ -50,8 +50,6 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
|
|||||||
this.node.Value = {};
|
this.node.Value = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('files load', this)
|
|
||||||
|
|
||||||
if ( !this.node.Value.Value && !this.readonly ) {
|
if ( !this.node.Value.Value && !this.readonly ) {
|
||||||
this.dbRecord = await this.api.createFileGroup(this.page.UUID, this.node.UUID);
|
this.dbRecord = await this.api.createFileGroup(this.page.UUID, this.node.UUID);
|
||||||
this.fileRecords = this.dbRecord.files;
|
this.fileRecords = this.dbRecord.files;
|
||||||
|
@ -46,7 +46,6 @@ export class FormInputComponent extends EditorNodeContract implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.editorService = this.editorService.getEditor(this.editorUUID);
|
this.editorService = this.editorService.getEditor(this.editorUUID);
|
||||||
this.editorService.registerNodeEditor(this.nodeId, this).then(() => {
|
this.editorService.registerNodeEditor(this.nodeId, this).then(() => {
|
||||||
console.log('form input node', this.node);
|
|
||||||
if ( !this.node.AdditionalData ) {
|
if ( !this.node.AdditionalData ) {
|
||||||
this.node.AdditionalData = {};
|
this.node.AdditionalData = {};
|
||||||
}
|
}
|
||||||
@ -68,7 +67,6 @@ export class FormInputComponent extends EditorNodeContract implements OnInit {
|
|||||||
const db = await this.dbApi.getDatabase(this.node.AdditionalData.selectSourceDatabaseId);
|
const db = await this.dbApi.getDatabase(this.node.AdditionalData.selectSourceDatabaseId);
|
||||||
if ( db ) {
|
if ( db ) {
|
||||||
const data = await db.data();
|
const data = await db.data();
|
||||||
console.log('loaded db data', data, this.node.AdditionalData);
|
|
||||||
this.selectChoices = data.map(x => {
|
this.selectChoices = data.map(x => {
|
||||||
return {
|
return {
|
||||||
display: x.data[this.node.AdditionalData.selectDatabaseDisplayColumnId],
|
display: x.data[this.node.AdditionalData.selectDatabaseDisplayColumnId],
|
||||||
|
@ -36,8 +36,6 @@ export class NormComponent extends EditorNodeContract implements OnInit, OnDestr
|
|||||||
super();
|
super();
|
||||||
this.contents = this.initialValue;
|
this.contents = this.initialValue;
|
||||||
this.savedValue = this.initialValue;
|
this.savedValue = this.initialValue;
|
||||||
|
|
||||||
console.log('Norm editor component', this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isDark() {
|
public isDark() {
|
||||||
|
@ -20,13 +20,11 @@ export class VersionModalComponent implements OnInit {
|
|||||||
protected alerts: AlertController,
|
protected alerts: AlertController,
|
||||||
protected modals: ModalController,
|
protected modals: ModalController,
|
||||||
protected editorService: EditorService,
|
protected editorService: EditorService,
|
||||||
) {
|
) { }
|
||||||
console.log('version modal', this);
|
|
||||||
}
|
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.pageVersions = await this.editorService.loadPageVersions(this.pageId);
|
this.pageVersions = await this.editorService.loadPageVersions(this.pageId);
|
||||||
this.onVersionClick(this.pageVersions[0]);
|
await this.onVersionClick(this.pageVersions[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss(reload = false) {
|
dismiss(reload = false) {
|
||||||
|
@ -262,7 +262,6 @@ export class WysiwygComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const target = this.getPathToElement(mutation.target);
|
const target = this.getPathToElement(mutation.target);
|
||||||
console.log({mutation, target, type: mutation.type, data: mutation.target.textContent});
|
|
||||||
|
|
||||||
const innerHTML = this.editable.nativeElement.innerHTML;
|
const innerHTML = this.editable.nativeElement.innerHTML;
|
||||||
|
|
||||||
@ -304,11 +303,9 @@ export class WysiwygComponent implements OnInit {
|
|||||||
|
|
||||||
applyRemoteContentMutation(mutation: MutationBroadcast) {
|
applyRemoteContentMutation(mutation: MutationBroadcast) {
|
||||||
this.applyingRemoteMutation = true;
|
this.applyingRemoteMutation = true;
|
||||||
console.log('got remote content mutation', mutation);
|
|
||||||
|
|
||||||
if ( this.editable ) {
|
if ( this.editable ) {
|
||||||
const target = this.getElementFromPath(mutation.path);
|
const target = this.getElementFromPath(mutation.path);
|
||||||
console.log(target);
|
|
||||||
if ( target ) {
|
if ( target ) {
|
||||||
if ( mutation.type === 'characterData' ) {
|
if ( mutation.type === 'characterData' ) {
|
||||||
this.ignoreNextMutation = true;
|
this.ignoreNextMutation = true;
|
||||||
|
@ -318,7 +318,6 @@ export class ApiService {
|
|||||||
const uuidMap = await new Promise(async (res, rej) => {
|
const uuidMap = await new Promise(async (res, rej) => {
|
||||||
this.post('/offline/sync', { dirtyRecords }).subscribe({
|
this.post('/offline/sync', { dirtyRecords }).subscribe({
|
||||||
next: async result => {
|
next: async result => {
|
||||||
console.log('sync result', result);
|
|
||||||
res(result.data);
|
res(result.data);
|
||||||
},
|
},
|
||||||
error: rej,
|
error: rej,
|
||||||
@ -812,14 +811,14 @@ export class ApiService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCodium(PageId: string, NodeId: string, CodiumId: string): Promise<any> {
|
public getCodium(PageId: string, NodeId: string, CodiumId: string, version?: number): Promise<any> {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
const existingLocalCodiums = await this.db.codiums.where({ UUID: CodiumId }).toArray();
|
const existingLocalCodiums = await this.db.codiums.where({ UUID: CodiumId }).toArray();
|
||||||
const existingLocalCodium = existingLocalCodiums.length > 0 ? existingLocalCodiums[0] as Codium : undefined;
|
const existingLocalCodium = existingLocalCodiums.length > 0 ? existingLocalCodiums[0] as Codium : undefined;
|
||||||
|
|
||||||
// If offline, try to load it from the local DB
|
// If offline, try to load it from the local DB
|
||||||
if ( this.isOffline ) {
|
if ( this.isOffline ) {
|
||||||
if ( existingLocalCodium ) {
|
if ( existingLocalCodium && !version ) {
|
||||||
return res(existingLocalCodium.getSaveRecord());
|
return res(existingLocalCodium.getSaveRecord());
|
||||||
} else {
|
} else {
|
||||||
return rej(new ResourceNotAvailableOfflineError());
|
return rej(new ResourceNotAvailableOfflineError());
|
||||||
@ -827,8 +826,12 @@ export class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If online, fetch the codium and store/update it locally
|
// If online, fetch the codium and store/update it locally
|
||||||
this.get(`/code/${PageId}/${NodeId}/get/${CodiumId}`).subscribe({
|
this.get(`/code/${PageId}/${NodeId}/get/${CodiumId}?version=${version}`).subscribe({
|
||||||
next: async result => {
|
next: async result => {
|
||||||
|
if ( version ) {
|
||||||
|
return res(result.data);
|
||||||
|
}
|
||||||
|
|
||||||
if ( existingLocalCodium ) {
|
if ( existingLocalCodium ) {
|
||||||
existingLocalCodium.fillFromRecord(result.data);
|
existingLocalCodium.fillFromRecord(result.data);
|
||||||
|
|
||||||
@ -915,20 +918,28 @@ export class ApiService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDatabaseColumns(PageId: string, NodeId: string, DatabaseId: string): Promise<any[]> {
|
public getDatabaseColumns(PageId: string, NodeId: string, DatabaseId: string, databaseVersion?: number): Promise<any[]> {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
// If offline, fetch the columns from the local database
|
// If offline, fetch the columns from the local database
|
||||||
if ( this.isOffline ) {
|
if ( this.isOffline ) {
|
||||||
|
if ( databaseVersion ) {
|
||||||
|
return rej(new ResourceNotAvailableOfflineError());
|
||||||
|
}
|
||||||
|
|
||||||
const columns = (await this.db.databaseColumns.where({ DatabaseId }).toArray()) as DatabaseColumn[];
|
const columns = (await this.db.databaseColumns.where({ DatabaseId }).toArray()) as DatabaseColumn[];
|
||||||
return res(columns.filter(x => !x.deleted).map(x => x.getSaveRecord()));
|
return res(columns.filter(x => !x.deleted).map(x => x.getSaveRecord()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If online, fetch the columns and sync the local database
|
// If online, fetch the columns and sync the local database
|
||||||
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/columns`).subscribe({
|
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/columns?database_version=${databaseVersion}`).subscribe({
|
||||||
next: async results => {
|
next: async results => {
|
||||||
// Resolve this first, so the UI doesn't need to wait for the db sync to render
|
// Resolve this first, so the UI doesn't need to wait for the db sync to render
|
||||||
res(results.data);
|
res(results.data);
|
||||||
|
|
||||||
|
if ( databaseVersion ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for ( const def of results.data ) {
|
for ( const def of results.data ) {
|
||||||
const existingColumnDef = await this.db.databaseColumns.where({
|
const existingColumnDef = await this.db.databaseColumns.where({
|
||||||
DatabaseId, UUID: def.UUID,
|
DatabaseId, UUID: def.UUID,
|
||||||
@ -992,21 +1003,25 @@ export class ApiService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDatabase(PageId: string, NodeId: string, DatabaseId: string): Promise<any> {
|
public getDatabase(PageId: string, NodeId: string, DatabaseId: string, version?: number): Promise<any> {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
const existingLocalDatabases = await this.db.databases.where({ UUID: DatabaseId }).toArray();
|
const existingLocalDatabases = await this.db.databases.where({ UUID: DatabaseId }).toArray();
|
||||||
const existingLocalDatabase = existingLocalDatabases.length > 0 ? existingLocalDatabases[0] as Database : undefined;
|
const existingLocalDatabase = existingLocalDatabases.length > 0 ? existingLocalDatabases[0] as Database : undefined;
|
||||||
|
|
||||||
if ( this.isOffline ) {
|
if ( this.isOffline ) {
|
||||||
if ( existingLocalDatabase ) {
|
if ( existingLocalDatabase && !version ) {
|
||||||
return res(existingLocalDatabase.getSaveRecord());
|
return res(existingLocalDatabase.getSaveRecord());
|
||||||
} else {
|
} else {
|
||||||
return rej(new ResourceNotAvailableOfflineError());
|
return rej(new ResourceNotAvailableOfflineError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}`).subscribe({
|
this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}?version=${version}`).subscribe({
|
||||||
next: async result => {
|
next: async result => {
|
||||||
|
if ( version ) {
|
||||||
|
return res(result.data);
|
||||||
|
}
|
||||||
|
|
||||||
if ( existingLocalDatabase ) {
|
if ( existingLocalDatabase ) {
|
||||||
existingLocalDatabase.fillFromRecord(result.data);
|
existingLocalDatabase.fillFromRecord(result.data);
|
||||||
|
|
||||||
|
@ -54,8 +54,6 @@ export class DatabaseService extends Dexie {
|
|||||||
}
|
}
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
console.log('db', this);
|
|
||||||
|
|
||||||
const staticClass = this.constructor as typeof DatabaseService;
|
const staticClass = this.constructor as typeof DatabaseService;
|
||||||
const schema: any = {};
|
const schema: any = {};
|
||||||
|
|
||||||
|
@ -119,7 +119,6 @@ export class EditorService {
|
|||||||
protected session: SessionService,
|
protected session: SessionService,
|
||||||
) {
|
) {
|
||||||
this.instanceUUID = uuid_v4();
|
this.instanceUUID = uuid_v4();
|
||||||
console.log('editor service', this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditor(uuid?: string) {
|
getEditor(uuid?: string) {
|
||||||
|
@ -9,6 +9,7 @@ export default class HostRecord {
|
|||||||
public UpdatedAt: string;
|
public UpdatedAt: string;
|
||||||
public Value: any;
|
public Value: any;
|
||||||
public AdditionalData: any;
|
public AdditionalData: any;
|
||||||
|
public associatedTypeVersionNum?: number;
|
||||||
|
|
||||||
public get UUID(): string {
|
public get UUID(): string {
|
||||||
return this.privUUID;
|
return this.privUUID;
|
||||||
@ -31,6 +32,7 @@ export default class HostRecord {
|
|||||||
load(data: any) {
|
load(data: any) {
|
||||||
this.type = data.Type;
|
this.type = data.Type;
|
||||||
this.privUUID = data.UUID;
|
this.privUUID = data.UUID;
|
||||||
|
this.associatedTypeVersionNum = data.associated_type_version_num;
|
||||||
|
|
||||||
[
|
[
|
||||||
'CreatedAt',
|
'CreatedAt',
|
||||||
|
Loading…
Reference in New Issue
Block a user