-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Julius Härtl <[email protected]>
- Loading branch information
1 parent
1530f48
commit e7ab9f2
Showing
9 changed files
with
440 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020 Julius Härtl <[email protected]> | ||
* | ||
* @author Julius Härtl <[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\Mail\Dashboard; | ||
|
||
use OCA\Mail\AppInfo\Application; | ||
use OCA\Mail\Service\AccountService; | ||
use OCP\AppFramework\Services\IInitialState; | ||
use OCP\Dashboard\IWidget; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\Util; | ||
|
||
class MailWidget implements IWidget { | ||
|
||
/** @var IL10N */ | ||
private $l10n; | ||
|
||
/** @var IURLGenerator */ | ||
private $urlGenerator; | ||
|
||
/** @var AccountService */ | ||
private $accountService; | ||
|
||
/** @var IInitialState */ | ||
private $initialState; | ||
|
||
/** @var string|null */ | ||
private $userId; | ||
|
||
public function __construct(IL10N $l10n, | ||
IURLGenerator $urlGenerator, | ||
AccountService $accountService, | ||
IInitialState $initialState, | ||
?string $userId) { | ||
$this->l10n = $l10n; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->accountService = $accountService; | ||
$this->initialState = $initialState; | ||
$this->userId = $userId; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getId(): string { | ||
return Application::APP_ID; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTitle(): string { | ||
return $this->l10n->t('Important mail'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getOrder(): int { | ||
return 4; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIconClass(): string { | ||
return 'icon-mail'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getUrl(): ?string { | ||
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('mail.page.index')); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function load(): void { | ||
Util::addScript(Application::APP_ID, 'dashboard'); | ||
|
||
$this->initialState->provideInitialState( | ||
'mail-accounts', | ||
$this->accountService->findByUserId($this->userId) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2020 Julius Härtl <[email protected]> | ||
* | ||
* @author Julius Härtl <[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\Mail\Listener; | ||
|
||
use OCA\Mail\Dashboard\MailWidget; | ||
use OCP\Dashboard\RegisterWidgetEvent; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
|
||
class DashboardPanelListener implements IEventListener { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function handle(Event $event): void { | ||
if (!($event instanceof RegisterWidgetEvent)) { | ||
return; | ||
} | ||
|
||
$event->registerWidget(MailWidget::class); | ||
} | ||
} |
Oops, something went wrong.