Skip to content

Commit a5e0f3a

Browse files
committed
[BUG] Fix Drag & Drop not working and fix config refusing to load with any value errors present
1 parent d525841 commit a5e0f3a

File tree

6 files changed

+119
-68
lines changed

6 files changed

+119
-68
lines changed

backend/src/main/java/dev/firstdark/configeditor/converter/ConfigConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ private void tomlToJson(CommentedConfig newConfig, JsonObject values, HashMap<St
9595
tomlToJson(nestedConfig, nestedJson, comments, finalKey);
9696
stringArray.add(nestedJson);
9797
} else {
98-
throw new RuntimeException(item + " is not a valid type");
98+
stringArray.add(new JsonPrimitive(String.valueOf(item)));
99+
newConfig.getOptionalComment(key).ifPresent(comment -> comments.put(finalKey, comment));
100+
//throw new RuntimeException(finalKey + " has an invalid value");
99101
}
100102
}
101103
targetObject.add(key, stringArray);

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@fortawesome/free-solid-svg-icons": "^6.5.2",
2121
"@fortawesome/vue-fontawesome": "^3.0.8",
2222
"@highlightjs/vue-plugin": "^2.1.0",
23-
"@vueuse/core": "^10.9.0",
23+
"@vueuse/core": "^13.8.0",
2424
"animate.css": "^4.1.1",
2525
"flowbite": "^2.3.0",
2626
"flowbite-vue": "^0.1.9",

frontend/src/assets/css/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,11 @@
216216
z-index: 100000 !important;
217217
}
218218

219+
.highlight-zone {
220+
width: 100%;
221+
background: rgba(255, 255, 255, 0.1) !important;
222+
cursor: copy;
223+
border: 4px dashed gray;
224+
}
219225

