From fef604d551057e0a1918844dda72bb44f9bca892 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Thu, 14 Feb 2019 16:36:44 +0100 Subject: [PATCH] v8: Update NuCache dashboard (#4435) --- .../dashboard/settings/nucache.controller.js | 137 ++++++++++++------ .../src/views/dashboard/settings/nucache.html | 48 +++--- .../settings/overlays/nucache.rebuild.html | 7 + .../settings/overlays/nucache.reload.html | 7 + .../settings/publishedstatus.controller.js | 9 +- .../dashboard/settings/publishedstatus.html | 12 +- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 2 + src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 2 + .../Umbraco/config/lang/en_us.xml | 2 + 9 files changed, 146 insertions(+), 80 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.rebuild.html create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.reload.html 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 @@ -
+
-
- Loading... +
+

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.

+
- +
-
-
-
- -
\ No newline at end of file +
diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.rebuild.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.rebuild.html new file mode 100644 index 0000000000..c8bbb5350e --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.rebuild.html @@ -0,0 +1,7 @@ +
+ +
+ Rebuild content in cmsContentNu database table. Expensive. +
+ +
diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.reload.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.reload.html new file mode 100644 index 0000000000..77ca7ec476 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/overlays/nucache.reload.html @@ -0,0 +1,7 @@ +
+ +
+ Trigger a in-memory and local file cache reload on all servers. +
+ +
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 507ed9c240..27c3e57ddf 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 @@ -1,15 +1,16 @@ -function publishedStatusController($scope, umbRequestHelper, $log, $http, $q, $timeout) { +function publishedStatusController($scope, $http, umbRequestHelper) { + + var vm = this; // note: must defined base url in BackOfficeController - umbRequestHelper.resourcePromise( $http.get(umbRequestHelper.getApiUrl('publishedStatusBaseUrl', 'GetPublishedStatusUrl')), 'Failed to get published status url') .then(function (result) { //result = 'views/dashboard/developer/nucache.html' - $scope.includeUrl = result; + vm.includeUrl = result; }); } -angular.module("umbraco").controller("Umbraco.Dashboard.PublishedStatusController", publishedStatusController); \ No newline at end of file +angular.module("umbraco").controller("Umbraco.Dashboard.PublishedStatusController", publishedStatusController); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.html index 59db29314c..d939f55f71 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.html +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.html @@ -1,11 +1,11 @@ -
+

Published Status

-
- Loading... -
-
+ + + +
-
\ No newline at end of file +
diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index 1662bb434d..78f7d2c171 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -616,9 +616,11 @@ Et øjeblik... Forrige Egenskaber + Genopbyg E-mail der skal modtage indhold af formular Papirkurv Din papirkurv er tom + Genindlæs Mangler Fjern Omdøb diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index 4f5fc5a464..b900cc1fd8 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -646,9 +646,11 @@ One moment please... Previous Properties + Rebuild Email to receive form data Recycle Bin Your recycle bin is empty + Reload Remaining Remove Rename diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index 010a79af5b..30d5ff6b8e 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -649,9 +649,11 @@ One moment please... Previous Properties + Rebuild Email to receive form data Recycle Bin Your recycle bin is empty + Reload Remaining Remove Rename