ui fixes for config in json format

This commit is contained in:
Mikaël Cluseau
2026-01-25 10:16:37 +01:00
parent f2b23df97b
commit 63a206f1ac
4 changed files with 18 additions and 7 deletions

1
ui/build Executable file
View File

@ -0,0 +1 @@
trunk build --release

View File

@ -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)