Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improvements to Dashboard API #12609

Merged
merged 2 commits into from Mar 20, 2018
Merged

Further improvements to Dashboard API #12609

merged 2 commits into from Mar 20, 2018

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Mar 9, 2018

fixes #12608

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Mar 9, 2018
@sgiehl sgiehl added this to the 3.3.1 milestone Mar 9, 2018
*
* @return array[]
*/
public function getDashboards()
public function getDashboards($login = '', $returnDefaultIfEmpty = true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method was kind of useless without the additional parameters, as it did not allow to fetch dashboards of a specific user. Also it always returned at least one dashboard, even if there isn't one in the database. Therefor the second param can now be set, to get the real result of the database. We can't simply change this behavior, as it would break Matomo Mobile

@@ -138,7 +138,7 @@ public function saveLayout()
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
$this->getModel()->updateLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
$this->getModel()->createOrUpdateDashboard(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures, that the dashboard is created if it does not yet exists. That is e.g. the case if all dashboards were removed from database. The UI then shows the default dashboard (with id 1), even if it isn't stored in DB. Changing the dashboard in UI will trigger an updateLayout (which failed before, as the dashboard wasn't created).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice solution 👍

if (!empty($layout)) {
$layout = $this->dashboard->removeDisabledPluginFromLayout($layout);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved that block, as it might be possible that the default layout might contain unavailable widgets as well.

@diosmosis
Copy link
Member

👍 looks good

@mattab
Copy link
Member

mattab commented Mar 20, 2018

@sgiehl 👍 nicely done!

I'm merging now, but could you please add an entry in the CHANGELOG for the new API feature/behavior?

@mattab mattab merged commit 4bf917c into 3.x-dev Mar 20, 2018
@mattab mattab deleted the dashboard branch March 20, 2018 10:09
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
* Further improvements to Dashboard API

* adds some tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better handling of situation when there are no dashboards for a user
3 participants