Added dynamic base path determination for HTTP requests #1

Merged
cheetah merged 2 commits from cascha42/msg-email:master into master 4 days ago

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

Loading…
Cancel
Save