From 98bec5686da0c4b7d0279b94968040b01e3218fa Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Mon, 13 Dec 2021 15:21:21 +0100 Subject: add group searcher dont work for now --- src/components/GroupMaker.vue | 22 ++++++++++++++++++- src/components/GroupView.vue | 47 +++++++++++++++++++++++++++++++++++++++++ src/components/Searcher.vue | 13 ++++++------ src/services/ChatService.js | 12 +++++++++++ src/services/CommandsService.js | 14 +++++++++++- src/views/Home.vue | 2 +- 6 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 src/components/GroupView.vue diff --git a/src/components/GroupMaker.vue b/src/components/GroupMaker.vue index 59f83fd..f3da293 100644 --- a/src/components/GroupMaker.vue +++ b/src/components/GroupMaker.vue @@ -49,11 +49,15 @@ export default { "users": this.users_selection }) - if(status === 201) + if(status === 201) { this.$notify({ type: "success", text: "Group created!" }) + + this.close() + } + }, async set_users() { @@ -77,3 +81,19 @@ export default { } } + + diff --git a/src/components/GroupView.vue b/src/components/GroupView.vue new file mode 100644 index 0000000..1608cf4 --- /dev/null +++ b/src/components/GroupView.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/components/Searcher.vue b/src/components/Searcher.vue index 8488fd4..a1093a2 100644 --- a/src/components/Searcher.vue +++ b/src/components/Searcher.vue @@ -61,9 +61,10 @@ export default { else this.current = this.sugestions[0] }, - execute_current() { - let out = this.current[1](this) - + async execute_current() { + let out = await this.current[1](this) + + console.log(out) if(out instanceof Object) { this.search = '' this.commands = out @@ -71,25 +72,23 @@ export default { }, hotkeys(e) { + e.preventDefault() + switch(e.code) { case 'Escape': this.close() break case 'ArrowDown': - e.preventDefault() this.change_current(1) break case 'ArrowUp': - e.preventDefault() this.change_current(-1) break case 'Tab': - e.preventDefault() this.change_current(1) break case 'Enter': this.execute_current() - e.preventDefault() break case 'ShiftLeft': this.commands = CommandsService diff --git a/src/services/ChatService.js b/src/services/ChatService.js index ab1e6c2..08deba2 100644 --- a/src/services/ChatService.js +++ b/src/services/ChatService.js @@ -13,5 +13,17 @@ export default { } }) .catch(error => error_notify(error)) + }, + + async get_all_user_groups() { + return await axios + .get(url+'groups/') + .then(res => { + return { + status: res.status, + data: res.data + } + }) + .catch(error => error_notify(error)) } } diff --git a/src/services/CommandsService.js b/src/services/CommandsService.js index 01a758e..e21c8f7 100644 --- a/src/services/CommandsService.js +++ b/src/services/CommandsService.js @@ -1,11 +1,23 @@ import AuthService from "./AuthService" +import ChatService from "./ChatService" import store from "@/store/index.js" import router from '@/router/index.js' +function set_groups(data) { + return {[data.name.replace(" ", "_")]() {console.log(data.name)}} +} + export default { groups() { return { - send(searcher) {console.log(searcher)}, + async send() { + const {data, status} = await ChatService.get_all_user_groups() + if (status!==200) + return {} + const test1 = set_groups(data[0]) + const test2 = set_groups(data[0]) + return {test1, test2} + }, make(searcher) { searcher.$emit('toogle_group_maker') diff --git a/src/views/Home.vue b/src/views/Home.vue index abf6fc8..5355520 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -38,7 +38,7 @@ export default { }, toogleSearcherShow() { this.popups.searcher_show = !this.popups.searcher_show }, - hideSearcher() { this.popups.searcher_show = false }, + hideSearcher() { this.popups.searcher_show = true }, toogleGroupShow() { this.popups.group_maker_show = !this.popups.group_maker_show }, hideGroup() { this.popups.group_maker_show = false } -- cgit v1.2.3