From bdd0b9cfd0bf61a4272954ec4e8943013358995a Mon Sep 17 00:00:00 2001 From: Tobias Kurze Date: Tue, 11 Aug 2020 16:41:40 +0200 Subject: [PATCH] imporvements of recorders and room views, also changed API URL -> but still buggy --- src/api/Repository.js | 3 +- src/api/index.ts | 2 +- src/components/Recorders.vue | 56 ++++++++++++++++++++++++++++++------ src/components/Rooms.vue | 53 +++++++++++++++++++++++++++++----- src/main.ts | 7 +++++ 5 files changed, 103 insertions(+), 18 deletions(-) diff --git a/src/api/Repository.js b/src/api/Repository.js index c44b289..234a26f 100644 --- a/src/api/Repository.js +++ b/src/api/Repository.js @@ -4,7 +4,8 @@ import Vue from "vue"; import axios from "axios"; import store from "@/store"; -const baseDomain = "http://localhost:5443"; +//const baseDomain = "http://localhost:5443"; +const baseDomain = ""; const API_URL = `${baseDomain}/api/v1`; const api = axios.create({ diff --git a/src/api/index.ts b/src/api/index.ts index b6e563b..38eb7a7 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,7 +1,7 @@ import Vue from 'vue'; import axios from 'axios'; -const API_URL = 'http://localhost:5443/api'; +import { API_URL } from '@/main.ts' export function fetchSurveys() { return axios.get(`${API_URL}/surveys/`); diff --git a/src/components/Recorders.vue b/src/components/Recorders.vue index f29faf2..467192b 100644 --- a/src/components/Recorders.vue +++ b/src/components/Recorders.vue @@ -18,16 +18,29 @@ {{$t('Recorders')}} {{$t('list')}}
- - {{$t('All recorders')}} - {{$t('Offline recorders')}} - {{$t('Non offline recorders')}} - + + + {{$t('All recorders')}} + {{$t('Offline recorders')}} + {{$t('Non offline recorders')}} + + + + Clear Filter + +

{{ $tc('recorders_defined', recorders.length, {num: recorders.length})}}:

+
- - {{ $t('All rooms') }} - {{ $t('Rooms with recorders') }} - {{ $t('Rooms without recorders') }} - - + + + {{ $t('All rooms') }} + {{ $t('Rooms with recorders') }} + {{ $t('Rooms without recorders') }} + + + + + Clear Filter + + +

{{ $tc('rooms_defined', rooms.length, {num: rooms.length}) }}:

+ -
{{ $t('name') }}:  @@ -384,9 +398,12 @@ export default { onlyShowRoomsWithRecorder: false, onlyShowRoomsWithoutRecorder: false, tabIndex: 0, + filter: '', updateValues: {}, formEditField: {}, show_assigned_recorders: false, + currentPage: 1, + elementsPerPage: 30, form: { name: null, alternate_name: null, @@ -397,6 +414,17 @@ export default { }; }, methods: { + get_rows() { + const start = (this.currentPage - 1) * this.elementsPerPage; + const end = start + this.elementsPerPage; + return this.rooms.slice(start, end); + }, + num_pages() { + return Math.ceil(this.rooms.length / this.elementsPerPage); + }, + change_page(page) { + this.currentPage = page; + }, showAllRooms() { this.onlyShowRoomsWithRecorder = false; this.onlyShowRoomsWithoutRecorder = false; @@ -478,13 +506,24 @@ export default { rooms() { if (this.onlyShowRoomsWithRecorder) { return this.$store.state.rooms.filter((item) => { + if(this.filter !== '') { + return (item.name.includes(this.filter) || item.building_name != null && item.building_name.includes(this.filter)) && item.recorder; + } return item.recorder; }); } else if (this.onlyShowRoomsWithoutRecorder) { return this.$store.state.rooms.filter((item) => { + if(this.filter !== '') { + return (item.name.includes(this.filter) || item.building_name != null && item.building_name.includes(this.filter)) && !item.recorder; + } return !item.recorder; }); } + if(this.filter !== ''){ + return this.$store.state.rooms.filter((item)=>{ + return (item.name.includes(this.filter) || item.building_name != null && item.building_name.includes(this.filter)); + }) + } return this.$store.state.rooms; }, recorders() { diff --git a/src/main.ts b/src/main.ts index 7bd7831..b3a821c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -120,6 +120,13 @@ localize('de', de); Vue.component('ValidationObserver', ValidationObserver); Vue.component('ValidationProvider', ValidationProvider); +//const API_URL = 'http://localhost:5443/api'; +//const baseDomain = "http://localhost:5443"; +const baseDomain = ""; +export const API_URL = `${baseDomain}/api`; +export const API_V1_URL = `${baseDomain}/api/v1`; + + // const socket = io('ws://localhost:5000',{autoConnect: false, reconnectionAttempts: 3}); const socket = io('ws://localhost:5443', { autoConnect: false,