diff --git a/typo3/sysext/dashboard/Documentation/Configuration/Index.rst b/typo3/sysext/dashboard/Documentation/Configuration/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..c4576196329fbde0e767d4b28208bd2a70099ba1 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/Index.rst @@ -0,0 +1,19 @@ +.. include:: ../Includes.txt + +.. _configuration: + +============= +Configuration +============= + +Target group: **Developers** and **Integrators** + +.. toctree:: + :maxdepth: 3 + :titlesonly: + + WidgetRegistration + WidgetGroupCreation + WidgetSettings + WidgetTemplate + PermissionHandlingOfWidgets diff --git a/typo3/sysext/dashboard/Documentation/Configuration/PermissionHandlingOfWidgets.rst b/typo3/sysext/dashboard/Documentation/Configuration/PermissionHandlingOfWidgets.rst new file mode 100644 index 0000000000000000000000000000000000000000..9cab3fea65722753621a220a386f822bd387d7e4 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/PermissionHandlingOfWidgets.rst @@ -0,0 +1,17 @@ +.. include:: ../Includes.txt + +.. _permission-handling-of-widgets: + +====================== +Permissions of widgets +====================== + +Backend users marked as administrator have always access to all registered widgets. + +Other backend users can be restricted via :guilabel:`Access List > Dashboard widgets` inside of user groups. +Each widget needs to be explicitly allowed. + +.. figure:: /Images/AccessRestriction.png + :align: center + + Granting access to dashboard widgets for backend users. diff --git a/typo3/sysext/dashboard/Documentation/Configuration/WidgetGroupCreation.rst b/typo3/sysext/dashboard/Documentation/Configuration/WidgetGroupCreation.rst new file mode 100644 index 0000000000000000000000000000000000000000..970f4d5621d08dbfbca087398ce551a9871f66e6 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/WidgetGroupCreation.rst @@ -0,0 +1,44 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _create-widget-group: + +=================== +Create widget group +=================== + +Widget groups are used to group widgets into tabs. +This will have an effect when adding new widgets to an dashboard. +See :ref:`adding-widgets` to get an idea of the UI. + +Groups are defines as PHP array in :file:`Configuration/Backend/DashboardWidgetGroups.php`:: + + <?php + + return [ + 'general' => [ + 'title' => 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widget_group.general', + ], + 'systemInfo' => [ + 'title' => 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widget_group.system', + ], + 'typo3' => [ + 'title' => 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widget_group.typo3', + ], + 'news' => [ + 'title' => 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widget_group.news', + ], + 'documentation' => [ + 'title' => 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widget_group.documentation', + ], + ]; + +The file has to return an array of groups. +Each group consists of an array key used as identifier and an single option :php:`title`. +The title will be processed through translation and can be an ``LLL`` reference. + +Each extension can create arbitrary widget groups. + +Widgets can be assigned to multiple groups using the :option:`groupNames`. +Please read :ref:`register-new-widget` to understand how this is done. diff --git a/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst b/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst new file mode 100644 index 0000000000000000000000000000000000000000..a2bfc80ae752bb92f006354f17fbbc50225eb597 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst @@ -0,0 +1,224 @@ +.. include:: ../Includes.txt + +Widgets need to be provided by an extension, e.g. by ext:dashboard. +They are provided as a PHP class with specific feature sets. +Each of the widgets can be registered with different configurations as documented below. + +.. include:: /Shared/DifferenceRegistrationAndImplementation.rst.txt + +The below example will use the RSS Widget as an concrete example. + +.. _register-new-widget: + +=================== +Register new Widget +=================== + +Registration happens through :ref:`Dependency Injection <t3coreapi:DependencyInjection>` +either in :file:`Services.yaml` or :file:`Services.php`. +Both files can exist and will be merged. + +:file:`Services.yaml` is recommended and easier to write, +while :file:`Services.php` provide way more flexibility. + +Naming widgets +-------------- + +Widgets receive a name in form of ``dashboard.widget.vendor.ext_key.widgetName``. + +``vendor`` + Should be a snaked version of composer vendor. + +``ext_key`` + Should be the extension key. + +This prevents naming conflicts if multiple 3rd Party extensions are installed. + +Services.yaml File +------------------ + +In order to turn the PHP class :php:`\TYPO3\CMS\Dashboard\Widgets\RssWidget` into an actual widget, +the following service registration can be used inside of :file:`Configuration/Services.yaml`:: + + services: + _defaults: + autowire: true + autoconfigure: true + public: false + + TYPO3\CMS\Dashboard\: + resource: '../Classes/*' + + dashboard.widget.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget' + arguments: + $view: '@dashboard.views.widget' + $buttonProvider: '@dashboard.buttons.t3news' + $cache: '@cache.dashboard.rss' + $options: + feedUrl: 'https://www.typo3.org/rss' + tags: + - name: dashboard.widget + identifier: 't3news' + groupNames: 'news' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.description' + iconIdentifier: 'content-widget-rss' + height: 'large' + width: 'medium' + +The beginning of the file is not related to the widget itself, but dependency injection in general, +see: :ref:`t3coreapi:configure-dependency-injection-in-extensions`. + +Service configuration +""""""""""""""""""""" + +The last block configured a service called :yaml:`dashboard.widget.t3news`. + +This service is configured to use the existing PHP class :php:`TYPO3\CMS\Dashboard\Widgets\RssWidget`. +When creating the instance of this class, an array is provided for the constructor argument :php:`$options`. +This way the same PHP class can be used with different configuration to create new widgets. + +The following keys are defined for the service: + +.. option:: class + + In example: :php:`TYPO3\CMS\Dashboard\Widgets\RssWidget`. + + Defines concrete PHP class to use as implementation. + +.. option:: arguments + + Highly depending on the used widget. + Each widget can define custom arguments, which should be documented. + + Documentation for provided widgets is available at :ref:`widgets`. + +.. option:: tags + + Registers the service as an actual widget for ext:dashboard. + See :ref:`register-new-widget-tags-section`. + +.. _register-new-widget-tags-section: + +Tags Section +"""""""""""" + +In order to turn the instance into a widget, the tag ``dashboard.widget`` is configured in `tags` section. +The following options are mandatory and need to be provided: + +.. option:: name + + Always has to be ``dashboard.widget``. + Defines that this tag configured the service to be registered as a widget for + ext:dashboard. + +.. option:: identifier + + In example: ``t3news``. + + Used to store which widgets are currently assigned to dashboards. + Furthermore used to allow access control, see :ref:`permission-handling-of-widgets`. + +.. option:: groupNames + + In example: ``news``. + + Defines which groups should contain the widget. + Used when adding widgets to a dashboard to group related widgets in tabs. + Multiple names can be defined as comma separated string, e.g.: ``typo3, general``. + + See :ref:`create-widget-group` regarding how to create new widget groups. + There is no difference between custom groups and existing groups. + Widgets are registered to all groups by their name. + +.. option:: title + + In example: ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.title``. + + Defines the title of the widget. Language references are resolved. + +.. option:: description + + In example: ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.description``. + + Defines the description of the widget. Language references are resolved. + +.. option:: iconIdentifier + + In example: ``content-widget-rss``. + + One of registered icons. + Icons can be registered through :ref:`t3coreapi:icon`. + +The following options are optional and have default values which will be used if not defined: + +.. option:: height + + In example: ``large``. + + Has to be an string value ``large``, ``medium`` or ``small``. + +.. option:: width + + In example ``medium``. + + Has to be an string value ``large``, ``medium`` or ``small``. + +.. option:: additionalCssClasses + + Will be added to the surrounding rendered markup. + Usually used when working with Graphs. + +Splitting up Services.yaml +-------------------------- + +In case the :file:`Services.yaml` is getting to large, it can be split up. +The official documentation can be found at `symfony.com <https://symfony.com/doc/current/service_container/import.html>`__. +An example to split up all Widget related configuration would look like: + +:file:`Configuration/Services.yaml`:: + + imports: + - { resource: Backend/DashboardWidgets.yaml } + +.. note:: + + Note that you have to repeat all necessary information, e.g. :yaml:`services:` section with :yaml:`_defaults:` again. + +:file:`Configuration/Backend/DashboardWidgets.yaml`:: + + services: + _defaults: + autowire: true + autoconfigure: true + public: false + + TYPO3\CMS\Dashboard\Widgets\: + resource: '../Classes/Widgets/*' + + dashboard.buttons.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider' + arguments: + $title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems' + $link: 'https://typo3.org/project/news' + $target: '_blank' + + dashboard.widget.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget' + arguments: + $view: '@dashboard.views.widget' + $buttonProvider: '@dashboard.buttons.t3news' + $cache: '@cache.dashboard.rss' + $options: + feedUrl: 'https://www.typo3.org/rss' + tags: + - name: dashboard.widget + identifier: 't3news' + groupNames: 'news' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.description' + iconIdentifier: 'content-widget-rss' + height: 'large' + width: 'medium' + diff --git a/typo3/sysext/dashboard/Documentation/Configuration/WidgetSettings.rst b/typo3/sysext/dashboard/Documentation/Configuration/WidgetSettings.rst new file mode 100644 index 0000000000000000000000000000000000000000..09ea909e2c6c6e083c35a8ff4a0ccb5094f37698 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/WidgetSettings.rst @@ -0,0 +1,29 @@ +.. include:: ../Includes.txt + +.. _adjust-settings-of-widget: + +===================================== +Adjust settings of registered widgets +===================================== + +Each widget is registered with an identifier, and all :file:`Services.*` files are merged. +Therefore it is possible to override widgets. +In order to override, the extension which should override has to be loaded after the extension that registered the widget. + +Concrete options depend on the widget to configure. +Each widget should provide an documentation covering all possible options and their meaning. +For delivered widgets by ext:dashboard see :ref:`widget`. + +In case an widget defined by ext:dashboard should be adjusted, +the extension has to define a dependency to ext:dashboard. + +Afterwards the widget can be registered again, with different options. See +:ref:`register-new-widget` to get an in depth example of how to register an widget. + +Why not adjust specific settings? +--------------------------------- + +There is no documented way to adjust specific settings, +as this would result in a situation where multiple extensions are loaded in different order +changing settings of widgets. +That would lead to an complex system. diff --git a/typo3/sysext/dashboard/Documentation/Configuration/WidgetTemplate.rst b/typo3/sysext/dashboard/Documentation/Configuration/WidgetTemplate.rst new file mode 100644 index 0000000000000000000000000000000000000000..a21e66142f9e5880dd57bcb78bbe64bba9b246c0 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Configuration/WidgetTemplate.rst @@ -0,0 +1,29 @@ +.. include:: ../Includes.txt + +.. _adjust-template-of-widget: + +========================== +Adjust template of widgets +========================== + +When adding own widgets, it might be necessary to provide custom templates. +In such a case the file path containing the template files needs to be added. +Thats done in the same way as for other Extbase backend modules: + +.. code-block:: typoscript + + module.tx_dashboard { + view { + templateRootPaths { + 110 = EXT:extension_key/Resources/Private/Templates/Dashboard/Widgets/ + } + } + } + +The location of that snippet depends on your setup and preferences. +Add it in database "Setup" ``config`` field of an "Template" ``sys_template`` record. +Or follow one of the other file based ways. See :ref:`t3sitepackage:typoscript-configuration`. + +.. note:: + + Keys ``0 - 100`` are reserved for TYPO3 system extension. diff --git a/typo3/sysext/dashboard/Documentation/Developer/AddingButtons.rst b/typo3/sysext/dashboard/Documentation/Developer/AddingButtons.rst new file mode 100644 index 0000000000000000000000000000000000000000..c13cf128674468c6022ed85ac1e01d08a1e93dc3 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Developer/AddingButtons.rst @@ -0,0 +1,100 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _adding-buttons: + +======================= +Adding button to Widget +======================= + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets + +In order to add a button to a widget, a new dependency to an :php:class:`ButtonProviderInterface` can be added. + +Template +-------- + +The output itself is done inside of the Fluid template, for example :file:`Resources/Private/Templates/Widget/RssWidget.html`: + +.. code-block:: html + + <f:if condition="{button}"> + <a href="{button.link}" target="{button.target}" class="widget-cta"> + {f:translate(id: button.title, default: button.title)} + </a> + </f:if> + +Configuration +------------- + +The configuration is done through an configured Instance of the dependency, for example :file:`Services.yaml`: + +.. code-block:: yaml + + services: + # … + + dashboard.buttons.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider' + arguments: + $title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems' + $link: 'https://typo3.org/project/news' + $target: '_blank' + + dashboard.widget.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget' + arguments: + # … + $buttonProvider: '@dashboard.buttons.t3news' + # … + +.. program:: TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider + +.. option:: $title + + The title used for the button. E.g. an ``LLL:EXT:`` reference like + ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems``. + +.. option:: $link + + The link to use for the button. Clicking the button will open the link. + +.. option:: $target + + The target of the link, e.g. ``_blank``. + ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems``. + +Implementation +-------------- + +An example implementation could look like this: + +:file:`Classes/Widgets/RssWidget.php`:: + + class RssWidget implements WidgetInterface + { + /** + * @var ButtonProviderInterface|null + */ + private $buttonProvider; + + public function __construct( + // … + ButtonProviderInterface $buttonProvider = null, + // … + ) { + $this->buttonProvider = $buttonProvider; + } + + public function renderWidgetContent(): string + { + $this->view->setTemplate('Widget/RssWidget'); + $this->view->assignMultiple([ + // … + 'button' => $this->buttonProvider, + // … + ]); + return $this->view->render(); + } + } diff --git a/typo3/sysext/dashboard/Documentation/Developer/GraphWidgetImplementation.rst b/typo3/sysext/dashboard/Documentation/Developer/GraphWidgetImplementation.rst new file mode 100644 index 0000000000000000000000000000000000000000..ba3d09c7270e64556bd39fd61b6cbc2b2ad66bc2 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Developer/GraphWidgetImplementation.rst @@ -0,0 +1,183 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _graph-widget-implementation: + +====================== +Implement graph widget +====================== + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets + +First of all a new data provider is required, which will provide the data for the chart. +Next the data will be provided to the widget instance, which will be rendered with RequireJS modules and Css. + +To make the dashboard aware of this workflow, some interfaces come together: + +* :php:class:`EventDataInterface` + +* :php:class:`AdditionalCssInterface` + +* :php:class:`RequireJsModuleInterface` + +Also the existing template file :file:`Widget/ChartWidget` is used, which provides necessary HTML to render the chart. +The provided ``eventData`` will be rendered as a chart and therefore has to match the expected structure. + +An example would be :file:`Classes/Widgets/BarChartWidget.php`:: + + class BarChartWidget implements WidgetInterface, EventDataInterface, AdditionalCssInterface, RequireJsModuleInterface + { + /** + * @var ChartDataProviderInterface + */ + private $dataProvider; + + public function __construct( + // … + ChartDataProviderInterface $dataProvider, + // … + ) { + // … + $this->dataProvider = $dataProvider; + // … + } + + public function renderWidgetContent(): string + { + $this->view->setTemplate('Widget/ChartWidget'); + $this->view->assignMultiple([ + // … + 'configuration' => $this->configuration, + // … + ]); + return $this->view->render(); + } + + public function getEventData(): array + { + return [ + 'graphConfig' => [ + 'type' => 'bar', + 'options' => [ + // … + ], + 'data' => $this->dataProvider->getChartData(), + ], + ]; + } + + public function getCssFiles(): array + { + return ['EXT:dashboard/Resources/Public/Css/Contrib/chart.css']; + } + + public function getRequireJsModules(): array + { + return [ + 'TYPO3/CMS/Dashboard/Contrib/chartjs', + 'TYPO3/CMS/Dashboard/ChartInitializer', + ]; + } + } + +Together with :file:`Services.yaml`: + +.. code-block:: yaml + + services: + dashboard.widget.sysLogErrors: + class: 'TYPO3\CMS\Dashboard\Widgets\BarChartWidget' + arguments: + # … + $dataProvider: '@TYPO3\CMS\Dashboard\Widgets\Provider\SysLogErrorsDataProvider' + # … + tags: + - name: dashboard.widget + additionalCssClasses: 'dashboard-item--chart' + +The configuration adds necessary CSS classes, as well as the ``dataProvider`` to use. +The provider implements :php:class:`ChartDataProviderInterface` and could look like the following. + +:file:`Classes/Widgets/Provider/SysLogErrorsDataProvider`:: + + class SysLogErrorsDataProvider implements ChartDataProviderInterface + { + /** + * Number of days to gather information for. + * + * @var int + */ + protected $days = 31; + + /** + * @var array + */ + protected $labels = []; + + /** + * @var array + */ + protected $data = []; + + public function __construct(int $days = 31) + { + $this->days = $days; + } + + public function getChartData(): array + { + $this->calculateDataForLastDays(); + return [ + 'labels' => $this->labels, + 'datasets' => [ + [ + 'label' => $this->getLanguageService()->sL('LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.sysLogErrors.chart.dataSet.0'), + 'backgroundColor' => WidgetApi::getDefaultChartColors()[0], + 'border' => 0, + 'data' => $this->data + ] + ] + ]; + } + + protected function getNumberOfErrorsInPeriod(int $start, int $end): int + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_log'); + return (int)$queryBuilder + ->count('*') + ->from('sys_log') + ->where( + $queryBuilder->expr()->eq( + 'type', + $queryBuilder->createNamedParameter(SystemLogType::ERROR, Connection::PARAM_INT) + ), + $queryBuilder->expr()->gte( + 'tstamp', + $queryBuilder->createNamedParameter($start, Connection::PARAM_INT) + ), + $queryBuilder->expr()->lte( + 'tstamp', + $queryBuilder->createNamedParameter($end, Connection::PARAM_INT) + ) + ) + ->execute() + ->fetchColumn(); + } + + protected function calculateDataForLastDays(): void + { + $format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d'; + for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) { + $this->labels[] = date($format, strtotime('-' . $daysBefore . ' day')); + $startPeriod = strtotime('-' . $daysBefore . ' day 0:00:00'); + $endPeriod = strtotime('-' . $daysBefore . ' day 23:59:59'); + $this->data[] = $this->getNumberOfErrorsInPeriod($startPeriod, $endPeriod); + } + } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } + } diff --git a/typo3/sysext/dashboard/Documentation/Developer/Index.rst b/typo3/sysext/dashboard/Documentation/Developer/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..b2adc2774c75d81174d55dc41dd78ebc167a8aa2 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Developer/Index.rst @@ -0,0 +1,23 @@ +.. include:: ../Includes.txt + +.. _for-developer: + +============== +For Developers +============== + +Target group: **Developers** + +Welcome to our small dashboard introduction. +We will explain how to create widget groups and implement widgets. + +.. include:: /Shared/DifferenceRegistrationAndImplementation.rst.txt + +.. toctree:: + :maxdepth: 3 + :titlesonly: + + WidgetImplementation + AddingButtons + GraphWidgetImplementation + Interfaces diff --git a/typo3/sysext/dashboard/Documentation/Developer/Interfaces.rst b/typo3/sysext/dashboard/Documentation/Developer/Interfaces.rst new file mode 100644 index 0000000000000000000000000000000000000000..c5934a46205ff86d34ea423c79e350903bbc7f48 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Developer/Interfaces.rst @@ -0,0 +1,177 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _interfaces: + +========== +Interfaces +========== + +The following list provides information for all necessary interfaces that are used inside of this documentation. +For up to date information, please check the source code. + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets + +.. php:class:: WidgetInterface + + Has to be implemented by all widgets. + This interface defines public API used by ext:dashboard to interact with widgets. + + .. php:method:: renderWidgetContent() + + :returntype: string + :returns: The rendered HTML to display. + +.. php:class:: WidgetConfigurationInterface + + Used internally in ext:dashboard. + Used to separate internal configuration from widgets. + Can be required in widget classes and passed to view. + + .. php:method:: getIdentifier() + + :returntype: string + :returns: Unique identifer of a widget. + + .. php:method:: getServiceName() + + :returntype: string + :returns: Service name providing the widget implementation. + + .. php:method:: getGroupNames() + + :returntype: array + :returns: Group names associated to this widget. + + .. php:method:: getTitle() + + :returntype: string + :returns: Title of a widget, this is used for the widget selector. + + .. php:method:: getDescription() + + :returntype: string + :returns: Description of a widget, this is used for the widget selector. + + .. php:method:: getIconIdentifier() + + :returntype: string + :returns: Icon identifier of a widget, this is used for the widget selector. + + .. php:method:: getHeight() + + :returntype: int + :returns: Height of a widget in rows (1-6). + + .. php:method:: getWidth() + + :returntype: int + :returns: Width of a widget in columns (1-4). + + .. php:method:: getAdditionalCssClasses() + + :returntype: array + :returns: Additional CSS classes which should be added to the rendered widget. + +.. php:class:: RequireJsModuleInterface + + Widgets implementing this interface will add the provided RequireJS modules. + Those modules will be loaded in dashboard view if the widget is added at least once. + + .. php:method:: getRequireJsModules() + + Returns a list of RequireJS modules that should be loaded, e.g.:: + + return [ + 'TYPO3/CMS/MyExtension/ModuleName', + 'TYPO3/CMS/MyExtension/Module2Name', + ]; + + See also :ref:`t3coreapi:requirejs` for further information regarding RequireJS + in TYPO3 Backend. + + :returntype: array + :returns: List of modules to require. + +.. php:class:: AdditionalJavaScriptInterface + + Widgets implementing this interface will add the provided JavaScript files. + Those files will be loaded in dashboard view if the widget is added at least once. + + .. php:method:: getJsFiles() + + Returns a list of JavaScript file names that should be included, e.g.:: + + return [ + 'EXT:my_extension/Resources/Public/JavaScript/file.js', + 'EXT:my_extension/Resources/Public/JavaScript/file2.js', + ]; + + :returntype: array + :returns: List of JS files to load. + +.. php:class:: AdditionalCssInterface + + Widgets implementing this interface will add the provided Css files. + Those files will be loaded in dashboard view if the widget is added at least once. + + .. php:method:: getCssFiles() + + Returns a list of Css file names that should be included, e.g.:: + + return [ + 'EXT:my_extension/Resources/Public/Css/widgets.css', + 'EXT:my_extension/Resources/Public/Css/list-widget.css', + ]; + + :returntype: array + :returns: List of Css files to load. + +.. php:class:: ButtonProviderInterface + + .. php:method:: getTitle() + + :returntype: string + :returns: The title used for the button. E.g. an ``LLL:EXT:`` reference like + ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems``. + + .. php:method:: getLink() + + :returntype: string + :returns: The link to use for the button. Clicking the button will open the link. + + .. php:method:: getTarget() + + :returntype: string + :returns: The target of the link, e.g. ``_blank``. + ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems``. + +.. php:class:: NumberWithIconDataProviderInterface + + .. php:method:: getNumber() + + :returntype: integer + :returns: The number to display for an number widget. + +.. php:class:: EventDataInterface + + .. php:method:: getEventData() + + :returntype: array + :returns: Returns data which should be send to the widget as JSON encoded value. + +.. php:class:: ChartDataProviderInterface + + .. php:method:: getChartData() + + :returntype: array + :returns: Provide the data for a graph. + The data and options you have depend on the type of chart. + More information can be found in the documentation of the specific type: + + Bar + https://www.chartjs.org/docs/latest/charts/bar.html#data-structure + + Doughnut + https://www.chartjs.org/docs/latest/charts/doughnut.html#data-structure diff --git a/typo3/sysext/dashboard/Documentation/Developer/WidgetImplementation.rst b/typo3/sysext/dashboard/Documentation/Developer/WidgetImplementation.rst new file mode 100644 index 0000000000000000000000000000000000000000..f4e5a4c693cb672fbce3e7707ee846c38c0850cd --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Developer/WidgetImplementation.rst @@ -0,0 +1,184 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _implement-new-widget: + +==================== +Implement new widget +==================== + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets + +.. seealso:: + + For information regarding registration of widgets, see: :ref:`register-new-widget`. + This section describes the implementation of new widgets for developers. + +Each extension can provide multiple Widgets. +ext:dashboard already ships with some widget implementations. + +Each widget has to be implemented as a PHP class. +The PHP class defines the concrete implementation and features of a widget, +while registration adds necessary options for a concrete instance of a widget. + +For example a TYPO3.org RSS Widget would consist of an :php:`RssWidget` PHP class. +This class would provide the implementation to fetch rss news and display them. +The concrete registration will provide the URL to RSS feed. + +PHP class +--------- + +Each Widget has to be a PHP class. +This class has to implement the :php:class:`WidgetInterface` and could look like this:: + + class RssWidget implements WidgetInterface + { + /** + * @var WidgetConfigurationInterface + */ + private $configuration; + + /** + * @var StandaloneView + */ + private $view; + + /** + * @var Cache + */ + private $cache; + + /** + * @var array + */ + private $options; + + /** + * @var ButtonProviderInterface|null + */ + private $buttonProvider; + + public function __construct( + WidgetConfigurationInterface $configuration, + Cache $cache, + StandaloneView $view, + ButtonProviderInterface $buttonProvider = null, + array $options = [] + ) { + $this->configuration = $configuration; + $this->view = $view; + $this->cache = $cache; + $this->options = [ + 'limit' => 5, + ] + $options; + $this->buttonProvider = $buttonProvider; + } + + public function renderWidgetContent(): string + { + $this->view->setTemplate('Widget/RssWidget'); + $this->view->assignMultiple([ + 'items' => $this->getRssItems(), + 'options' => $this->options, + 'button' => $this->getButton(), + 'configuration' => $this->configuration, + ]); + return $this->view->render(); + } + + protected function getRssItems(): array + { + $items = []; + + // Logic to populate $items array + + return $items; + } + } + +The class should always provide documentation how to use in :file:`Services.yaml`. +The above class is documented at :ref:`rss-widget`. +The documentation should provide all possible options and an concrete example. +It should make it possible for integrators to register new widgets using the implementation. + +The difference between ``$options`` and ``$configuration`` in above example is the following: +``$options`` are the options for this implementation which can be provided through :file:`Services.yaml`. +``$configuration`` is an instance of :php:class:`WidgetConfigurationInterface` holding all internal configuration, like icon identifier. + +.. _implement-new-widget-fluid: + +Using Fluid +----------- + +Most widgets will need a template. +Therefore each widget can define :php:`StandaloneView` as requirement for DI in constructor, like done in RSS example. +In order to provide a common configured instance to all widgets, +the following service can be used in :file:`Services.yaml` to provide the instance: + +.. code-block:: yaml + + dashboard.widget.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget' + arguments: + $view: '@dashboard.views.widget' + +The instance will be pre configured with paths, see :ref:`adjust-template-of-widget`, +and can be used as shown in RSS widget example above. + +Providing custom JS +------------------- + +There are two ways to add JavaScript for an widget: + +RequireJS AMD module + Implement :php:class:`RequireJsModuleInterface`:: + + class RssWidget implements WidgetInterface, RequireJsModuleInterface + { + public function getRequireJsModules(): array + { + return [ + 'TYPO3/CMS/MyExtension/ModuleName', + 'TYPO3/CMS/MyExtension/Module2Name', + ]; + } + } + + .. seealso:: + + :ref:`t3coreapi:requirejs` for more info about RequireJS in TYPO3 Backend. + +Plain JS files + Implement :php:class:`AdditionalJavaScriptInterface`:: + + class RssWidget implements WidgetInterface, AdditionalJavaScriptInterface + { + public function getJsFiles(): array + { + return [ + 'EXT:my_extension/Resources/Public/JavaScript/file.js', + 'EXT:my_extension/Resources/Public/JavaScript/file2.js', + ]; + } + } + +Both ways can also be combined. + +Providing custom CSS +-------------------- + +It is possible to add custom Css to style widgets. + +Implement :php:class:`AdditionalCssInterface`:: + + class RssWidget implements WidgetInterface, AdditionalCssInterface + { + public function getCssFiles(): array + { + return [ + 'EXT:my_extension/Resources/Public/Css/widgets.css', + 'EXT:my_extension/Resources/Public/Css/list-widget.css', + ]; + } + } diff --git a/typo3/sysext/dashboard/Documentation/Editor/Index.rst b/typo3/sysext/dashboard/Documentation/Editor/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..3a89a1b4a88839b04eee48c1b7babd9a09c91a94 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Editor/Index.rst @@ -0,0 +1,126 @@ +.. include:: ../Includes.txt + +.. _for-editors: + +=========== +For Editors +=========== + +Target group: **Editors** + +Welcome to our small dashboard introduction. +We will explain the basic usage of the TYPO3 dashboard. + +.. _opening-dashboard: + +Opening Dashboard +================= + +TODO: Add documentation once dashboard position is fixed. + +.. _adding-dashboard: + +Adding Dashboard +================ + +The ext:dashboard allows to have multiple dashboards. +Switching between different dashboards is possible by using the corresponding tab. + +In order to add further dashboards, press the :guilabel:`+` sign. + +.. figure:: /Images/DashboardTabs.png + :align: center + + Tabs allowing to switch and add dashboards. + +A wizard should open which allows to add the new dashboard. + +There you can select a preset. At least the the default preset, which is shipped +by core should be available. Depending on system configuration further dashboard +presets might be available. + +.. figure:: /Images/DashboardWizard.png + :align: center + + Wizard to add a new dashboard. + +.. _editing-dashboard: + +Editing Dashboard +================= + +Existing dashboards can be edited and deleted. +On the right side of the tab bar are the icons which allow deletion and adjusting +settings of the currently active dashboard. + +.. figure:: /Images/DashboardTabs.png + :align: center + + Icons on the right side of the tab bar allow adjusting settings or deletion of + the currently selected dashboard. + +.. _adding-widgets: + +Adding Widgets +============== + +Widgets can be added to a dashboard. +Dashboards which do not contain any widget yet, offer a dialog in the middle of +the screen, which allows to add one or more widgets to the current dashboard. + +All dashboards allow to add further widgets in the lower right corner through the +:guilabel:`+` Icon. + +.. figure:: /Images/AddWidget.png + :align: center + + Empty dashboard with possibilities to add new widgets. + +Once the action to add a new wizard was triggered, a wizard opens which allows to +select the widget to add. + +Widgets are grouped in tabs and can be added by clicking on them. + +.. figure:: /Images/WidgetWizard.png + :align: center + + Wizard to select a new widget that will be added to the active dashboard. + +.. _moving-widgets: + +Moving Widgets +============== + +Widgets can be moved around. Therefore a widget needs to be hovered. +If a widget is hovered some icons appear in the upper right corner of the widget. + +To move the widget, click and hold left mouse button on the cross icon. +Then move to the target position. + +.. figure:: /Images/WidgetMove.png + :align: center + + Widget in hover mode with additional icons in upper right corner. + +.. _deleting-widgets: + +Deleting Widgets +================ + +To delete a widget, the widget needs to be hovered. +If a widget is hovered some icons appear in the upper right corner of the widget. + +Click the trash icon which appears to delete the widget. + +.. figure:: /Images/WidgetMove.png + :align: center + + Widget in hover mode with additional icons in upper right corner. + +In order to prevent accidentally deletion, a modal is shown to confirm deletion. +Confirm by clicking the :guilabel:`Remove` button. + +.. figure:: /Images/WidgetDelete.png + :align: center + + Modal to confirm deletion of widget. diff --git a/typo3/sysext/dashboard/Documentation/Images/AccessRestriction.png b/typo3/sysext/dashboard/Documentation/Images/AccessRestriction.png new file mode 100644 index 0000000000000000000000000000000000000000..5b6301b7f92525fb65d6e4554b9e400cc1a5d6dc Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/AccessRestriction.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/AddWidget.png b/typo3/sysext/dashboard/Documentation/Images/AddWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..48e636eda46972aa598222b6463817277e69e1a7 Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/AddWidget.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/DashboardTabs.png b/typo3/sysext/dashboard/Documentation/Images/DashboardTabs.png new file mode 100644 index 0000000000000000000000000000000000000000..0c14fb5e65d56c325f750ee11a13890ed0ebc9b4 Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/DashboardTabs.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/DashboardWizard.png b/typo3/sysext/dashboard/Documentation/Images/DashboardWizard.png new file mode 100644 index 0000000000000000000000000000000000000000..62d1a6d581e16a4d85ad92adb2f6fb4d01e0e697 Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/DashboardWizard.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/WidgetDelete.png b/typo3/sysext/dashboard/Documentation/Images/WidgetDelete.png new file mode 100644 index 0000000000000000000000000000000000000000..c20317d74cb533d2605069a1a49675e4d55b56db Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/WidgetDelete.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/WidgetMove.png b/typo3/sysext/dashboard/Documentation/Images/WidgetMove.png new file mode 100644 index 0000000000000000000000000000000000000000..e9eef029326cc700ef2973cc753f75ab440fed7b Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/WidgetMove.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/WidgetWizard.png b/typo3/sysext/dashboard/Documentation/Images/WidgetWizard.png new file mode 100644 index 0000000000000000000000000000000000000000..62bb23b28e045ba40dd4fb555155f15fba7703c5 Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/WidgetWizard.png differ diff --git a/typo3/sysext/dashboard/Documentation/Images/em.png b/typo3/sysext/dashboard/Documentation/Images/em.png new file mode 100644 index 0000000000000000000000000000000000000000..6092bf186a37e31c01e94d0ad5bf1e0ac53c5c15 Binary files /dev/null and b/typo3/sysext/dashboard/Documentation/Images/em.png differ diff --git a/typo3/sysext/dashboard/Documentation/Includes.txt b/typo3/sysext/dashboard/Documentation/Includes.txt new file mode 100644 index 0000000000000000000000000000000000000000..957d50c9b575a22a1380f034fbff30a5b6f54160 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Includes.txt @@ -0,0 +1,20 @@ +.. This is 'Includes.txt'. It is included at the very top of each and + every ReST source file in THIS documentation project (= manual). + +.. role:: aspect (emphasis) +.. role:: html(code) +.. role:: js(code) +.. role:: php(code) +.. role:: typoscript(code) +.. role:: typescript(code) +.. role:: shell(code) +.. role:: sql(code) +.. role:: yaml(code) + +.. role:: ts(typoscript) + :class: typoscript +.. role:: javascript(js) + :class: js + +.. default-role:: code +.. highlight:: yaml diff --git a/typo3/sysext/dashboard/Documentation/Index.rst b/typo3/sysext/dashboard/Documentation/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..a83fd0dd65225b7cb9f2a06e2ecf3d66e4fad4d5 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Index.rst @@ -0,0 +1,61 @@ +.. include:: Includes.txt + +.. _start: + +======================== +Dashboard Core extension +======================== + +:Extension key: + dashboard + +:Version: + |release| + +:Language: + en + +:Description: + Manual for our dashboard extension, which adds a dashboard with widgets to TYPO3. + +:Keywords: + dashboard, widgets + +:Copyright: + 2020-2020 + +:Author: + TYPO3 CMS Core Development Team + +:License: + Open Content License available from `www.opencontent.org/opl.shtml + <http://www.opencontent.org/opl.shtml>`_ + +:Rendered: + |today| + +The content of this document is related to TYPO3, +a GNU/GPL CMS/Framework available from `www.typo3.org +<http://www.typo3.org/>`_ + +**TYPO3** + +The content of this document is related to TYPO3 CMS, +a GNU/GPL CMS/Framework available from `typo3.org +<https://typo3.org/>`_ . + +**For Contributors** + +You are welcome to help improve this guide. Just click on "Edit on GitHub" +on the top right to submit your change request. + +**Table of Contents** + +.. toctree:: + + Introduction/Index + Installation/Index + Editor/Index + Configuration/Index + Developer/Index + Widgets/Index diff --git a/typo3/sysext/dashboard/Documentation/Installation/Index.rst b/typo3/sysext/dashboard/Documentation/Installation/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..cec7a9e2d45b1c0890c98b551ce323a43eec25ca --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Installation/Index.rst @@ -0,0 +1,49 @@ +.. include:: ../Includes.txt +.. highlight:: bash + +.. _installation: + +============ +Installation +============ + +Target group: **Administrators** + +This extension is part of the TYPO3 core. + +Installation with composer +========================== + +Check whether you are already using the extension with:: + + composer show | grep dashboard + +This should either give you no result or something similar to::: + + typo3/cms-dashboard v10.4.0 Dashboard for TYPO3. + +If it is not yet installed, use the ``composer require`` command to install the extension:: + + composer require typo3/cms-dashboard ^10.4 + +The given version depends on the version of the TYPO3 core you are using. + +Now head over to the extension manager and activate the extension. + +.. figure:: ../Images/em.png + :class: with-shadow + :alt: Extension manager with filtered dashboard extension + + Extension manager with filtered dashboard extension + +Installation without composer +============================= + +In an installation without composer, the extension is already shipped. You just have to activate it. +Head over to the extension manager and activate the extension. + +.. figure:: ../Images/em.png + :class: with-shadow + :alt: Extension manager with filtered dashboard extension + + Extension manager with filtered dashboard extension diff --git a/typo3/sysext/dashboard/Documentation/Introduction/Index.rst b/typo3/sysext/dashboard/Documentation/Introduction/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..38d84534d4fd6654fbb0c74f753dec37255ce656 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Introduction/Index.rst @@ -0,0 +1,18 @@ +.. include:: ../Includes.txt + +.. _introduction: + +============ +Introduction +============ + +What does it do? +================ + +This extension provides a new TYPO3 backend module "Dashboard". +Users can create multiple dashboards visible in this module, and switch between those +dashboards. +Each of the dashboards can have multiple widgets. + +Developers are able to create new widgets. +Integrators and developers are able to register new widgets through configuration. diff --git a/typo3/sysext/dashboard/Documentation/Settings.cfg b/typo3/sysext/dashboard/Documentation/Settings.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e78ab065ec1bf244005178067e1674a53dc99fcb --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Settings.cfg @@ -0,0 +1,48 @@ +[general] + +; endless list of all of the general simple settings +; you can use in 'conf.py' + +project = Dashboard +version = latest (10-dev) +release = latest (10-dev) +t3author = TYPO3 Core Team + Contributors, TYPO3 Documentation Team +copyright = 2020-2020 + +description = This documentation is about TYPO3's system extension + "dashboard" which provides provides dashboard with widgets + +[html_theme_options] + +; for theme t3SphinxThemeRtd + +# Add 'Edit me on Github' button +github_branch = master +github_repository = TYPO3/TYPO3.CMS +path_to_documentation_dir = typo3/sysext/dashboard/Documentation + +# show as related links +project_contact = +project_home = https://forge.typo3.org/projects/typo3cms-core +project_issues = https://forge.typo3.org/projects/typo3cms-core/issues +project_repository = https://git.typo3.org/Packages/TYPO3.CMS.git + + +[intersphinx_mapping] + +# These are common mappings. Uncomment only what you really use! + +# h2document = https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/ +t3coreapi = https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ +# t3editors = https://docs.typo3.org/m/typo3/tutorial-editors/master/en-us/ +# t3extbasebook = https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/Index.html +# t3install = https://docs.typo3.org/m/typo3/guide-installation/master/en-us/ +# t3l10n = https://docs.typo3.org/m/typo3/guide-frontendlocalization/master/en-us/ +# t3start = https://docs.typo3.org/m/typo3/tutorial-getting-started/master/en-us/ +t3sitepackage = https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/ +# t3tca = https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ +# t3templating = https://docs.typo3.org/m/typo3/tutorial-templating-with-fluid/master/en-us/ +# t3ts45 = https://docs.typo3.org/m/typo3/tutorial-typoscript-in-45-minutes/master/en-us/ +# t3tsconfig = https://docs.typo3.org/m/typo3/reference-tsconfig/master/en-us/ +# t3tsref = https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ +# linkvalidator = https://docs.typo3.org/c/typo3/cms-linkvalidator/master/en-us/ diff --git a/typo3/sysext/dashboard/Documentation/Shared/DifferenceRegistrationAndImplementation.rst.txt b/typo3/sysext/dashboard/Documentation/Shared/DifferenceRegistrationAndImplementation.rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a6a04fd55fa287cfffc40c6522e513889e18f0b --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Shared/DifferenceRegistrationAndImplementation.rst.txt @@ -0,0 +1,13 @@ +.. note:: + + Difference between **registration** of widgets and **implementation** of widgets: + + Widgets provide some functionality, e.g. collect system log errors over a time span. + This functionality is provided by the implementation, a PHP class with some code. + The registration is done in :file:`Services.yaml`, + in order to create the actual widget with provided functionality. + During registration options can be set, e.g. the time span. + + Registration is documented at :ref:`register-new-widget`, + while implementation is documented at + :ref:`implement-new-widget`. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/BarChartWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/BarChartWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..79cd900cd8e389d98501bb023a2a6a3c5bdbbb26 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/BarChartWidget.rst @@ -0,0 +1,72 @@ +.. include:: ../Includes.txt + +.. highlight:: php + +.. _bar-chart-widget: + +================ +Bar Chart Widget +================ + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets + +Widgets using this class will show a bar chart with the provided data. + +This kind of widgets are useful if you want to show some statistics of for example +historical data. + +.. program:: TYPO3\CMS\Dashboard\Widgets\BarChartWidget + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + dashboard.widget.sysLogErrors: + class: 'TYPO3\CMS\Dashboard\Widgets\BarChartWidget' + arguments: + $dataProvider: '@TYPO3\CMS\Dashboard\Widgets\Provider\SysLogErrorsDataProvider' + $view: '@dashboard.views.widget' + $buttonProvider: '@TYPO3\CMS\Dashboard\Widgets\Provider\SysLogButtonProvider' + tags: + - name: dashboard.widget + identifier: 'sysLogErrors' + groupNames: 'systemInfo' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.sysLogErrors.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.sysLogErrors.description' + iconIdentifier: 'content-widget-chart-bar' + additionalCssClasses: 'dashboard-item--chart' + height: 'medium' + width: 'medium' + +Options +------- + +For this widget, there are no options available. + +Dependencies +------------ + +.. option:: $dataProvider + + To add data to a Bar Chart widget, you need to have a DataProvider that implements + the interface :php:class:`ChartDataProviderInterface`. + + See :ref:`graph-widget-implementation` for further information. + +.. option:: $buttonProvider + + Optionally you can add a button with a link to some additional data. + This button should be provided by a ButtonProvider that implements the interface :php:class:`ButtonProviderInterface`. + + See :ref:`adding-buttons` for further info and configuration options. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/CTAButtonWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/CTAButtonWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..937a204ae754747577034569eefa8df4d06e9ff7 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/CTAButtonWidget.rst @@ -0,0 +1,68 @@ +.. include:: ../Includes.txt + +.. _cta-button-widget: + +================= +CTA Button Widget +================= + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets +.. program:: TYPO3\CMS\Dashboard\Widgets\CtaWidget + +Widgets using this class will show a CTA (=Call to action) button to easily go to +a specific page or do a specific action. You can add a button to the widget by +defining a button provider. + +You can use this kind of widget to link to for example a manual or to an important +website that is used a lot by the users. + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + dashboard.widget.docGettingStarted: + class: 'TYPO3\CMS\Dashboard\Widgets\CtaWidget' + arguments: + $view: '@dashboard.views.widget' + $buttonProvider: '@dashboard.buttons.docGettingStarted' + $options: + text: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.documentation.gettingStarted.text' + tags: + - name: dashboard.widget + identifier: 'docGettingStarted' + groupNames: 'documentation' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.documentation.gettingStarted.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.documentation.gettingStarted.description' + iconIdentifier: 'content-widget-text' + height: 'small' + +Options +------- + +.. option:: text + + Adds an optional text to the widget to give some more background information + about what a user can expect when clicking the button. + You can either enter a normal string or a translation string + e.g. ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.documentation.gettingStarted.text``. + +Dependencies +------------ + +.. option:: $buttonProvider + + Provides the actual button to show within the widget. + This button should be provided by a ButtonProvider that implements the interface :php:class:`ButtonProviderInterface`. + + See :ref:`adding-buttons` for further info and configuration options. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/DoughnutChartWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/DoughnutChartWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..c776b875f06f6b3496a4b7da808881353249343b --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/DoughnutChartWidget.rst @@ -0,0 +1,67 @@ +.. include:: ../Includes.txt + +.. _doughnut-chart-widget: + +===================== +Doughnut Chart Widget +===================== + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets +.. program:: TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget + +Widgets using this class will show a doughnut chart with the provided data. + +This kind of widgets are useful if you want to show the relational proportions +between data. + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + dashboard.widget.typeOfUsers: + class: 'TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget' + arguments: + $view: '@dashboard.views.widget' + $dataProvider: '@TYPO3\CMS\Dashboard\Widgets\Provider\TypeOfUsersChartDataProvider' + tags: + - name: dashboard.widget + identifier: 'typeOfUsers' + groupNames: 'systemInfo' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.typeOfUsers.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.typeOfUsers.description' + iconIdentifier: 'content-widget-chart-pie' + additionalCssClasses: 'dashboard-item--chart' + height: 'medium' + +Options +------- + +For this widget, there are no options available. + +Dependencies +------------ + +.. option:: $dataProvider + + To add data to a Bar Chart widget, you need to have a DataProvider that implements + the interface :php:class:`ChartDataProviderInterface`. + + See :ref:`graph-widget-implementation` for further information. + +.. option:: $buttonProvider + + Optionally you can add a button with a link to some additional data. + This button should be provided by a ButtonProvider that implements the interface :php:class:`ButtonProviderInterface`. + + See :ref:`adding-buttons` for further info and configuration options. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/Index.rst b/typo3/sysext/dashboard/Documentation/Widgets/Index.rst new file mode 100644 index 0000000000000000000000000000000000000000..9e723ca58ec2acfc58f0689ba98863c653b28aed --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/Index.rst @@ -0,0 +1,17 @@ +.. include:: ../Includes.txt + +.. _widgets: + +======= +Widgets +======= + +The following section will provide information for all provided widgets. +For each widget an example registration will be provided, +together with all configuration options. + +.. toctree:: + :glob: + :titlesonly: + + *Widget diff --git a/typo3/sysext/dashboard/Documentation/Widgets/ListWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/ListWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..55c9e5c65f3c2700c67c497f91735317206773a5 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/ListWidget.rst @@ -0,0 +1,56 @@ +.. include:: ../Includes.txt + +.. _list-widget: + +=========== +List Widget +=========== + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets +.. program:: TYPO3\CMS\Dashboard\Widgets\ListWidget + +Widgets using this class will show a simple list of items provided by a data +provider. + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + dashboard.widget.testList: + class: 'TYPO3\CMS\Dashboard\Widgets\ListWidget' + arguments: + $dataProvider: '@Vendor\Ext\Widgets\Provider\TestListWidgetDataProvider' + $view: '@dashboard.views.widget' + tags: + - name: dashboard.widget + identifier: 'testList' + groupNames: 'general' + title: 'List widget' + description: 'Description of widget' + iconIdentifier: 'content-widget-list' + height: 'large' + width: 'large' + +Options +------- + +For this widget, there are no options available. + +Dependencies +------------ + +.. option:: $dataProvider + + This class should provide the items to show. + This data provider needs to implement the :php:class:`ListDataProviderInterface`. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/NumberWithIconWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/NumberWithIconWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..26cde05f1a29ec466eb87bfb3c22248800cc8f71 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/NumberWithIconWidget.rst @@ -0,0 +1,74 @@ +.. include:: ../Includes.txt + +.. _number-widget: + +======================= +Number With Icon Widget +======================= + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets +.. program:: TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget + +Widgets using this class will show a widget with a number, some additional +text and an icon. + +This kind of widgets are useful if you want to show some simple stats. + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + dashboard.widget.failedLogins: + class: 'TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget' + arguments: + $dataProvider: '@TYPO3\CMS\Dashboard\Widgets\Provider\NumberOfFailedLoginsDataProvider' + $view: '@dashboard.views.widget' + $options: + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.title' + subtitle: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.subtitle' + icon: 'content-elements-login' + tags: + - name: dashboard.widget + identifier: 'failedLogins' + groupNames: 'systemInfo' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.description' + iconIdentifier: 'content-widget-number' +Options +------- + +.. option:: title + + The main title that will be shown in the widget as an explanation of the shown number. + You can either enter a normal string or a translation string. + e.g. ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.title`` + +.. option:: subtitle + + The optional subtitle that will give some additional information about the number and title. + You can either enter a normal string or a translation string + e.g. ``LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.failedLogins.subtitle`` + +.. option:: icon + + The icon-identifier of the icon that should be shown in the widget. + You should register your icon with the :ref:`t3coreapi:icon`. + +Dependencies +------------ + +.. option:: $dataProvider + + This class should provide the number to show. + This data provider needs to implement the :php:class:`NumberWithIconDataProviderInterface`. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. diff --git a/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst new file mode 100644 index 0000000000000000000000000000000000000000..48baa41e74a1b29f5253b6e5aafa19dcaad330c8 --- /dev/null +++ b/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst @@ -0,0 +1,99 @@ +.. include:: ../Includes.txt + +.. _rss-widget: + +========== +RSS Widget +========== + +.. php:namespace:: TYPO3\CMS\Dashboard\Widgets +.. program:: TYPO3\CMS\Dashboard\Widgets\RssWidget + +Widgets using this class will show a list of items of the configured RSS feed. + +You can use this kind of widget to create a widget showing your own RSS feed. + +Example +------- + +:file:`Configuration/Services.yaml`:: + + services: + + cache.dashboard.rss: + class: 'TYPO3\CMS\Core\Cache\Frontend\FrontendInterface' + factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] + arguments: + $identifier: 'dashboard_rss' + + dashboard.buttons.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider' + arguments: + $title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems' + $link: 'https://typo3.org/project/news' + $target: '_blank' + + dashboard.widget.t3news: + class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget' + arguments: + $view: '@dashboard.views.widget' + $cache: '@cache.dashboard.rss' + $buttonProvider: '@dashboard.buttons.t3news' + $options: + feedUrl: 'https://www.typo3.org/rss' + # 12 hours cache + lifeTime: 43200 + tags: + - name: dashboard.widget + identifier: 't3news' + groupNames: 'typo3' + title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.title' + description: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.description' + iconIdentifier: 'content-widget-rss' + height: 'large' + width: 'medium' + +Options +------- + +The following options are available via :yaml:`services.dashboard.widget.t3news.arguments.$options`: + +.. option:: feedUrl + + Defines the URL or file providing the RSS Feed. + This is read by the widget in order to fetch entries to show. + +.. option:: lifeTime + + Default: ``43200`` + + Defines how long to wait, in seconds, until fetching RSS Feed again. + +.. option:: limit + + Default: ``5`` + + Defines how many RSS items should be shown. + +Dependencies +------------ + +.. option:: $buttonProvider + + Provides an optional button to show which is used to open the source of RSS data. + This button should be provided by a ButtonProvider that implements the interface :php:class:`ButtonProviderInterface`. + + See :ref:`adding-buttons` for further info and configuration options. + +.. option:: $view + + Used to render a Fluidtemplate. + This should not be changed. + The default is to use the pre configured Fluid StandaloneView for EXT:dashboard. + + See :ref:`implement-new-widget-fluid` for further information. + +.. option:: $cache + + Used to cache fetched RSS items. + This should not be changed.