From 44f62ae605198f3fd63e8d5b9132bf210ba84753 Mon Sep 17 00:00:00 2001 From: Jonas Kuche Date: Wed, 15 Jan 2025 13:06:21 +0100 Subject: [PATCH] fix(playground): resolve bugs (#1718) --- .../dialogs/new-db-dialog/new-db-dialog.component.ts | 4 ++++ .../sql-playground/collab/collab.backend.ts | 2 +- .../sql-playground/collab/local.backend.ts | 5 +++-- .../sql-playground/state/sql-playground.effects.ts | 11 +++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/fbs-core/web/src/app/dialogs/new-db-dialog/new-db-dialog.component.ts b/modules/fbs-core/web/src/app/dialogs/new-db-dialog/new-db-dialog.component.ts index 245f43755..dde89774a 100644 --- a/modules/fbs-core/web/src/app/dialogs/new-db-dialog/new-db-dialog.component.ts +++ b/modules/fbs-core/web/src/app/dialogs/new-db-dialog/new-db-dialog.component.ts @@ -3,6 +3,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { UntypedFormControl, Validators } from "@angular/forms"; import { MatSnackBar } from "@angular/material/snack-bar"; import { SqlPlaygroundService } from "../../service/sql-playground.service"; +import { Store } from "@ngrx/store"; +import { loadDatabases } from "../../page-components/sql-playground/db-control-panel/state/databases.actions"; /** * Updates course information in dialog @@ -21,6 +23,7 @@ export class NewDbDialogComponent { private sqlPlaygroundService: SqlPlaygroundService, @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef, + private store: Store, private snackbar: MatSnackBar ) {} @@ -39,6 +42,7 @@ export class NewDbDialogComponent { .createDatabase(this.data.token.id, this.name.value) .subscribe( () => { + this.store.dispatch(loadDatabases()); this.dialogRef.close({ success: true }); }, (error) => { diff --git a/modules/fbs-core/web/src/app/page-components/sql-playground/collab/collab.backend.ts b/modules/fbs-core/web/src/app/page-components/sql-playground/collab/collab.backend.ts index 459cd866b..18562a354 100644 --- a/modules/fbs-core/web/src/app/page-components/sql-playground/collab/collab.backend.ts +++ b/modules/fbs-core/web/src/app/page-components/sql-playground/collab/collab.backend.ts @@ -31,7 +31,7 @@ export class CollaborativeBackend implements Backend { url: window.location.hostname === "localhost" ? "ws://127.0.0.1:1234" - : "wss://feedback.mni.thm.de/collab", + : "/collab/", name: id, token, }); diff --git a/modules/fbs-core/web/src/app/page-components/sql-playground/collab/local.backend.ts b/modules/fbs-core/web/src/app/page-components/sql-playground/collab/local.backend.ts index 673c195ba..a1c9d13c2 100644 --- a/modules/fbs-core/web/src/app/page-components/sql-playground/collab/local.backend.ts +++ b/modules/fbs-core/web/src/app/page-components/sql-playground/collab/local.backend.ts @@ -56,8 +56,9 @@ export class LocalBackend implements Backend { } private loadLocalStorage(): QueryTab[] { - const loadedData = localStorage.getItem("tabs"); - return JSON.parse(loadedData)?.tabs ?? []; + return (JSON.parse(localStorage.getItem("tabs"))?.tabs ?? []).map( + (tab) => ({ id: crypto.randomUUID(), ...tab }) + ); } streamMetaChanges(): Observable<{ key: string; value: any }> { diff --git a/modules/fbs-core/web/src/app/page-components/sql-playground/state/sql-playground.effects.ts b/modules/fbs-core/web/src/app/page-components/sql-playground/state/sql-playground.effects.ts index ea8b2be8b..3fe952b39 100644 --- a/modules/fbs-core/web/src/app/page-components/sql-playground/state/sql-playground.effects.ts +++ b/modules/fbs-core/web/src/app/page-components/sql-playground/state/sql-playground.effects.ts @@ -82,10 +82,13 @@ export class SqlPlaygroundEffects { .getResults(token.id, activeDb, result.id) .pipe( retry(), - map((res) => - SqlPlaygroundActions.submitStatementSuccess({ - resultset: res, - }) + mergeMap((res) => + of( + SqlPlaygroundActions.submitStatementSuccess({ + resultset: res, + }), + SqlPlaygroundActions.updateScheme() + ) ), catchError((error) => of(SqlPlaygroundActions.submitStatementFailure({ error }))