IDashboardManager.php 3.4 KB

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