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/nucache.controller.js index aab133d786..c3baf7246e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js @@ -1,57 +1,112 @@ -function nuCacheController($scope, umbRequestHelper, $log, $http, $q, $timeout) { +function nuCacheController($scope, $http, umbRequestHelper, localizationService, overlayService) { - $scope.reload = function () { - if ($scope.working) return; - if (confirm("Trigger a in-memory and local file cache reload on all servers.")) { - $scope.working = true; - umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "ReloadCache")), - 'Failed to trigger a cache reload') - .then(function (result) { - $scope.working = false; - }); - } - }; + var vm = this; - $scope.collect = function () { - if ($scope.working) return; - $scope.working = true; + vm.collect = collect; + vm.reload = reload; + vm.verify = verify; + vm.rebuild = rebuild; + + function reload(event) { + if (vm.working) return; + + const dialog = { + view: "views/dashboard/settings/overlays/nucache.reload.html", + submitButtonLabelKey: "general_ok", + submit: function (model) { + performReload(); + overlayService.close(); + }, + close: function () { + overlayService.close(); + } + }; + + localizationService.localize("general_reload").then(value => { + dialog.title = value; + overlayService.open(dialog); + }); + + event.preventDefault() + event.stopPropagation(); + } + + function collect() { + if (vm.working) return; + vm.working = true; umbRequestHelper.resourcePromise( $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "Collect")), 'Failed to verify the cache.') .then(function (result) { - $scope.working = false; - $scope.status = result; + vm.working = false; + vm.status = result; }); - }; + } - $scope.verify = function () { - if ($scope.working) return; - $scope.working = true; + function verify() { + if (vm.working) return; + vm.working = true; umbRequestHelper.resourcePromise( $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "GetStatus")), 'Failed to verify the cache.') .then(function (result) { - $scope.working = false; - $scope.status = result; + vm.working = false; + vm.status = result; }); - }; + } - $scope.rebuild = function () { - if ($scope.working) return; - if (confirm("Rebuild cmsContentNu table content. Expensive.")) { - $scope.working = true; - umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "RebuildDbCache")), - 'Failed to rebuild the cache.') - .then(function (result) { - $scope.working = false; - $scope.status = result; - }); - } - }; + function rebuild(event) { + if (vm.working) return; - $scope.working = false; - $scope.verify(); + const dialog = { + view: "views/dashboard/settings/overlays/nucache.rebuild.html", + submitButtonLabelKey: "general_ok", + submit: function (model) { + performRebuild(); + overlayService.close(); + }, + close: function () { + overlayService.close(); + } + }; + + localizationService.localize("general_rebuild").then(value => { + dialog.title = value; + overlayService.open(dialog); + }); + + event.preventDefault() + event.stopPropagation(); + } + + function performReload() { + vm.working = true; + + umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "ReloadCache")), + 'Failed to trigger a cache reload') + .then(function (result) { + vm.working = false; + }); + } + + function performRebuild() { + vm.working = true; + + umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "RebuildDbCache")), + 'Failed to rebuild the cache.') + .then(function (result) { + vm.working = false; + vm.status = result; + }); + } + + function init() { + vm.working = false; + verify(); + } + + init(); } -angular.module("umbraco").controller("Umbraco.Dashboard.NuCacheController", nuCacheController); \ No newline at end of file +angular.module("umbraco").controller("Umbraco.Dashboard.NuCacheController", nuCacheController); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html index ad2eece90b..63f2e73c6c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html @@ -1,54 +1,44 @@ -
You are running the brand new NuCache!
-- - NuCache is working. - NuCache says: {{status}} +
+ NuCache is working. + NuCache says: {{vm.status}}
-- This lets you refresh the status, or collect snapshots (after running a CLR GC). -
+This lets you refresh the status, or collect snapshots (after running a CLR GC).
+This lets you rebuild the database cache (status above), ie the content of the cmsContentNu table. Rebuilding can be expensive.
+This lets you reload the in-memory and local file cache by entirely reloading it from the data in the cmsContentNu table, but it does not rebuild that table. This is relatively fast. Triggers the reload on all servers in an LB environment.
+