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\IRequest;
use OCA\Radio\Dashboard\RadioWidget;
class Application extends App implements IBootstrap {
public const APP_ID = 'radio';
@ -22,6 +24,8 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
$context->registerSearchProvider(SearchProvider::class);
$context->registerDashboardWidget(RadioWidget::class);
$context->registerService('request', static function ($c) {
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"
:title="t('radio', 'Search')" />
</template>
<template #footer>
<Player
:pinned="true" />