From 21bc43bb844328bb514383c219bfe55b4b3a2911 Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Fri, 7 Nov 2025 20:56:32 -0600 Subject: [PATCH] wip(Dashboard): grid widgets --- assets/bootstrap.js | 1 + .../dashboard_widgets_controller.js | 40 +++++++++++++++++++ importmap.php | 3 ++ .../Framework/Scheduler/MonitorDispatcher.php | 4 +- templates/base.html.twig | 9 ++++- templates/index/index.html.twig | 38 ++++++++++++------ 6 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 assets/controllers/dashboard_widgets_controller.js diff --git a/assets/bootstrap.js b/assets/bootstrap.js index 26a3bfa..bd4586f 100644 --- a/assets/bootstrap.js +++ b/assets/bootstrap.js @@ -10,6 +10,7 @@ import { startStimulusApp } from '@symfony/stimulus-bundle'; import Popover from '@stimulus-components/popover'; import Dialog from '@stimulus-components/dialog'; import Dropdown from '@stimulus-components/dropdown'; + import 'animate.css'; const app = startStimulusApp(); diff --git a/assets/controllers/dashboard_widgets_controller.js b/assets/controllers/dashboard_widgets_controller.js new file mode 100644 index 0000000..babf5e8 --- /dev/null +++ b/assets/controllers/dashboard_widgets_controller.js @@ -0,0 +1,40 @@ +import { Controller } from '@hotwired/stimulus'; +import {GridStack} from "../vendor/gridstack/gridstack.index.js"; + +/* +* The following line makes this controller "lazy": it won't be downloaded until needed +* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers +*/ + +/* stimulusFetch: 'lazy' */ +export default class extends Controller { + grid; + + initialize() { + + } + + connect() { + this.grid = GridStack.init({ + column: 2, + alwaysShowResizeHandle: true, + margin: "2rem", + resizable: { + handles: 'e,se,s,sw,w' + } + }); + + this.grid.load(); + } + + // Add custom controller actions here + // fooBar() { this.fooTarget.classList.toggle(this.bazClass) } + + disconnect() { + // Called anytime its element is disconnected from the DOM + // (on page change, when it's removed from or moved in the DOM, etc.) + + // Here you should remove all event listeners added in "connect()" + // this.fooTarget.removeEventListener('click', this._fooBar) + } +} diff --git a/importmap.php b/importmap.php index 83ec592..53f4acf 100644 --- a/importmap.php +++ b/importmap.php @@ -70,4 +70,7 @@ return [ '@ungap/custom-elements' => [ 'version' => '1.3.0', ], + 'gridstack' => [ + 'version' => '12.3.3', + ], ]; diff --git a/src/Monitor/Framework/Scheduler/MonitorDispatcher.php b/src/Monitor/Framework/Scheduler/MonitorDispatcher.php index b298542..4c0c00f 100644 --- a/src/Monitor/Framework/Scheduler/MonitorDispatcher.php +++ b/src/Monitor/Framework/Scheduler/MonitorDispatcher.php @@ -33,7 +33,9 @@ class MonitorDispatcher 'tvshows' => MonitorTvShowCommand::class, ]; - $monitors = $this->monitorRepository->findBy(['status' => ['New', 'Active']]); + $monitors = $this->monitorRepository->findBy([ + 'status' => ['New', 'Active'], + ]); foreach ($monitors as $monitor) { $monitor->setStatus('In Progress'); diff --git a/templates/base.html.twig b/templates/base.html.twig index 8253e29..2d8ee4f 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -11,7 +11,14 @@ {% endblock %} {% block javascripts %} - {% block importmap %}{{ importmap('app') }}{% endblock %} + {% block pre_js %}{% endblock %} + + {% block importmap %} + {{ importmap('app') }} + {% endblock %} + + {% block post_js %}{% endblock %} + {% endblock %} diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index 336ecd7..f9935fc 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -4,20 +4,31 @@ {% block h2 %}Dashboard{% endblock %} {% block body %} -
-
- - - +
+
+
+
+ + + +
+
- - - -
-
- - - +
+
+ + + +
+
+ +
+
+ + + +
+
@@ -45,5 +56,6 @@ {% endfor %}
+
{% endblock %}