Skip to content

Commit

Permalink
In progress
Browse files Browse the repository at this point in the history
Signed-off-by: Gary Kim <[email protected]>
  • Loading branch information
gary-kim committed Jan 25, 2021
1 parent 0f88d83 commit ce1b21a
Show file tree
Hide file tree
Showing 9 changed files with 1,462 additions and 228 deletions.
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

0 comments on commit ce1b21a

Please sign in to comment.