Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#103 closed Bug (fixed)

Hitting the refresh button should refresh the exact same page

Reported by: matt Owned by:
Priority: major Milestone: Piwik 0.9 - Surviving The Wild
Component: Core Keywords:
Cc: Sensitive:

Description (last modified by matt)

This problem comes from the fact that we use ajax to load every content in piwik, so the URL remains the same all the time.

To fix this we can use the # in the URL, the same way Gmail does.

proposal

  • at least following variables should be persisted in V1: day/period/idSite/module/action
  • how to implement it? I would suggest the Facebook way (ie. the query after the #, eg. #module=Referers&action=getSearchEngines&idSite=1 etc.)
  • see http://dev.piwik.org/trac/wiki/HowToTestUI which lists all UI features; good place to start to get a feeling of what is necessary to persist

Calendar

Currently changing the date in the calendar also changes the currently viewed section (reset to Dashboard).

Instead we should reload the same category.

Ressources

See Jquery History

jQuery history plugin: It uses the hash (fragment)
method that was mentioned earlier in this thread. You essentially need to be able to store some text that encapsulates the current page state so that it can be recreated by the browser on reload; no information beyond that in the URL is maintained in any reliable way. This particular plugin also has the effect of making the "back" and "forward" buttons undo and redo page state changes, which you may or may not want.

Attachments (1)

103 patch.diffs (7.8 KB) - added by kpham 5 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 6 years ago by matt (mattab)

  • Description modified (diff)

comment:2 Changed 6 years ago by matt (mattab)

  • Description modified (diff)

comment:3 Changed 6 years ago by matt (mattab)

  • Milestone changed from Future features to DigitalVibes

comment:4 Changed 6 years ago by matt (mattab)

  • Description modified (diff)

comment:5 Changed 5 years ago by matt (mattab)

  • Description modified (diff)

comment:6 Changed 5 years ago by matt (mattab)

  • Milestone changed from DigitalVibes to Surviving The Wild

comment:7 Changed 5 years ago by matt (mattab)

  • Description modified (diff)

Changed 5 years ago by kpham

comment:8 Changed 5 years ago by kpham

added patch for this ticket.
This patch was tested on ie7 and FireFox on both linux and windows.

  1. This patch should help piwik to know which module and action user want based on the anchor params: e.g: #module=VisitTime&action=index
  1. Hitting refresh should work as well :)
svn st:
A      plugins/CoreHome/templates/url_anchor.js
M      plugins/CoreHome/templates/menu.js
M      plugins/CoreHome/templates/calendar.js
M      plugins/CoreHome/templates/sites_selection.tpl
M      plugins/CoreHome/templates/js_css_includes.tpl

comment:9 Changed 5 years ago by matt (mattab)

kpham, thanks for patch.

I think however code can be improved, especially because in the future we'd like to persist more parameters than period/date/idsite/module/action therefore it should be modular.

Feedback
On the architecture side: I would think of having a broadcaster javascript object that you would call with a simple api like: changeParameter(string).
For example:

<a href="broadcast.changeParameter('module=Referers&action=getKeywords')">View full keywords report</
or
<a href="broadcast.changeParameter('date=yesterday&period=day&module=Referers&action=getKeywords')">View full keywords report for yesterday</a>

This function would update the hash. Then it would trigger an event that says "onParametersUpdate" for example, and this function would do the job to call the right url in ajax to load below the menu (ie. there will be some menu code moved from existing javascript to this function). Later we could persist other parameters and add the code necessary to restore the page state in this function.

What do you think about such a design?

Other feedback on the code

  • updateAnchor has a li_id parameter but it's not used?
  • for example, calendar.js shouldn't have to do substring matches, it should call a method on the broadcast object (eg. getVariableFromAnchor('date')) that would do the work and return the right variable from the hash, or false
  • isAnchorExists should return false rather than undefined
  • getParamValueFromUrl should work well when passed a URL with anchor (ie the api of the object to handle the hash should be very simple to use from outside)
  • also please have a look at Piwik Coding Standard

also:

  • does the back button work as expected on the browser?
  • we should aim to persist the parameters date and period as well.
  • Persisting idSite could wait for the V2 as it has some added complications (ie. you need to fetch the minDate for this website, fetch the website name and set it in the global piwik javascript array, etc.)

let me know what you think.

comment:10 Changed 5 years ago by kpham

Hi Matt,

I agree with your comments. I will make those changes and re-submit another patch for this ticket. Looks like the back button doesn't work as expected. Another problem is when you're not login and use the anchor params; it doesn't work.

Thanks,
Khanh.

comment:11 Changed 5 years ago by tobiesch

just to emphasize that this is an important fix: it is mighty annoying that every time you change the date it will redirect you to the dashboard and you have to go back all the way!

comment:12 Changed 5 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [1095]) - Refresh and back button now work! great contribution by Khanh Pham fixed #103
it's using the jquery history plugin. period, date, idsite, module and action are persisted across requests, making Piwik much nicer and faster to use.

comment:13 Changed 5 years ago by matt (mattab)

(In [1096]) it should work better with the main broadcast.js file :) refs #103

comment:14 Changed 5 years ago by dzirt

comment:15 Changed 5 years ago by Zithromax

comment:16 Changed 5 years ago by dzirt

comment:17 Changed 5 years ago by alivenk

comment:18 Changed 3 years ago by phillipnoyce

comment:19 Changed 3 years ago by phillipnoyce

Note: See TracTickets for help on using tickets.