luciozambon / eGiga2m

eGiga2m is a web graphic data viewer.
GNU General Public License v3.0
1 stars 3 forks source link

CVS export with ArchivingRoot #2

Closed PhilLAL closed 3 years ago

PhilLAL commented 3 years ago

Hello Lucio, it seems the CSV export does not work, but other formats like JSON works : when clicking on Export menu, selecting CSV format, I let default (1000 samples) and then I clicked on the link displayed ̀SERVER_NAME/eGiga2m/lib/service/export_service.php?conf=&ts=00009,1,1;00003,1,2&format=csv, a HTTP message appears "the requested URL was not found on this server"

Since the directory /var/www/html/eGiga2m/lib/service/ does not contain export_service.php but it contains a hdb_export_service.php file, I imagine this is due to an old architecture from before compatibility with both HDB++ and ArchivingRoot. So I replaced the url by SERVER_NAME/eGiga2m/lib/service/hdb_export_service.php?conf=&ts=00009,1,1;00003,1,2&format=csv I got then the following message: no start (date/time) selected

Please notice that we use ArchivingRoot and not HDB++, and also Flot and not HighCharts.

Do you have any idea how to make it work ? Thank you.

luciozambon commented 3 years ago

It's correct to edit file: https://github.com/luciozambon/eGiga2m/blob/master/egiga2m_conf.js and insert a reference to file: https://github.com/luciozambon/eGiga2m/blob/master/lib/service/hdb_plot_service.php then you should add the start time, e.g. SERVER_NAME/eGiga2m/lib/service/hdb_export_service.php?conf=&ts=00009,1,1;00003,1,2&start=2020-12-20 00:00:00&format=csv or SERVER_NAME/eGiga2m/lib/service/hdb_export_service.php?conf=&ts=00009,1,1;00003,1,2&start=last 8 hours&format=csv

PhilLAL commented 3 years ago

Hi @luciozambon thank you for your fast answer.

I already modified egiga2m_conf.js, here was the content (while the error occured):

function initConf(conf) {
        // hcExportService = "http://ecsproxy.elettra.trieste.it:8080/highcharts-export-web/";
        if (conf=='thomx') {
                plotService = "./lib/service/hdb_plot_service.php?conf=thomx";
                treeService = "./lib/service/hdb_tree_service.php?conf=thomx";
                exportService = "/var/www/html/eGiga2m/lib/service/hdb_export_service.php?conf=thomx"
        }
        else if (conf=='<second-configuration>') {
                plotService = "./lib/service/hdbpp_plot_service.php?conf=<second-configuration>";
                treeService = "./lib/service/hdbpp_tree_service.php?conf=<second-configuration>";
                exportService = "/var/www/html/eGiga2m/lib/service/hdbpp_export_service.php?conf=<second-configuration>"
        }

        // this is the default configuration, comment it if unnecessary
        plotService = "./lib/service/hdb_plot_service.php?conf=thomx";
        treeService = "./lib/service/hdb_tree_service.php?conf=thomx";
}
/* 
  // optional "see also" button, used to open other sites, for instance other installations of eGiga2m
  // start and stop parameters can be propagated to the targeted links
  var see_also = 
    "<li><a href='add here link'>add here a label</a></li>" +
    "<li class='divider'></li>" +
    "<li><a href='./egiga2m.html?conf=your_configuration&start=<!--start-->&stop=<!--stop-->'>your_configuration</a></li>";
*/

  // events are displaied only in HighChars version
  // var events = ['error', 'alarm', 'command', 'button'];
  var events = [];

  // extract time series name from data dropped on tree widget
  // this extraction is dependent on the environment so it must be custom for your system
  function extractTimeseries(dropData) {
    myproperty = dropData.split('</property>');
    mystring = myproperty[0].split('string>');
    myts = mystring[1].split('<');
    return myts[0];
  }

So the exportServicevariable has been modified to refer to hdb_export_service.php.

Moreover, it seems to me the users should not edit the url to insert variables since a window is used for this purpose, am I right?

luciozambon commented 3 years ago

Start and stop should be configured in the inputs on the left upper side anyway all controls are placed in the URL in order to be modified by advanced users. For example this URL has been generated by an external script: http://luciozambon.altervista.org/egiga2m/index_plot.html?conf=&ts=2,1;2,2;2,3;2,4;2,5;2,6;2,7;2,8;2,9;2,10&start=last%2031%20days;last%20396%20days;last%20761%20days;last%201126%20days;last%201491%20days;last%201856%20days;last%202221%20days;last%202586%20days;last%202951%20days;last%203316%20days&stop=last%201%20days;last%20366%20days;last%20731%20days;last%201096%20days;last%201461%20days;last%201826%20days;last%202191%20days;last%202556%20days;last%202921%20days;last%203286%20days&tsLabel=2020;2019;2018;2017;2016;2015;2014;2013;2012;2011&xLabel=TS%20molo/temperatura%20aria%20%5B%C2%B0C%5D;;;;;;;;;&xShow=1;0;0;0;0;0;0;0;0;0

PhilLAL commented 3 years ago

Ok, thank you, Indeed, I forget to define start in the GUI window.

So I understand the fact that the URL is not defined is a bug since the egiga2m_conf.js file has been modified to include plotService = "./lib/service/hdb_plot_service.php?conf=thomx";, do you confirm?

How could I fix to avoid this error message for the users?

luciozambon commented 3 years ago

I confirm that egiga2m_conf.js should be configured in order to have all ready for the end user. The conf parameteer (?conf=thomx) is meant for deployment with more than one database. If you have only one DB it is useless, you should place all parameters out of the condition "if (conf=='') {" in particular the export service "exportService = '/lib/service/hdbpp_export_service.php?conf='"

The end user should specify start time and time series; in the plot part there isn't any error message or warning in this case, may be the solution should be to add an early error message. The missing stop time is meant as all the data untill now, the missing of start time is meant as all the data from the begin of the archiviation, in the long term it could became too much data.

If you want to make start time optional also in the export part you have to substitute 7 times

WHERE time > '{$start[$xaxis-1]}'

with

WHERE 1=1

but only when empty($_REQUEST['start']) is true

PhilLAL commented 3 years ago

Thank you for these details @luciozambon I understand there should be a line exportService = "./lib/service/hdb_export_service.php?conf="; into the generic section of https://github.com/luciozambon/eGiga2m/blob/master/egiga2m_conf.js and I added this line in my file. It could be added as a default config into the repo for new users.

I also had to keep the ?conf=thomx) in generic part of https://github.com/luciozambon/eGiga2m/blob/master/egiga2m_conf.js to be able to select the attributes to display, probably because ./lib/service/hdb_conf.php does not include a generic configuration. Perhaps a default config can also be added in this file.

Hope you an happy end of year.

PhilLAL commented 3 years ago

I let this issue opened to remind to complete the default egiga2m_conf.js config file. I can open another issue if you prefer?

luciozambon commented 3 years ago

added in hdb_conf.php