From b0c752bc5ce3fec11e4c785b7edcae623fc0d68b Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 4 Feb 2020 19:18:35 +0100 Subject: [PATCH] Removed concrete type checks for back-office published cache details, so now working from interface. Renamed controller and FE assets to more generic name. --- .../NuCache/PublishedSnapshotService.cs | 2 - .../PublishedSnapshotServiceBase.cs | 2 +- ...s => publishedsnapshotcache.controller.js} | 12 ++-- ...cache.html => publishedsnapshotcache.html} | 2 +- .../settings/publishedstatus.controller.js | 2 - .../Editors/BackOfficeServerVariables.cs | 2 +- .../Editors/NuCacheStatusController.cs | 61 ------------------- .../PublishedSnapshotCacheStatusController.cs | 46 ++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 2 +- 9 files changed, 56 insertions(+), 75 deletions(-) rename src/Umbraco.Web.UI.Client/src/views/dashboard/settings/{nucache.controller.js => publishedsnapshotcache.controller.js} (80%) rename src/Umbraco.Web.UI.Client/src/views/dashboard/settings/{nucache.html => publishedsnapshotcache.html} (99%) delete mode 100644 src/Umbraco.Web/Editors/NuCacheStatusController.cs create mode 100644 src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs index f4636857b5..5d99aa6aaa 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1788,8 +1788,6 @@ AND cmsContentNu.nodeId IS NULL " and " + ms + " snapshot" + (ms > 1 ? "s" : "") + "."; } - public override string StatusUrl => "views/dashboard/settings/nucache.html"; - public override void Collect() { var contentCollect = _contentStore.CollectAsync(); diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs index 33ac485a26..5c30bb8410 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs @@ -41,7 +41,7 @@ namespace Umbraco.Web.PublishedCache public abstract string GetStatus(); - public virtual string StatusUrl => string.Empty; + public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html"; public virtual void Collect() { diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js similarity index 80% rename from src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js rename to src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js index c3baf7246e..5270892fa5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js @@ -1,4 +1,4 @@ -function nuCacheController($scope, $http, umbRequestHelper, localizationService, overlayService) { +function publishedSnapshotCacheController($scope, $http, umbRequestHelper, localizationService, overlayService) { var vm = this; @@ -35,7 +35,7 @@ if (vm.working) return; vm.working = true; umbRequestHelper.resourcePromise( - $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "Collect")), + $http.get(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "Collect")), 'Failed to verify the cache.') .then(function (result) { vm.working = false; @@ -47,7 +47,7 @@ if (vm.working) return; vm.working = true; umbRequestHelper.resourcePromise( - $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "GetStatus")), + $http.get(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "GetStatus")), 'Failed to verify the cache.') .then(function (result) { vm.working = false; @@ -83,7 +83,7 @@ vm.working = true; umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "ReloadCache")), + $http.post(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "ReloadCache")), 'Failed to trigger a cache reload') .then(function (result) { vm.working = false; @@ -94,7 +94,7 @@ vm.working = true; umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "RebuildDbCache")), + $http.post(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "RebuildDbCache")), 'Failed to rebuild the cache.') .then(function (result) { vm.working = false; @@ -109,4 +109,4 @@ init(); } -angular.module("umbraco").controller("Umbraco.Dashboard.NuCacheController", nuCacheController); +angular.module("umbraco").controller("Umbraco.Dashboard.PublishedSnapshotCacheController", publishedSnapshotCacheController); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html similarity index 99% rename from src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html rename to src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html index 0b14e9c3ff..e1f95ad62d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js index 27c3e57ddf..ca4d5e1450 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js @@ -7,8 +7,6 @@ $http.get(umbRequestHelper.getApiUrl('publishedStatusBaseUrl', 'GetPublishedStatusUrl')), 'Failed to get published status url') .then(function (result) { - - //result = 'views/dashboard/developer/nucache.html' vm.includeUrl = result; }); diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index b85bc1187e..8764590118 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -286,7 +286,7 @@ namespace Umbraco.Web.Editors controller => controller.DeleteById(int.MaxValue)) }, { - "nuCacheStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + "publishedSnapshotCacheStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetStatus()) }, { diff --git a/src/Umbraco.Web/Editors/NuCacheStatusController.cs b/src/Umbraco.Web/Editors/NuCacheStatusController.cs deleted file mode 100644 index 3494b7ba96..0000000000 --- a/src/Umbraco.Web/Editors/NuCacheStatusController.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Web.Http; -using Umbraco.Web.Cache; -using Umbraco.Web.Composing; -using Umbraco.Web.PublishedCache; -using Umbraco.Web.PublishedCache.NuCache; -using Umbraco.Web.WebApi; - -namespace Umbraco.Web.Editors -{ - public class NuCacheStatusController : UmbracoAuthorizedApiController - { - private readonly IPublishedSnapshotService _publishedSnapshotService; - - public NuCacheStatusController(IPublishedSnapshotService publishedSnapshotService) - { - _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); - } - - private IPublishedSnapshotService PublishedSnapshotService - { - get - { - var svc = _publishedSnapshotService as PublishedSnapshotService; - if (svc == null) - throw new NotSupportedException("Not running NuCache."); - return svc; - } - } - - [HttpPost] - public string RebuildDbCache() - { - var service = PublishedSnapshotService; - service.Rebuild(); - return service.GetStatus(); - } - - [HttpGet] - public string GetStatus() - { - var service = PublishedSnapshotService; - return service.GetStatus(); - } - - [HttpGet] - public string Collect() - { - var service = PublishedSnapshotService; - GC.Collect(); - service.Collect(); - return service.GetStatus(); - } - - [HttpPost] - public void ReloadCache() - { - Current.DistributedCache.RefreshAllPublishedSnapshot(); - } - } -} diff --git a/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs b/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs new file mode 100644 index 0000000000..6a701fdcfa --- /dev/null +++ b/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs @@ -0,0 +1,46 @@ +using System; +using System.Web.Http; +using Umbraco.Web.Cache; +using Umbraco.Web.Composing; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.WebApi; + +namespace Umbraco.Web.Editors +{ + public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController + { + private readonly IPublishedSnapshotService _publishedSnapshotService; + + public PublishedSnapshotCacheStatusController(IPublishedSnapshotService publishedSnapshotService) + { + _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); + } + + [HttpPost] + public string RebuildDbCache() + { + _publishedSnapshotService.Rebuild(); + return _publishedSnapshotService.GetStatus(); + } + + [HttpGet] + public string GetStatus() + { + return _publishedSnapshotService.GetStatus(); + } + + [HttpGet] + public string Collect() + { + GC.Collect(); + _publishedSnapshotService.Collect(); + return _publishedSnapshotService.GetStatus(); + } + + [HttpPost] + public void ReloadCache() + { + Current.DistributedCache.RefreshAllPublishedSnapshot(); + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c612ea4361..ed5cee711a 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -406,7 +406,7 @@ - +