Dashboard Plugin

The Dashboard plugin provides a flexible and extensible dashboard system for creating customizable user interfaces with various widget types. It allows users to create, manage, and customize their own dashboards with different types of widgets.

Features

  • Create and manage multiple dashboards
  • Support for various widget types:
  • Data Grid Store (DGS) widgets
  • Chart widgets (bar, line, pie, etc.)
  • Custom widgets with filters
  • Detailed widgets
  • Drag-and-drop widget layout
  • Widget refresh functionality
  • Permission-based widget access
  • Customizable widget filters
  • Responsive design

Widget Types

1. Data Grid Store (DGS) Widgets

DGS widgets are used to display tabular data with sorting, filtering, and pagination capabilities.

<?php

namespace plugin\Plugin\widgets\WidgetClass;

class WidgetClass extends DataGridStoreWidget
{
    public const IDENT = 'widget_ident';

    /**
     * @return IStore
     */
    protected function getStore(): IStore
    {
        return new Store();
    }
}

2. Chart Widgets

Chart widgets provide visualization capabilities using various chart types:

<?php

class ChartWidget extends AbstractWidget implements IChartWidget
{
    protected function loadData(): void
    {
        // Load your data here
    }

    protected function getLabels(): array
    {
        return ['Label 1', 'Label 2'];
    }

    protected function getDatasets(): array
    {
        return [
            [
                'label' => 'Dataset 1',
                'data' => [10, 20]
            ]
        ];
    }
}

Supported chart types: - Bar charts - Line charts - Pie charts - Doughnut charts - Radar charts - Polar area charts - Bubble charts - Scatter charts

3. Filtered Widgets

Widgets can implement filters for data filtering:

<?php

class FilteredWidget extends AbstractWidget implements IDashboardWidgetFilters
{
    public function getFilterFields(): array
    {
        return [
            new WidgetFilterValuesObject('filter_name', 'Filter Label', 'text')
        ];
    }
}

Database Setup

To add a new widget to the system, you need to create a database entry:

INSERT INTO dashboard_widgets(title, name, ident, section_ident)
VALUES ('Widget', 'Plugin Widget', 'widget', 'dashboard_widget_widget');

Optional: add section to widget

INSERT INTO festi_sections (caption, ident, mask)
VALUES ('Dashboard Widget: Widget', 'dashboard_widget_widget', '6');

Widget Implementation

Basic Widget Structure

All widgets must implement the IDashboardWidget interface:

interface IDashboardWidget
{
    public const IDENT = '';

    public function getDashboardValuesObject(): DashboardValuesObject;
    public function getDashboardWidgetValuesObject(): DashboardWidgetValuesObject;
    public function getBlock(): IStore|IDisplayStoreAction|string|callable;
    public function getIndex(): int;
    public function isRefresh(): bool;
    public function getBlockType(): string;
    public function getCSS(): array;
    public function getAttributes(): array;
}

Widget Options

Common widget options:

  • OPTION_INDEX: Widget position index
  • OPTION_REFRESH: Enable/disable refresh functionality
  • OPTION_BLOCK_TYPE: Type of content block
  • OPTION_PER_PAGE: Items per page (for DGS widgets)
  • OPTION_CHART_TYPE: Chart visualization type

Usage Examples

Creating a Dashboard

$dashboardPlugin = Core::getInstance()->getPluginInstance('Dashboard');
$dashboard = new DashboardValuesObject([
    'id_user' => $userId,
    'title' => 'My Dashboard'
]);
$dashboardId = $dashboardPlugin->createDashboard($dashboard);

Adding a Widget to Dashboard

$widget = new DashboardWidgetValuesObject([
    'title' => 'My Widget',
    'className' => 'MyWidgetClass'
]);
$widgetId = $dashboardPlugin->createDashboardWidget($dashboardId, $widget);

Removing a Widget

$dashboardPlugin->removeWidget($dashboardId, $widgetId);