Added dynamic base path determination for HTTP requests

pull/1/head
cascha42 5 months ago
parent 6a37826822
commit 0ccd6e6c5d

@ -87,7 +87,7 @@
<v-btn color="warning" :disabled="index == 0" @click="moveProcessingCMD(index, true)" icon>
<v-icon>mdi-arrow-up</v-icon>
</v-btn>
<v-btn color="warning" :disabled="index == configData.handling.processing.length" @click="moveProcessingCMD(index, false)" icon>
<v-btn color="warning" :disabled="index == configData.handling.processing.length - 1" @click="moveProcessingCMD(index, false)" icon>
<v-icon>mdi-arrow-down</v-icon>
</v-btn>
</v-col>
@ -157,7 +157,6 @@
new Vue({
el: '#app',
vuetify: new Vuetify(),
http: { root: '/' },
data() {
return {
configTab: null,
@ -187,10 +186,12 @@
}
},
credentialsData: {},
basePath: '',
}
},
created() {
this.loadConfig()
this.basePath = window.location.pathname.replace(/\/$/, '');
this.loadConfig();
},
methods: {
moveProcessingCMD(index, down) {
@ -199,7 +200,7 @@
this.configData.handling.processing.splice(index + (down ? -1 : 1), 0, entry)
},
loadConfig() {
this.$http.get('/config').then(response => {
this.$http.get(`${this.basePath}/config`).then(response => {
const newConfig = response.body
newConfig.handling.processing = newConfig.handling.processing.map((x) => {
x._id = btoa(JSON.stringify(x))
@ -208,10 +209,9 @@
this.configData = newConfig
}, response => {
})
this.$http.get('/credentials').then(response => {
this.$http.get(`${this.basePath}/credentials`).then(response => {
this.credentialsData = response.body
}, response => {
})
});
},
storeConfig() {
const storeConfig = JSON.parse(JSON.stringify(this.configData))
@ -224,18 +224,18 @@
if (!!x[n] && x[n].length > 0) y[n] = x[n]
return y
})
this.$http.post('/config', storeConfig).then(response => {
this.$http.post(`${this.basePath}/config`, storeConfig).then(response => {
})
.then(this.$http.post('/restart'))
.then(() => this.$http.post(`${this.basePath}/restart`))
.then(() => {
document.body.style = 'display:none'
setTimeout(() => window.location.reload(), 1e3)
})
});
},
storeCredentials() {
this.$http.post('/credentials', this.credentialsData).then(response => {
this.$http.post(`${this.basePath}/credentials`, this.credentialsData).then(response => {
})
.then(this.$http.post('/restart'))
.then(() => this.$http.post(`${this.basePath}/restart`))
.then(() => {
document.body.style = 'display:none'
setTimeout(() => window.location.reload(), 1e3)
@ -258,4 +258,4 @@
</script>
</body>
</html>
</html>

Loading…
Cancel
Save