Islandora-Labs / islandora_usage_stats_charts

Module that provides charts showing usage statistics for Islandora objects.
GNU General Public License v3.0
1 stars 0 forks source link

Charts disappeared #28

Closed bondjimbond closed 4 years ago

bondjimbond commented 4 years ago

Not sure why, but charts are not showing, and there are no errors reported.

See https://dc.arcabc.ca/islandora/object/dc%3Aroot -- the "Usage Statistics" dropdown appears at the bottom of the page, and expands as well, but no actual content appears. Nothing is revealed in the console.

Tried changing the JQuery version, no effect.

Even weirder -- the dropdown appears when logged out, but disappears when logged in.

Any ideas what could be happening?

mjordan commented 4 years ago

This is ringing a bell... did you open another issue recently about a chart not showing up? My first guess is that it's a caching issue. Did you just dial up page caching?

bondjimbond commented 4 years ago

I brought it up on Slack, but didn't make an issue. Caching is my thought too, but I don't know what to do about it... can't turn off the caching.

mjordan commented 4 years ago

@bondjimbond only thing I can think of, and it's just a guess, is that at the moment the cache was built, there was a glitch in downloading the Chart.js javascript file from cloudfare. If that is true (and I have absolutely no idea if it is), I wonder if using a local copy, as described in #6, would help reduce the risk of it happening again.

bondjimbond commented 4 years ago

That could work!

mjordan commented 4 years ago

@bondjimbond do you want me to work on #7 to see if that helps?

bondjimbond commented 4 years ago

Do you mean #6? (#7 is closed.) That would be great if you have the time, thanks!

mjordan commented 4 years ago

Yes, sorry #6

mjordan commented 4 years ago

@bondjimbond looks like to use a local copy of Chart.js, you need to build it with npm or Bower (https://www.chartjs.org/docs/latest/getting-started/installation.html). It's not a single file JavaScript library. Do you still want to try this option?

bondjimbond commented 4 years ago

Sure... Is there a way maybe for the module to first check if a local copy is installed, and then if not try for the remotely hosted copy?

mjordan commented 4 years ago

@bondjimbond can you try this?

  1. In your drupal/sites/all/libraries directory, create a subdirectory chartjs
  2. In your new chartjs directory, run wget https://github.com/chartjs/Chart.js/releases/download/v2.9.3/Chart.bundle.js
  3. You should now have a file called Chart.bundle.js.
  4. At admin/islandora/tools/islandora_usage_stats_charts, enter the URL to the newly downloaded Chart.bundle.js file, e.g. https://arcabc.ca/sites/all/libraries/chartjs/Chart.bundle.js

I'm entirely sure this will work, since I can't get either npm or bower to install Chart.js (untrusted certificate error). But it should.

bondjimbond commented 4 years ago

Error when loading:

Failed to load resource: the server responded with a status of 404 () js_UMFtXMK85ue7pvck9drFrxxl8t-gwzIY6GQWiWk59b4.js:55 Uncaught ReferenceError: Chart is not defined at js_UMFtXMK85ue7pvck9drFrxxl8t-gwzIY6GQWiWk59b4.js:55

mjordan commented 4 years ago

In the module code the URL to the Chart library is marked as 'external', which according to https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x should not be aggregated. Yet the filename in the 404 error you are seeing suggests it is being aggregated.

Can you confirm that the URL to Chart.bundle.js as defined in step 4 above is correct? Test it by copying it and then visiting it in a private window.

mjordan commented 4 years ago

On my dev VM, using the URL http://localhost:8000/sites/all/libraries/chartjs/Chart.bundle.js and with Javascipt aggregation enabled, charts are working for me. I'm not getting the 404 error you are seeing. Let me know if your URL is correct and we'll take it from there.

bondjimbond commented 4 years ago

Whoops, made a mistake in my wget apparently. Yep, it's working now!

mjordan commented 4 years ago

Very good. I've documented this over at #6 and will update the readme accordingly.