nfsen-ng icon indicating copy to clipboard operation
nfsen-ng copied to clipboard

fronted uses the client's timezone

Open zavndw opened this issue 2 years ago • 5 comments

if the client looks at the server graphs from a different time zone, it is required to set the time shift in the interface

zavndw avatar Oct 15 '21 19:10 zavndw

Hi zavndw can you tell how to config the timezone for frontend , I found frontend dumping flow with wrong timerzone.

whh516 avatar Dec 27 '21 15:12 whh516

Hi zavndw can you tell how to config the timezone for frontend , I found frontend dumping flow with wrong timerzone.

Hello. Requires a little frontend revision. Now he takes the timezone from the browser, you need to make this behavior customization. If I understand correctly, then in this place you need to make changes https://github.com/mbolli/nfsen-ng/blob/master/frontend/js/nfsen-ng.js#L672

zavndw avatar Dec 28 '21 05:12 zavndw

fixed,THX

whh516 avatar Dec 28 '21 13:12 whh516

what would be your preference: to take the timezone from the server or to specify it in the config? or both?

mbolli avatar Jan 18 '22 09:01 mbolli

select the time zone on the web. Default server zone

zavndw avatar Jan 18 '22 09:01 zavndw

Got the same problem but didn't quite understand which variable or value I should change.

If I understand correctly, then in this place you need to make changes https://github.com/mbolli/nfsen-ng/blob/master/frontend/js/nfsen-ng.js#L672

Is this the correct method I should edit?

/**
* reads options from api_graph_options, performs a request on the API
* and tries to display the received data in the dygraph.
*/
function updateGraph()

FontouraAbreu avatar Feb 09 '24 14:02 FontouraAbreu

I believe here is where I should edit the position var

$.each(data.data, function (datetime, series) {
                    var position = [new Date(datetime * 1000)];

                    // add all serie values to position array
                    $.each(series, function (y, val) {
                        position.push(val);
                    });

                    // push position array to dygraph data
                    if (dygraph_did_zoom !== true) {
                        dygraph_data.push(position);
                    } else {
                        // when zoomed in, insert position array at the start index of replacement data
                        dygraph_data.splice(index_to_insert, 0, position);
                        index_to_insert++; // increase index, or data will get inserted backwards
                    }
                });

I changed var position = [new Date(datetime * 1000)]; to var position = [new Date((datetime * 1000) - (3 * 60 * 60 * 1000))];

and then /var/www/html/nfsen-ng/backend/cli.php stop | start. But nothing changed.

Am I missing something here?

FontouraAbreu avatar Feb 09 '24 14:02 FontouraAbreu

I changed var position = [new Date(datetime * 1000)]; to var position = [new Date((datetime * 1000) - (3 * 60 * 60 * 1000))];

Oopsie, the correct should be:

var position = [new Date((datetime * 1000) + (3 * 60 * 60 * 1000))];

since my TZ is UTC-3

Solved.

FontouraAbreu avatar Feb 09 '24 14:02 FontouraAbreu

@FontouraAbreu can you test #90 or apply these changes https://github.com/mbolli/nfsen-ng/pull/90/commits/8334fc9243aeefa0ce27794e997dc0090f343541 to see if the automatic server timezone detection works?

mbolli avatar Feb 09 '24 16:02 mbolli

Sure thing! I will start redoing everything from scratch by next week's end and will use the prep-php-82 branch.

Personally, I prefer a '.conf' file to set these kind of things as said in #17. But I'll surely give preference to an updated php version.

FontouraAbreu avatar Feb 09 '24 16:02 FontouraAbreu

@FontouraAbreu can you test #90 or apply these changes 8334fc9 to see if the automatic server timezone detection works?

Testing this one now, but just to make sure:

This server you talked about, is it the host machine where the application is running or the apache server?


I'm using apache2 so nfsen-ng should detect the timezone setting I made at /etc/php/8.2/apache2/php.ini?

If this is the case for the "server" mentioned, I've already changed it to my current timezone(UTC-3) and restarted the apache and the nfsen-ng service.

Graph date is being displayed correctly:

image

As my last .nfcap files are from 13h00. But the graph still tries to fill the remaining utc offset hours. Is this just a visual issue?

FontouraAbreu avatar Feb 26 '24 16:02 FontouraAbreu

I've just noticed the dates are wrong. For some reason its showing that this data is from 2022, not sure why this is happening


My profiles-data directory structure:

root@nfsen-ng:~# tree -d /var/nfdump/profiles-data/live/source/
/var/nfdump/profiles-data/live/source/
└── 2024
    └── 02
        ├── 21
        ├── 22
        ├── 23
        ├── 24
        ├── 25
        └── 26

9 directories

My machine current date:

root@nfsen-ng:~# date
Mon Feb 26 13:28:47 -03 2024

FontouraAbreu avatar Feb 26 '24 16:02 FontouraAbreu

very weird. when using nfdump does it show the correct dates?

mbolli avatar Feb 27 '24 12:02 mbolli

@mbolli - yes it does show the correct date

image

FontouraAbreu avatar Feb 28 '24 16:02 FontouraAbreu

@mbolli any hints on why this might be happening?

FontouraAbreu avatar Mar 14 '24 13:03 FontouraAbreu

@FontouraAbreu are you on v0.3.1?

mbolli avatar Mar 14 '24 13:03 mbolli

oops, now I am. It works now: image

Thanks

FontouraAbreu avatar Mar 14 '24 14:03 FontouraAbreu

perfect! :)

mbolli avatar Mar 14 '24 14:03 mbolli