Skip to content

Commit

Permalink
Now distingushing between a "reload TLS" issue and a "You don't have …
Browse files Browse the repository at this point in the history
…access to case" issue.
  • Loading branch information
epugh committed Aug 24, 2023
1 parent 1b57ce7 commit 4f97873
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
27 changes: 20 additions & 7 deletions app/assets/javascripts/controllers/mainCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ angular.module('QuepidApp')
var bootstrapCase = function() {
return caseSvc.get(caseNo)
.then(function(acase) {
if (angular.isUndefined(acase)){
throw new Error('Could not retrieve case ' + caseNo + '. Confirm that the case has been shared with you via a team you are a member of!');
}

caseSvc.selectTheCase(acase);
settingsSvc.setCaseTries(acase.tries);
Expand Down Expand Up @@ -142,15 +145,25 @@ angular.module('QuepidApp')
loadSnapshots();
updateCaseMetadata();
paneSvc.refreshElements();
}).catch(function() {
var resultsTuple = caseTryNavSvc.swapQuepidUrlTLS();
}).catch(function(error) {
// brittle logic, but check if we throw the TLS error or if it's from something else.'
var message = error.message;
if (message === 'Need to change to different TLS'){
var resultsTuple = caseTryNavSvc.swapQuepidUrlTLS();

var quepidUrlToSwitchTo = resultsTuple[0];
var protocolToSwitchTo = resultsTuple[1];
var quepidUrlToSwitchTo = resultsTuple[0];
var protocolToSwitchTo = resultsTuple[1];

flash.to('search-error').error = '<a href="' + quepidUrlToSwitchTo + '" class="btn btn-primary form-control">Click Here to <span class="glyphicon glyphicon-refresh"></span> Reload Quepid in <code>' + protocolToSwitchTo + '</code> Protocol!';
loadSnapshots();
updateCaseMetadata();
flash.to('search-error').error = '<a href="' + quepidUrlToSwitchTo + '" class="btn btn-primary form-control">Click Here to <span class="glyphicon glyphicon-refresh"></span> Reload Quepid in <code>' + protocolToSwitchTo + '</code> Protocol!';
}
else if (message.startsWith('Could not retrieve case')){
flash.to('search-error').error = message;
}
else {
flash.to('search-error').error = 'Could not load the case ' + caseNo + ' due to: ' + message;
}
//loadSnapshots();
//updateCaseMetadata();
paneSvc.refreshElements();
});

Expand Down
29 changes: 17 additions & 12 deletions app/assets/javascripts/controllers/queriesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,23 @@ angular.module('QuepidApp')
if ( isNaN(tryNo) ) { // If we didn't specify a try, then we need to get the latest
caseSvc.get(caseNo)
.then(function(acase) {

tryNo = acase.lastTry;
console.log('We do not have a tryNo, so we grabbed the lastTry from the case, and using it as the id:' + tryNo);
lastScoreTracker = {
'score': $scope.queries.avgQuery.currentScore.score,
'all_rated': $scope.queries.avgQuery.currentScore.allRated,
'try_number': tryNo,
'queries': $scope.queries.avgQuery.currentScore.queries,
};

$log.info('sending score information to mothership');
caseSvc.trackLastScore(caseNo, lastScoreTracker);
if (angular.isUndefined(acase)){
$log.info('Did not find a case for ' + caseNo + ' and therefore not scoring');
}
else {
tryNo = acase.lastTry;

$log.info('We do not have a tryNo, so we grabbed the lastTry from the case, and using it as the id:' + tryNo);
lastScoreTracker = {
'score': $scope.queries.avgQuery.currentScore.score,
'all_rated': $scope.queries.avgQuery.currentScore.allRated,
'try_number': tryNo,
'queries': $scope.queries.avgQuery.currentScore.queries,
};

$log.info('sending score information to mothership');
caseSvc.trackLastScore(caseNo, lastScoreTracker);
}
});
}
else {
Expand Down
9 changes: 4 additions & 5 deletions app/assets/javascripts/services/caseSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
angular.module('QuepidApp')
.service('caseSvc', [
'$http', '$filter', '$q', '$rootScope',
'flash',
'$log',
'caseTryNavSvc', 'queriesSvc', 'settingsSvc',
'broadcastSvc',
function caseSvc(
$http, $filter, $q, $rootScope,
flash,
$log,
caseTryNavSvc, queriesSvc, settingsSvc,
broadcastSvc
) {
Expand Down Expand Up @@ -478,9 +478,8 @@ angular.module('QuepidApp')

svc.allCases[index] = acase;
return acase;
}, function(response) {
flash.to('search-error').error = 'Either the case does not exist or you do not have permissions to access it!';
return response;
}, function() {
$log.info('Did not find the case ' + id);
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/jshint/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def javascript_files
# I am skipping them via this terrible way because I can't get JSHint exclude_paths to work.
# They should be fixed to pass jshint!
files_to_skip = [ 'user_pulse.js', 'tour.js' ]

# This file is a copied from node_modules/ace-builds to make Ace happy, so ignore
files_to_skip << 'mode-json.js'

js_asset_files = []
file_paths.each do |path|
Dir.glob(path) do |file|
Expand Down

0 comments on commit 4f97873

Please sign in to comment.