From 0915e4e1013c12a30372c713c2fe057acc119991 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Mon, 14 Dec 2020 14:36:10 +0100 Subject: [PATCH] add dashboard widget, only handling internal 'Follow' subtypes for the moment Signed-off-by: Julien Veyssier --- css/dashboard.css | 7 ++ img/add_user.svg | 87 ++++++++++++++ lib/AppInfo/Application.php | 2 + lib/Dashboard/SocialWidget.php | 83 ++++++++++++++ src/dashboard.js | 32 ++++++ src/views/Dashboard.vue | 200 +++++++++++++++++++++++++++++++++ webpack.common.js | 3 +- webpack.dev.js | 12 -- webpack.prod.js | 7 -- 9 files changed, 412 insertions(+), 21 deletions(-) create mode 100644 css/dashboard.css create mode 100644 img/add_user.svg create mode 100644 lib/Dashboard/SocialWidget.php create mode 100644 src/dashboard.js create mode 100644 src/views/Dashboard.vue delete mode 100644 webpack.dev.js delete mode 100644 webpack.prod.js diff --git a/css/dashboard.css b/css/dashboard.css new file mode 100644 index 00000000..6f79efe9 --- /dev/null +++ b/css/dashboard.css @@ -0,0 +1,7 @@ +.icon-social { + background-image: url('../img/social-dark.svg'); +} + +body.theme--dark .icon-social { + background-image: url('../img/social.svg'); +} diff --git a/img/add_user.svg b/img/add_user.svg new file mode 100644 index 00000000..c9c2b73a --- /dev/null +++ b/img/add_user.svg @@ -0,0 +1,87 @@ + + + +image/svg+xml + + + + + + + + + + \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1324c806..93f45f6b 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -38,6 +38,7 @@ use OCA\Social\Service\ConfigService; use OCA\Social\Service\UpdateService; use OCA\Social\WellKnown\WebfingerHandler; use OCA\Social\Listeners\ProfileSectionListener; +use OCA\Social\Dashboard\SocialWidget; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -68,6 +69,7 @@ class Application extends App implements IBootstrap { $context->registerSearchProvider(UnifiedSearchProvider::class); $context->registerWellKnownHandler(WebfingerHandler::class); $context->registerEventListener(BeforeTemplateRenderedEvent::class, ProfileSectionListener::class); + $context->registerDashboardWidget(SocialWidget::class); } public function boot(IBootContext $context): void { diff --git a/lib/Dashboard/SocialWidget.php b/lib/Dashboard/SocialWidget.php new file mode 100644 index 00000000..495dddcb --- /dev/null +++ b/lib/Dashboard/SocialWidget.php @@ -0,0 +1,83 @@ + + * + * @author Julien Veyssier + * + * @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\Social\Dashboard; + +use OCP\Dashboard\IWidget; +use OCP\IL10N; +use OCA\Social\AppInfo\Application; + +class SocialWidget implements IWidget { + + /** @var IL10N */ + private $l10n; + + public function __construct( + IL10N $l10n + ) { + $this->l10n = $l10n; + } + + /** + * @inheritDoc + */ + public function getId(): string { + return 'social_notifications'; + } + + /** + * @inheritDoc + */ + public function getTitle(): string { + return $this->l10n->t('Social notifications'); + } + + /** + * @inheritDoc + */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ + public function getIconClass(): string { + return 'icon-social'; + } + + /** + * @inheritDoc + */ + public function getUrl(): ?string { + return \OC::$server->getURLGenerator()->linkToRoute('social.local.streamNotifications', []); + } + + /** + * @inheritDoc + */ + public function load(): void { + \OC_Util::addScript(Application::APP_NAME, 'dashboard'); + \OC_Util::addStyle(Application::APP_NAME, 'dashboard'); + } +} \ No newline at end of file diff --git a/src/dashboard.js b/src/dashboard.js new file mode 100644 index 00000000..48132a91 --- /dev/null +++ b/src/dashboard.js @@ -0,0 +1,32 @@ +/* jshint esversion: 6 */ + +/** + * Nextcloud - social + * + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Julien Veyssier + * @copyright Julien Veyssier 2020 + */ + +import Vue from 'vue' +import { translate, translatePlural } from '@nextcloud/l10n' +import Dashboard from './views/Dashboard' + +Vue.prototype.t = translate +Vue.prototype.n = translatePlural +Vue.prototype.OC = window.OC +Vue.prototype.OCA = window.OCA + +document.addEventListener('DOMContentLoaded', function() { + + OCA.Dashboard.register('social_notifications', (el, { widget }) => { + const View = Vue.extend(Dashboard) + new View({ + propsData: { title: widget.title }, + }).$mount(el) + }) + +}) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue new file mode 100644 index 00000000..bb5cbf8a --- /dev/null +++ b/src/views/Dashboard.vue @@ -0,0 +1,200 @@ + + + + + diff --git a/webpack.common.js b/webpack.common.js index d432a44c..132c04a3 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -8,6 +8,5 @@ webpackConfig.entry = { social: path.join(__dirname, 'src', 'main.js'), ostatus: path.join(__dirname, 'src', 'ostatus.js'), profilePage: path.join(__dirname, 'src', 'profile.js'), + dashboard: path.join(__dirname, 'src', 'dashboard.js'), } - -module.exports = webpackConfig diff --git a/webpack.dev.js b/webpack.dev.js deleted file mode 100644 index 439d2b0a..00000000 --- a/webpack.dev.js +++ /dev/null @@ -1,12 +0,0 @@ -const { merge } = require('webpack-merge'); -const common = require('./webpack.common.js'); - -module.exports = merge(common, { - mode: 'development', - devServer: { - historyApiFallback: true, - noInfo: true, - overlay: true - }, - devtool: 'source-map', -}) diff --git a/webpack.prod.js b/webpack.prod.js deleted file mode 100644 index 4ff9c2c1..00000000 --- a/webpack.prod.js +++ /dev/null @@ -1,7 +0,0 @@ -const { merge } = require('webpack-merge') -const common = require('./webpack.common.js') - -module.exports = merge(common, { - mode: 'production', - devtool: '#source-map' -})