SpangleLabs / history-explorer-card

A card for Home Assistant Lovelace for exploring the history of your entities interactively and in real time.
MIT License
120 stars 2 forks source link

Export to CSV not working #21

Open dana-se opened 5 months ago

dana-se commented 5 months ago

Hello, I can't get the Export as CSV or Export statistics as CSV to work. Am I missing something?

Logger: frontend.js.latest.202406101 Source: components/system_log/init.py:333 First occurred: 16:07:09 (2 occurrences) Last logged: 16:13:43

Uncaught error from Edge 126.0.0.0 on Windows 10 ReferenceError: moment is not defined r.exportFile (/hacsfiles/history-explorer-card/history-explorer-card.js:17:66937) L.exportStatistics (/hacsfiles/history-explorer-card/history-explorer-card.js:93:7656) Uncaught error from Edge 126.0.0.0 on Windows 10 ReferenceError: moment is not defined o.exportFile (/hacsfiles/history-explorer-card/history-explorer-card.js:17:65198) L.exportFile (/hacsfiles/history-explorer-card/history-explorer-card.js:93:7543)

kramergfij commented 4 months ago

Same problem here in firefox. Exporting, just waits forever until F5 is pressed to refresh the window. Reverting to release 1.0.53 and it works fine.

rotdrop commented 2 months ago

I suppose that commit d49bcb5 might be the cause; switching to "normal JS imports" should also imply that each source file needs to include its dependencies. So adding

import "../deps/moment.js";
var moment = window.HXLocal_moment;

just at the top of the history-csv-exporter.js file and rebuilding the JS asset cured the problem for me.

0sy commented 1 month ago

I suppose that commit d49bcb5 might be the cause; switching to "normal JS imports" should also imply that each source file needs to include its dependencies. So adding

import "../deps/moment.js";
var moment = window.HXLocal_moment;

just at the top of the history-csv-exporter.js file and rebuilding the JS asset cured the problem for me.

How does one "rebuild" the JS asset?

rotdrop commented 1 month ago

You need nodejs installed after that something like "npm run build" (see package.json, "scripts"). You probably also need something like "yarn install" or "npm ci" before trying to rebuild. Do not quite remember. I can eventually generate a pull request, but right now I just do not have the time.

0sy commented 1 month ago

You need nodejs installed after that something like "npm run build" (see package.json, "scripts"). You probably also need something like "yarn install" or "npm ci" before trying to rebuild. Do not quite remember. I can eventually generate a pull request, but right now I just do not have the time.

Thanks for taking the time to answer - that's way above what I can do without starting ww3.

I have downgraded to 1.0.53 for now, and CSV exporting works.

Cheers

ando2040 commented 1 month ago

Unfortunately 1.0.53 doesn't work for me with Chrome - so +1 for a fix please. It's been bugging me ever since I switched from alexarch version but I've only just got around to looking if there was an issue open.