Add load method for apps to bootstrap their panels
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
879b756995
commit
31a1494529
|
@ -23,11 +23,13 @@
|
|||
|
||||
namespace OC\Dashboard;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Dashboard\IManager;
|
||||
use OCP\Dashboard\IPanel;
|
||||
use OCP\ILogger;
|
||||
use OCP\IServerContainer;
|
||||
use Throwable;
|
||||
|
||||
class Manager implements IManager {
|
||||
|
||||
|
@ -46,7 +48,7 @@ class Manager implements IManager {
|
|||
|
||||
private 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');
|
||||
throw new InvalidArgumentException('Dashboard panel with this id has already been registered');
|
||||
}
|
||||
|
||||
$this->panels[$panel->getId()] = $panel;
|
||||
|
@ -88,6 +90,15 @@ class Manager implements IManager {
|
|||
'level' => ILogger::FATAL,
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$panel->load();
|
||||
} catch (Throwable $e) {
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Error during dashboard panel loading: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
]);
|
||||
}
|
||||
}
|
||||
$this->lazyPanels = [];
|
||||
}
|
||||
|
|
|
@ -32,32 +32,38 @@ namespace OCP\Dashboard;
|
|||
interface IPanel {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string Unique id that identifies the panel, e.g. the app id
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getId(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string User facing title of the panel
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getTitle(): string;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return int Initial order for panel sorting
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getOrder(): int;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string css class that displays an icon next to the panel title
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getIconClass(): string;
|
||||
|
||||
/**
|
||||
* @return string The absolute url to the apps own view
|
||||
* @return string|null The absolute url to the apps own view
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getUrl(): string;
|
||||
public function getUrl(): ?string;
|
||||
|
||||
/**
|
||||
* Execute panel bootstrap code like loading scripts and providing initial state
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function load(): void;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue