mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[8.6] [Fix][Infrastructure UI] Incorrect payload in time range when landing on the Hosts View (#147390) (#147424)
# Backport This will backport the following commits from `main` to `8.6`: - [[Fix][Infrastructure UI] Incorrect payload in time range when landing on the Hosts View (#147390)](https://github.com/elastic/kibana/pull/147390) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"jennypavlova","email":"dzheni.pavlova@elastic.co"},"sourceCommit":{"committedDate":"2022-12-13T09:43:15Z","message":"[Fix][Infrastructure UI] Incorrect payload in time range when landing on the Hosts View (#147390)\n\nCloses #146581 \r\n\r\n## Summary\r\n\r\nThis PR fixes the initial `from` date range calculation. The idea is to\r\nconvert first the initial range of minutes to milliseconds. Then in\r\norder to get the date of `CALCULATED_DATE_RANGE_TO` - (the calculated\r\ninitial range in milliseconds) and call `getTime()` to receive the\r\ncalculated `from` date as timestamp.\r\n\r\nTo test that you can open the host page without the time range in the\r\nURL. Then check the `from` value as in the screenshot attached to the\r\nstory and you can use an [Unix timestamp\r\nconverter](https://www.unixtimestamp.com/) to verify that the\r\ncalculation is correct","sha":"29841da10b140d8bb0e24d5af4c55e64b6f473c9","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Infra Monitoring UI","backport:prev-minor","v8.7.0"],"number":147390,"url":"https://github.com/elastic/kibana/pull/147390","mergeCommit":{"message":"[Fix][Infrastructure UI] Incorrect payload in time range when landing on the Hosts View (#147390)\n\nCloses #146581 \r\n\r\n## Summary\r\n\r\nThis PR fixes the initial `from` date range calculation. The idea is to\r\nconvert first the initial range of minutes to milliseconds. Then in\r\norder to get the date of `CALCULATED_DATE_RANGE_TO` - (the calculated\r\ninitial range in milliseconds) and call `getTime()` to receive the\r\ncalculated `from` date as timestamp.\r\n\r\nTo test that you can open the host page without the time range in the\r\nURL. Then check the `from` value as in the screenshot attached to the\r\nstory and you can use an [Unix timestamp\r\nconverter](https://www.unixtimestamp.com/) to verify that the\r\ncalculation is correct","sha":"29841da10b140d8bb0e24d5af4c55e64b6f473c9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147390","number":147390,"mergeCommit":{"message":"[Fix][Infrastructure UI] Incorrect payload in time range when landing on the Hosts View (#147390)\n\nCloses #146581 \r\n\r\n## Summary\r\n\r\nThis PR fixes the initial `from` date range calculation. The idea is to\r\nconvert first the initial range of minutes to milliseconds. Then in\r\norder to get the date of `CALCULATED_DATE_RANGE_TO` - (the calculated\r\ninitial range in milliseconds) and call `getTime()` to receive the\r\ncalculated `from` date as timestamp.\r\n\r\nTo test that you can open the host page without the time range in the\r\nURL. Then check the `from` value as in the screenshot attached to the\r\nstory and you can use an [Unix timestamp\r\nconverter](https://www.unixtimestamp.com/) to verify that the\r\ncalculation is correct","sha":"29841da10b140d8bb0e24d5af4c55e64b6f473c9"}}]}] BACKPORT--> Co-authored-by: jennypavlova <dzheni.pavlova@elastic.co>
This commit is contained in:
parent
952ad51e5c
commit
33bc977a8a
1 changed files with 4 additions and 3 deletions
|
@ -25,10 +25,11 @@ const DEFAULT_QUERY = {
|
|||
const DEFAULT_FROM_MINUTES_VALUE = 15;
|
||||
const INITIAL_DATE = new Date();
|
||||
export const INITIAL_DATE_RANGE = { from: `now-${DEFAULT_FROM_MINUTES_VALUE}m`, to: 'now' };
|
||||
const CALCULATED_DATE_RANGE_FROM = new Date(
|
||||
INITIAL_DATE.getMinutes() - DEFAULT_FROM_MINUTES_VALUE
|
||||
).getTime();
|
||||
const CALCULATED_DATE_RANGE_TO = INITIAL_DATE.getTime();
|
||||
const DEFAULT_FROM_IN_MILLISECONDS = DEFAULT_FROM_MINUTES_VALUE * 60000;
|
||||
const CALCULATED_DATE_RANGE_FROM = new Date(
|
||||
CALCULATED_DATE_RANGE_TO - DEFAULT_FROM_IN_MILLISECONDS
|
||||
).getTime();
|
||||
|
||||
const INITIAL_HOSTS_STATE: HostsState = {
|
||||
query: DEFAULT_QUERY,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue