diff options
Diffstat (limited to 'src/components/group')
| -rw-r--r-- | src/components/group/GroupMaker.vue | 99 | ||||
| -rw-r--r-- | src/components/group/GroupView.vue | 47 |
2 files changed, 146 insertions, 0 deletions
diff --git a/src/components/group/GroupMaker.vue b/src/components/group/GroupMaker.vue new file mode 100644 index 0000000..f3da293 --- /dev/null +++ b/src/components/group/GroupMaker.vue | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | <template> | ||
| 2 | <div class="group_maker"> | ||
| 3 | Group maker | ||
| 4 | <form @submit="make_group"> | ||
| 5 | <input | ||
| 6 | v-model="group_name" | ||
| 7 | ref='input' | ||
| 8 | type="text" | ||
| 9 | placeholder="Type group name..." | ||
| 10 | /> | ||
| 11 | |||
| 12 | <select multiple v-model="users_selection"> | ||
| 13 | |||
| 14 | <option | ||
| 15 | v-for="user in users" | ||
| 16 | :key="user.id" | ||
| 17 | :value="user.id"> | ||
| 18 | {{user.username}} | ||
| 19 | </option> | ||
| 20 | |||
| 21 | </select> | ||
| 22 | </form> | ||
| 23 | </div> | ||
| 24 | </template> | ||
| 25 | |||
| 26 | <script> | ||
| 27 | import ChatService from "@/services/ChatService.js" | ||
| 28 | import AuthService from "@/services/AuthService.js" | ||
| 29 | |||
| 30 | export default { | ||
| 31 | data() { | ||
| 32 | return { | ||
| 33 | group_name: "", | ||
| 34 | users_selection: [], | ||
| 35 | users: [] | ||
| 36 | } | ||
| 37 | }, | ||
| 38 | |||
| 39 | methods: { | ||
| 40 | close() { | ||
| 41 | this.$emit('close') | ||
| 42 | }, | ||
| 43 | |||
| 44 | async make_group(e) { | ||
| 45 | e.preventDefault() | ||
| 46 | console.log(this.users_selection) | ||
| 47 | const {status} = await ChatService.group_create({ | ||
| 48 | "name": this.group_name, | ||
| 49 | "users": this.users_selection | ||
| 50 | }) | ||
| 51 | |||
| 52 | if(status === 201) { | ||
| 53 | this.$notify({ | ||
| 54 | type: "success", | ||
| 55 | text: "Group created!" | ||
| 56 | }) | ||
| 57 | |||
| 58 | this.close() | ||
| 59 | } | ||
| 60 | |||
| 61 | }, | ||
| 62 | |||
| 63 | async set_users() { | ||
| 64 | const {status, data} = await AuthService.info("all=true") | ||
| 65 | |||
| 66 | if(status === 200) | ||
| 67 | this.users = data.users | ||
| 68 | else | ||
| 69 | this.close() | ||
| 70 | |||
| 71 | console.log(this.users) | ||
| 72 | } | ||
| 73 | }, | ||
| 74 | |||
| 75 | created() { | ||
| 76 | this.$nextTick(function () { | ||
| 77 | this.$refs.input.focus() | ||
| 78 | |||
| 79 | this.set_users() | ||
| 80 | }) | ||
| 81 | } | ||
| 82 | } | ||
| 83 | </script> | ||
| 84 | |||
| 85 | <style scoped> | ||
| 86 | |||
| 87 | .group_maker { | ||
| 88 | position: absolute; | ||
| 89 | width: 30%; | ||
| 90 | height: 80%; | ||
| 91 | top: 50%; | ||
| 92 | left: 50%; | ||
| 93 | background-color: #202020; | ||
| 94 | padding: 20px; | ||
| 95 | border-radius: 10px; | ||
| 96 | transform: translate(-50%, -50%); | ||
| 97 | } | ||
| 98 | |||
| 99 | </style> | ||
diff --git a/src/components/group/GroupView.vue b/src/components/group/GroupView.vue new file mode 100644 index 0000000..1608cf4 --- /dev/null +++ b/src/components/group/GroupView.vue | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | <template> | ||
| 2 | <div class="group_view"> | ||
| 3 | Group maker | ||
| 4 | <form @submit="send_message"> | ||
| 5 | <inout type="text" ref="input" /> | ||
| 6 | </form> | ||
| 7 | </div> | ||
| 8 | </template> | ||
| 9 | |||
| 10 | <script> | ||
| 11 | import ChatService from "@/services/ChatService.js" | ||
| 12 | |||
| 13 | export default { | ||
| 14 | data() { | ||
| 15 | return { | ||
| 16 | } | ||
| 17 | }, | ||
| 18 | |||
| 19 | methods: { | ||
| 20 | close() { | ||
| 21 | this.$emit('close') | ||
| 22 | }, | ||
| 23 | }, | ||
| 24 | |||
| 25 | created() { | ||
| 26 | this.$nextTick(function () { | ||
| 27 | this.$refs.input.focus() | ||
| 28 | }) | ||
| 29 | } | ||
| 30 | } | ||
| 31 | </script> | ||
| 32 | |||
| 33 | <style scoped> | ||
| 34 | |||
| 35 | .group_view { | ||
| 36 | position: absolute; | ||
| 37 | width: 30%; | ||
| 38 | height: 80%; | ||
| 39 | top: 50%; | ||
| 40 | left: 50%; | ||
| 41 | background-color: #202020; | ||
| 42 | padding: 20px; | ||
| 43 | border-radius: 10px; | ||
| 44 | transform: translate(-50%, -50%); | ||
| 45 | } | ||
| 46 | |||
| 47 | </style> | ||
