summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2021-11-19 09:57:58 +0100
committerjdlugosz963 <jdlugosz963@gmail.com>2021-11-19 09:57:58 +0100
commit10abd20260050174dd508038f0b95c5f8f740933 (patch)
treedfad854c6f510873ae3c12f21457fea1b0c9d72f
parent7f2f1e63826c0acb4514edfb1fbf7a884893f8c4 (diff)
downloadlom_frontend-10abd20260050174dd508038f0b95c5f8f740933.tar.gz
lom_frontend-10abd20260050174dd508038f0b95c5f8f740933.zip
fix bugs
-rw-r--r--src/components/Searcher.vue18
-rw-r--r--src/services/AuthService.js12
-rw-r--r--src/services/CommandsService.js32
-rw-r--r--src/store/index.js1
4 files changed, 42 insertions, 21 deletions
diff --git a/src/components/Searcher.vue b/src/components/Searcher.vue
index 4a252a0..43dd7bd 100644
--- a/src/components/Searcher.vue
+++ b/src/components/Searcher.vue
@@ -1,6 +1,14 @@
1<template> 1<template>
2 <div id="searcher"> 2 <div id="searcher">
3 <input type="text" v-model='search' ref='input' @keydown="hotkeys" placeholder="Search!"> 3 <input
4 type="text"
5 v-model='search'
6 ref='input'
7 @keydown="hotkeys"
8 @blur="close()"
9 placeholder="Search!"
10 />
11
4 <Sugestion 12 <Sugestion
5 v-for="sugestion in sugestions" 13 v-for="sugestion in sugestions"
6 :key="sugestion[0]" 14 :key="sugestion[0]"
@@ -41,6 +49,10 @@ export default {
41 this.sugestions = sugestions 49 this.sugestions = sugestions
42 }, 50 },
43 51
52 close() {
53 this.$emit('close')
54 },
55
44 change_current(a=1) { 56 change_current(a=1) {
45 let index = this.sugestions.findIndex(element => element===this.current) 57 let index = this.sugestions.findIndex(element => element===this.current)
46 let new_current = this.sugestions[index+a] 58 let new_current = this.sugestions[index+a]
@@ -61,8 +73,8 @@ export default {
61 hotkeys(e) { 73 hotkeys(e) {
62 switch(e.code) { 74 switch(e.code) {
63 case 'Escape': 75 case 'Escape':
64 this.$emit('close') 76 this.close()
65 break 77 break
66 case 'ArrowDown': 78 case 'ArrowDown':
67 e.preventDefault() 79 e.preventDefault()
68 this.change_current(1) 80 this.change_current(1)
diff --git a/src/services/AuthService.js b/src/services/AuthService.js
index ff1e468..758157c 100644
--- a/src/services/AuthService.js
+++ b/src/services/AuthService.js
@@ -5,6 +5,7 @@ const url = 'http://localhost:8000/api/auth/'
5 5
6const error_notify = (error) => { 6const error_notify = (error) => {
7 for (const [key, values] of Object.entries(error.response.data)) { 7 for (const [key, values] of Object.entries(error.response.data)) {
8 console.log(values)
8 values.forEach(value => { 9 values.forEach(value => {
9 Vue.notify({ 10 Vue.notify({
10 type: 'error', 11 type: 'error',
@@ -43,5 +44,16 @@ export default {
43 }) 44 })
44 .catch(error => error_notify(error)) 45 .catch(error => error_notify(error))
45 46
47 },
48
49 async logout() {
50 return await axios
51 .post(url+'logout/')
52 .then(res => {
53 return {
54 status: res.status
55 }
56 })
57 .catch(error => error_notify(error))
46 } 58 }
47} \ No newline at end of file 59} \ No newline at end of file
diff --git a/src/services/CommandsService.js b/src/services/CommandsService.js
index 1248c6d..f8a815f 100644
--- a/src/services/CommandsService.js
+++ b/src/services/CommandsService.js
@@ -1,24 +1,20 @@
1import AuthService from "./AuthService"
2import store from "@/store/index.js"
3import router from '@/router/index.js'
4
1export default { 5export default {
2 logout() { 6 logout() {
3 console.log("logout :)") 7 AuthService.logout()
8 store.dispatch('logout')
9 router.push('/login')
4 }, 10 },
5 last_message() { 11 friends() {
6 console.log("last massege") 12 console.log("list")
7 }, 13 },
8 chat() { 14 tab() {
9 return { 15 return {
10 search() {console.log("search")}, 16 on() {},
11 add() {console.log("add friend")}, 17 off() {}
12 next_tab() { 18 }
13 return { 19 }
14 hi_in_next_tab() {
15 console.log('Hello there! :)')
16 }
17 }
18 }
19 }
20 },
21 notifications() {},
22 users() {},
23 groups() {}
24} 20}
diff --git a/src/store/index.js b/src/store/index.js
index fa8a1bd..02e3efa 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -41,6 +41,7 @@ const store = new Vuex.Store({
41 }, 41 },
42 logout: ({commit}) => { 42 logout: ({commit}) => {
43 commit('reset_state') 43 commit('reset_state')
44 Axios.defaults.headers.common['Authorization'] = null;
44 } 45 }
45 } 46 }
46}) 47})