Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fronted uses the client's timezone #68

Closed
zavndw opened this issue Oct 15, 2021 · 18 comments · Fixed by #90
Closed

fronted uses the client's timezone #68

zavndw opened this issue Oct 15, 2021 · 18 comments · Fixed by #90
Assignees

Comments

@zavndw
Copy link

zavndw commented Oct 15, 2021

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

@whh516
Copy link

whh516 commented Dec 27, 2021

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

@zavndw
Copy link
Author

zavndw commented Dec 28, 2021

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

@whh516
Copy link

whh516 commented Dec 28, 2021

fixed,THX

@mbolli
Copy link
Owner

mbolli commented Jan 18, 2022

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

@zavndw
Copy link
Author

zavndw commented Jan 18, 2022

select the time zone on the web. Default server zone

@FontouraAbreu
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

@mbolli
Copy link
Owner

mbolli commented Feb 9, 2024

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

@FontouraAbreu
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link
Contributor

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

@mbolli
Copy link
Owner

mbolli commented Feb 27, 2024

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

@FontouraAbreu
Copy link
Contributor

@mbolli - yes it does show the correct date

image

@FontouraAbreu
Copy link
Contributor

@mbolli any hints on why this might be happening?

@mbolli mbolli reopened this Mar 14, 2024
@mbolli
Copy link
Owner

mbolli commented Mar 14, 2024

@FontouraAbreu are you on v0.3.1?

@FontouraAbreu
Copy link
Contributor

oops, now I am. It works now:
image

Thanks

@mbolli
Copy link
Owner

mbolli commented Mar 14, 2024

perfect! :)

@mbolli mbolli closed this as completed Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants