beginning to implement dashboard widget

This commit is contained in:
Jonas Heinrich 2020-11-10 14:37:36 +01:00
parent 914ac91868
commit 55b419b338
3 changed files with 67 additions and 1 deletions

View File

@ -11,6 +11,8 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IRequest; use OCP\IRequest;
use OCA\Radio\Dashboard\RadioWidget;
class Application extends App implements IBootstrap { class Application extends App implements IBootstrap {
public const APP_ID = 'radio'; public const APP_ID = 'radio';
@ -22,6 +24,8 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void { public function register(IRegistrationContext $context): void {
$context->registerSearchProvider(SearchProvider::class); $context->registerSearchProvider(SearchProvider::class);
$context->registerDashboardWidget(RadioWidget::class);
$context->registerService('request', static function ($c) { $context->registerService('request', static function ($c) {
return $c->get(IRequest::class); return $c->get(IRequest::class);
}); });

View File

@ -0,0 +1,63 @@
<?php
namespace OCA\Radio\Dashboard;
use OCP\Dashboard\IWidget;
use OCP\IL10N;
use OCA\Radio\AppInfo\Application;
class RadioWidget implements IWidget {
/** @var IL10N */
private $l10n;
public function __construct(
IL10N $l10n
) {
$this->l10n = $l10n;
}
/**
* @inheritDoc
*/
public function getId(): string {
return 'radio';
}
/**
* @inheritDoc
*/
public function getTitle(): string {
return $this->l10n->t('Favorite Radio stations');
}
/**
* @inheritDoc
*/
public function getOrder(): int {
return 10;
}
/**
* @inheritDoc
*/
public function getIconClass(): string {
return 'icon-radio';
}
/**
* @inheritDoc
*/
public function getUrl(): ?string {
return \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => 'connected-accounts']);
}
/**
* @inheritDoc
*/
public function load(): void {
\OC_Util::addScript(Application::APP_ID, Application::APP_ID . '-dashboard');
\OC_Util::addStyle(Application::APP_ID, 'dashboard');
}
}

View File

@ -27,7 +27,6 @@
icon="icon-search" icon="icon-search"
:title="t('radio', 'Search')" /> :title="t('radio', 'Search')" />
</template> </template>
<template #footer> <template #footer>
<Player <Player
:pinned="true" /> :pinned="true" />