diff --git a/flask_monitoringdashboard/frontend/js/controllers/configuration.js b/flask_monitoringdashboard/frontend/js/controllers/configuration.js index f906deb7..2e68f757 100644 --- a/flask_monitoringdashboard/frontend/js/controllers/configuration.js +++ b/flask_monitoringdashboard/frontend/js/controllers/configuration.js @@ -98,14 +98,14 @@ export function ConfigurationController($scope, $http, menuService, endpointServ $scope.fetchTelemetryConsent = function () { $http.post(`/dashboard/get_telemetry_answered`) .then(function (response) { - $scope.telemetryConsent = response.data.get_telemetry_answered ? 'true' : 'false'; + $scope.telemetryConsent = response.data.get_telemetry_answered; }, function (error) { console.error('Error fetching telemetry consent:', error); }); }; $scope.handleTelemetry = function (consent) { - $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent === 'true' }) + $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent }) .then(function (response) { }, function (error) { console.error('Error updating telemetry consent:', error); diff --git a/flask_monitoringdashboard/frontend/js/controllers/surveyController.js b/flask_monitoringdashboard/frontend/js/controllers/surveyController.js index 7b26f8be..04afb4a1 100644 --- a/flask_monitoringdashboard/frontend/js/controllers/surveyController.js +++ b/flask_monitoringdashboard/frontend/js/controllers/surveyController.js @@ -1,4 +1,4 @@ -export function SurveyController($scope, $http) { +export function SurveyController($scope, $http, $sce) { $scope.surveyShow = false; $scope.surveyCompleted = false; // New flag for survey completion $scope.surveyVariationIndex = 0; @@ -8,7 +8,11 @@ export function SurveyController($scope, $http) { 'We value your opinion! Click here to share your thoughts.', 'Help us improve! Participate in our short survey.' ]; - + + $scope.surveyVariations = $scope.surveyVariations.map(variation => + $sce.trustAsHtml(variation) + ); + $scope.fetchSurveyStatus = function () { $http.post('/dashboard/survey_status') diff --git a/flask_monitoringdashboard/frontend/js/controllers/telemetryController.js b/flask_monitoringdashboard/frontend/js/controllers/telemetryController.js index 62cc83c2..a28a4d3c 100644 --- a/flask_monitoringdashboard/frontend/js/controllers/telemetryController.js +++ b/flask_monitoringdashboard/frontend/js/controllers/telemetryController.js @@ -2,15 +2,15 @@ export function TelemetryController($scope, $http) { $scope.telemetryShow = false; $scope.followUpShow = false; - $scope.fetchConsent = function () { + $scope.fetchTelemetryConsent = function () { $http.post(`/dashboard/get_telemetry_answered`) .then(function (response) { $scope.telemetryShow = !response.data.get_telemetry_answered; }, function (error) { - console.error('Error fetching consent:', error); + console.error('Error fetching telemetry consent:', error); }); }; - $scope.fetchConsent(); + $scope.fetchTelemetryConsent(); $scope.handleTelemetry = function (consent) { $scope.telemetryShow = false; @@ -20,7 +20,7 @@ export function TelemetryController($scope, $http) { .then(function (response) { $scope.telemetryShow = false; }, function (error) { - console.error('Error:', error); + console.error('Error updating telemetry consent:', error); }); }; @@ -56,7 +56,6 @@ export function TelemetryController($scope, $http) { } } } - $http.post('https://parseapi.back4app.com/classes/FollowUp', { reasons: feedback }, config) .then(function (response) { console.log('Feedback sent:', response.data); diff --git a/flask_monitoringdashboard/static/js/app.js b/flask_monitoringdashboard/static/js/app.js index dad8e76c..6cb690f3 100644 --- a/flask_monitoringdashboard/static/js/app.js +++ b/flask_monitoringdashboard/static/js/app.js @@ -49,7 +49,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 */ ConfigurationController: () => (/* binding */ ConfigurationController)\n/* harmony export */ });\nconst HEADERS = {\r\n headers: {\r\n 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'\r\n }\r\n}\r\n\r\nfunction ConfigurationController($scope, $http, menuService, endpointService, modalService) {\r\n endpointService.reset();\r\n menuService.reset('configuration');\r\n modalService.setConfirm('delete', () => deleteUser($scope.user));\r\n modalService.setConfirm('edit', () => editUser($scope.user));\r\n modalService.setConfirm('create', createUser);\r\n\r\n $scope.details = {};\r\n $scope.config = {};\r\n $scope.error = {};\r\n $scope.userData = [];\r\n\r\n $http.get('api/users').then(function (response) {\r\n $scope.userData = response.data;\r\n });\r\n\r\n $http.get('api/deploy_details').then(function (response) {\r\n $scope.details = response.data;\r\n });\r\n $http.get('api/deploy_config').then(function (response) {\r\n $scope.config = response.data;\r\n });\r\n\r\n $scope.openModal = function (name, user) {\r\n $scope.user = user;\r\n $(`#${name}Modal`).modal();\r\n }\r\n\r\n function fetchUsers() {\r\n $http.get('api/users').then(function (response) {\r\n $scope.userData = response.data; // reload user data\r\n });\r\n }\r\n\r\n function createUser() {\r\n $http.post(\r\n 'api/user/create',\r\n $.param({\r\n 'username': $('#create-username')[0].value,\r\n 'password': $('#create-pwd')[0].value,\r\n 'password2': $('#create-pwd2')[0].value,\r\n 'is_admin': $('#create-admin')[0].checked,\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#createModal').modal('hide');\r\n modalService.setErrorMessage('create', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('create', errorResponse.data.message);\r\n });\r\n }\r\n\r\n function editUser() {\r\n $http.post(\r\n 'api/user/edit',\r\n $.param({\r\n 'user_id': $scope.user.id,\r\n 'old_password': $('#edit-old-pwd')[0].value,\r\n 'new_password': $('#edit-new-pwd')[0].value,\r\n 'new_password2': $('#edit-new-pwd2')[0].value,\r\n 'is_admin': $('#edit-admin')[0].checked,\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#editModal').modal('hide');\r\n modalService.setErrorMessage('edit', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('edit', errorResponse.data.message);\r\n });\r\n }\r\n\r\n function deleteUser(user) {\r\n $http.post(\r\n 'api/user/delete',\r\n $.param({\r\n 'user_id': user.id\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#deleteModal').modal('hide');\r\n modalService.setErrorMessage('delete', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('delete', errorResponse.data.message);\r\n });\r\n }\r\n\r\n $scope.telemetryConsent;\r\n\r\n $scope.fetchTelemetryConsent = function () {\r\n $http.post(`/dashboard/get_telemetry_answered`)\r\n .then(function (response) {\r\n $scope.telemetryConsent = response.data.get_telemetry_answered ? 'true' : 'false';\r\n }, function (error) {\r\n console.error('Error fetching telemetry consent:', error);\r\n });\r\n };\r\n\r\n $scope.handleTelemetry = function (consent) {\r\n $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent === 'true' })\r\n .then(function (response) {\r\n }, function (error) {\r\n console.error('Error updating telemetry consent:', error);\r\n });\r\n };\r\n\r\n $scope.fetchTelemetryConsent();\r\n\r\n}\n\n//# sourceURL=webpack://frontend/./js/controllers/configuration.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ConfigurationController: () => (/* binding */ ConfigurationController)\n/* harmony export */ });\nconst HEADERS = {\r\n headers: {\r\n 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'\r\n }\r\n}\r\n\r\nfunction ConfigurationController($scope, $http, menuService, endpointService, modalService) {\r\n endpointService.reset();\r\n menuService.reset('configuration');\r\n modalService.setConfirm('delete', () => deleteUser($scope.user));\r\n modalService.setConfirm('edit', () => editUser($scope.user));\r\n modalService.setConfirm('create', createUser);\r\n\r\n $scope.details = {};\r\n $scope.config = {};\r\n $scope.error = {};\r\n $scope.userData = [];\r\n\r\n $http.get('api/users').then(function (response) {\r\n $scope.userData = response.data;\r\n });\r\n\r\n $http.get('api/deploy_details').then(function (response) {\r\n $scope.details = response.data;\r\n });\r\n $http.get('api/deploy_config').then(function (response) {\r\n $scope.config = response.data;\r\n });\r\n\r\n $scope.openModal = function (name, user) {\r\n $scope.user = user;\r\n $(`#${name}Modal`).modal();\r\n }\r\n\r\n function fetchUsers() {\r\n $http.get('api/users').then(function (response) {\r\n $scope.userData = response.data; // reload user data\r\n });\r\n }\r\n\r\n function createUser() {\r\n $http.post(\r\n 'api/user/create',\r\n $.param({\r\n 'username': $('#create-username')[0].value,\r\n 'password': $('#create-pwd')[0].value,\r\n 'password2': $('#create-pwd2')[0].value,\r\n 'is_admin': $('#create-admin')[0].checked,\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#createModal').modal('hide');\r\n modalService.setErrorMessage('create', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('create', errorResponse.data.message);\r\n });\r\n }\r\n\r\n function editUser() {\r\n $http.post(\r\n 'api/user/edit',\r\n $.param({\r\n 'user_id': $scope.user.id,\r\n 'old_password': $('#edit-old-pwd')[0].value,\r\n 'new_password': $('#edit-new-pwd')[0].value,\r\n 'new_password2': $('#edit-new-pwd2')[0].value,\r\n 'is_admin': $('#edit-admin')[0].checked,\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#editModal').modal('hide');\r\n modalService.setErrorMessage('edit', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('edit', errorResponse.data.message);\r\n });\r\n }\r\n\r\n function deleteUser(user) {\r\n $http.post(\r\n 'api/user/delete',\r\n $.param({\r\n 'user_id': user.id\r\n }),\r\n HEADERS\r\n ).then(function (successResponse) {\r\n fetchUsers();\r\n $('#deleteModal').modal('hide');\r\n modalService.setErrorMessage('delete', null); // remove error message.\r\n }, function (errorResponse) {\r\n modalService.setErrorMessage('delete', errorResponse.data.message);\r\n });\r\n }\r\n\r\n $scope.telemetryConsent;\r\n\r\n $scope.fetchTelemetryConsent = function () {\r\n $http.post(`/dashboard/get_telemetry_answered`)\r\n .then(function (response) {\r\n $scope.telemetryConsent = response.data.get_telemetry_answered;\r\n }, function (error) {\r\n console.error('Error fetching telemetry consent:', error);\r\n });\r\n };\r\n\r\n $scope.handleTelemetry = function (consent) {\r\n $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent })\r\n .then(function (response) {\r\n }, function (error) {\r\n console.error('Error updating telemetry consent:', error);\r\n });\r\n };\r\n\r\n $scope.fetchTelemetryConsent();\r\n\r\n}\n\n//# sourceURL=webpack://frontend/./js/controllers/configuration.js?"); /***/ }), @@ -225,7 +225,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 */ SurveyController: () => (/* binding */ SurveyController)\n/* harmony export */ });\nfunction SurveyController($scope, $http) {\r\n $scope.surveyShow = false;\r\n $scope.surveyCompleted = false; // New flag for survey completion\r\n $scope.surveyVariationIndex = 0;\r\n $scope.surveyVariations = [\r\n 'Please take a moment to fill out our survey.',\r\n 'Your feedback is valuable! Take our quick survey.',\r\n 'We value your opinion! Click here to share your thoughts.',\r\n 'Help us improve! Participate in our short survey.'\r\n ];\r\n \r\n\r\n $scope.fetchSurveyStatus = function () {\r\n $http.post('/dashboard/survey_status')\r\n .then(function (response) {\r\n $scope.surveyVariationIndex = response.data.surveyVariationIndex;\r\n $scope.surveyCompleted = response.data.surveyCompleted;\r\n $scope.surveyShow = !$scope.surveyCompleted && ($scope.surveyVariationIndex < $scope.surveyVariations.length);\r\n }, function (error) {\r\n console.error('Error fetching survey status:', error);\r\n });\r\n };\r\n $scope.fetchSurveyStatus();\r\n\r\n $scope.closeSurvey = function () {\r\n if (!$scope.surveyCompleted) {\r\n $scope.surveyVariationIndex++;\r\n $http.post('/dashboard/survey_status', { surveyVariationIndex: $scope.surveyVariationIndex })\r\n .then(function (response) {\r\n $scope.surveyShow = false;\r\n }, function (error) {\r\n console.error('Error:', error);\r\n });\r\n }\r\n };\r\n\r\n $scope.surveyClicked = function () {\r\n $http.post('/dashboard/survey_clicked')\r\n .then(function (response) {\r\n $scope.surveyCompleted = true;\r\n $scope.surveyShow = false;\r\n }, function (error) {\r\n console.error('Error:', error);\r\n });\r\n };\r\n}\r\n\n\n//# sourceURL=webpack://frontend/./js/controllers/surveyController.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SurveyController: () => (/* binding */ SurveyController)\n/* harmony export */ });\nfunction SurveyController($scope, $http, $sce) {\r\n $scope.surveyShow = false;\r\n $scope.surveyCompleted = false; // New flag for survey completion\r\n $scope.surveyVariationIndex = 0;\r\n $scope.surveyVariations = [\r\n 'Please take a moment to fill out our survey.',\r\n 'Your feedback is valuable! Take our quick survey.',\r\n 'We value your opinion! Click here to share your thoughts.',\r\n 'Help us improve! Participate in our short survey.'\r\n ];\r\n\r\n $scope.surveyVariations = $scope.surveyVariations.map(variation =>\r\n $sce.trustAsHtml(variation)\r\n );\r\n \r\n\r\n $scope.fetchSurveyStatus = function () {\r\n $http.post('/dashboard/survey_status')\r\n .then(function (response) {\r\n $scope.surveyVariationIndex = response.data.surveyVariationIndex;\r\n $scope.surveyCompleted = response.data.surveyCompleted;\r\n $scope.surveyShow = !$scope.surveyCompleted && ($scope.surveyVariationIndex < $scope.surveyVariations.length);\r\n }, function (error) {\r\n console.error('Error fetching survey status:', error);\r\n });\r\n };\r\n $scope.fetchSurveyStatus();\r\n\r\n $scope.closeSurvey = function () {\r\n if (!$scope.surveyCompleted) {\r\n $scope.surveyVariationIndex++;\r\n $http.post('/dashboard/survey_status', { surveyVariationIndex: $scope.surveyVariationIndex })\r\n .then(function (response) {\r\n $scope.surveyShow = false;\r\n }, function (error) {\r\n console.error('Error:', error);\r\n });\r\n }\r\n };\r\n\r\n $scope.surveyClicked = function () {\r\n $http.post('/dashboard/survey_clicked')\r\n .then(function (response) {\r\n $scope.surveyCompleted = true;\r\n $scope.surveyShow = false;\r\n }, function (error) {\r\n console.error('Error:', error);\r\n });\r\n };\r\n}\r\n\n\n//# sourceURL=webpack://frontend/./js/controllers/surveyController.js?"); /***/ }), @@ -236,7 +236,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 */ TelemetryController: () => (/* binding */ TelemetryController)\n/* harmony export */ });\nfunction TelemetryController($scope, $http) {\r\n $scope.telemetryShow = false;\r\n $scope.followUpShow = false;\r\n\r\n $scope.fetchConsent = function () {\r\n $http.post(`/dashboard/get_telemetry_answered`)\r\n .then(function (response) {\r\n $scope.telemetryShow = !response.data.get_telemetry_answered;\r\n }, function (error) {\r\n console.error('Error fetching consent:', error);\r\n });\r\n };\r\n $scope.fetchConsent();\r\n\r\n $scope.handleTelemetry = function (consent) {\r\n $scope.telemetryShow = false;\r\n $scope.followUpShow = !consent;\r\n\r\n $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent })\r\n .then(function (response) {\r\n $scope.telemetryShow = false;\r\n }, function (error) {\r\n console.error('Error:', error);\r\n });\r\n };\r\n\r\n $scope.reasons = {\r\n privacy: false,\r\n performance: false,\r\n trust: false,\r\n other: false\r\n };\r\n $scope.customReason = '';\r\n\r\n var config = {\r\n headers: {\r\n 'X-Parse-Application-Id': '',\r\n 'X-Parse-REST-API-Key': '',\r\n 'Content-Type': 'application/json'\r\n }\r\n };\r\n\r\n $scope.submitFollowUp = function () {\r\n $scope.followUpShow = false;\r\n\r\n var feedback = [];\r\n for (var key in $scope.reasons) {\r\n if ($scope.reasons[key]) {\r\n if (key === 'other') {\r\n feedback.push(key);\r\n if ($scope.customReason.trim() !== '') {\r\n feedback.push({ other: $scope.customReason });\r\n }\r\n } else {\r\n feedback.push(key);\r\n }\r\n }\r\n }\r\n\r\n $http.post('https://parseapi.back4app.com/classes/FollowUp', { reasons: feedback }, config)\r\n .then(function (response) {\r\n console.log('Feedback sent:', response.data);\r\n }, function (error) {\r\n console.error('Error sending feedback:', error);\r\n });\r\n };\r\n}\n\n//# sourceURL=webpack://frontend/./js/controllers/telemetryController.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TelemetryController: () => (/* binding */ TelemetryController)\n/* harmony export */ });\nfunction TelemetryController($scope, $http) {\r\n $scope.telemetryShow = false;\r\n $scope.followUpShow = false;\r\n\r\n $scope.fetchTelemetryConsent = function () {\r\n $http.post(`/dashboard/get_telemetry_answered`)\r\n .then(function (response) {\r\n $scope.telemetryShow = !response.data.get_telemetry_answered;\r\n }, function (error) {\r\n console.error('Error fetching telemetry consent:', error);\r\n });\r\n };\r\n $scope.fetchTelemetryConsent();\r\n\r\n $scope.handleTelemetry = function (consent) {\r\n $scope.telemetryShow = false;\r\n $scope.followUpShow = !consent;\r\n\r\n $http.post('/dashboard/telemetry/accept_telemetry', { 'consent': consent })\r\n .then(function (response) {\r\n $scope.telemetryShow = false;\r\n }, function (error) {\r\n console.error('Error updating telemetry consent:', error);\r\n });\r\n };\r\n\r\n $scope.reasons = {\r\n privacy: false,\r\n performance: false,\r\n trust: false,\r\n other: false\r\n };\r\n $scope.customReason = '';\r\n\r\n var config = {\r\n headers: {\r\n 'X-Parse-Application-Id': '',\r\n 'X-Parse-REST-API-Key': '',\r\n 'Content-Type': 'application/json'\r\n }\r\n };\r\n\r\n $scope.submitFollowUp = function () {\r\n $scope.followUpShow = false;\r\n\r\n var feedback = [];\r\n for (var key in $scope.reasons) {\r\n if ($scope.reasons[key]) {\r\n if (key === 'other') {\r\n feedback.push(key);\r\n if ($scope.customReason.trim() !== '') {\r\n feedback.push({ other: $scope.customReason });\r\n }\r\n } else {\r\n feedback.push(key);\r\n }\r\n }\r\n }\r\n $http.post('https://parseapi.back4app.com/classes/FollowUp', { reasons: feedback }, config)\r\n .then(function (response) {\r\n console.log('Feedback sent:', response.data);\r\n }, function (error) {\r\n console.error('Error sending feedback:', error);\r\n });\r\n };\r\n}\n\n//# sourceURL=webpack://frontend/./js/controllers/telemetryController.js?"); /***/ }), diff --git a/flask_monitoringdashboard/static/pages/telemetry.html b/flask_monitoringdashboard/static/pages/telemetry.html index cbae7ee0..c7c1f977 100644 --- a/flask_monitoringdashboard/static/pages/telemetry.html +++ b/flask_monitoringdashboard/static/pages/telemetry.html @@ -1,8 +1,12 @@
Help us enhance our services by allowing anonymous telemetry collection. This data helps us understand usage + patterns and improve your experience. You have full control and can modify your choice at any time in the + "Configuration" section. +