From ef60f71a1b07154fd383612fce714daf22a9da17 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 23 Aug 2024 20:22:04 +0200 Subject: [PATCH 1/8] remove html injection --- webapp/src/components/pages/TaskList.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/src/components/pages/TaskList.vue b/webapp/src/components/pages/TaskList.vue index b12354b02..ba5edfefe 100644 --- a/webapp/src/components/pages/TaskList.vue +++ b/webapp/src/components/pages/TaskList.vue @@ -66,7 +66,9 @@ -
+
+ {{ task.displayInformation.summary.preview }} +
From 86336329cb3884b8e9ff1bd35858f1b6233a7c41 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Sun, 25 Aug 2024 15:44:52 +0200 Subject: [PATCH 2/8] added the functionality of undoing a model deletion in the model, as stated in the issue #756 --- .../src/components/sidebar/ModelLibrary.vue | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index b478c670b..19a3700e9 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -126,7 +126,7 @@ import { List } from "immutable"; import { onMounted, ref } from "vue"; import { useRouter } from "vue-router"; -import { EmptyMemory } from "@epfml/discojs"; +import { EmptyMemory, Model } from "@epfml/discojs"; import { IndexedDB } from "@epfml/discojs-web"; import { useToaster } from "@/composables/toaster"; @@ -157,6 +157,8 @@ memoryStore.$subscribe((_, state) => { const memory = memoryStore.useIndexedDB ? new IndexedDB() : new EmptyMemory(); +let tempDeletedModel : { id : string; model : Model, metadata : ModelMetadata} | undefined; + onMounted(async () => { await memoryStore.initModels(); }); @@ -210,11 +212,34 @@ function sortModels(a: ModelMetadata, b: ModelMetadata): number { } -function deleteModelConfirm(modelID: string){ - toaster.default(`Click here to confirm the model deletion`, { - onClick: () => deleteModel(modelID), - duration: 10000, - }); +async function deleteModelConfirm(modelID: string){ + const modelInfo = models.value.find(([id]) => id === modelID); + const model = await memory.getModel(modelID); + if (!modelInfo) return + + deleteModel(modelID).then(() => { + console.log("ici") + tempDeletedModel = { id : modelID, model : model, metadata : modelInfo[1]}; + toaster.info("Model deleted. Click here to undo", { + onClick: () => undoDeleteModel(), + duration : 10000, + }); + }) +} + +async function undoDeleteModel() { + try { + if (!tempDeletedModel) throw new Error("No model to restore"); + memoryStore.addModel(tempDeletedModel.id, tempDeletedModel.metadata); + await memory.saveModel(tempDeletedModel.id, tempDeletedModel.model); + toaster.success("Successfully restored the model"); + } catch (e) { + let msg = "Unable to restore model"; + if (e instanceof Error) msg += `: ${e.message}`; + toaster.error(msg); + } finally { + tempDeletedModel = undefined; + } } async function deleteModel(modelID: string): Promise { From ab1339b46cc4998cac8a2669ba222f347c497e14 Mon Sep 17 00:00:00 2001 From: tomasoignons <134852018+tomasoignons@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:57:52 +0200 Subject: [PATCH 3/8] removed unecessary console.log Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com> --- webapp/src/components/sidebar/ModelLibrary.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index 19a3700e9..7507d789a 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -218,7 +218,6 @@ async function deleteModelConfirm(modelID: string){ if (!modelInfo) return deleteModel(modelID).then(() => { - console.log("ici") tempDeletedModel = { id : modelID, model : model, metadata : modelInfo[1]}; toaster.info("Model deleted. Click here to undo", { onClick: () => undoDeleteModel(), From a1a379bb5077a0ef47653ed37497d7adceca72ba Mon Sep 17 00:00:00 2001 From: tomasoignons <134852018+tomasoignons@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:58:17 +0200 Subject: [PATCH 4/8] simplify code by unwraping argument Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com> --- webapp/src/components/sidebar/ModelLibrary.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index 7507d789a..70c06c28e 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -213,7 +213,7 @@ function sortModels(a: ModelMetadata, b: ModelMetadata): number { async function deleteModelConfirm(modelID: string){ - const modelInfo = models.value.find(([id]) => id === modelID); + const modelInfo = models.value.find(id => id === modelID); const model = await memory.getModel(modelID); if (!modelInfo) return From 1ea7b11260ec3d92d3d91150bed8e1bb598f7c65 Mon Sep 17 00:00:00 2001 From: tomasoignons <134852018+tomasoignons@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:59:05 +0200 Subject: [PATCH 5/8] replace boolean with === to check undefined Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com> --- webapp/src/components/sidebar/ModelLibrary.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index 70c06c28e..8a29cba42 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -215,7 +215,7 @@ function sortModels(a: ModelMetadata, b: ModelMetadata): number { async function deleteModelConfirm(modelID: string){ const modelInfo = models.value.find(id => id === modelID); const model = await memory.getModel(modelID); - if (!modelInfo) return + if (modelInfo === undefined) return deleteModel(modelID).then(() => { tempDeletedModel = { id : modelID, model : model, metadata : modelInfo[1]}; From dd57ac4fa867bd5a127d3111e8c47a70fcd50e45 Mon Sep 17 00:00:00 2001 From: tomasoignons <134852018+tomasoignons@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:59:33 +0200 Subject: [PATCH 6/8] simplify code Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com> --- webapp/src/components/sidebar/ModelLibrary.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index 8a29cba42..674c6399a 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -220,7 +220,7 @@ async function deleteModelConfirm(modelID: string){ deleteModel(modelID).then(() => { tempDeletedModel = { id : modelID, model : model, metadata : modelInfo[1]}; toaster.info("Model deleted. Click here to undo", { - onClick: () => undoDeleteModel(), + onClick: undoDeleteModel, duration : 10000, }); }) From cbbac5f9b239dc21b0df75bba3ede0a34c919fbd Mon Sep 17 00:00:00 2001 From: tomasoignons <134852018+tomasoignons@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:59:46 +0200 Subject: [PATCH 7/8] replace boolean with === to check undefined Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com> --- webapp/src/components/sidebar/ModelLibrary.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index 674c6399a..cf3c45341 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -228,7 +228,7 @@ async function deleteModelConfirm(modelID: string){ async function undoDeleteModel() { try { - if (!tempDeletedModel) throw new Error("No model to restore"); + if (tempDeletedModel === undefined) throw new Error("No model to restore"); memoryStore.addModel(tempDeletedModel.id, tempDeletedModel.metadata); await memory.saveModel(tempDeletedModel.id, tempDeletedModel.model); toaster.success("Successfully restored the model"); From eecd99547092c65d1280343c64cb452c3445ccf7 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 30 Aug 2024 13:08:27 +0200 Subject: [PATCH 8/8] we cannot unwrap the id, otherwise it crashes --- webapp/src/components/sidebar/ModelLibrary.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/sidebar/ModelLibrary.vue b/webapp/src/components/sidebar/ModelLibrary.vue index cf3c45341..0645e08ed 100644 --- a/webapp/src/components/sidebar/ModelLibrary.vue +++ b/webapp/src/components/sidebar/ModelLibrary.vue @@ -213,7 +213,7 @@ function sortModels(a: ModelMetadata, b: ModelMetadata): number { async function deleteModelConfirm(modelID: string){ - const modelInfo = models.value.find(id => id === modelID); + const modelInfo = models.value.find(([id]) => id === modelID); const model = await memory.getModel(modelID); if (modelInfo === undefined) return