Improve version modal previews and remove debugging logging
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2021-03-16 10:39:06 -05:00
parent aa27fefef4
commit 94c6a66dff
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
14 changed files with 33 additions and 33 deletions

View File

@ -57,7 +57,6 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
useValue: {
highlight(code: string, lang: string, callback?: (error: any, code: string) => void): string {
const highlighted = hljs.highlight(lang, code, true);
console.log('highlighed', highlighted);
if ( callback ) {
callback(null, highlighted.value);

View File

@ -152,7 +152,7 @@ export class CodeComponent extends EditorNodeContract implements OnInit {
res();
}).catch(rej);
} 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.initialValue = this.dbRecord.code;
this.editorValue = this.dbRecord.code;

View File

@ -139,7 +139,6 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
}
onRowDragEnd($event) {
console.log($event, this);
if ( !this.isInitialLoad && this.editorService.canEdit() ) {
this.dirty = true;
this.triggerSaveDebounce();
@ -369,7 +368,8 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
this.node.value = this.dbRecord.UUID;
} else {
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.notAvailableOffline = false;
} catch (e: unknown) {
@ -382,7 +382,8 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit {
}
// 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);
const rows = await this.api.getDatabaseEntries(this.page.UUID, this.node.UUID, this.node.Value.Value);

View File

@ -39,7 +39,6 @@ export class BooleanEditorComponent implements ICellEditorAngularComp, AfterView
agInit(params: ICellEditorParams): void {
this.params = params;
this.value = this.params.value;
console.log('bool params', {params});
// @ts-ignore
const values = params.colDef.additionalData.labelType.split('_');

View File

@ -25,8 +25,6 @@ export class PageLinkEditorComponent implements OnInit {
// @ts-ignore
this.pages = params._pagesData || [];
console.log('page link editor comp', this);
setTimeout(() => {
this.selectable.open();
});

View File

@ -50,8 +50,6 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
this.node.Value = {};
}
console.log('files load', this)
if ( !this.node.Value.Value && !this.readonly ) {
this.dbRecord = await this.api.createFileGroup(this.page.UUID, this.node.UUID);
this.fileRecords = this.dbRecord.files;

View File

@ -46,7 +46,6 @@ export class FormInputComponent extends EditorNodeContract implements OnInit {
ngOnInit() {
this.editorService = this.editorService.getEditor(this.editorUUID);
this.editorService.registerNodeEditor(this.nodeId, this).then(() => {
console.log('form input node', this.node);
if ( !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);
if ( db ) {
const data = await db.data();
console.log('loaded db data', data, this.node.AdditionalData);
this.selectChoices = data.map(x => {
return {
display: x.data[this.node.AdditionalData.selectDatabaseDisplayColumnId],

View File

@ -36,8 +36,6 @@ export class NormComponent extends EditorNodeContract implements OnInit, OnDestr
super();
this.contents = this.initialValue;
this.savedValue = this.initialValue;
console.log('Norm editor component', this);
}
public isDark() {

View File

@ -20,13 +20,11 @@ export class VersionModalComponent implements OnInit {
protected alerts: AlertController,
protected modals: ModalController,
protected editorService: EditorService,
) {
console.log('version modal', this);
}
) { }
async ngOnInit() {
this.pageVersions = await this.editorService.loadPageVersions(this.pageId);
this.onVersionClick(this.pageVersions[0]);
await this.onVersionClick(this.pageVersions[0]);
}
dismiss(reload = false) {

View File

@ -262,7 +262,6 @@ export class WysiwygComponent implements OnInit {
}
const target = this.getPathToElement(mutation.target);
console.log({mutation, target, type: mutation.type, data: mutation.target.textContent});
const innerHTML = this.editable.nativeElement.innerHTML;
@ -304,11 +303,9 @@ export class WysiwygComponent implements OnInit {
applyRemoteContentMutation(mutation: MutationBroadcast) {
this.applyingRemoteMutation = true;
console.log('got remote content mutation', mutation);
if ( this.editable ) {
const target = this.getElementFromPath(mutation.path);
console.log(target);
if ( target ) {
if ( mutation.type === 'characterData' ) {
this.ignoreNextMutation = true;

View File

@ -318,7 +318,6 @@ export class ApiService {
const uuidMap = await new Promise(async (res, rej) => {
this.post('/offline/sync', { dirtyRecords }).subscribe({
next: async result => {
console.log('sync result', result);
res(result.data);
},
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) => {
const existingLocalCodiums = await this.db.codiums.where({ UUID: CodiumId }).toArray();
const existingLocalCodium = existingLocalCodiums.length > 0 ? existingLocalCodiums[0] as Codium : undefined;
// If offline, try to load it from the local DB
if ( this.isOffline ) {
if ( existingLocalCodium ) {
if ( existingLocalCodium && !version ) {
return res(existingLocalCodium.getSaveRecord());
} else {
return rej(new ResourceNotAvailableOfflineError());
@ -827,8 +826,12 @@ export class ApiService {
}
// 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 => {
if ( version ) {
return res(result.data);
}
if ( existingLocalCodium ) {
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) => {
// If offline, fetch the columns from the local database
if ( this.isOffline ) {
if ( databaseVersion ) {
return rej(new ResourceNotAvailableOfflineError());
}
const columns = (await this.db.databaseColumns.where({ DatabaseId }).toArray()) as DatabaseColumn[];
return res(columns.filter(x => !x.deleted).map(x => x.getSaveRecord()));
}
// 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 => {
// Resolve this first, so the UI doesn't need to wait for the db sync to render
res(results.data);
if ( databaseVersion ) {
return;
}
for ( const def of results.data ) {
const existingColumnDef = await this.db.databaseColumns.where({
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) => {
const existingLocalDatabases = await this.db.databases.where({ UUID: DatabaseId }).toArray();
const existingLocalDatabase = existingLocalDatabases.length > 0 ? existingLocalDatabases[0] as Database : undefined;
if ( this.isOffline ) {
if ( existingLocalDatabase ) {
if ( existingLocalDatabase && !version ) {
return res(existingLocalDatabase.getSaveRecord());
} else {
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 => {
if ( version ) {
return res(result.data);
}
if ( existingLocalDatabase ) {
existingLocalDatabase.fillFromRecord(result.data);

View File

@ -54,8 +54,6 @@ export class DatabaseService extends Dexie {
}
this.initialized = true;
console.log('db', this);
const staticClass = this.constructor as typeof DatabaseService;
const schema: any = {};

View File

@ -119,7 +119,6 @@ export class EditorService {
protected session: SessionService,
) {
this.instanceUUID = uuid_v4();
console.log('editor service', this);
}
getEditor(uuid?: string) {

View File

@ -9,6 +9,7 @@ export default class HostRecord {
public UpdatedAt: string;
public Value: any;
public AdditionalData: any;
public associatedTypeVersionNum?: number;
public get UUID(): string {
return this.privUUID;
@ -31,6 +32,7 @@ export default class HostRecord {
load(data: any) {
this.type = data.Type;
this.privUUID = data.UUID;
this.associatedTypeVersionNum = data.associated_type_version_num;
[
'CreatedAt',