-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/surverytelemetry-frontend-featur…
…e' into telemetry-consent-api
- Loading branch information
Showing
15 changed files
with
362 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 47 additions & 22 deletions
69
flask_monitoringdashboard/frontend/js/controllers/surveyController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,52 @@ | ||
export function SurveyController($scope, $http) { | ||
$scope.surveyShow = true; | ||
$scope.reasons = { | ||
privacy: false, | ||
performance: false, | ||
trust: false, | ||
other: false | ||
export function SurveyController($scope, $http, $sce) { | ||
$scope.surveyShow = false; | ||
$scope.surveyCompleted = false; | ||
|
||
// Fetch local storage variation index | ||
const storedIndex = localStorage.getItem('surveyVariationIndex'); | ||
$scope.surveyVariationIndex = storedIndex && !isNaN(parseInt(storedIndex)) ? parseInt(storedIndex) : 0; | ||
|
||
// Variations of the survey prompt | ||
$scope.surveyVariations = [ | ||
'Please take a moment to <a href="https://forms.gle/kWD5mqcibS2V5f3Y6" target="_blank">fill out our survey</a>.', | ||
'Your feedback is valuable! <a href="https://forms.gle/kWD5mqcibS2V5f3Y6" target="_blank">Take our quick survey.</a>', | ||
'We value your opinion! Click <a href="https://forms.gle/kWD5mqcibS2V5f3Y6" target="_blank">here</a> to share your thoughts.', | ||
'Help us improve! Participate in our <a href="https://forms.gle/kWD5mqcibS2V5f3Y6" target="_blank">short survey</a>.' | ||
]; | ||
|
||
// Mark as trusted HTML | ||
$scope.surveyVariations = $scope.surveyVariations.map(variation => | ||
$sce.trustAsHtml(variation) | ||
); | ||
|
||
// Fetches the survey from database | ||
$scope.fetchSurveyFilled = function () { | ||
$http.post('/dashboard/get_is_survey_filled') | ||
.then(function (response) { | ||
$scope.surveyCompleted = response.data.is_survey_filled; | ||
}, function (error) { | ||
console.error('Error fetching survey status:', error); | ||
}); | ||
$scope.surveyShow = !$scope.surveyCompleted && ($scope.surveyVariationIndex < $scope.surveyVariations.length); | ||
}; | ||
$scope.fetchSurveyFilled(); | ||
|
||
$scope.submitFollowUp = function() { | ||
$scope.followUpShow = false; | ||
|
||
var feedback = []; | ||
for (var key in $scope.reasons) { | ||
if ($scope.reasons[key]) { | ||
feedback.push(key !== 'other' ? key : { other: $scope.customReason }); | ||
} | ||
// Increment surveyVariation in localStorage | ||
$scope.closeSurvey = function () { | ||
if (!$scope.surveyCompleted) { | ||
$scope.surveyVariationIndex++; | ||
localStorage.setItem('surveyVariationIndex', $scope.surveyVariationIndex.toString()); | ||
} | ||
|
||
$http.post('/api/feedback', { reasons: feedback }) | ||
.then(function(response) { | ||
console.log('Feedback sent:', response.data); | ||
}, function(error) { | ||
console.error('Error sending feedback:', error); | ||
}; | ||
|
||
// Mark survey as filled in database | ||
$scope.surveyFilled = function () { | ||
$http.post('/dashboard/survey_has_been_filled') | ||
.then(function (response) { | ||
}, function (error) { | ||
console.error('Error:', error); | ||
}); | ||
$scope.surveyCompleted = true; | ||
$scope.surveyShow = false; | ||
}; | ||
} | ||
} |
Oops, something went wrong.