From bbed144517735c8a260a01871386552c4c23bac3 Mon Sep 17 00:00:00 2001 From: iriska-gri <79623434+iriska-gri@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:28:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/front/src/components/UI/date-select.vue | 61 +++++++++++++++ src/front/src/views/AboutPortalPage.vue | 82 +++++++++------------ src/watcher/views.py | 2 +- 3 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 src/front/src/components/UI/date-select.vue diff --git a/src/front/src/components/UI/date-select.vue b/src/front/src/components/UI/date-select.vue new file mode 100644 index 000000000..b497ec442 --- /dev/null +++ b/src/front/src/components/UI/date-select.vue @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue index 09b661050..d13eb5acf 100644 --- a/src/front/src/views/AboutPortalPage.vue +++ b/src/front/src/views/AboutPortalPage.vue @@ -89,35 +89,16 @@ - - - - - - - - + + + + @@ -134,12 +115,14 @@ import moment from 'moment' import lineGraph from '@/components/graph/line-graph.vue' import { axiosApiInstance } from '@/utils/axios-api' import Feedmodul from '@/components/UI/aboutportal/feedmodul.vue' +import DateSelect from '@/components/UI/date-select.vue' export default { components: { lineGraph, - Feedmodul }, + Feedmodul, + DateSelect }, setup(){ @@ -147,10 +130,8 @@ setup(){ const feedback = ref([]) const countvising = ref({now: 0, week: 0, year: 0}) const crit = ref([]) - const menudate = ref(false) - const selectedDateStart = ref(null) const startdate =ref(moment(new Date(new Date().getFullYear(), 0, 1)).format('YYYY-MM-DD')) - + const endate =ref(moment(new Date(new Date().getFullYear(), 11, 31)).format('YYYY-MM-DD')) const arrlines = {} @@ -232,10 +213,23 @@ setup(){ }), ), ); + + + const returnstart = (dates) => { + startdate.value = dates + visition() + } + + const returnend = (dates) => { + endate.value = dates + visition() + } const visition = () => { + // ${startdate.value} - axiosApiInstance.get(`api/watcher/counter/?start=${startdate.value}`).then(result => { + + axiosApiInstance.get(`api/watcher/counter/?start=${startdate.value}&end=${endate.value}`).then(result => { visiting.value = result.data.result feedback.value = result.data.feedback @@ -359,13 +353,7 @@ setup(){ visition() - const dateStart = () => { - startdate.value = moment(selectedDateStart.value).format('YYYY-MM-DD') - visition() - let d = new Date(new Date().getFullYear(), 0, 1) - console.log( moment(new Date(new Date().getFullYear(), 0, 1)).format('YYYY-MM-DD'), '222222222222222222222222222'); - menudate.value=false - } + return { visiting, @@ -376,13 +364,11 @@ setup(){ feedback, countvising, crit, - menudate, - selectedDateStart, - dateStart - - - - + visition, + returnstart, + returnend, + endate, + startdate } } diff --git a/src/watcher/views.py b/src/watcher/views.py index c3a4d2dd3..6990bcc6f 100644 --- a/src/watcher/views.py +++ b/src/watcher/views.py @@ -21,7 +21,7 @@ class Counter(ListAPIView): def get(self, request): print(request.GET.get("start"), '-----------------------') - res = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), '2024-12-31']).annotate(Sum('count')) + res = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")]).annotate(Sum('count')) result = CountSerializer(res, many=True).data # Обратная связь