This commit is contained in:
j3d1 2023-06-29 00:08:22 +02:00
parent 6ada06af52
commit 27d21545fc
5 changed files with 31 additions and 10 deletions

View file

@ -247,12 +247,11 @@ class ServerSetUnion {
async get(auth, target) {
try {
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.get(auth, target))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -260,12 +259,11 @@ class ServerSetUnion {
async post(auth, target, data) {
try {
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.post(auth, target, data))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -273,12 +271,11 @@ class ServerSetUnion {
async patch(auth, target, data) {
try {
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.patch(auth, target, data))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -286,12 +283,11 @@ class ServerSetUnion {
async put(auth, target, data) {
try {
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.put(auth, target, data))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -299,12 +295,11 @@ class ServerSetUnion {
async delete(auth, target) {
try {
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.delete(auth, target))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}

View file

@ -78,6 +78,9 @@ export default createStore({
setDomains(state, domains) {
state.domains = domains;
},
setFiles(state, files) {
state.files = files;
},
logout(state) {
state.user = null;
state.token = null;
@ -251,6 +254,22 @@ export default createStore({
const servers = await dispatch('getHomeServers')
return await servers.delete(getters.signAuth, '/api/friends/' + id + '/')
},
async fetchFiles({state, commit, dispatch, getters}) {
if (state.last_load.files > Date.now() - 1000 * 60 * 60 * 24) {
return state.files
}
const servers = await dispatch('getHomeServers')
const data = await servers.get(getters.signAuth, '/api/files/')
commit('setFiles', data)
state.last_load.files = Date.now()
return data
},
async pushFile({state, dispatch, getters}, {file}) {
const servers = await dispatch('getHomeServers')
const data = await servers.post(getters.signAuth, '/api/files/', file)
state.files.push(data)
return data
},
async fetchTags({state, commit, dispatch, getters}) {
if (state.last_load.tags > Date.now() - 1000 * 60 * 60 * 24) {
return state.tags

View file

@ -58,6 +58,7 @@ import {mapActions, mapGetters, mapState} from "vuex";
import BaseLayout from "@/components/BaseLayout.vue";
import TagField from "@/components/TagField.vue";
import PropertyField from "@/components/PropertyField.vue";
import CombinedFileField from "@/components/CombinedFileField.vue";
export default {
name: "InventoryEdit",
@ -78,6 +79,7 @@ export default {
BaseLayout,
TagField,
PropertyField,
CombinedFileField,
...BIcons
},
props: {

View file

@ -69,6 +69,7 @@ import {mapActions, mapState} from "vuex";
import BaseLayout from "@/components/BaseLayout.vue";
import TagField from "@/components/TagField.vue";
import PropertyField from "@/components/PropertyField.vue";
import CombinedFileField from "@/components/CombinedFileField.vue";
export default {
name: "InventoryNew",
@ -76,6 +77,7 @@ export default {
BaseLayout,
TagField,
PropertyField,
CombinedFileField,
...BIcons
},
data() {

View file

@ -45,6 +45,9 @@ export default defineConfig({
'^/static/': {
target: "http://127.0.0.1:8000/",
},
'^/media/': {
target: "http://127.0.0.1:8000/",
},
'^/wiki/': {
target: "http://127.0.0.1:8080/",
rewrite: (path) => path.replace(/^\/wiki/, ''),