wkallhof / uLogs

An Umbraco Trace Log viewer plugin for the Umbraco 7.3 Back-Office that allows you to view logs by date and a variety of other refinements.
Apache License 2.0
4 stars 1 forks source link

Invalid request for date #1

Closed bjarnef closed 8 years ago

bjarnef commented 8 years ago

I tried the package with Umbraco 7.3.0-RC.

But when I choose 9/7/15 (today) it returns an error:

Failed to load resource: the server responded with a status of 400 (Bad Request)
http://localhost:30659/umbraco/backoffice/uLogs/uLogsApi/GetLogsForDate?date=2015-09-07T00:00:00+02:00 Failed to load resource: the server responded with a status of 400 (Bad Request)
<Error>
<Message>The request is invalid.</Message>
<MessageDetail>The parameters dictionary contains a null entry for parameter 'date' of non-nullable type 'System.DateTime' for method 'System.Collections.Generic.IEnumerable`1[uLogs.Models.LogDataItem] GetLogsForDate(System.DateTime)' in 'uLogs.Controllers.uLogsApiController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.</MessageDetail>
</Error>

image

However for another date (8/25/15) it does not fail:

image

wkallhof commented 8 years ago

I pushed out a fix (hopefully) for this issue. Please upgrade your NuGet reference to 1.0.6-RC

Issue When we read in the trace log files, we need to treat the current day's log a little differently. Umbraco does not add the log date to the log file name for the current day, so we just pass in DateTime.Now.Date. This resulted in a different date format parsed in JS for some reasons to do with localization, etc.

The 'fix' was to use the URI encoding when passing the date request back to the server to get logs. This escapes the characters appropriately.

Let me know if the update works.

bjarnef commented 8 years ago

Great, it now works without any errors.

A suggestion: When changing the dropdown it sets the $dirty property on the form, which cause the "unsaved changes" dialog to pop up, when you go away from the page.

I think you can use the noDirtyCheck directive on the select element (and on the search input) to prevent this: https://github.com/umbraco/Umbraco-CMS/blob/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Web.UI.Client/src/common/directives/validation/nodirtycheck.directive.js

I have used it in my package Color Palettes as it shouldn't set $dirty property when checking some checkboxes https://github.com/bjarnef/color-palettes/blob/master/ColorPalettes/ColorPalettes/ColorPalettes/views/colorpalettes.settings.html#L30

wkallhof commented 8 years ago

Excellent, thank you for that.

I have updated the inputs with the noDirtyCheck directive in the latest version.