From c1c9562e6747791053fbbca57c6d76c1efa58ff1 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Tue, 16 May 2023 10:28:22 +0200 Subject: [PATCH] =?UTF-8?q?finalisation=20pr=C3=A9sentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DashboardHomepageController.php | 12 ++++- .../public/vuejs/HomepageWidget/MyWidget.vue | 53 +++++++++++++++---- .../Widget/Widgets/WidgetNumber.php | 4 +- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/DashboardHomepageController.php b/src/Bundle/ChillMainBundle/Controller/DashboardHomepageController.php index da5110efb..ae37faf41 100644 --- a/src/Bundle/ChillMainBundle/Controller/DashboardHomepageController.php +++ b/src/Bundle/ChillMainBundle/Controller/DashboardHomepageController.php @@ -85,7 +85,7 @@ class DashboardHomepageController extends AbstractController{ if (!$this->security->getUser() instanceof User) { throw new AccessDeniedHttpException('You must be authenticated and a user to see the dashboard'); } - + // --------------Bar--------------------- $config = [ 'alias' => 'bar', ]; @@ -96,6 +96,16 @@ class DashboardHomepageController extends AbstractController{ 'user' => 19, 'what' => 'accompanying_period_by_month', ]; + // --------------Number------------------ + /*$config = [ + 'alias' => 'number', + ]; + + $context = [ + 'user' => $this->security->getUser(), + //'what' => 'notification_unread', + 'what' => 'notification_sender', + ];*/ $data = $this->widgetHandlerManager->getDataForWidget($config, $context); return new JsonResponse($data,Response::HTTP_OK,[]); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyWidget.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyWidget.vue index 0c025cdbf..3edfbfb50 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyWidget.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyWidget.vue @@ -1,7 +1,7 @@ @@ -15,7 +15,7 @@ import { CategoryScale, LinearScale } from 'chart.js' -import { Bar } from 'vue-chartjs' +import {Bar} from 'vue-chartjs' import {defineComponent} from 'vue' import {makeFetch} from "../../lib/api/apiMethods"; @@ -36,23 +36,56 @@ export default defineComponent({ } }, async mounted() { - this.loaded_bar=false; - this.loaded_number=false; + this.loaded_bar = false; + this.loaded_number = false; const url = '/fr/dashboard/raw_data'; try { - const response: { data: any, options: any, type: any} = await makeFetch("GET", url); + const response: { data: any, options: any, type: any } = await makeFetch("GET", url); this.chartData = response.data; this.chartOptions = response.options; - if(response.type == 'bar'){ + if (response.type == 'bar') { this.loaded_bar = true; - } - else { + } else { this.loaded_number = true - this.number = response.data.datasets[0].data[0]; + this.number = response.data.datasets[0].data[0] + " "+ response.data.labels[0]; } } catch (error) { console.log(error); } - } + }, + /*methods: { + async makeNumberWidget() { + let body = { + config: { + alias: 'number' + }, + context: { + what: 'notification_unread', + user: 19 //Ne rien mettre ou via les refs + } + }; + try { + const response: { + data: any, + options: any, + type: any + } = await makeFetch('POST', '/{_locale}//{_locale}/dashboard/widget/number', body) + this.chartData = response.data; + this.chartOptions = response.options; + this.loaded_number = true; + this.number = response.data.datasets[0].data[0] + response.data.labels[0]; + } catch (error) { + console.log(error) + } + + + }, + }*/ }) + diff --git a/src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php b/src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php index 1ee41df67..ad2f1566e 100644 --- a/src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php +++ b/src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php @@ -70,7 +70,7 @@ class WidgetNumber implements WidgetHandlerInterface //Count the number of notification the sender send $countSend = $this->notificationRepository->countAllForSender($user); $dataForWidget = [ - 'labels' => ['Notification Send'], + 'labels' => ['notification(s) envoyée(s)'], 'datasets' => [ [ 'backgroundColor' => ['#41B883'], @@ -84,7 +84,7 @@ class WidgetNumber implements WidgetHandlerInterface //Count the number of unread notification by the current User $countUnread = $this->notificationRepository->countUnreadByUser($user); $dataForWidget = [ - 'labels' => ['Notification Unread'], + 'labels' => ['notification(s) non lue(s)'], 'datasets' => [ [ 'backgroundColor' => ['#41B883'],