diff --git a/html/ui/app-492d80052b1d2654.js b/html/ui/app-7f4645e84eaae7ce.js
similarity index 95%
rename from html/ui/app-492d80052b1d2654.js
rename to html/ui/app-7f4645e84eaae7ce.js
index 764c04b..edbf548 100644
--- a/html/ui/app-492d80052b1d2654.js
+++ b/html/ui/app-7f4645e84eaae7ce.js
@@ -133,7 +133,12 @@ createApp({
})
},
uploadConfig() {
- this.apiPost('/configs', this.$refs.configUpload.files[0], (v) => {}, "text/vnd.yaml")
+ const file = this.$refs.configUpload.files[0];
+ let contentType = "text/vnd.yaml";
+ if (file.name.endsWith(".json")) {
+ contentType = "application/json";
+ }
+ this.apiPost('/configs', file, (v) => {}, contentType, true)
},
hostFromTemplateAdd() {
let v = this.forms.hostFromTemplate;
@@ -148,7 +153,7 @@ createApp({
}
this.apiDelete('/hosts-from-template/'+v, (v) => { this.forms.hostFromTemplateDel = "" });
},
- apiPost(action, data, onload, contentType = 'application/json') {
+ apiPost(action, data, onload, contentType = 'application/json', raw = false) {
event.preventDefault()
if (data === undefined) {
@@ -190,7 +195,7 @@ createApp({
xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token)
}
- if (contentType == "application/json") {
+ if (!raw && contentType == "application/json") {
xhr.send(JSON.stringify(data))
} else {
xhr.send(data)
diff --git a/html/ui/index.html b/html/ui/index.html
index 2814983..774f6d4 100644
--- a/html/ui/index.html
+++ b/html/ui/index.html
@@ -246,7 +246,7 @@ header .utils > * {
}
-
+
diff --git a/ui/build b/ui/build
new file mode 100755
index 0000000..287faaf
--- /dev/null
+++ b/ui/build
@@ -0,0 +1 @@
+trunk build --release
diff --git a/ui/js/app.js b/ui/js/app.js
index 764c04b..edbf548 100644
--- a/ui/js/app.js
+++ b/ui/js/app.js
@@ -133,7 +133,12 @@ createApp({
})
},
uploadConfig() {
- this.apiPost('/configs', this.$refs.configUpload.files[0], (v) => {}, "text/vnd.yaml")
+ const file = this.$refs.configUpload.files[0];
+ let contentType = "text/vnd.yaml";
+ if (file.name.endsWith(".json")) {
+ contentType = "application/json";
+ }
+ this.apiPost('/configs', file, (v) => {}, contentType, true)
},
hostFromTemplateAdd() {
let v = this.forms.hostFromTemplate;
@@ -148,7 +153,7 @@ createApp({
}
this.apiDelete('/hosts-from-template/'+v, (v) => { this.forms.hostFromTemplateDel = "" });
},
- apiPost(action, data, onload, contentType = 'application/json') {
+ apiPost(action, data, onload, contentType = 'application/json', raw = false) {
event.preventDefault()
if (data === undefined) {
@@ -190,7 +195,7 @@ createApp({
xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token)
}
- if (contentType == "application/json") {
+ if (!raw && contentType == "application/json") {
xhr.send(JSON.stringify(data))
} else {
xhr.send(data)