diff --git a/js/layouts/dashboard/dashboard.js b/js/layouts/dashboard/dashboard.js index be0732240..0dde452f2 100644 --- a/js/layouts/dashboard/dashboard.js +++ b/js/layouts/dashboard/dashboard.js @@ -273,11 +273,15 @@ class IboDashboard extends HTMLElement { let sSaveUrl = GetAbsoluteUrlAppRoot() + '/pages/UI.php?route=dashboard.save&values='+encodeURIComponent(JSON.stringify(aPayload)); fetch(sSaveUrl) .then(async data => { - // TODO 3.3 What's returned ? + const res = await data.json(); + if(res.status === 'ok') { + CombodoToast.OpenToast(res.message, 'success'); + this.SetEditMode(false); + this.aLastSavedState = aPayload; + } else { + CombodoToast.OpenToast(res.message, 'error'); + } }) - - this.SetEditMode(false); - this.aLastSavedState = aPayload; } diff --git a/sources/Controller/Base/Layout/DashboardController.php b/sources/Controller/Base/Layout/DashboardController.php index 93797f882..9b9c3a731 100644 --- a/sources/Controller/Base/Layout/DashboardController.php +++ b/sources/Controller/Base/Layout/DashboardController.php @@ -88,6 +88,8 @@ class DashboardController extends Controller { $sValues = utils::ReadParam('values', '', false, utils::ENUM_SANITIZATION_FILTER_RAW_DATA); $aValues = !empty($sValues) ? json_decode($sValues, true, 20) : []; + $sStatus = 'error'; + $sMessage = 'Unknown error'; try { // Get the form block from the service (and the compiler) @@ -106,15 +108,21 @@ class DashboardController extends Controller XMLSerializer::GetInstance()->Serialize($aValues, $oDomNode, 'DashboardGrid', 'Dashboard'); $sXml = $oDomNode->ownerDocument->saveXML(); $oDashboard->PersistDashboard($sXml); + $sStatus = 'ok'; + $sMessage = 'Dashboard saved'; // } // } } catch (Exception $e) { IssueLog::Exception($e->getMessage(), $e); - return null; + $sStatus = 'error'; + $sMessage = $e->getMessage(); } $oPage = new JsonPage(); - $oPage->SetData($aValues); + $oPage->SetData([ + 'status' => $sStatus, + 'message' => $sMessage + ]); $oPage->SetOutputDataOnly(true); return $oPage; }