IDashboardManager.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Nextcloud - Dashboard App
  5. *
  6. * This file is licensed under the Affero General Public License version 3 or
  7. * later. See the COPYING file.
  8. *
  9. * @author Maxence Lange <maxence@artificial-owl.com>
  10. * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCP\Dashboard;
  28. use OCP\Dashboard\Exceptions\DashboardAppNotAvailableException;
  29. use OCP\Dashboard\Model\IWidgetConfig;
  30. use OCP\Dashboard\Service\IEventsService;
  31. use OCP\Dashboard\Service\IWidgetsService;
  32. /**
  33. * Interface IDashboardManager
  34. *
  35. * IDashboardManager should be used to manage widget from the backend.
  36. * The call can be done from any Service.
  37. *
  38. * @since 15.0.0
  39. *
  40. * @package OCP\Dashboard
  41. */
  42. interface IDashboardManager {
  43. /**
  44. * Register a IWidgetsService.
  45. *
  46. * @since 15.0.0
  47. *
  48. * @param IWidgetsService $widgetsService
  49. */
  50. public function registerWidgetsService(IWidgetsService $widgetsService);
  51. /**
  52. * Register a IEventsService.
  53. *
  54. * @since 15.0.0
  55. *
  56. * @param IEventsService $eventsService
  57. */
  58. public function registerEventsService(IEventsService $eventsService);
  59. /**
  60. * returns the OCP\Dashboard\Model\IWidgetConfig for a widgetId and userId.
  61. *
  62. * @see IWidgetConfig
  63. *
  64. * @since 15.0.0
  65. *
  66. * @param string $widgetId
  67. * @param string $userId
  68. *
  69. * @throws DashboardAppNotAvailableException
  70. * @return IWidgetConfig
  71. */
  72. public function getWidgetConfig(string $widgetId, string $userId): IWidgetConfig;
  73. /**
  74. * Create push notifications for users.
  75. * $payload is an array that will be send to the Javascript method
  76. * called on push.
  77. * $uniqueId needs to be used if you send the push to multiples users
  78. * and multiples groups so that one user does not have duplicate
  79. * notifications.
  80. *
  81. * Push notifications are created in database and broadcast to user
  82. * that are running dashboard.
  83. *
  84. * @since 15.0.0
  85. *
  86. * @param string $widgetId
  87. * @param array $users
  88. * @param array $payload
  89. * @param string $uniqueId
  90. * @throws DashboardAppNotAvailableException
  91. */
  92. public function createUsersEvent(string $widgetId, array $users, array $payload, string $uniqueId = '');
  93. /**
  94. * Create push notifications for groups. (ie. createUsersEvent())
  95. *
  96. * @since 15.0.0
  97. *
  98. * @param string $widgetId
  99. * @param array $groups
  100. * @param array $payload
  101. * @param string $uniqueId
  102. * @throws DashboardAppNotAvailableException
  103. */
  104. public function createGroupsEvent(string $widgetId, array $groups, array $payload, string $uniqueId = '');
  105. /**
  106. * Create push notifications for everyone. (ie. createUsersEvent())
  107. *
  108. * @since 15.0.0
  109. *
  110. * @param string $widgetId
  111. * @param array $payload
  112. * @param string $uniqueId
  113. * @throws DashboardAppNotAvailableException
  114. */
  115. public function createGlobalEvent(string $widgetId, array $payload, string $uniqueId = '');
  116. }