refs #22468 fix empty php array becoming an array instead of an object in UI

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
pull/22531/head
Julien Veyssier 5 years ago
parent 3c62767873
commit e8f37dd2b2
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
  1. 6
      apps/dashboard/lib/Controller/DashboardController.php

@ -103,8 +103,12 @@ class DashboardController extends Controller {
'url' => $widget->getUrl()
];
}, $this->dashboardManager->getWidgets());
$configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', '{}');
$configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', '');
$statuses = json_decode($configStatuses, true);
// We avoid getting an empty array as it will not produce an object in UI's JS
// It does not matter if some statuses are missing from the array, missing ones are considered enabled
$statuses = ($statuses && count($statuses) > 0) ? $statuses : ['weather' => true];
$this->inititalStateService->provideInitialState('dashboard', 'panels', $widgets);
$this->inititalStateService->provideInitialState('dashboard', 'statuses', $statuses);
$this->inititalStateService->provideInitialState('dashboard', 'layout', $userLayout);

Loading…
Cancel
Save