summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/models.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/store/models.js b/store/models.js
index 44dbb56..04717f2 100644
--- a/store/models.js
+++ b/store/models.js
@@ -149,4 +149,56 @@ export const actions = {
return res;
},
+ // Create a model upload
+ async upload({ commit, rootGetters }, payload) {
+ commit("loadingStatus", true, { root: true });
+ let status = 400;
+ let api = this.$config.api;
+
+ const form = new FormData();
+ form.append("file", payload.file);
+
+ await fetch(`${api}/v1/models/${payload.id}/upload`, {
+ method: "POST",
+ headers: {
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ body: form,
+ })
+ .then(async (response) => {
+ status = response.status;
+ })
+ .catch((e) => {
+ status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+
+ return status;
+ },
+ // Delete a model upload
+ async deleteUpload({ commit, rootGetters }, data) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ await fetch(`${api}/v1/models/${data.id}/upload/${data.uid}`, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ })
+ .then(async (response) => {
+ res.status = response.status;
+ res.data = await response.text();
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+
+ return res;
+ },
};