Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dashboard #247

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions css/dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.icon-riotchat-dark {
background-image: url(./../img/app-dark.svg);
}
15 changes: 13 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@

namespace OCA\RiotChat\AppInfo;

use OCA\RiotChat\Dashboard\RiotChatWidget;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IRegistrationContext;

class Application extends App {
class Application extends App Implements IBootstrap {
public const APP_ID = 'riotchat';

public const AvailableSettings = [
Expand All @@ -47,7 +51,14 @@ public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}

public static function AvailableLabs() {
public function register(IRegistrationContext $context): void {
$context->registerDashboardWidget(RiotChatWidget::class);
}

public function boot(IBootContext $context): void {
}

public static function AvailableLabs(): array {
// Element Web has removed the current Labs system. https://github.com/gary-kim/riotchat/issues/139
// TODO: Remove the labs feature fully
return [];
Expand Down
84 changes: 84 additions & 0 deletions lib/Dashboard/RiotChatWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Gary Kim <[email protected]>
*
* @author Gary Kim <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\RiotChat\Dashboard;

use OCA\RiotChat\AppInfo\Application;
use OCP\Dashboard\IWidget;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Util;

class RiotChatWidget implements IWidget {

/** @var IInitialStateService */
private $initialStateService;
/** @var IUserSession */
private $userSession;
/** @var IL10N */
private $l10n;

public function __construct(
IInitialStateService $initialStateService,
IUserSession $userSession,
IL10N $l10n,
IURLGenerator $urlGenerator
) {
$this->initialStateService = $initialStateService;
$this->userSession = $userSession;
$this->l10n = $l10n;
}

public function getId(): string {
return 'riotchat';
}

public function getTitle(): string {
return $this->l10n->t('Element for Nextcloud');
}

public function getOrder(): int {
return 50;
}

public function getIconClass(): string {
return 'icon-riotchat-dark';
}

public function getUrl(): ?string {
return null;
}

public function load(): void {
$user = $this->userSession->getUser();
if ($user === null) {
return;
}
Util::addScript(Application::APP_ID, 'dashboard');
Util::addStyle(Application::APP_ID, 'dashboard');
}
}
Loading