ui fixes for config in json format
This commit is contained in:
@ -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)
|
||||
@ -246,7 +246,7 @@ header .utils > * {
|
||||
}
|
||||
</style>
|
||||
<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/GetCopy-7e3c9678f9647d40.js" integrity="sha384-LzxUXylxE/t25HyTch8y2qvKcehvP2nqCo37swIBGEKZZUzHVJVQrS5UJDWNskTA"></script>
|
||||
<script src="/ui/Cluster-703dcdca97841304.js" integrity="sha384-ifGpq/GB1nDfqczm5clTRtcfnc9UMkT+SptMyS3UG9Di3xoKORtOGGjmK5RnJx+v"></script>
|
||||
|
||||
11
ui/js/app.js
11
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)
|
||||
|
||||
Reference in New Issue
Block a user