diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 85d348ee3df..b21b670ce5e 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -34,6 +34,7 @@ use OCA\Talk\Collaboration\Resources\ConversationProvider; use OCA\Talk\Collaboration\Resources\Listener as ResourceListener; use OCA\Talk\Config; +use OCA\Talk\Dashboard\TalkPanel; use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Files\Listener as FilesListener; @@ -87,6 +88,8 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(AddFeaturePolicyEvent::class, FeaturePolicyListener::class); $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); $context->registerEventListener(BeforeUserLoggedOutEvent::class, BeforeUserLoggedOutListener::class); + + $context->registerDashboardPanel(TalkPanel::class); } public function boot(IBootContext $context): void { diff --git a/lib/Dashboard/TalkPanel.php b/lib/Dashboard/TalkPanel.php new file mode 100644 index 00000000000..081e8770666 --- /dev/null +++ b/lib/Dashboard/TalkPanel.php @@ -0,0 +1,70 @@ + + * + * @author Julius Härtl + * + * @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 . + * + */ + +namespace OCA\Talk\Dashboard; + + +class TalkPanel implements \OCP\Dashboard\IPanel { + + /** + * @inheritDoc + */ + public function getId(): string { + return 'spreed'; + } + + /** + * @inheritDoc + */ + public function getTitle(): string { + return 'Talk'; + } + + /** + * @inheritDoc + */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ + public function getIconClass(): string { + return 'icon-talk'; + } + + /** + * @inheritDoc + */ + public function getUrl(): ?string { + return \OC::$server->getURLGenerator()->getAbsoluteURL('/apps/spreed'); + } + + /** + * @inheritDoc + */ + public function load(): void { + \OC_Util::addScript('spreed', 'dashboard'); + } +} diff --git a/src/dashboard.js b/src/dashboard.js new file mode 100644 index 00000000000..b516f8d26a2 --- /dev/null +++ b/src/dashboard.js @@ -0,0 +1,54 @@ +/* + * @copyright Copyright (c) 2020 Julius Härtl + * + * @author Julius Härtl + * + * @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 . + * + */ + +import Vue from 'vue' +import { generateFilePath } from '@nextcloud/router' +import { getRequestToken } from '@nextcloud/auth' +import { translate, translatePlural } from '@nextcloud/l10n' +import Dashboard from './views/Dashboard' + +// CSP config for webpack dynamic chunk loading +// eslint-disable-next-line +__webpack_nonce__ = btoa(getRequestToken()) + +// Correct the root of the app for chunk loading +// OC.linkTo matches the apps folders +// OC.generateUrl ensure the index.php (or not) +// We do not want the index.php since we're loading files +// eslint-disable-next-line +__webpack_public_path__ = generateFilePath('spreed', '', 'js/') + +Vue.prototype.t = translate +Vue.prototype.n = translatePlural +Vue.prototype.OC = OC +Vue.prototype.OCA = OCA + +document.addEventListener('DOMContentLoaded', function() { + + OCA.Dashboard.register('spreed', (el) => { + const View = Vue.extend(Dashboard) + new View({ + propsData: {}, + }).$mount(el) + }) + +}) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue new file mode 100644 index 00000000000..446ada68554 --- /dev/null +++ b/src/views/Dashboard.vue @@ -0,0 +1,115 @@ + + + + + + + diff --git a/webpack.common.js b/webpack.common.js index 6b0fd495c2d..d14ac70ac82 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -12,6 +12,7 @@ module.exports = { 'talk-public-share-auth-sidebar': path.join(__dirname, 'src', 'mainPublicShareAuthSidebar.js'), 'talk-public-share-sidebar': path.join(__dirname, 'src', 'mainPublicShareSidebar.js'), 'flow': path.join(__dirname, 'src', 'flow.js'), + 'dashboard': path.join(__dirname, 'src', 'dashboard.js'), }, output: { path: path.resolve(__dirname, './js'),