diff --git a/.gitignore b/.gitignore index 680bd19c8e..0b6eeaec46 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ !/apps/cloud_federation_api !/apps/comments !/apps/contactsinteraction +!/apps/dashboard !/apps/dav !/apps/files !/apps/federation diff --git a/apps/dashboard/appinfo/app.php b/apps/dashboard/appinfo/app.php new file mode 100644 index 0000000000..3edd53762f --- /dev/null +++ b/apps/dashboard/appinfo/app.php @@ -0,0 +1,24 @@ + + * + * @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 . + * + */ + +$app = new \OCP\AppFramework\App('dashboard'); diff --git a/apps/dashboard/appinfo/info.xml b/apps/dashboard/appinfo/info.xml new file mode 100644 index 0000000000..9d3b7fc841 --- /dev/null +++ b/apps/dashboard/appinfo/info.xml @@ -0,0 +1,30 @@ + + + dashboard + Dashboard + Dashboard app + + 7.0.0 + agpl + Julius Härtl + Dashboard + + + customization + + https://github.com/nextcloud/server/issues + + + + + + + + Dashboard + dashboard.dashboard.index + dashboard.svg + -1 + + + diff --git a/apps/dashboard/appinfo/routes.php b/apps/dashboard/appinfo/routes.php new file mode 100644 index 0000000000..5ad8e9073d --- /dev/null +++ b/apps/dashboard/appinfo/routes.php @@ -0,0 +1,28 @@ + + * + * @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 . + * + */ + +return [ + 'routes' => [ + ['name' => 'dashboard#index', 'url' => '/', 'verb' => 'GET'], + ] +]; diff --git a/apps/dashboard/img/dashboard.svg b/apps/dashboard/img/dashboard.svg new file mode 100644 index 0000000000..a942dfc4a5 --- /dev/null +++ b/apps/dashboard/img/dashboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php new file mode 100644 index 0000000000..75a34727c8 --- /dev/null +++ b/apps/dashboard/lib/Controller/DashboardController.php @@ -0,0 +1,79 @@ + + * + * @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\Dashboard\Controller; + +use OCA\Viewer\Event\LoadViewer; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\Dashboard\IManager; +use OCP\Dashboard\IPanel; +use OCP\Dashboard\IRegisterPanelEvent; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\IInitialStateService; +use OCP\IRequest; + +class DashboardController extends Controller { + + /** @var IInitialStateService */ + private $inititalStateService; + /** @var IEventDispatcher */ + private $eventDispatcher; + /** @var IManager */ + private $dashboardManager; + + public function __construct($appName, IRequest $request, IInitialStateService $initialStateService, IEventDispatcher $eventDispatcher, IManager $dashboardManager) { + parent::__construct($appName, $request); + + $this->inititalStateService = $initialStateService; + $this->eventDispatcher = $eventDispatcher; + $this->dashboardManager = $dashboardManager; + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + * @return TemplateResponse + */ + public function index(): TemplateResponse { + $this->eventDispatcher->dispatchTyped(new IRegisterPanelEvent($this->dashboardManager)); + + $dashboardManager = $this->dashboardManager; + $this->inititalStateService->provideLazyInitialState('dashboard', 'panels', function () use ($dashboardManager) { + return array_map(function (IPanel $panel) { + return [ + 'id' => $panel->getId(), + 'title' => $panel->getTitle(), + 'iconClass' => $panel->getIconClass(), + 'url' => $panel->getUrl() + ]; + }, $dashboardManager->getPanels()); + }); + + if (class_exists(LoadViewer::class)) { + $this->eventDispatcher->dispatchTyped(new LoadViewer()); + } + + return new TemplateResponse('dashboard', 'index'); + } +} diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue new file mode 100644 index 0000000000..9f8598de21 --- /dev/null +++ b/apps/dashboard/src/App.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/apps/dashboard/src/main.js b/apps/dashboard/src/main.js new file mode 100644 index 0000000000..998f538356 --- /dev/null +++ b/apps/dashboard/src/main.js @@ -0,0 +1,9 @@ +import Vue from 'vue' +import App from './App.vue' + +const Dashboard = Vue.extend(App) +const Instance = new Dashboard({}).$mount('#app') + +window.OCA.Dashboard = { + register: (app, callback) => Instance.register(app, callback), +} diff --git a/apps/dashboard/templates/index.php b/apps/dashboard/templates/index.php new file mode 100644 index 0000000000..b9e614b0f1 --- /dev/null +++ b/apps/dashboard/templates/index.php @@ -0,0 +1,4 @@ + +
diff --git a/apps/dashboard/webpack.js b/apps/dashboard/webpack.js new file mode 100644 index 0000000000..ac45549892 --- /dev/null +++ b/apps/dashboard/webpack.js @@ -0,0 +1,11 @@ +const path = require('path') + +module.exports = { + entry: path.join(__dirname, 'src', 'main.js'), + output: { + path: path.resolve(__dirname, './js'), + publicPath: '/js/', + filename: 'dashboard.js', + jsonpFunction: 'webpackJsonpDashboard' + } +} diff --git a/webpack.common.js b/webpack.common.js index ee8db43e72..249647c314 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -6,6 +6,7 @@ const { VueLoaderPlugin } = require('vue-loader') const accessibility = require('./apps/accessibility/webpack') const comments = require('./apps/comments/webpack') const core = require('./core/webpack') +const dashboard = require('./apps/dashboard/webpack') const files = require('./apps/files/webpack') const files_sharing = require('./apps/files_sharing/webpack') const files_trashbin = require('./apps/files_trashbin/webpack') @@ -21,6 +22,7 @@ const modules = { accessibility, comments, core, + dashboard, files, files_sharing, files_trashbin,