summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-10-04 20:55:04 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-10-04 20:55:04 +0200
commit8806bb5f857502eec2ad9132757458d714fff442 (patch)
tree1e182e6fc7a857da1c6a6efafc7ffc4572c5711a /store
parentc593fb22ac9c572a6f65306424ece315d0809836 (diff)
Add search
Diffstat (limited to 'store')
-rw-r--r--store/models.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/store/models.js b/store/models.js
index 890ba8c..c884aa6 100644
--- a/store/models.js
+++ b/store/models.js
@@ -49,6 +49,36 @@ export const actions = {
return res;
},
+ // Filter models
+ async filter({ commit }, data) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ const page = data.page ? data.page : 0;
+
+ await fetch(`${api}/v1/models/filter?page=${page}`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ q: data.q }),
+ })
+ .then(async (response) => {
+ res.data = await response.json();
+ res.status = response.status;
+ if (res.status == 200) {
+ commit("saveModels", res.data);
+ }
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+
+ return res;
+ },
// Find a model by its id
async findModel({ commit }, id) {
commit("loadingStatus", true, { root: true });