diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Searcher.vue | 18 | ||||
| -rw-r--r-- | src/services/AuthService.js | 12 | ||||
| -rw-r--r-- | src/services/CommandsService.js | 32 | ||||
| -rw-r--r-- | src/store/index.js | 1 |
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 | ||
| 6 | const error_notify = (error) => { | 6 | const 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 @@ | |||
| 1 | import AuthService from "./AuthService" | ||
| 2 | import store from "@/store/index.js" | ||
| 3 | import router from '@/router/index.js' | ||
| 4 | |||
| 1 | export default { | 5 | export 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 | }) |
