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

View File

@ -133,7 +133,12 @@ createApp({
}) })
}, },
uploadConfig() { 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() { hostFromTemplateAdd() {
let v = this.forms.hostFromTemplate; let v = this.forms.hostFromTemplate;
@ -148,7 +153,7 @@ createApp({
} }
this.apiDelete('/hosts-from-template/'+v, (v) => { this.forms.hostFromTemplateDel = "" }); 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() event.preventDefault()
if (data === undefined) { if (data === undefined) {
@ -190,7 +195,7 @@ createApp({
xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token) xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token)
} }
if (contentType == "application/json") { if (!raw && contentType == "application/json") {
xhr.send(JSON.stringify(data)) xhr.send(JSON.stringify(data))
} else { } else {
xhr.send(data) xhr.send(data)

View File

@ -246,7 +246,7 @@ header .utils > * {
} }
</style> </style>
<script src="/ui/jsonpatch.min-942279a1c4209cc2.js" integrity="sha384-GcPrkRS12jtrElEkbJcrZ8asvvb9s3mc+CUq9UW/8bL4L0bpkmh9M+oFnWN6qLq2"></script> <script src="/ui/jsonpatch.min-942279a1c4209cc2.js" integrity="sha384-GcPrkRS12jtrElEkbJcrZ8asvvb9s3mc+CUq9UW/8bL4L0bpkmh9M+oFnWN6qLq2"></script>
<script src="/ui/app-492d80052b1d2654.js" defer integrity="sha384-uSjgCS+NzQPUHO1r5S81fX5l/4Q/MVAvhLXeDfu/fFdDRUzHu/EBrKEw8v5OQeMv" type="module"></script> <script src="/ui/app-7f4645e84eaae7ce.js" defer integrity="sha384-31uiQnXVSPLDq61o+chfyKRkSdkmzv023M7KafOo+0xRw5AM70BUFyYO6yo0kPiZ" type="module"></script>
<script src="/ui/Downloads-c9374f19f52c46d.js" integrity="sha384-WQIkCSxlUkvu4jFIWwS3bESMaazGwwnBn9dyvB7nItz3L8BmusRMsJACzfJa7sC4"></script> <script src="/ui/Downloads-c9374f19f52c46d.js" integrity="sha384-WQIkCSxlUkvu4jFIWwS3bESMaazGwwnBn9dyvB7nItz3L8BmusRMsJACzfJa7sC4"></script>
<script src="/ui/GetCopy-7e3c9678f9647d40.js" integrity="sha384-LzxUXylxE/t25HyTch8y2qvKcehvP2nqCo37swIBGEKZZUzHVJVQrS5UJDWNskTA"></script> <script src="/ui/GetCopy-7e3c9678f9647d40.js" integrity="sha384-LzxUXylxE/t25HyTch8y2qvKcehvP2nqCo37swIBGEKZZUzHVJVQrS5UJDWNskTA"></script>
<script src="/ui/Cluster-703dcdca97841304.js" integrity="sha384-ifGpq/GB1nDfqczm5clTRtcfnc9UMkT+SptMyS3UG9Di3xoKORtOGGjmK5RnJx+v"></script> <script src="/ui/Cluster-703dcdca97841304.js" integrity="sha384-ifGpq/GB1nDfqczm5clTRtcfnc9UMkT+SptMyS3UG9Di3xoKORtOGGjmK5RnJx+v"></script>

1
ui/build Executable file
View File

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

View File

@ -133,7 +133,12 @@ createApp({
}) })
}, },
uploadConfig() { 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() { hostFromTemplateAdd() {
let v = this.forms.hostFromTemplate; let v = this.forms.hostFromTemplate;
@ -148,7 +153,7 @@ createApp({
} }
this.apiDelete('/hosts-from-template/'+v, (v) => { this.forms.hostFromTemplateDel = "" }); 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() event.preventDefault()
if (data === undefined) { if (data === undefined) {
@ -190,7 +195,7 @@ createApp({
xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token) xhr.setRequestHeader('Authorization', 'Bearer '+this.session.token)
} }
if (contentType == "application/json") { if (!raw && contentType == "application/json") {
xhr.send(JSON.stringify(data)) xhr.send(JSON.stringify(data))
} else { } else {
xhr.send(data) xhr.send(data)