summaryrefslogtreecommitdiffstats
path: root/apps/dashboard/lib/Controller
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-06-15 08:18:50 +0200
committerJulius Härtl <jus@bitgrid.net>2020-08-05 17:01:27 +0200
commit429049c809226f3750647a19a4cb48e0d3d4ea75 (patch)
tree3a66ed71df4d417dacfb888ce831e5db7d98267d /apps/dashboard/lib/Controller
parent55473dd2eb042078b7fc5aef37e7b7fb614554fa (diff)
downloadnextcloud-server-429049c809226f3750647a19a4cb48e0d3d4ea75.tar.gz
nextcloud-server-429049c809226f3750647a19a4cb48e0d3d4ea75.zip
Allow userdefined order and start with drag and drop resorting
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/dashboard/lib/Controller')
-rw-r--r--apps/dashboard/lib/Controller/DashboardController.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php
index 687fbace380..e796ae67ccd 100644
--- a/apps/dashboard/lib/Controller/DashboardController.php
+++ b/apps/dashboard/lib/Controller/DashboardController.php
@@ -26,13 +26,16 @@ declare(strict_types=1);
namespace OCA\Dashboard\Controller;
+use OCA\Dashboard\AppInfo\Application;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Dashboard\IManager;
use OCP\Dashboard\IPanel;
use OCP\Dashboard\RegisterPanelEvent;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IConfig;
use OCP\IInitialStateService;
use OCP\IRequest;
@@ -44,19 +47,27 @@ class DashboardController extends Controller {
private $eventDispatcher;
/** @var IManager */
private $dashboardManager;
+ /** @var IConfig */
+ private $config;
+ /** @var string */
+ private $userId;
public function __construct(
string $appName,
IRequest $request,
IInitialStateService $initialStateService,
IEventDispatcher $eventDispatcher,
- IManager $dashboardManager
+ IManager $dashboardManager,
+ IConfig $config,
+ $userId
) {
parent::__construct($appName, $request);
$this->inititalStateService = $initialStateService;
$this->eventDispatcher = $eventDispatcher;
$this->dashboardManager = $dashboardManager;
+ $this->config = $config;
+ $this->userId = $userId;
}
/**
@@ -67,7 +78,7 @@ class DashboardController extends Controller {
public function index(): TemplateResponse {
$this->eventDispatcher->dispatchTyped(new RegisterPanelEvent($this->dashboardManager));
- $dashboardManager = $this->dashboardManager;
+ $userLayout = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', 'calendar,recommendations,spreed,mail'));
$panels = array_map(function (IPanel $panel) {
return [
'id' => $panel->getId(),
@@ -75,8 +86,9 @@ class DashboardController extends Controller {
'iconClass' => $panel->getIconClass(),
'url' => $panel->getUrl()
];
- }, $dashboardManager->getPanels());
+ }, $this->dashboardManager->getPanels());
$this->inititalStateService->provideInitialState('dashboard', 'panels', $panels);
+ $this->inititalStateService->provideInitialState('dashboard', 'layout', $userLayout);
if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatchTyped(new LoadViewer());
@@ -84,4 +96,14 @@ class DashboardController extends Controller {
return new TemplateResponse('dashboard', 'index');
}
+
+ /**
+ * @NoAdminRequired
+ * @param string $layout
+ * @return JSONResponse
+ */
+ public function updateLayout(string $layout): JSONResponse {
+ $this->config->setUserValue($this->userId, 'dashboard', 'layout', $layout);
+ return new JSONResponse(['layout' => $layout]);
+ }
}