From d7a3ed67bde3861a53f061785ce77cca03288773 Mon Sep 17 00:00:00 2001
From: toshski <104477758+toshski@users.noreply.github.com>
Date: Thu, 26 Oct 2023 07:04:34 +1300
Subject: [PATCH] feat: Bundle Upload Tester (#1441)
* Bundle Upload Tester
* Add Error Handler/Msgs to Import function
---
ui/src/locales/en-GB.json | 1 +
.../sections/OptionsSceneDataImportExport.vue | 70 ++++++++++++++++---
2 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/ui/src/locales/en-GB.json b/ui/src/locales/en-GB.json
index 9395c05df..013a71791 100644
--- a/ui/src/locales/en-GB.json
+++ b/ui/src/locales/en-GB.json
@@ -202,5 +202,6 @@
"No matching attributes":"No matching attributes",
"Only required when troubleshooting search issues, this will enable a Tab in the Scene Details to display what search fields exist and their values for a scene":"Only required when troubleshooting search issues, this will enable a Tab in the Scene Details to display what search fields exist and their values for a scene",
"Scene Id Required": "Scene Id Required",
+ "Occasionaly test uploading your export bundles. Browser memory constraints may cause problems restoring large exports. Use this function to test if your browser can load an export.": "Occasionaly test uploading your export bundles. Browser memory constraints may cause problems restoring large exports. Use this function to test if your browser can load an export.",
"Go": "Go"
}
diff --git a/ui/src/views/options/sections/OptionsSceneDataImportExport.vue b/ui/src/views/options/sections/OptionsSceneDataImportExport.vue
index 96ac36c12..d4a879f92 100644
--- a/ui/src/views/options/sections/OptionsSceneDataImportExport.vue
+++ b/ui/src/views/options/sections/OptionsSceneDataImportExport.vue
@@ -160,8 +160,8 @@
Overwrite existing data
-
-
+
@@ -176,14 +176,27 @@
-
-
-
Export
+
+
+
+
+
+ Test
+
+
+ {{ progressMsg }}
+
+
+
+
@@ -217,6 +230,8 @@ export default {
currentPlaylist: '0',
myUrl: '/download/xbvr-content-bundle.json',
file: null,
+ testfile: null,
+ progressMsg:"",
uploadData: '',
activeTab: 0,
activeSubTab: 0
@@ -236,13 +251,46 @@ export default {
watch: {
// when a file is selected, then this will fire the upload process
file: function (o, n) {
- if (this.file != null) {
- const reader = new FileReader()
- reader.onload = (event) => {
- this.uploadData = JSON.stringify(JSON.parse(event.target.result))
- this.restoreContent()
+ try {
+ if (this.file != null) {
+ const reader = new FileReader()
+ reader.onload = (event) => {
+ try {
+ this.uploadData = JSON.stringify(JSON.parse(event.target.result))
+ this.restoreContent()
+ } catch (error) {
+ this.$buefy.toast.open({message: `Error: ${error.message}`, type: 'is-danger', duration: 30000})
+ }
+ }
+ reader.readAsText(this.file)
}
- reader.readAsText(this.file)
+ } catch (error) {
+ this.$buefy.toast.open({message: `Error: ${error.message}`, type: 'is-danger', duration: 30000})
+ }
+ },
+ testfile: function (o, n) {
+ try {
+ this.$buefy.toast.open({message: `Loading: ` + this.testfile.name, type: 'is-primary', duration: 30000})
+ if (this.testfile != null) {
+ this.progressMsg = "Uploading " + this.testfile.name
+ const reader = new FileReader()
+ reader.onload = (event) => {
+ try {
+ this.progressMsg = "File uploaded, converting to Json " + this.testfile.name
+ this.uploadData = JSON.stringify(JSON.parse(event.target.result))
+ this.progressMsg = ""
+ this.$buefy.toast.open({message: `Success Loading: ` + this.testfile.name, type: 'is-success', duration: 5000})
+ } catch (error) {
+ this.progressMsg = "Error: " + error.message
+ this.$buefy.toast.open({message: `Error: ${error.message}`, type: 'is-danger', duration: 30000})
+ }
+
+ }
+ reader.readAsText(this.testfile)
+ }
+ } catch (error) {
+ this.progressMsg = "Error: " + error.message
+ this.$buefy.toast.open({message: `Error: ${error.message}`, type: 'is-danger', duration: 30000})
}
}
},