220226
/* No More Tailwind CSS V1.0.1 Jan 2023 */ .no-more-tailwind a:link { color: blue; text-decoration: underline; cursor: auto; } .no-more-tailwind a:visited { color: purple; text-decoration: underline; cursor: auto; } .no-more-tailwind a:link:active { color: dodgerblue; } .no-more-tailwind a:visited:active { color: rebeccapurple; } .no-more-tailwind address { display: block; font-style: italic; } .no-more-tailwind area { display: none; } .no-more-tailwind article { display: block; } .no-more-tailwind aside { display: block; } .no-more-tailwind audio { display: block; } .no-more-tailwind b { font-weight: bold; } .no-more-tailwind bdo { unicode-bidi: bidi-override; } .no-more-tailwind blockquote { display: block; margin-top: 1em; margin-bottom: 1em; margin-left: 40px; margin-right: 40px; } .no-more-tailwind body { display: block; margin: 0px; } .no-more-tailwind body:focus { outline: none; } .no-more-tailwind caption { display: table-caption; text-align: center; } .no-more-tailwind cite { font-style: italic; } .no-more-tailwind code { font-family: monospace; } .no-more-tailwind col { display: table-column; } .no-more-tailwind colgroup { display: table-column-group } .no-more-tailwind datalist { display: none; } .no-more-tailwind dd { display: block; margin-left: 40px; } .no-more-tailwind del { text-decoration: line-through; } .no-more-tailwind details { display: block; } .no-more-tailwind details { display: block; } .no-more-tailwind dfn { font-style: italic; } .no-more-tailwind div { display: block; } .no-more-tailwind dl { display: block; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; } .no-more-tailwind dt { display: block; } .no-more-tailwind em { font-style: italic; } .no-more-tailwind embed:focus { outline: none; } .no-more-tailwind fieldset { display: block; margin-left: 2px; margin-right: 2px; padding-top: 0.35em; padding-bottom: 0.625em; padding-left: 0.75em; padding-right: 0.75em; border: 2px groove dimgray; } .no-more-tailwind figcaption { display: block; } .no-more-tailwind figure { display: block; margin-top: 1em; margin-bottom: 1em; margin-left: 40px; margin-right: 40px; } .no-more-tailwind footer { display: block; } .no-more-tailwind form { display: block; margin-top: 0em; } .no-more-tailwind h1 { display: block; font-size: 2em; margin-top: 0.67em; margin-bottom: 0.67em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind h2 { display: block; font-size: 1.5em; margin-top: 0.83em; margin-bottom: 0.83em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind h3 { display: block; font-size: 1.17em; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind h4 { display: block; margin-top: 1.33em; margin-bottom: 1.33em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind h5 { display: block; margin-top: 1.33em; margin-bottom: 1.33em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind h6 { display: block; margin-top: 1.33em; margin-bottom: 1.33em; margin-left: 0; margin-right: 0; font-weight: bold; } .no-more-tailwind head { display: none; } .no-more-tailwind header { display: block; } .no-more-tailwind hr { display: block; margin-top: 0.5em; margin-bottom: 0.5em; margin-left: auto; margin-right: auto; border-style: inset; border-width: 1px; } .no-more-tailwind html { display: block; } .no-more-tailwind html:focus { outline: none; } .no-more-tailwind i { font-style: italic; } .no-more-tailwind iframe:focus { outline: none; } .no-more-tailwind iframe[seamless] { display: block; } .no-more-tailwind img { display: inline-block; } .no-more-tailwind ins { text-decoration: underline; } .no-more-tailwind kbd { font-family: monospace; } .no-more-tailwind label { cursor: default; } .no-more-tailwind legend { display: block; padding-left: 2px; padding-right: 2px; border: none; } .no-more-tailwind li { display: list-item; } .no-more-tailwind link { display: none; } .no-more-tailwind map { display: inline; } .no-more-tailwind mark { background-color: yellow; color: black; } .no-more-tailwind menu { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; padding-left: 40px; } .no-more-tailwind nav { display: block; } .no-more-tailwind object:focus { outline: none; } .no-more-tailwind ol { display: block; list-style-type: decimal; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; padding-left: 40px; } .no-more-tailwind output { display: inline; } .no-more-tailwind p { display: block; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; } .no-more-tailwind param { display: none; } .no-more-tailwind pre { display: block; font-family: monospace; white-space: pre; margin: 1em 0; } .no-more-tailwind q { display: inline; } .no-more-tailwind q::before { content: open-quote; } .no-more-tailwind q::after { content: close-quote; } .no-more-tailwind rt { line-height: normal; } .no-more-tailwind s { text-decoration: line-through; } .no-more-tailwind samp { font-family: monospace; } .no-more-tailwind script { display: none; } .no-more-tailwind section { display: block; } .no-more-tailwind small { font-size: smaller; } .no-more-tailwind strike { text-decoration: line-through; } .no-more-tailwind strong { font-weight: bold; } .no-more-tailwind style { display: none; } .no-more-tailwind sub { vertical-align: sub; font-size: smaller; } .no-more-tailwind summary { display: block; } .no-more-tailwind sup { vertical-align: super; font-size: smaller; } .no-more-tailwind table { display: table; border-collapse: separate; border-spacing: 2px; border-color: gray; } .no-more-tailwind tbody { display: table-row-group; vertical-align: middle; border-color: inherit; } .no-more-tailwind td { display: table-cell; vertical-align: inherit; } .no-more-tailwind tfoot { display: table-footer-group; vertical-align: middle; border-color: inherit; } .no-more-tailwind th { display: table-cell; vertical-align: inherit; font-weight: bold; text-align: center; } .no-more-tailwind thead { display: table-header-group; vertical-align: middle; border-color: inherit; } .no-more-tailwind title { display: none; } .no-more-tailwind tr { display: table-row; vertical-align: inherit; border-color: inherit; } .no-more-tailwind u { text-decoration: underline; } .no-more-tailwind ul { display: block; list-style-type: disc; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; padding-left: 40px; } .no-more-tailwind var { font-style: italic; }

frontend/src/components/splashes/LoadingSplash.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<img src="@/assets/img/config_editor_light.svg" class="block dark:hidden w-full" alt="logo" />
55
<img src="@/assets/img/config_editor.svg" class="hidden dark:block w-full" alt="logo" />
66
<br /><br />
7-
<h4 data-text="Loading..." class="uppercase loading-animation">Loading...</h4>
7+
<h4 data-text="Loading..." class="uppercase loading-animation font-extrabold">Loading...</h4>
88
<br />
99
</div>
1010
</div>
@@ -34,6 +34,7 @@ onMounted(() => {
3434
max-width: 7em;
3535
white-space: nowrap;
3636
animation: loading 5s linear;
37+
color: gray;
3738
}
3839
@keyframes loading {
3940
0% {
Lines changed: 85 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,119 @@
11
<template>
2-
<div class="absolute top-0 left-0 w-full h-full bg-ct-light-primary dark:bg-ct-dark-primary flex items-center justify-center text-black dark:text-white">
3-
<div class="text-center">
4-
<h1 class="font-extrabold text-red-600 uppercase">WARNING: Make a backup of your config when working with this editor!</h1> <br/>
2+
<div
3+
ref="dropzoneRef"
4+
class="absolute top-0 left-0 w-full h-full bg-ct-light-primary dark:bg-ct-dark-primary flex items-center justify-center text-black dark:text-white"
5+
:class="isOverDropZone ? 'highlight-zone' : ''"
6+
>
7+
<div class="text-center" v-if="isOverDropZone">
8+
<FontAwesomeIcon :icon="faFileArrowDown" style="height: 40px;"/>
9+
<h1 class="font-extrabold">Drop your file here to load it</h1>
10+
</div>
11+
12+
<div class="text-center" v-if="!isOverDropZone">
13+
<h1 class="font-extrabold text-red-600 uppercase">
14+
WARNING: Make a backup of your config when working with this editor!
15+
</h1>
16+
<br />
517
<img src="@/assets/img/config_editor_light.svg" class="block dark:hidden w-full" alt="logo" />
618
<img src="@/assets/img/config_editor.svg" class="hidden dark:block w-full" alt="logo" />
719
<br /><br />
8-
<p class="font-bold">Please choose a config file, or drag-and-drop a file here to get started</p>
20+
<p class="font-bold">
21+
Please choose a config file, or drag-and-drop a file here to get started
22+
</p>
923
<br />
10-
<button type="button" @click="open()" class="text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center me-2 mb-2">
24+
<button
25+
type="button"
26+
@click="open()"
27+
class="text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center me-2 mb-2"
28+
>
1129
Select Config File
1230
</button>
1331

14-
<button type="button" @click="openEmbedEditor()" class="text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center me-2 mb-2">
32+
<button
33+
type="button"
34+
@click="openEmbedEditor()"
35+
class="text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center me-2 mb-2"
36+
>
1537
Embed Editor
1638
</button>
1739
<br />
1840
<br />
19-
<p class="text-yellow-500 dark:text-yellow-300 text-sm">Supports: <i>Simple RPC (3+), Simple RPC (4+), Simple Discord Link (3+) and Simple RPC Stardew Edition</i> configs</p>
41+
<p class="text-yellow-500 dark:text-yellow-300 text-sm">
42+
Supports:
43+
<i
44+
>Simple RPC (3+), Simple RPC (4+), Simple Discord Link (3+) and Simple RPC Stardew
45+
Edition</i
46+
>
47+
configs
48+
</p>
2049
</div>
2150
</div>
2251
</template>
2352

2453
<script setup lang="ts">
25-
import {onMounted} from "vue";
26-
import {useFileDialog} from "@vueuse/core";
27-
import {useEditor} from "@/stores/editor";
28-
import {useToast} from "@/stores/toaststore";
54+
import { ref } from 'vue'
55+
import { useDropZone, useFileDialog } from '@vueuse/core'
56+
import { useEditor } from '@/stores/editor'
57+
import { useToast } from '@/stores/toaststore'
2958
import { BACKEND_URL } from '@/composables/EditorFunctions'
3059
import router from '@/router'
60+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
61+
import { faFileArrowDown } from '@fortawesome/free-solid-svg-icons/faFileArrowDown'
3162
32-
onMounted(() => {
33-
document.body.addEventListener('dragover', evt => {
34-
evt.preventDefault();
35-
});
63+
const dropzoneRef = ref<HTMLDivElement>()
3664
37-
document.body.addEventListener('drop', evt => {
38-
evt.preventDefault();
39-
});
40-
})
65+
const loadFile = (file: File) => {
66+
const formData = new FormData()
67+
formData.append('file', file)
68+
69+
fetch(`${BACKEND_URL}/v1/parseupload`, {
70+
method: 'POST',
71+
body: formData
72+
})
73+
.then(async (res) => {
74+
const dt = await res.json()
75+
76+
if (!dt.error) {
77+
useEditor().setConfig(dt.data)
78+
useEditor().setOriginalConfig(dt.data.original)
79+
useEditor().setConfigLoaded(true)
80+
useEditor().setCurrentSection(Object.keys(dt.data.config)[0])
81+
useToast().showToast('Success', 2000, 'success')
82+
} else {
83+
useToast().showToast(dt.message, 2000, 'error')
84+
}
85+
})
86+
.catch((err) => {
87+
console.error(err)
88+
useToast().showToast(err, 2000, 'error')
89+
})
90+
}
91+
92+
const onDrop = (files: File[] | null) => {
93+
if (files && files.length > 0) {
94+
loadFile(files[0])
95+
}
96+
}
97+
98+
const { isOverDropZone } = useDropZone(dropzoneRef, {
99+
onDrop,
100+
multiple: false,
101+
preventDefaultForUnhandled: true,
102+
});
41103
42104
const openEmbedEditor = () => {
43-
router.push("/embed_editor").then(res => {
44-
useEditor().setEmbedEditor(true);
105+
router.push('/embed_editor').then(() => {
106+
useEditor().setEmbedEditor(true)
45107
})
46108
}
47109
48110
const { open, onChange } = useFileDialog({
49111
accept: '.toml'
50-
});
112+
})
51113
52114
onChange((files) => {
53115
if (files?.item(0)) {
54-
const formData = new FormData();
55-
formData.append('file', files[0]);
56-
57-
fetch(`${BACKEND_URL}/v1/parseupload`, {
58-
method: 'POST',
59-
body: formData
60-
}).then(async res => {
61-
const dt = await res.json();
62-
63-
if (!dt.error) {
64-
useEditor().setConfig(dt.data);
65-
useEditor().setOriginalConfig(dt.data.original);
66-
useEditor().setConfigLoaded(true);
67-
useEditor().setCurrentSection(Object.keys(dt.data.config)[0]);
68-
useToast().showToast('Success', 2000, "success");
69-
} else {
70-
useToast().showToast(dt.message, 2000, "error");
71-
}
72-
}).catch(err => {
73-
console.error(err)
74-
useToast().showToast(err, 2000, "error");
75-
})
116+
loadFile(files[0]);
76117
}
77118
})
78-
79119
</script>

frontend/yarn.lock

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,11 @@
800800
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597"
801801
integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==
802802

803+
"@types/web-bluetooth@^0.0.21":
804+
version "0.0.21"
805+
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz#525433c784aed9b457aaa0ee3d92aeb71f346b63"
806+
integrity sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==
807+
803808
"@typescript-eslint/eslint-plugin@^7.1.1":
804809
version "7.18.0"
805810
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz#b16d3cf3ee76bf572fdf511e79c248bdec619ea3"
@@ -1125,32 +1130,24 @@
11251130
"@vueuse/shared" "12.5.0"
11261131
vue "^3.5.13"
11271132

1128-
"@vueuse/core@^10.9.0":
1129-
version "10.11.1"
1130-
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.11.1.tgz#15d2c0b6448d2212235b23a7ba29c27173e0c2c6"
1131-
integrity sha512-guoy26JQktXPcz+0n3GukWIy/JDNKti9v6VEMu6kV2sYBsWuGiTU8OWdg+ADfUbHg3/3DlqySDe7JmdHrktiww==
1133+
"@vueuse/core@^13.8.0":
1134+
version "13.8.0"
1135+
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-13.8.0.tgz#760800f866dd8a1152a0a28e412ed53336e9ad7e"
1136+
integrity sha512-rmBcgpEpxY0ZmyQQR94q1qkUcHREiLxQwNyWrtjMDipD0WTH/JBcAt0gdcn2PsH0SA76ec291cHFngmyaBhlxA==
11321137
dependencies:
1133-
"@types/web-bluetooth" "^0.0.20"
1134-
"@vueuse/metadata" "10.11.1"
1135-
"@vueuse/shared" "10.11.1"
1136-
vue-demi ">=0.14.8"
1137-
1138-
"@vueuse/metadata@10.11.1":
1139-
version "10.11.1"
1140-
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.11.1.tgz#209db7bb5915aa172a87510b6de2ca01cadbd2a7"
1141-
integrity sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==
1138+
"@types/web-bluetooth" "^0.0.21"
1139+
"@vueuse/metadata" "13.8.0"
1140+
"@vueuse/shared" "13.8.0"
11421141

11431142
"@vueuse/metadata@12.5.0":
11441143
version "12.5.0"
11451144
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-12.5.0.tgz#8f1778a2894bdda2bf458054377a379d40276306"
11461145
integrity sha512-Ui7Lo2a7AxrMAXRF+fAp9QsXuwTeeZ8fIB9wsLHqzq9MQk+2gMYE2IGJW48VMJ8ecvCB3z3GsGLKLbSasQ5Qlg==
11471146

1148-
"@vueuse/shared@10.11.1":
1149-
version "10.11.1"
1150-
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.11.1.tgz#62b84e3118ae6e1f3ff38f4fbe71b0c5d0f10938"
1151-
integrity sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==
1152-
dependencies:
1153-
vue-demi ">=0.14.8"
1147+
"@vueuse/metadata@13.8.0":
1148+
version "13.8.0"
1149+
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-13.8.0.tgz#5bf97b8733346fc1abf0c20c31e01ea672279c0e"
1150+
integrity sha512-BYMp3Gp1kBUPv7AfQnJYP96mkX7g7cKdTIgwv/Jgd+pfQhz678naoZOAcknRtPLP4cFblDDW7rF4e3KFa+PfIA==
11541151

11551152
"@vueuse/shared@12.5.0":
11561153
version "12.5.0"
@@ -1159,6 +1156,11 @@
11591156
dependencies:
11601157
vue "^3.5.13"
11611158

1159+
"@vueuse/shared@13.8.0":
1160+
version "13.8.0"
1161+
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-13.8.0.tgz#ed7baa8ad19e164a7626592531694bfe6c94d2e3"
1162+
integrity sha512-x4nfM0ykW+RmNJ4/1IzZsuLuWWrNTxlTWUiehTGI54wnOxIgI9EDdu/O5S77ac6hvQ3hk2KpOVFHaM0M796Kbw==
1163+
11621164
acorn-jsx@^5.3.2:
11631165
version "5.3.2"
11641166
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
@@ -3111,7 +3113,7 @@ vscode-uri@^3.0.8:
31113113
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.1.0.tgz#dd09ec5a66a38b5c3fffc774015713496d14e09c"
31123114
integrity sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==
31133115

3114-
vue-demi@>=0.14.8, vue-demi@^0.14.10:
3116+
vue-demi@^0.14.10:
31153117
version "0.14.10"
31163118
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.10.tgz#afc78de3d6f9e11bf78c55e8510ee12814522f04"
31173119
integrity sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==

0 commit comments

Comments
 (0)