From 673d70dfc5ac5cab63bda1c0d0d5d7a21bf420e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 27 May 2020 09:07:17 +0200 Subject: [PATCH 01/17] Add new dashboard public API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/composer/composer/autoload_classmap.php | 3 + lib/composer/composer/autoload_static.php | 3 + lib/private/Dashboard/Manager.php | 46 +++++++++++++ lib/private/Server.php | 1 + lib/public/Dashboard/IManager.php | 46 +++++++++++++ lib/public/Dashboard/IPanel.php | 69 ++++++++++++++++++++ lib/public/Dashboard/IRegisterPanelEvent.php | 50 ++++++++++++++ 7 files changed, 218 insertions(+) create mode 100644 lib/private/Dashboard/Manager.php create mode 100644 lib/public/Dashboard/IManager.php create mode 100644 lib/public/Dashboard/IPanel.php create mode 100644 lib/public/Dashboard/IRegisterPanelEvent.php diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 54a335a738..cfc47c7290 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -166,6 +166,9 @@ return array( 'OCP\\Dashboard\\Exceptions\\DashboardAppNotAvailableException' => $baseDir . '/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php', 'OCP\\Dashboard\\IDashboardManager' => $baseDir . '/lib/public/Dashboard/IDashboardManager.php', 'OCP\\Dashboard\\IDashboardWidget' => $baseDir . '/lib/public/Dashboard/IDashboardWidget.php', + 'OCP\\Dashboard\\IManager' => $baseDir . '/lib/public/Dashboard/IManager.php', + 'OCP\\Dashboard\\IPanel' => $baseDir . '/lib/public/Dashboard/IPanel.php', + 'OCP\\Dashboard\\IRegisterPanelEvent' => $baseDir . '/lib/public/Dashboard/IRegisterPanelEvent.php', 'OCP\\Dashboard\\Model\\IWidgetConfig' => $baseDir . '/lib/public/Dashboard/Model/IWidgetConfig.php', 'OCP\\Dashboard\\Model\\IWidgetRequest' => $baseDir . '/lib/public/Dashboard/Model/IWidgetRequest.php', 'OCP\\Dashboard\\Model\\WidgetSetting' => $baseDir . '/lib/public/Dashboard/Model/WidgetSetting.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 1320041cfe..f823712b58 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -195,6 +195,9 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Dashboard\\Exceptions\\DashboardAppNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php', 'OCP\\Dashboard\\IDashboardManager' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IDashboardManager.php', 'OCP\\Dashboard\\IDashboardWidget' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IDashboardWidget.php', + 'OCP\\Dashboard\\IManager' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IManager.php', + 'OCP\\Dashboard\\IPanel' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IPanel.php', + 'OCP\\Dashboard\\IRegisterPanelEvent' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IRegisterPanelEvent.php', 'OCP\\Dashboard\\Model\\IWidgetConfig' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetConfig.php', 'OCP\\Dashboard\\Model\\IWidgetRequest' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetRequest.php', 'OCP\\Dashboard\\Model\\WidgetSetting' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetSetting.php', diff --git a/lib/private/Dashboard/Manager.php b/lib/private/Dashboard/Manager.php new file mode 100644 index 0000000000..99d8999c24 --- /dev/null +++ b/lib/private/Dashboard/Manager.php @@ -0,0 +1,46 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\Dashboard; + +use OCP\Dashboard\IManager; +use OCP\Dashboard\IPanel; + +class Manager implements IManager { + private $panels = []; + + /** + * @inheritDoc + */ + public function registerPanel(IPanel $panel): void { + if (array_key_exists($panel->getId(), $this->panels)) { + throw new \InvalidArgumentException('Dashboard panel with this id has already been registered'); + } + + $this->panels[$panel->getId()] = $panel; + } + + public function getPanels(): array { + return $this->panels; + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index eff190176b..582718cd7c 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1357,6 +1357,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerAlias(IDashboardManager::class, DashboardManager::class); + $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class); $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); $this->registerAlias(ISubAdmin::class, SubAdmin::class); diff --git a/lib/public/Dashboard/IManager.php b/lib/public/Dashboard/IManager.php new file mode 100644 index 0000000000..a5185ae22a --- /dev/null +++ b/lib/public/Dashboard/IManager.php @@ -0,0 +1,46 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Dashboard; + +/** + * Interface IManager + * + * @package OCP\Dashboard + * @since 20.0.0 + */ +interface IManager { + + /** + * @param IPanel $panel + * @since 20.0.0 + */ + public function registerPanel(IPanel $panel): void; + + /** + * @since 20.0.0 + * + * @return IPanel[] + */ + public function getPanels(): array; +} diff --git a/lib/public/Dashboard/IPanel.php b/lib/public/Dashboard/IPanel.php new file mode 100644 index 0000000000..1b0e3c11d1 --- /dev/null +++ b/lib/public/Dashboard/IPanel.php @@ -0,0 +1,69 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Dashboard; + +/** + * Interface IPanel + * + * @package OCP\Dashboard + * @since 20.0.0 + */ +interface IPanel { + + /** + * @return string + * @since 20.0.0 + */ + public function getId(): string; + + /** + * @return string + * @since 20.0.0 + */ + public function getTitle(): string; + + /** + * @return int + * @since 20.0.0 + */ + public function getOrder(): int; + + /** + * @return string + * @since 20.0.0 + */ + public function getIconClass(): string; + + /** + * @return string The absolute path to an icon in SVG + * @since 20.0.0 + */ + public function getIconUrl(): string; + + /** + * @return string The absolute url to the apps own view + * @since 20.0.0 + */ + public function getUrl(): string; +} diff --git a/lib/public/Dashboard/IRegisterPanelEvent.php b/lib/public/Dashboard/IRegisterPanelEvent.php new file mode 100644 index 0000000000..f322d87d82 --- /dev/null +++ b/lib/public/Dashboard/IRegisterPanelEvent.php @@ -0,0 +1,50 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Dashboard; + +use OCP\EventDispatcher\Event; + +/** + * Class IRegisterPanelEvent + * + * @package OCP\Dashboard + * @since 20.0.0 + */ +class IRegisterPanelEvent extends Event { + private $manager; + + public function __construct(IManager $manager) { + parent::__construct(); + + $this->manager = $manager; + } + + /** + * @param IPanel $panel + * @since 20.0.0 + */ + public function registerPanel(IPanel $panel) { + $this->manager->registerPanel($panel); + } +} From 544fcdb549381f233dbfd9ca57cf6e7afb490104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 27 May 2020 09:10:40 +0200 Subject: [PATCH 02/17] Deprecate old dashboard API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/public/Dashboard/IDashboardManager.php | 7 +++++++ lib/public/Dashboard/IDashboardWidget.php | 8 ++++++++ lib/public/Dashboard/Model/IWidgetConfig.php | 6 ++++++ lib/public/Dashboard/Model/IWidgetRequest.php | 8 ++++++++ lib/public/Dashboard/Model/WidgetSetting.php | 13 +++++++++++++ lib/public/Dashboard/Model/WidgetSetup.php | 13 +++++++++++++ lib/public/Dashboard/Model/WidgetTemplate.php | 18 ++++++++++++++++++ .../Dashboard/Service/IEventsService.php | 4 ++++ .../Dashboard/Service/IWidgetsService.php | 2 ++ 9 files changed, 79 insertions(+) diff --git a/lib/public/Dashboard/IDashboardManager.php b/lib/public/Dashboard/IDashboardManager.php index 812338bfb3..164a86cd8b 100644 --- a/lib/public/Dashboard/IDashboardManager.php +++ b/lib/public/Dashboard/IDashboardManager.php @@ -38,6 +38,7 @@ use OCP\Dashboard\Service\IWidgetsService; * The call can be done from any Service. * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard */ @@ -48,6 +49,7 @@ interface IDashboardManager { * Register a IWidgetsService. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param IWidgetsService $widgetsService */ @@ -58,6 +60,7 @@ interface IDashboardManager { * Register a IEventsService. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param IEventsService $eventsService */ @@ -70,6 +73,7 @@ interface IDashboardManager { * @see IWidgetConfig * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param string $userId @@ -92,6 +96,7 @@ interface IDashboardManager { * that are running dashboard. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $users @@ -106,6 +111,7 @@ interface IDashboardManager { * Create push notifications for groups. (ie. createUsersEvent()) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $groups @@ -120,6 +126,7 @@ interface IDashboardManager { * Create push notifications for everyone. (ie. createUsersEvent()) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $payload diff --git a/lib/public/Dashboard/IDashboardWidget.php b/lib/public/Dashboard/IDashboardWidget.php index ef8b9c74d1..4d1b0c1147 100644 --- a/lib/public/Dashboard/IDashboardWidget.php +++ b/lib/public/Dashboard/IDashboardWidget.php @@ -45,6 +45,7 @@ use OCP\Dashboard\Model\WidgetTemplate; * Multiple widget can be defined in the same appinfo/info.xml. * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard */ @@ -54,6 +55,7 @@ interface IDashboardWidget { * Should returns the (unique) Id of the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -64,6 +66,7 @@ interface IDashboardWidget { * Should returns the [display] name of the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -75,6 +78,7 @@ interface IDashboardWidget { * This description is displayed in the listing of the available widgets. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -88,6 +92,7 @@ interface IDashboardWidget { * @see WidgetTemplate * * @since 15.0.0 + * @deprecated 20.0.0 * * @return WidgetTemplate */ @@ -101,6 +106,7 @@ interface IDashboardWidget { * @see WidgetSetup * * @since 15.0.0 + * @deprecated 20.0.0 * * @return WidgetSetup */ @@ -119,6 +125,7 @@ interface IDashboardWidget { * @see IWidgetConfig * * @since 15.0.0 + * @deprecated 20.0.0 * * @param IWidgetConfig $settings */ @@ -134,6 +141,7 @@ interface IDashboardWidget { * @see IWidgetRequest * * @since 15.0.0 + * @deprecated 20.0.0 * * @param IWidgetRequest $request */ diff --git a/lib/public/Dashboard/Model/IWidgetConfig.php b/lib/public/Dashboard/Model/IWidgetConfig.php index 41c9e23317..078c14c742 100644 --- a/lib/public/Dashboard/Model/IWidgetConfig.php +++ b/lib/public/Dashboard/Model/IWidgetConfig.php @@ -36,6 +36,7 @@ use OCP\Dashboard\IDashboardWidget; * @see IDashboardWidget::loadWidget * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Model */ @@ -46,6 +47,7 @@ interface IWidgetConfig { * Returns the userId * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -56,6 +58,7 @@ interface IWidgetConfig { * Returns the widgetId * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -75,6 +78,7 @@ interface IWidgetConfig { * ] * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -105,6 +109,7 @@ interface IWidgetConfig { * Dashboard app. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -115,6 +120,7 @@ interface IWidgetConfig { * Returns if the widget is enabled/displayed in this user's dashboard. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return bool */ diff --git a/lib/public/Dashboard/Model/IWidgetRequest.php b/lib/public/Dashboard/Model/IWidgetRequest.php index 18ad855006..5f1f2e396c 100644 --- a/lib/public/Dashboard/Model/IWidgetRequest.php +++ b/lib/public/Dashboard/Model/IWidgetRequest.php @@ -38,6 +38,7 @@ use OCP\Dashboard\IDashboardWidget; * @see IDashboardWidget::requestWidget * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Model */ @@ -47,6 +48,7 @@ interface IWidgetRequest { * Get the widgetId. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -57,6 +59,7 @@ interface IWidgetRequest { * Get the WidgetClass. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return IDashboardWidget */ @@ -76,6 +79,7 @@ interface IWidgetRequest { * callback); * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -88,6 +92,7 @@ interface IWidgetRequest { * @see getRequest * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -98,6 +103,7 @@ interface IWidgetRequest { * Returns the result. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -108,6 +114,7 @@ interface IWidgetRequest { * add a result (as string) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $key * @param string $result @@ -120,6 +127,7 @@ interface IWidgetRequest { * add a result (as array) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $key * @param array $result diff --git a/lib/public/Dashboard/Model/WidgetSetting.php b/lib/public/Dashboard/Model/WidgetSetting.php index 6242960760..406811e1f8 100644 --- a/lib/public/Dashboard/Model/WidgetSetting.php +++ b/lib/public/Dashboard/Model/WidgetSetting.php @@ -45,6 +45,7 @@ use JsonSerializable; * @see WidgetTemplate::addSetting * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Model */ @@ -73,6 +74,7 @@ final class WidgetSetting implements JsonSerializable { * WidgetSetting constructor. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $type */ @@ -85,6 +87,7 @@ final class WidgetSetting implements JsonSerializable { * Set the name of the setting (full string, no space) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $name * @@ -100,6 +103,7 @@ final class WidgetSetting implements JsonSerializable { * Get the name of the setting * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -112,6 +116,7 @@ final class WidgetSetting implements JsonSerializable { * Set the title/display name of the setting. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $title * @@ -127,6 +132,7 @@ final class WidgetSetting implements JsonSerializable { * Get the title of the setting * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -139,6 +145,7 @@ final class WidgetSetting implements JsonSerializable { * Set the type of the setting (input, checkbox, ...) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $type * @@ -154,6 +161,7 @@ final class WidgetSetting implements JsonSerializable { * Get the type of the setting. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -166,6 +174,7 @@ final class WidgetSetting implements JsonSerializable { * Set the placeholder (in case of type=input) * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $text * @@ -181,6 +190,7 @@ final class WidgetSetting implements JsonSerializable { * Get the placeholder. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -193,6 +203,7 @@ final class WidgetSetting implements JsonSerializable { * Set the default value of the setting. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $value * @@ -208,6 +219,7 @@ final class WidgetSetting implements JsonSerializable { * Get the default value. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -218,6 +230,7 @@ final class WidgetSetting implements JsonSerializable { /** * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ diff --git a/lib/public/Dashboard/Model/WidgetSetup.php b/lib/public/Dashboard/Model/WidgetSetup.php index 18dc0abd48..2a1fc87741 100644 --- a/lib/public/Dashboard/Model/WidgetSetup.php +++ b/lib/public/Dashboard/Model/WidgetSetup.php @@ -38,6 +38,7 @@ use JsonSerializable; * @see IDashboardWidget::getWidgetSetup * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Model */ @@ -73,6 +74,7 @@ final class WidgetSetup implements JsonSerializable { * * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $type * @@ -90,6 +92,7 @@ final class WidgetSetup implements JsonSerializable { * Returns all sizes defined for the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -101,6 +104,7 @@ final class WidgetSetup implements JsonSerializable { * Add a new size to the setup. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $type * @param int $width @@ -121,6 +125,7 @@ final class WidgetSetup implements JsonSerializable { * Returns menu entries. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -136,6 +141,7 @@ final class WidgetSetup implements JsonSerializable { * $text is the display name of the menu entry. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $function * @param string $icon @@ -161,6 +167,7 @@ final class WidgetSetup implements JsonSerializable { * $delay is the time in seconds between each call. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $function * @param int $delay @@ -180,6 +187,7 @@ final class WidgetSetup implements JsonSerializable { * Get delayed jobs. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -192,6 +200,7 @@ final class WidgetSetup implements JsonSerializable { * Get the push function, called when an event is send to the front-end * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -204,6 +213,7 @@ final class WidgetSetup implements JsonSerializable { * frontend. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $function * @@ -220,6 +230,7 @@ final class WidgetSetup implements JsonSerializable { * Returns the default settings for a widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -235,6 +246,7 @@ final class WidgetSetup implements JsonSerializable { * @see WidgetSetting * * @since 15.0.0 + * @deprecated 20.0.0 * * @param array $settings * @@ -249,6 +261,7 @@ final class WidgetSetup implements JsonSerializable { /** * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ diff --git a/lib/public/Dashboard/Model/WidgetTemplate.php b/lib/public/Dashboard/Model/WidgetTemplate.php index e25abb0254..10285cfb00 100644 --- a/lib/public/Dashboard/Model/WidgetTemplate.php +++ b/lib/public/Dashboard/Model/WidgetTemplate.php @@ -37,6 +37,7 @@ use JsonSerializable; * @see IDashboardWidget::getWidgetTemplate * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Model */ @@ -66,6 +67,7 @@ final class WidgetTemplate implements JsonSerializable { * Get the icon class of the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -80,6 +82,7 @@ final class WidgetTemplate implements JsonSerializable { * @see addCss * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $icon * @@ -95,6 +98,7 @@ final class WidgetTemplate implements JsonSerializable { * Get CSS files to be included when displaying a widget * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -106,6 +110,7 @@ final class WidgetTemplate implements JsonSerializable { * path and name of CSS files * * @since 15.0.0 + * @deprecated 20.0.0 * * @param array $css * @@ -121,6 +126,7 @@ final class WidgetTemplate implements JsonSerializable { * Add a CSS file to be included when displaying a widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $css * @@ -136,6 +142,7 @@ final class WidgetTemplate implements JsonSerializable { * Get JS files to be included when loading a widget * * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ @@ -147,6 +154,7 @@ final class WidgetTemplate implements JsonSerializable { * Set an array of JS files to be included when loading a widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param array $js * @@ -162,6 +170,7 @@ final class WidgetTemplate implements JsonSerializable { * Add a JS file to be included when loading a widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $js * @@ -177,6 +186,7 @@ final class WidgetTemplate implements JsonSerializable { * Get the HTML file that contains the content of the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -188,6 +198,7 @@ final class WidgetTemplate implements JsonSerializable { * Set the HTML file that contains the content of the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $content * @@ -203,6 +214,7 @@ final class WidgetTemplate implements JsonSerializable { * Get the JS function to be called when loading the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @return string */ @@ -215,6 +227,7 @@ final class WidgetTemplate implements JsonSerializable { * dashboard * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $function * @@ -232,6 +245,7 @@ final class WidgetTemplate implements JsonSerializable { * @see WidgetSetting * * @since 15.0.0 + * @deprecated 20.0.0 * * @return WidgetSetting[] */ @@ -243,6 +257,7 @@ final class WidgetTemplate implements JsonSerializable { * Define all WidgetSetting for the widget. * * @since 15.0.0 + * @deprecated 20.0.0 * * @see WidgetSetting * @@ -262,6 +277,7 @@ final class WidgetTemplate implements JsonSerializable { * @see WidgetSetting * * @since 15.0.0 + * @deprecated 20.0.0 * * @param WidgetSetting $setting * @@ -279,6 +295,7 @@ final class WidgetTemplate implements JsonSerializable { * @see WidgetSetting::setName * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $key * @@ -295,6 +312,7 @@ final class WidgetTemplate implements JsonSerializable { /** * @since 15.0.0 + * @deprecated 20.0.0 * * @return array */ diff --git a/lib/public/Dashboard/Service/IEventsService.php b/lib/public/Dashboard/Service/IEventsService.php index f79d1a28e5..0e5931878e 100644 --- a/lib/public/Dashboard/Service/IEventsService.php +++ b/lib/public/Dashboard/Service/IEventsService.php @@ -35,6 +35,7 @@ use OCP\Dashboard\IDashboardManager; * are used by the IDashboardManager when creating push event. * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Service */ @@ -47,6 +48,7 @@ interface IEventsService { * @see IDashboardManager::createUsersEvent * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $users @@ -62,6 +64,7 @@ interface IEventsService { * @see IDashboardManager::createGroupsEvent * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $groups @@ -77,6 +80,7 @@ interface IEventsService { * @see IDashboardManager::createGlobalEvent * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param array $payload diff --git a/lib/public/Dashboard/Service/IWidgetsService.php b/lib/public/Dashboard/Service/IWidgetsService.php index dea20489e1..059d91a666 100644 --- a/lib/public/Dashboard/Service/IWidgetsService.php +++ b/lib/public/Dashboard/Service/IWidgetsService.php @@ -36,6 +36,7 @@ use OCP\Dashboard\Model\IWidgetConfig; * configuration of a widget for a user. * * @since 15.0.0 + * @deprecated 20.0.0 * * @package OCP\Dashboard\Service */ @@ -45,6 +46,7 @@ interface IWidgetsService { * Returns the IWidgetConfig for a widgetId and userId * * @since 15.0.0 + * @deprecated 20.0.0 * * @param string $widgetId * @param string $userId From 5a1874910bbb87551bb0195b725279c9c1a33beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 8 Jun 2020 15:39:26 +0200 Subject: [PATCH 03/17] Add dashboard app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .gitignore | 1 + apps/dashboard/appinfo/app.php | 24 ++++ apps/dashboard/appinfo/info.xml | 30 +++++ apps/dashboard/appinfo/routes.php | 28 +++++ apps/dashboard/img/dashboard.svg | 1 + .../lib/Controller/DashboardController.php | 79 ++++++++++++ apps/dashboard/src/App.vue | 119 ++++++++++++++++++ apps/dashboard/src/main.js | 9 ++ apps/dashboard/templates/index.php | 4 + apps/dashboard/webpack.js | 11 ++ webpack.common.js | 2 + 11 files changed, 308 insertions(+) create mode 100644 apps/dashboard/appinfo/app.php create mode 100644 apps/dashboard/appinfo/info.xml create mode 100644 apps/dashboard/appinfo/routes.php create mode 100644 apps/dashboard/img/dashboard.svg create mode 100644 apps/dashboard/lib/Controller/DashboardController.php create mode 100644 apps/dashboard/src/App.vue create mode 100644 apps/dashboard/src/main.js create mode 100644 apps/dashboard/templates/index.php create mode 100644 apps/dashboard/webpack.js diff --git a/.gitignore b/.gitignore index 680bd19c8e..0b6eeaec46 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ !/apps/cloud_federation_api !/apps/comments !/apps/contactsinteraction +!/apps/dashboard !/apps/dav !/apps/files !/apps/federation diff --git a/apps/dashboard/appinfo/app.php b/apps/dashboard/appinfo/app.php new file mode 100644 index 0000000000..3edd53762f --- /dev/null +++ b/apps/dashboard/appinfo/app.php @@ -0,0 +1,24 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +$app = new \OCP\AppFramework\App('dashboard'); diff --git a/apps/dashboard/appinfo/info.xml b/apps/dashboard/appinfo/info.xml new file mode 100644 index 0000000000..9d3b7fc841 --- /dev/null +++ b/apps/dashboard/appinfo/info.xml @@ -0,0 +1,30 @@ + + + dashboard + Dashboard + Dashboard app + + 7.0.0 + agpl + Julius Härtl + Dashboard + + + customization + + https://github.com/nextcloud/server/issues + + + + + + + + Dashboard + dashboard.dashboard.index + dashboard.svg + -1 + + + diff --git a/apps/dashboard/appinfo/routes.php b/apps/dashboard/appinfo/routes.php new file mode 100644 index 0000000000..5ad8e9073d --- /dev/null +++ b/apps/dashboard/appinfo/routes.php @@ -0,0 +1,28 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +return [ + 'routes' => [ + ['name' => 'dashboard#index', 'url' => '/', 'verb' => 'GET'], + ] +]; diff --git a/apps/dashboard/img/dashboard.svg b/apps/dashboard/img/dashboard.svg new file mode 100644 index 0000000000..a942dfc4a5 --- /dev/null +++ b/apps/dashboard/img/dashboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php new file mode 100644 index 0000000000..75a34727c8 --- /dev/null +++ b/apps/dashboard/lib/Controller/DashboardController.php @@ -0,0 +1,79 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Dashboard\Controller; + +use OCA\Viewer\Event\LoadViewer; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\Dashboard\IManager; +use OCP\Dashboard\IPanel; +use OCP\Dashboard\IRegisterPanelEvent; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\IInitialStateService; +use OCP\IRequest; + +class DashboardController extends Controller { + + /** @var IInitialStateService */ + private $inititalStateService; + /** @var IEventDispatcher */ + private $eventDispatcher; + /** @var IManager */ + private $dashboardManager; + + public function __construct($appName, IRequest $request, IInitialStateService $initialStateService, IEventDispatcher $eventDispatcher, IManager $dashboardManager) { + parent::__construct($appName, $request); + + $this->inititalStateService = $initialStateService; + $this->eventDispatcher = $eventDispatcher; + $this->dashboardManager = $dashboardManager; + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + * @return TemplateResponse + */ + public function index(): TemplateResponse { + $this->eventDispatcher->dispatchTyped(new IRegisterPanelEvent($this->dashboardManager)); + + $dashboardManager = $this->dashboardManager; + $this->inititalStateService->provideLazyInitialState('dashboard', 'panels', function () use ($dashboardManager) { + return array_map(function (IPanel $panel) { + return [ + 'id' => $panel->getId(), + 'title' => $panel->getTitle(), + 'iconClass' => $panel->getIconClass(), + 'url' => $panel->getUrl() + ]; + }, $dashboardManager->getPanels()); + }); + + if (class_exists(LoadViewer::class)) { + $this->eventDispatcher->dispatchTyped(new LoadViewer()); + } + + return new TemplateResponse('dashboard', 'index'); + } +} diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue new file mode 100644 index 0000000000..9f8598de21 --- /dev/null +++ b/apps/dashboard/src/App.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/apps/dashboard/src/main.js b/apps/dashboard/src/main.js new file mode 100644 index 0000000000..998f538356 --- /dev/null +++ b/apps/dashboard/src/main.js @@ -0,0 +1,9 @@ +import Vue from 'vue' +import App from './App.vue' + +const Dashboard = Vue.extend(App) +const Instance = new Dashboard({}).$mount('#app') + +window.OCA.Dashboard = { + register: (app, callback) => Instance.register(app, callback), +} diff --git a/apps/dashboard/templates/index.php b/apps/dashboard/templates/index.php new file mode 100644 index 0000000000..b9e614b0f1 --- /dev/null +++ b/apps/dashboard/templates/index.php @@ -0,0 +1,4 @@ + +
diff --git a/apps/dashboard/webpack.js b/apps/dashboard/webpack.js new file mode 100644 index 0000000000..ac45549892 --- /dev/null +++ b/apps/dashboard/webpack.js @@ -0,0 +1,11 @@ +const path = require('path') + +module.exports = { + entry: path.join(__dirname, 'src', 'main.js'), + output: { + path: path.resolve(__dirname, './js'), + publicPath: '/js/', + filename: 'dashboard.js', + jsonpFunction: 'webpackJsonpDashboard' + } +} diff --git a/webpack.common.js b/webpack.common.js index ee8db43e72..249647c314 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -6,6 +6,7 @@ const { VueLoaderPlugin } = require('vue-loader') const accessibility = require('./apps/accessibility/webpack') const comments = require('./apps/comments/webpack') const core = require('./core/webpack') +const dashboard = require('./apps/dashboard/webpack') const files = require('./apps/files/webpack') const files_sharing = require('./apps/files_sharing/webpack') const files_trashbin = require('./apps/files_trashbin/webpack') @@ -21,6 +22,7 @@ const modules = { accessibility, comments, core, + dashboard, files, files_sharing, files_trashbin, From 4b9d47fa536335ca7ebd69ad4098967dfbe5aceb Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 11 Jun 2020 04:20:57 +0200 Subject: [PATCH 04/17] Modify dashboard welcome sentences Signed-off-by: Jan-Christoph Borchardt --- apps/dashboard/src/App.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue index 9f8598de21..04c0a75969 100644 --- a/apps/dashboard/src/App.vue +++ b/apps/dashboard/src/App.vue @@ -39,7 +39,7 @@ export default { const time = this.timer.getHours() if (time > 18) { - return t('dashboard', '🌙 Good evening') + return t('dashboard', '🌙 Time to call it a day') } if (time > 12) { return t('dashboard', '☀ Good afternoon') @@ -47,7 +47,10 @@ export default { if (time === 12) { return t('dashboard', '🍽 Time for lunch') } - return t('dashboard', '🌄 Good morning') + if (time > 5) { + return t('dashboard', '🌄 Good morning') + } + return t('dashboard', '🦉 Have a night owl') }, }, watch: { From 829bf1ad11caaf4e76f64addf406f0f72586d5ba Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 11 Jun 2020 04:21:24 +0200 Subject: [PATCH 05/17] Fix Dashboard layout, positioning and responsiveness Signed-off-by: Jan-Christoph Borchardt --- apps/dashboard/src/App.vue | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue index 04c0a75969..88839a6a5a 100644 --- a/apps/dashboard/src/App.vue +++ b/apps/dashboard/src/App.vue @@ -86,37 +86,43 @@ export default { From a0cd7604812069ea7a06b89d1c104360ba2626e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 23 Jun 2020 17:01:55 +0200 Subject: [PATCH 06/17] Separate icon from translatable text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/dashboard/appinfo/app.php | 24 ------------------------ apps/dashboard/src/App.vue | 14 ++++++-------- 2 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 apps/dashboard/appinfo/app.php diff --git a/apps/dashboard/appinfo/app.php b/apps/dashboard/appinfo/app.php deleted file mode 100644 index 3edd53762f..0000000000 --- a/apps/dashboard/appinfo/app.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * @author Julius Härtl - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -$app = new \OCP\AppFramework\App('dashboard'); diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue index 88839a6a5a..af38e4c7b2 100644 --- a/apps/dashboard/src/App.vue +++ b/apps/dashboard/src/App.vue @@ -1,6 +1,6 @@