# HG changeset patch # User ymh # Date 1413267174 -7200 # Node ID 16a1925df2df969c666a8d25323b8ec43875f883 # Parent 986ee928a866f026cf272830b461c38d8fc2dddd add status to annotation creation. Improve error management for annotation creation diff -r 986ee928a866 -r 16a1925df2df annot-server/webapp/__init__.py --- a/annot-server/webapp/__init__.py Tue Oct 14 05:07:37 2014 +0200 +++ b/annot-server/webapp/__init__.py Tue Oct 14 08:12:54 2014 +0200 @@ -17,7 +17,3 @@ app.config.from_object(config) import webapp.views - -@app.teardown_appcontext -def shutdown_session(exception=None): - database.db_session.remove() diff -r 986ee928a866 -r 16a1925df2df annot-server/websockets.py --- a/annot-server/websockets.py Tue Oct 14 05:07:37 2014 +0200 +++ b/annot-server/websockets.py Tue Oct 14 08:12:54 2014 +0200 @@ -93,13 +93,17 @@ } def error_callback(failure): - raise http.HttpException(500,"Error when processing message : %r" % failure) + res = params.copy() + res['status'] = 'KO' + res['failure'] = str(failure) + self.sendMessage(json.dumps(res)) def annot_callback(res): if 'ts' in res: res['ts'] = res['ts'].isoformat()+'Z' if 'uuid' in res: res['uuid'] = str(res['uuid']) + res['status'] = 'OK' self.sendMessage(json.dumps(res)) diff -r 986ee928a866 -r 16a1925df2df client/app/app.js --- a/client/app/app.js Tue Oct 14 05:07:37 2014 +0200 +++ b/client/app/app.js Tue Oct 14 08:12:54 2014 +0200 @@ -26,7 +26,7 @@ //console.log('homeCtrl 1', $scope, $location, context); console.log('homeCtrl 2', context); $scope.data = dataModel.data; - + dataModel.data.$promise.then(function(data) { if(typeof data.categories!=='undefined' && data.categories.length>0){ var cats = []; @@ -43,7 +43,7 @@ $scope.allCatLabels = cats; } }); - + $scope.selectedlevel = false; $scope.currentInterval = false; @@ -63,13 +63,13 @@ $scope.currentInterval = $interval(function(){ $interval.cancel($scope.currentInterval); $scope.showAlertDiv = false; }, 2000, 1); } $scope.annotPile = []; - - + + // Socket management var sock = null; var ellog = null; - + ellog = document.getElementById('log'); function log(m) { if(ellog){ @@ -96,7 +96,7 @@ } window.location = 'http://autobahn.ws/unsupportedbrowser'; } - + if (sock) { sock.onopen = function() { if(context.logging===true){ @@ -113,9 +113,10 @@ }; sock.onmessage = function(e) { - if(context.logging===true){ - log('Got message: ' + e.data); + if(context.logging){ + console.log('Got message: ', e.data); } + var data_json = JSON.parse(e.data) //showAlert('Annotation bien reçue.', true); console.log('2 message', $scope.annotPile.length); if($scope.annotPile.length>0){ @@ -173,7 +174,7 @@ } } }; - + // Interface management $scope.selectLevel = function(label, code, c){ if(typeof c==='undefined'){ @@ -191,7 +192,7 @@ $scope.sendAnnotation(label, code, c); } }; - + }); })();