Skip to content

Commit

Permalink
Implement dashboard panel
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jul 13, 2020
1 parent 437d06e commit 0f502a2
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCA\Mail\Http\Middleware\ErrorMiddleware;
use OCA\Mail\Http\Middleware\ProvisioningMiddleware;
use OCA\Mail\Listener\AddressCollectionListener;
use OCA\Mail\Listener\DashboardPanelListener;
use OCA\Mail\Listener\DeleteDraftListener;
use OCA\Mail\Listener\DraftMailboxCreatorListener;
use OCA\Mail\Listener\FlagRepliedMessageListener;
Expand All @@ -57,6 +58,7 @@
use OCA\Mail\Service\UserPreferenceSevice;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use OCP\Dashboard\RegisterPanelEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\User\Events\UserDeletedEvent;
use OCP\Util;
Expand Down Expand Up @@ -112,5 +114,6 @@ private function registerEvents(IAppContainer $container): void {
$dispatcher->addServiceListener(NewMessagesSynchronized::class, NewMessageClassificationListener::class);
$dispatcher->addServiceListener(SaveDraftEvent::class, DraftMailboxCreatorListener::class);
$dispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
$dispatcher->addServiceListener(RegisterPanelEvent::class, DashboardPanelListener::class);
}
}
86 changes: 86 additions & 0 deletions lib/Dashboard/MailPanel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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 OCP\Dashboard\IPanel;
use OCP\IL10N;
use OCP\IURLGenerator;

class MailPanel implements IPanel {

/** @var IL10N */
private $l10n;
/** @var IURLGenerator */
private $urlGenerator;

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

/**
* @inheritDoc
*/
public function getId(): string {
return 'mail';
}

/**
* @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 {
\OCP\Util::addScript('mail', 'dashboard');
}
}
49 changes: 49 additions & 0 deletions lib/Listener/DashboardPanelListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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\MailPanel;
use OCP\Dashboard\RegisterPanelEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;

class DashboardPanelListener implements IEventListener {

/**
* @inheritDoc
*/
public function handle(Event $event): void {
if (!($event instanceof RegisterPanelEvent)) {
return;
}

$event->registerPanel(MailPanel::class);
}
}
43 changes: 43 additions & 0 deletions src/main-dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* @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/>.
*
*/

import Vue from 'vue'
import {getRequestToken} from '@nextcloud/auth'
import {generateFilePath} from '@nextcloud/router'

import App from './App'
import Nextcloud from './mixins/Nextcloud'
import Dashboard from './views/Dashboard'

__webpack_nonce__ = btoa(getRequestToken())
__webpack_public_path__ = generateFilePath('mail', '', 'js/')

Vue.mixin(Nextcloud)

document.addEventListener('DOMContentLoaded', function() {
OCA.Dashboard.register('mail', (el) => {
const View = Vue.extend(Dashboard)
new View({
propsData: {},
}).$mount(el)
})
})
37 changes: 37 additions & 0 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
- @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
-
- @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/>.
-
-->

<template>
<div>
No mails
</div>
</template>

<script>
export default {
name: 'Dashboard',
}
</script>

<style scoped>

</style>
1 change: 1 addition & 0 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (process.env.BUNDLE_ANALYZER_TOKEN) {
module.exports = {
entry: {
autoredirect: path.join(__dirname, 'src/autoredirect.js'),
dashboard: path.join(__dirname, 'src/main-dashboard.js'),
mail: path.join(__dirname, 'src/main.js'),
settings: path.join(__dirname, 'src/main-settings')
},
Expand Down

0 comments on commit 0f502a2

Please sign in to comment.