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

New Dashboard API to return list of all configured dashboard for a given user #3913

Closed
tsteur opened this issue Apr 23, 2013 · 11 comments
Closed
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Apr 23, 2013

I need an API to get configured dashboards for Piwik Mobile 2.

It's already implemented and will attach a diff soon. I'm not sure if I broke something because there are no tests. I think I've also fixed some issues in getAllDashboards. Just do a quick review please and I will send a pull request then. The diff will add three API methods getDashboards, getUserDashboards and getDefaultDashboard.

Structure will look like this (one entry per dashboard).

[
  {
    "name": "Dashboard",
    "widgets": [
      {
        "module": "VisitsSummary",
        "action": "getEvolutionGraph"
      },
      {
        "module": "Live",
        "action": "widget"
      },
      {
        "module": "VisitorInterest",
        "action": "getNumberOfVisitsPerVisitDuration"
      },
      {
        "module": "CoreHome",
        "action": "getPromoVideo"
      },
      {
        "module": "Referers",
        "action": "getKeywords"
      },
      {
        "module": "Referers",
        "action": "getWebsites"
      },
      {
        "module": "UserCountryMap",
        "action": "visitorMap"
      },
      {
        "module": "UserSettings",
        "action": "getBrowser"
      },
      {
        "module": "Referers",
        "action": "getSearchEngines"
      },
      {
        "module": "VisitTime",
        "action": "getVisitInformationPerServerTime"
      },
      {
        "module": "ExampleRssWidget",
        "action": "rssPiwik"
      }
    ]
  }
]

The structure is simple because I don't need more yet but we can still extend it later and add for example things like "layout": "33-33-33"

@tsteur
Copy link
Member Author

tsteur commented Apr 23, 2013

Attachment:
dashboard.patch

@tsteur
Copy link
Member Author

tsteur commented Apr 23, 2013

Attached the code. Kept it simple... Would make sense to extract some things to a Dashboard_Layout class but didn't want to refactor too much.

@mattab
Copy link
Member

mattab commented Apr 24, 2013

Nice improvements!

Review:

  • Piwik Mobile is based on "metadata" reports. Here you will get "widgets". It will work OK to match Widgets->Metadata for most reports since they are called the same, but I wanted to point this out.
    * (!property_exists($widget, 'isHidden') || !$widget->isHidden); could be: !empty($widget->isHidden)
  • in getLayout($idDashboard) the block
        if (empty($layout)) {
            $layout = $this->getDefaultLayout();
        }

should be last (because it's possible that the call to removeDisabledPluginFromLayout() will remove all widgets from existing layout, in which case we'd rather display default layout than empty.

  • the call to removeDisabledPluginFromLayout() could be done at the end of: getDefaultLayout() before the return statement, rather than done by the caller (in getLayout($idDashboard))
  • I agree it would be nice to refactor in Dashboard_Layout class (in 2.0 branch I'd like to refactor all plugins with big _Plugin classes and split up in new classes, so this is relevant!)

Do you want/need to get this in 1.12 or can we wait for 2.0 beta? It looks OK to be included in 1.12 so up to you.

@tsteur
Copy link
Member Author

tsteur commented Apr 24, 2013

thx! Will change some things and send pull request. You're right regarding removeDisabledPluginFromLayout. Will change that although it is a bit confusing that getDefaultLayout automatically removes disabled plugins and for instance getLayoutForUser does not and so on. But when cleaning this up I'd have to refactor the whole plugin because for instance removeDisabledPluginFromLayout is doing multiple things (removing plugins, adding columns if not present, encode/decode, ...).

Would be good to have it in 1.12 if possible. If we release an alpha version of Piwik Mobile 2 in a few weeks users can already see the dashboard feature.

In the beginning I will only display widgets in Piwik Mobile that are reports/metadata. Later I want to implement similar widgets for mobile app. And even later users should be able to write their own widgets :)

Will send a pull request once done.

@tsteur
Copy link
Member Author

tsteur commented Apr 25, 2013

In 9b5f738: refs #3913 provide a simple API for dashboards

@mattab
Copy link
Member

mattab commented Apr 25, 2013

In 4affef7: Merge pull request #64 from tsteur/dashboardapi

refs #3913 provide a simple API for dashboards

@mattab
Copy link
Member

mattab commented Apr 25, 2013

In cdd10f9: Refs #3913 missing <?php + license block

@mattab
Copy link
Member

mattab commented May 6, 2013

In fa4b7c4: Refs #3913 adding XML files so the build passes, but tests output is empty for now. Also moving to private unused methods (lets delete any unused method)

@tsteur
Copy link
Member Author

tsteur commented May 6, 2013

@matt I need API method "getDashboards", not "getUserDashboards" :) I want to display the default dashboard in Piwik Mobile if a user hasn't created his own dashboard to be consistent with Piwik.

@mattab
Copy link
Member

mattab commented May 7, 2013

In 096f890: Fixing build

refs #3913 Fixes API for dashboards + disabling Dashboard API tests for now

@mattab
Copy link
Member

mattab commented May 23, 2013

Thomas please reopen if anything is left on this for 1.12. Nice work!

@tsteur tsteur added this to the 1.12 - The Great 1.x Backlog milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

2 participants