IDashboardWidget.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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\Model\WidgetSetup;
  29. use OCP\Dashboard\Model\WidgetTemplate;
  30. use OCP\Dashboard\Model\IWidgetConfig;
  31. use OCP\Dashboard\Model\IWidgetRequest;
  32. /**
  33. * Interface IDashboardWidget
  34. *
  35. * This interface is used to create a widget: the widget must implement this
  36. * interface and be defined in appinfo/info.xml:
  37. *
  38. * <dashboard>
  39. * <widget>OCA\YourApp\YourWidget</widget>
  40. * </dashboard>
  41. *
  42. * Multiple widget can be defined in the same appinfo/info.xml.
  43. *
  44. * @since 15.0.0
  45. *
  46. * @package OCP\Dashboard
  47. */
  48. interface IDashboardWidget {
  49. /**
  50. * Should returns the (unique) Id of the widget.
  51. *
  52. * @since 15.0.0
  53. *
  54. * @return string
  55. */
  56. public function getId(): string;
  57. /**
  58. * Should returns the [display] name of the widget.
  59. *
  60. * @since 15.0.0
  61. *
  62. * @return string
  63. */
  64. public function getName(): string;
  65. /**
  66. * Should returns some text describing the widget.
  67. * This description is displayed in the listing of the available widgets.
  68. *
  69. * @since 15.0.0
  70. *
  71. * @return string
  72. */
  73. public function getDescription(): string;
  74. /**
  75. * Must generate and return a WidgetTemplate that define important stuff
  76. * about the Widget: icon, content, css or javascript.
  77. *
  78. * @see WidgetTemplate
  79. *
  80. * @since 15.0.0
  81. *
  82. * @return WidgetTemplate
  83. */
  84. public function getWidgetTemplate(): WidgetTemplate;
  85. /**
  86. * Must create and return a WidgetSetup containing the general setup of
  87. * the widget
  88. *
  89. * @see WidgetSetup
  90. *
  91. * @since 15.0.0
  92. *
  93. * @return WidgetSetup
  94. */
  95. public function getWidgetSetup(): WidgetSetup;
  96. /**
  97. * This method is called when a widget is loaded on the dashboard.
  98. * A widget is 'loaded on the dashboard' when one of these conditions
  99. * occurs:
  100. *
  101. * - the user is adding the widget on his dashboard,
  102. * - the user already added the widget on his dashboard and he is opening
  103. * the dashboard app.
  104. *
  105. * @see IWidgetConfig
  106. *
  107. * @since 15.0.0
  108. *
  109. * @param IWidgetConfig $settings
  110. */
  111. public function loadWidget(IWidgetConfig $settings);
  112. /**
  113. * This method s executed when the widget call the net.requestWidget()
  114. * from the Javascript API.
  115. *
  116. * This is used by the frontend to communicate with the backend.
  117. *
  118. * @see IWidgetRequest
  119. *
  120. * @since 15.0.0
  121. *
  122. * @param IWidgetRequest $request
  123. */
  124. public function requestWidget(IWidgetRequest $request);
  125. }