UNPKG

sheercms

Version:

Sheer Cliff CMS is a simple and powerful content management system (CMS) for Node JS.

74 lines (59 loc) 1.89 kB
app.controller('CacheController', function($scope, $timeout, CacheService) { $scope.data = { title: "Caching", message: "", messageType: "", //alert-success, alert-warning, alert-info, alert-danger }; $scope.stats = { count: 0 }; $scope.clearTypeCache = function(type) { setMessage("Clearing cache...", "alert-info"); if (type === 'client') { CacheService.clearClientCache(); setMessage("Client-side cache cleared!", "alert-success"); } else { if (type === 'all') CacheService.clearClientCache(); CacheService.clearCache(null, type).then(function (result) { setMessage(result.message, result.success ? "alert-success" : "alert-danger"); if (result.success === true) { $scope.stats.count = result.count; } }); } }; $scope.refresh = function() { clearMessage(); loadStats(); }; function clearMessage() { $scope.data.message = ""; $scope.data.messageType = ""; } function setMessage(msg, type, doTimeout) { $scope.data.messageType = type; $scope.data.message = msg; if (doTimeout === true) timeoutClearMessage(); } function timeoutClearMessage() { $timeout(function() { clearMessage(); }, 4000); } function init() { $scope.$parent.resize('.caching-view'); loadStats(); } function loadStats() { CacheService.getStats().then(function(result) { setMessage(result.message, result.success ? "alert-success" : "alert-danger"); if (result.success === true) { $scope.stats.count = result.count; } }); } init(); });