From 99c2fd7f8149ce4bddeb1f44c936a8eb3ff6c4d5 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 26 May 2020 19:05:15 +0200 Subject: [PATCH] https://dev.azure.com/umbraco/D-Team%20Tracker/_workitems/edit/6587 - LogViewerController --- .../Controllers}/LogViewerController.cs | 27 ++++++++++--------- .../Editors/BackOfficeServerVariables.cs | 24 ++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) rename src/{Umbraco.Web/Editors => Umbraco.Web.BackOffice/Controllers}/LogViewerController.cs (76%) diff --git a/src/Umbraco.Web/Editors/LogViewerController.cs b/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs similarity index 76% rename from src/Umbraco.Web/Editors/LogViewerController.cs rename to src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs index 31b29fd426..444ebbe988 100644 --- a/src/Umbraco.Web/Editors/LogViewerController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; -using System.Web.Http; +using Microsoft.AspNetCore.Mvc; using Umbraco.Core; using Umbraco.Core.Logging.Viewer; using Umbraco.Core.Models; -using Umbraco.Web.Mvc; -using Umbraco.Web.WebApi; +using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Exceptions; +using Umbraco.Web.Editors; -namespace Umbraco.Web.Editors +namespace Umbraco.Web.BackOffice.Controllers { /// /// Backoffice controller supporting the dashboard for viewing logs with some simple graphs & filtering @@ -33,60 +34,60 @@ namespace Umbraco.Web.Editors } [HttpGet] - public bool GetCanViewLogs([FromUri] DateTime? startDate = null,[FromUri] DateTime? endDate = null) + public bool GetCanViewLogs([FromQuery] DateTime? startDate = null,[FromQuery] DateTime? endDate = null) { var logTimePeriod = GetTimePeriod(startDate, endDate); return CanViewLogs(logTimePeriod); } [HttpGet] - public int GetNumberOfErrors([FromUri] DateTime? startDate = null,[FromUri] DateTime? endDate = null) + public int GetNumberOfErrors([FromQuery] DateTime? startDate = null,[FromQuery] DateTime? endDate = null) { var logTimePeriod = GetTimePeriod(startDate, endDate); //We will need to stop the request if trying to do this on a 1GB file if (CanViewLogs(logTimePeriod) == false) { - throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Unable to view logs, due to size")); + throw HttpResponseException.CreateNotificationValidationErrorResponse("Unable to view logs, due to size"); } return _logViewer.GetNumberOfErrors(logTimePeriod); } [HttpGet] - public LogLevelCounts GetLogLevelCounts([FromUri] DateTime? startDate = null,[FromUri] DateTime? endDate = null) + public LogLevelCounts GetLogLevelCounts([FromQuery] DateTime? startDate = null,[FromQuery] DateTime? endDate = null) { var logTimePeriod = GetTimePeriod(startDate, endDate); //We will need to stop the request if trying to do this on a 1GB file if (CanViewLogs(logTimePeriod) == false) { - throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Unable to view logs, due to size")); + throw HttpResponseException.CreateNotificationValidationErrorResponse("Unable to view logs, due to size"); } return _logViewer.GetLogLevelCounts(logTimePeriod); } [HttpGet] - public IEnumerable GetMessageTemplates([FromUri] DateTime? startDate = null,[FromUri] DateTime? endDate = null) + public IEnumerable GetMessageTemplates([FromQuery] DateTime? startDate = null,[FromQuery] DateTime? endDate = null) { var logTimePeriod = GetTimePeriod(startDate, endDate); //We will need to stop the request if trying to do this on a 1GB file if (CanViewLogs(logTimePeriod) == false) { - throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Unable to view logs, due to size")); + throw HttpResponseException.CreateNotificationValidationErrorResponse("Unable to view logs, due to size"); } return _logViewer.GetMessageTemplates(logTimePeriod); } [HttpGet] - public PagedResult GetLogs(string orderDirection = "Descending", int pageNumber = 1, string filterExpression = null, [FromUri]string[] logLevels = null, [FromUri] DateTime? startDate = null,[FromUri] DateTime? endDate = null) + public PagedResult GetLogs(string orderDirection = "Descending", int pageNumber = 1, string filterExpression = null, [FromQuery]string[] logLevels = null, [FromQuery] DateTime? startDate = null,[FromQuery] DateTime? endDate = null) { var logTimePeriod = GetTimePeriod(startDate, endDate); //We will need to stop the request if trying to do this on a 1GB file if (CanViewLogs(logTimePeriod) == false) { - throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Unable to view logs, due to size")); + throw HttpResponseException.CreateNotificationValidationErrorResponse("Unable to view logs, due to size"); } var direction = orderDirection == "Descending" ? Direction.Descending : Direction.Ascending; diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index a509ecfd29..404bf88c89 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -217,10 +217,10 @@ namespace Umbraco.Web.Editors // "dashboardApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( // controller => controller.GetDashboard(null)) // }, - { - "logApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetPagedEntityLog(0, 0, 0, Direction.Ascending, null)) - }, + // { + // "logApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + // controller => controller.GetPagedEntityLog(0, 0, 0, Direction.Ascending, null)) + // }, { "memberApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetByKey(Guid.Empty)) @@ -317,18 +317,18 @@ namespace Umbraco.Web.Editors // "backOfficeAssetsApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( // controller => controller.GetSupportedLocales()) // }, - { - "languageApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetAllLanguages()) - }, + // { + // "languageApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + // controller => controller.GetAllLanguages()) + // }, { "relationTypeApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetById(1)) }, - { - "logViewerApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetNumberOfErrors(null, null)) - }, + // { + // "logViewerApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + // controller => controller.GetNumberOfErrors(null, null)) + // }, // { // "webProfilingBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( // controller => controller.GetStatus())