diff --git a/flask_monitoringdashboard/frontend/js/controllers/databaseManagementController.js b/flask_monitoringdashboard/frontend/js/controllers/databaseManagementController.js index 9b7b0ab4..46c70db0 100644 --- a/flask_monitoringdashboard/frontend/js/controllers/databaseManagementController.js +++ b/flask_monitoringdashboard/frontend/js/controllers/databaseManagementController.js @@ -19,7 +19,7 @@ export function DatabaseManagementController($scope, $http, menuService, endpoin // Initialize the configuration for pruning $scope.pruneOnDemandConfig = { ageThresholdWeeks: 1, // Default value or null if you prefer no default - deleteCustomGraphs: false + deleteCustomGraphData: false }; // Variables for feedback messages @@ -30,9 +30,17 @@ export function DatabaseManagementController($scope, $http, menuService, endpoin // Function to prune the database $scope.pruneDatabase = function () { + let weekOrWeeks = $scope.pruneOnDemandConfig.ageThresholdWeeks === 1 ? ' week' : ' weeks'; + let confirmationMessage = 'Are you sure you want to prune all request data older than ' + + $scope.pruneOnDemandConfig.ageThresholdWeeks + weekOrWeeks + '?'; + if (!confirm(confirmationMessage)) { + return; // Stop the function if the user clicks 'Cancel' + } + + // Confirmation dialog const pruneData = { age_threshold_weeks: $scope.pruneOnDemandConfig.ageThresholdWeeks, - delete_custom_graphs: $scope.pruneOnDemandConfig.deleteCustomGraphs + delete_custom_graph_data: $scope.pruneOnDemandConfig.deleteCustomGraphData }; $http.post('/dashboard/database_pruning/prune_on_demand', pruneData) diff --git a/flask_monitoringdashboard/static/js/app.js b/flask_monitoringdashboard/static/js/app.js index 0d8d79d0..4ccae321 100644 --- a/flask_monitoringdashboard/static/js/app.js +++ b/flask_monitoringdashboard/static/js/app.js @@ -82,7 +82,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DatabaseManagementController: () => (/* binding */ DatabaseManagementController)\n/* harmony export */ });\nfunction DatabaseManagementController($scope, $http, menuService, endpointService) {\r\n endpointService.reset();\r\n menuService.reset('database_management');\r\n\r\n $scope.databaseSize = 'N/A';\r\n\r\n $scope.getDatabaseSize = function () {\r\n $http.get('/dashboard/database_pruning/get_database_size')\r\n .then(function (response) {\r\n $scope.databaseSize = response.data.size;\r\n }, function (error) {\r\n console.error('Error fetching database size:', error.data);\r\n });\r\n };\r\n\r\n $scope.getDatabaseSize();\r\n\r\n\r\n // Initialize the configuration for pruning\r\n $scope.pruneOnDemandConfig = {\r\n ageThresholdWeeks: 1, // Default value or null if you prefer no default\r\n deleteCustomGraphs: false\r\n };\r\n\r\n // Variables for feedback messages\r\n $scope.pruneOnDemandMessage = '';\r\n $scope.pruneOnDemandIsSuccess = false;\r\n\r\n $scope.pageSize = '10';\r\n\r\n // Function to prune the database\r\n $scope.pruneDatabase = function () {\r\n const pruneData = {\r\n age_threshold_weeks: $scope.pruneOnDemandConfig.ageThresholdWeeks,\r\n delete_custom_graphs: $scope.pruneOnDemandConfig.deleteCustomGraphs\r\n };\r\n\r\n $http.post('/dashboard/database_pruning/prune_on_demand', pruneData)\r\n .then(function (response) {\r\n $scope.pruneOnDemandIsSuccess = true;\r\n $scope.pruneOnDemandMessage = 'Database pruning complete.';\r\n }, function (error) {\r\n $scope.pruneOnDemandIsSuccess = false;\r\n $scope.pruneOnDemandMessage = 'Error pruning database: ' + (error.data.error || 'Unknown error');\r\n });\r\n };\r\n\r\n // Function to fetch the pruning schedule\r\n $scope.getPruningSchedule = function () {\r\n $http.get('/dashboard/database_pruning/get_pruning_schedule')\r\n .then(function (response) {\r\n $scope.pruningSchedule = response.data;\r\n }, function (error) {\r\n console.error('Error fetching pruning schedule:', error.data);\r\n });\r\n };\r\n $scope.getPruningSchedule();\r\n}\r\n\n\n//# sourceURL=webpack://frontend/./js/controllers/databaseManagementController.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DatabaseManagementController: () => (/* binding */ DatabaseManagementController)\n/* harmony export */ });\nfunction DatabaseManagementController($scope, $http, menuService, endpointService) {\r\n endpointService.reset();\r\n menuService.reset('database_management');\r\n\r\n $scope.databaseSize = 'N/A';\r\n\r\n $scope.getDatabaseSize = function () {\r\n $http.get('/dashboard/database_pruning/get_database_size')\r\n .then(function (response) {\r\n $scope.databaseSize = response.data.size;\r\n }, function (error) {\r\n console.error('Error fetching database size:', error.data);\r\n });\r\n };\r\n\r\n $scope.getDatabaseSize();\r\n\r\n\r\n // Initialize the configuration for pruning\r\n $scope.pruneOnDemandConfig = {\r\n ageThresholdWeeks: 1, // Default value or null if you prefer no default\r\n deleteCustomGraphData: false\r\n };\r\n\r\n // Variables for feedback messages\r\n $scope.pruneOnDemandMessage = '';\r\n $scope.pruneOnDemandIsSuccess = false;\r\n\r\n $scope.pageSize = '10';\r\n\r\n // Function to prune the database\r\n $scope.pruneDatabase = function () {\r\n let weekOrWeeks = $scope.pruneOnDemandConfig.ageThresholdWeeks === 1 ? ' week' : ' weeks';\r\n let confirmationMessage = 'Are you sure you want to prune all request data older than '\r\n + $scope.pruneOnDemandConfig.ageThresholdWeeks + weekOrWeeks + '?';\r\n if (!confirm(confirmationMessage)) {\r\n return; // Stop the function if the user clicks 'Cancel'\r\n }\r\n\r\n // Confirmation dialog\r\n const pruneData = {\r\n age_threshold_weeks: $scope.pruneOnDemandConfig.ageThresholdWeeks,\r\n delete_custom_graph_data: $scope.pruneOnDemandConfig.deleteCustomGraphData\r\n };\r\n\r\n $http.post('/dashboard/database_pruning/prune_on_demand', pruneData)\r\n .then(function (response) {\r\n $scope.pruneOnDemandIsSuccess = true;\r\n $scope.pruneOnDemandMessage = 'Database pruning complete.';\r\n }, function (error) {\r\n $scope.pruneOnDemandIsSuccess = false;\r\n $scope.pruneOnDemandMessage = 'Error pruning database: ' + (error.data.error || 'Unknown error');\r\n });\r\n };\r\n\r\n // Function to fetch the pruning schedule\r\n $scope.getPruningSchedule = function () {\r\n $http.get('/dashboard/database_pruning/get_pruning_schedule')\r\n .then(function (response) {\r\n $scope.pruningSchedule = response.data;\r\n }, function (error) {\r\n console.error('Error fetching pruning schedule:', error.data);\r\n });\r\n };\r\n $scope.getPruningSchedule();\r\n}\r\n\n\n//# sourceURL=webpack://frontend/./js/controllers/databaseManagementController.js?"); /***/ }), diff --git a/flask_monitoringdashboard/static/pages/database_management.html b/flask_monitoringdashboard/static/pages/database_management.html index af981a19..932a04cb 100644 --- a/flask_monitoringdashboard/static/pages/database_management.html +++ b/flask_monitoringdashboard/static/pages/database_management.html @@ -4,7 +4,7 @@
{{ databaseSize }}
{{ databaseSize }}
Year: {{ pruningSchedule.year }}
-Month: {{ pruningSchedule.month }}
-Day of the Month: {{ pruningSchedule.day_of_the_month }}
-Week: {{ pruningSchedule.week }}
-Day of the Week: {{ pruningSchedule.day_of_the_week }}
-Hour: {{ pruningSchedule.hour }}
-Minute: {{ pruningSchedule.minute }}
-Second: {{ pruningSchedule.second }}
-Next Run Time: {{ pruningSchedule.next_run_time }}
-Weeks to Keep: {{ pruningSchedule.weeks_to_keep }}
-Delete Custom Graphs: {{ pruningSchedule.delete_custom_graphs }}
+Year: {{ pruningSchedule.year }}
+Month: {{ pruningSchedule.month }}
+Day of the Month: {{ pruningSchedule.day_of_the_month }}
+Week: {{ pruningSchedule.week }}
+Day of the Week: {{ pruningSchedule.day_of_the_week }}
+Hour: {{ pruningSchedule.hour }}
+Minute: {{ pruningSchedule.minute }}
+Second: {{ pruningSchedule.second }}
+Next Run Time: {{ pruningSchedule.next_run_time }}
+Weeks to Keep: {{ pruningSchedule.weeks_to_keep }}
+Delete Custom Graphs: {{ pruningSchedule.delete_custom_graph_data }}
+