-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Use forceNow
query parameter when parsing timefilter
#16236
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -105,10 +106,21 @@ uiModules | |||
return this.calculateBounds(this.time); | |||
}; | |||
|
|||
Timefilter.prototype.getForceNow = function () { | |||
const query = querystring.parse(window.location.search.replace(/^\?/, '')).forceNow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being Angular code and all, should this use $location.search() instead? And actually, isn't that required since we're using hash routing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want this to be a normal querystring parameter outside of the AngularJS based hash routing, because I assumed that Canvas itself might not be using the hash based routing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fair enough. We are using hash routing though, and actually I think everything would need to. Though, I suppose an app could use search param routing...
So your intention is that you'd have something like http://localhost:5601/acd/app/canvas?forceNow=2001-01-01T00:00:00Z#/workpad/workpad-1ba0f600-47f0-4306-a587-17cc95a74281
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's the intent right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if an app needs the forceNow
parameter to be part of the hash route?
I think that's actually going to be the case for Canvas. Our router is going to assume that the entirety of the parameters it should be looking at come after the hash. I can work around it, but I wonder if the location of this setting can be left up to the app creating the URL somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing the application to decide where to look for the parameter in the URL is going against the intent of this change entirely. The goal is to make the applications abide by a standard "interface" and then they'll work with Reporting, changing where the forceNow
is for different applications is the exact thing that we're trying to avoid by introducing application specific logic.
With that being said, if we want to move the forceNow
to the hash parameters, we can, as we can support this within Kibana. There's been discussion about moving to non hash-based routing, but we can readdress this when this happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I'll add an issue in Canvas to address search params that could be in the URL already and we can push forward that way.
const $el = compile(); | ||
expect($el.attr('data-shared-timefilter')).to.eql('false'); | ||
|
||
expect($el.attr('data-shared-timefilter-from')).to.eql(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contrary to the test description, this isn't testing for null
. The code that uses this is checking for a truthy value... maybe the test should do the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is fine, but the test says "sets data-shared-timefilter-* to null", but it's not null, and it's not testing for null. My only beef here is the description of what is being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does doesn't set data-shared-timefilter-* using the timefilter when auto-refresh selector is enabled
seem any more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. My only issue was the mention of null
, since null is never the value and was not actually be tested for.
@kobelb this also doesn't seem to ever test the values returned when the |
Would you mind elaborating, I'm not following? |
Sorry, for some reason I was thinking You have 3 tests for |
Yeah... at the time my reasoning was that the supplier of |
💚 Build Succeeded |
💚 Build Succeeded |
* Using "forceNow" parameter to adjust "now" and exposing timeRange * Moving forceNow parameter to the hash, adding tests * Renaming test
How do I test this PR @kobelb ? Please & Thank you :) |
@bhavyarm the only thing that utilizes this right now is Reporting, so I'd recommend testing that Reporting works correctly when there's a delay between the Reporting job being created and when it's actually run. To do this, I created a Metric Visualization that displayed the max timestamp and a Metric Visualization that displayed the minimum timestamp, and I added them both to a Dashboard. I then clicked the "Generate PDF" button to create the Reporting job, and then immediately stopped the Kibana server. I wanted about 5 minutes, started the Kibana server back up and made sure that the timestamps in the PDF were relative to the time the job was created, as opposed to the current time. |
@kobelb thank you!!!! |
Reporting needs a way to emulate a different Date for
now
when parsing relative dates. This adds aforceNow
query parameter that can be used for this purpose.Were also adding
data-shared-timefilter-from
anddata-shared-timefilter-to
to expose the effective global time filters.