summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-01-08 13:15:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-01-08 22:34:36 +0000
commited9fa17467ad8f41c654187eb840d4b4e15d262d (patch)
tree21166f53d96811cc2c31f83c69a026eb2f97d53b /bitbake/lib
parent2e26745a134373dfde3aa2b16fef3df720436e77 (diff)
downloadpoky-ed9fa17467ad8f41c654187eb840d4b4e15d262d.tar.gz
bitbake: toaster: Improve client side error handling
Make use of the toastermain.settings.DEBUG flag to toggle the client side error logging. Make the error logging consistent by using console.warn/error across the project, this adds traceability to the warnings. Also handles the case where console is not available by stubbing it in libtoaster. (Bitbake rev: c34ebc51a6cbf90c64ef1ac461e475c6341f0f2a) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js39
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectapp.js28
-rw-r--r--bitbake/lib/toaster/toastergui/templates/base.html5
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layers.html8
-rw-r--r--bitbake/lib/toaster/toastergui/templates/mrb_section.html8
-rw-r--r--bitbake/lib/toaster/toastergui/templates/targets.html8
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py6
7 files changed, 69 insertions, 33 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 15815b333e..a2a0abd45b 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -81,14 +81,14 @@ var libtoaster = (function (){
81 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 81 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
82 success: function (_data) { 82 success: function (_data) {
83 if (_data.error != "ok") { 83 if (_data.error != "ok") {
84 console.log(_data.error); 84 console.warn(_data.error);
85 } else { 85 } else {
86 if (onsuccess != undefined) onsuccess(_data); 86 if (onsuccess != undefined) onsuccess(_data);
87 } 87 }
88 }, 88 },
89 error: function (_data) { 89 error: function (_data) {
90 console.log("Call failed"); 90 console.warn("Call failed");
91 console.log(_data); 91 console.warn(_data);
92 if (onfail) onfail(data); 92 if (onfail) onfail(data);
93 } }); 93 } });
94 }; 94 };
@@ -102,13 +102,13 @@ var libtoaster = (function (){
102 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 102 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
103 success: function (_data) { 103 success: function (_data) {
104 if (_data.error != "ok") { 104 if (_data.error != "ok") {
105 console.log(_data.error); 105 console.warn(_data.error);
106 } else { 106 } else {
107 if (onsuccess != undefined) onsuccess(_data); 107 if (onsuccess != undefined) onsuccess(_data);
108 } 108 }
109 }, 109 },
110 error: function (_data) { 110 error: function (_data) {
111 console.log(_data); 111 console.warn(_data);
112 if (onfail) onfail(data); 112 if (onfail) onfail(data);
113 } 113 }
114 }); 114 });
@@ -168,6 +168,7 @@ var libtoaster = (function (){
168 getProjectInfo: _getProjectInfo, 168 getProjectInfo: _getProjectInfo,
169 getLayerDepsForProject : _getLayerDepsForProject, 169 getLayerDepsForProject : _getLayerDepsForProject,
170 editProject : _editProject, 170 editProject : _editProject,
171 debug: false,
171 } 172 }
172})(); 173})();
173 174
@@ -203,6 +204,15 @@ function reload_params(params) {
203/* Things that happen for all pages */ 204/* Things that happen for all pages */
204$(document).ready(function() { 205$(document).ready(function() {
205 206
207 /* If we don't have a console object which might be the case in some
208 * browsers, no-op it to avoid undefined errors.
209 */
210 if (!window.console) {
211 window.console = {};
212 window.console.warn = function() {};
213 window.console.error = function() {};
214 }
215
206 /* 216 /*
207 * PrettyPrint plugin. 217 * PrettyPrint plugin.
208 * 218 *
@@ -320,4 +330,23 @@ $(document).ready(function() {
320 if (location.href.search('#warnings') > -1) { 330 if (location.href.search('#warnings') > -1) {
321 $('#collapse-warnings').addClass('in'); 331 $('#collapse-warnings').addClass('in');
322 } 332 }
333
334 function check_for_duplicate_ids () {
335 /* warn about duplicate element ids */
336 var ids = {};
337 $("[id]").each(function() {
338 if (this.id && ids[this.id]) {
339 console.warn('Duplicate element id #'+this.id);
340 }
341 ids[this.id] = true;
342 });
343 }
344
345 if (libtoaster.debug) {
346 check_for_duplicate_ids();
347 } else {
348 /* Debug is false so supress warnings by overriding the functions */
349 window.console.warn = function () {};
350 window.console.error = function () {};
351 }
323}); 352});
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
index bb97f3292c..767ea13a7e 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
@@ -136,7 +136,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
136 $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, value: currentValue}}) 136 $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, value: currentValue}})
137 .success(function (_data) { 137 .success(function (_data) {
138 if (_data.error != "ok") { 138 if (_data.error != "ok") {
139 alert(_data.error); 139 console.warn(_data.error);
140 deffered.reject(_data.error); 140 deffered.reject(_data.error);
141 } 141 }
142 deffered.resolve(_data.list); 142 deffered.resolve(_data.list);
@@ -152,12 +152,12 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
152 if (inXHRcall) { 152 if (inXHRcall) {
153 if (callparams.data === undefined) { 153 if (callparams.data === undefined) {
154 // we simply skip the data refresh calls 154 // we simply skip the data refresh calls
155 console.log("race on XHR, aborted"); 155 console.warn("race on XHR, aborted");
156 return; 156 return;
157 } else { 157 } else {
158 // we return a promise that we'll solve by reissuing the command later 158 // we return a promise that we'll solve by reissuing the command later
159 var delayed = $q.defer(); 159 var delayed = $q.defer();
160 console.log("race on XHR, delayed"); 160 console.warn("race on XHR, delayed");
161 $interval(function () {$scope._makeXHRCall(callparams).then(function (d) { delayed.resolve(d); });}, 100, 1); 161 $interval(function () {$scope._makeXHRCall(callparams).then(function (d) { delayed.resolve(d); });}, 100, 1);
162 162
163 return delayed.promise; 163 return delayed.promise;
@@ -171,7 +171,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
171 171
172 $http(callparams).success(function(_data, _status, _headers, _config) { 172 $http(callparams).success(function(_data, _status, _headers, _config) {
173 if (_data.error != "ok") { 173 if (_data.error != "ok") {
174 alert("Failed XHR request (" + _status + "): " + _data.error); 174 console.warn("Failed XHR request (" + _status + "): " + _data.error);
175 console.error("Failed XHR request: ", _data, _status, _headers, _config); 175 console.error("Failed XHR request: ", _data, _status, _headers, _config);
176 // stop refreshing hte page 176 // stop refreshing hte page
177 $interval.cancel($scope.pollHandle); 177 $interval.cancel($scope.pollHandle);
@@ -267,7 +267,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
267 deffered.resolve(_data); 267 deffered.resolve(_data);
268 } 268 }
269 }).error(function(_data, _status, _headers, _config) { 269 }).error(function(_data, _status, _headers, _config) {
270 alert("Failed HTTP XHR request (" + _status + ")" + _data); 270 console.warn("Failed HTTP XHR request (" + _status + ")" + _data);
271 console.error("Failed HTTP XHR request: ", _data, _status, _headers, _config); 271 console.error("Failed HTTP XHR request: ", _data, _status, _headers, _config);
272 inXHRcall = false; 272 inXHRcall = false;
273 deffered.reject(_data.error); 273 deffered.reject(_data.error);
@@ -298,7 +298,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
298 298
299 $scope.targetNamedBuild = function(target) { 299 $scope.targetNamedBuild = function(target) {
300 if ($scope.targetName === undefined && $scope.targetName1 === undefined){ 300 if ($scope.targetName === undefined && $scope.targetName1 === undefined){
301 alert("No target defined, please type in a target name"); 301 console.warn("No target defined, please type in a target name");
302 return; 302 return;
303 } 303 }
304 304
@@ -310,7 +310,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
310 targets: $scope.safeTargetName, 310 targets: $scope.safeTargetName,
311 } 311 }
312 }).then(function (data) { 312 }).then(function (data) {
313 console.log("received ", data); 313 console.warn("received ", data);
314 $scope.targetName = undefined; 314 $scope.targetName = undefined;
315 $scope.targetName1 = undefined; 315 $scope.targetName1 = undefined;
316 $location.hash('buildslist'); 316 $location.hash('buildslist');
@@ -357,7 +357,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
357 $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }}) 357 $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }})
358 .success(function (_data) { 358 .success(function (_data) {
359 if (_data.error != "ok") { 359 if (_data.error != "ok") {
360 alert(_data.error); 360 console.warn(_data.error);
361 } else { 361 } else {
362 if (_data.list.length > 0) { 362 if (_data.list.length > 0) {
363 // activate modal 363 // activate modal
@@ -369,7 +369,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
369 $scope.selectedItems = (function () { s = {}; for (var i = 0; i < items.length; i++) { s[items[i].id] = true; };return s; })(); 369 $scope.selectedItems = (function () { s = {}; for (var i = 0; i < items.length; i++) { s[items[i].id] = true; };return s; })();
370 370
371 $scope.ok = function() { 371 $scope.ok = function() {
372 console.log("scope selected is ", $scope.selectedItems); 372 console.warn("scope selected is ", $scope.selectedItems);
373 $modalInstance.close(Object.keys($scope.selectedItems).filter(function (e) { return $scope.selectedItems[e];})); 373 $modalInstance.close(Object.keys($scope.selectedItems).filter(function (e) { return $scope.selectedItems[e];}));
374 }; 374 };
375 375
@@ -378,7 +378,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
378 }; 378 };
379 379
380 $scope.update = function() { 380 $scope.update = function() {
381 console.log("updated ", $scope.selectedItems); 381 console.warn("updated ", $scope.selectedItems);
382 }; 382 };
383 }, 383 },
384 resolve: { 384 resolve: {
@@ -393,7 +393,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
393 393
394 modalInstance.result.then(function (selectedArray) { 394 modalInstance.result.then(function (selectedArray) {
395 selectedArray.push($scope.layerAddId); 395 selectedArray.push($scope.layerAddId);
396 console.log("selected", selectedArray); 396 console.warn("selected", selectedArray);
397 397
398 $scope._makeXHRCall({ 398 $scope._makeXHRCall({
399 method: "POST", url: $scope.urls.xhr_edit, 399 method: "POST", url: $scope.urls.xhr_edit,
@@ -473,7 +473,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
473 473
474 $scope.edit = function(elementid) { 474 $scope.edit = function(elementid) {
475 var data = {}; 475 var data = {};
476 console.log("edit with ", elementid); 476 console.warn("edit with ", elementid);
477 var alertText = undefined; 477 var alertText = undefined;
478 var alertZone = undefined; 478 var alertZone = undefined;
479 var oldLayers = []; 479 var oldLayers = [];
@@ -675,7 +675,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
675*/ 675*/
676 676
677function test_diff_arrays() { 677function test_diff_arrays() {
678 _diffArrays([1,2,3], [2,3,4], function(e,f) { return e==f; }, function(e) {console.log("added", e)}, function(e) {console.log("deleted", e);}) 678 _diffArrays([1,2,3], [2,3,4], function(e,f) { return e==f; }, function(e) {console.warn("added", e)}, function(e) {console.warn("deleted", e);})
679} 679}
680 680
681// test_diff_arrays(); 681// test_diff_arrays();
@@ -685,6 +685,6 @@ var s = undefined;
685function test_set_alert(text) { 685function test_set_alert(text) {
686 s = angular.element("div#main").scope(); 686 s = angular.element("div#main").scope();
687 s.displayAlert(s.zone3alerts, text); 687 s.displayAlert(s.zone3alerts, text);
688 console.log(s.zone3alerts); 688 console.warn(s.zone3alerts);
689 s.$digest(); 689 s.$digest();
690} 690}
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html
index bc7a0ee436..e95b5e0cac 100644
--- a/bitbake/lib/toaster/toastergui/templates/base.html
+++ b/bitbake/lib/toaster/toastergui/templates/base.html
@@ -21,6 +21,11 @@
21</script> 21</script>
22<script src="{% static 'js/libtoaster.js' %}"> 22<script src="{% static 'js/libtoaster.js' %}">
23</script> 23</script>
24{% if DEBUG %}
25<script>
26 libtoaster.debug = true;
27 </script>
28{% endif %}
24<script src="{% static 'js/base.js' %}"></script> 29<script src="{% static 'js/base.js' %}"></script>
25{%if MANAGED %} 30{%if MANAGED %}
26<script> 31<script>
diff --git a/bitbake/lib/toaster/toastergui/templates/layers.html b/bitbake/lib/toaster/toastergui/templates/layers.html
index ced54c2098..33160e5968 100644
--- a/bitbake/lib/toaster/toastergui/templates/layers.html
+++ b/bitbake/lib/toaster/toastergui/templates/layers.html
@@ -126,15 +126,15 @@ function _makeXHREditCall(data, onsuccess, onfail) {
126 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 126 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
127 success: function (_data) { 127 success: function (_data) {
128 if (_data.error != "ok") { 128 if (_data.error != "ok") {
129 alert(_data.error); 129 console.warn(_data.error);
130 } else { 130 } else {
131 updateButtons(_data.layers.map(function (e) {return e.id})); 131 updateButtons(_data.layers.map(function (e) {return e.id}));
132 if (onsuccess != undefined) onsuccess(_data); 132 if (onsuccess != undefined) onsuccess(_data);
133 } 133 }
134 }, 134 },
135 error: function (_data) { 135 error: function (_data) {
136 alert("Call failed"); 136 console.warn("Call failed");
137 console.log(_data); 137 console.warn(_data);
138 } 138 }
139 }); 139 });
140} 140}
@@ -215,7 +215,7 @@ function layerAdd(layerId, layerName, layerURL) {
215 data: {'type': 'layerdeps','value':layerId}, 215 data: {'type': 'layerdeps','value':layerId},
216 success: function(_data) { 216 success: function(_data) {
217 if (_data.error != "ok") { 217 if (_data.error != "ok") {
218 alert(_data.error); 218 console.warn(_data.error);
219 } else { 219 } else {
220 updateLayerCountLabels(_data.list.length+1); 220 updateLayerCountLabels(_data.list.length+1);
221 221
diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
index 73031e2d1f..432955ab88 100644
--- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
+++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
@@ -79,21 +79,21 @@ function _makeXHRBuildCall(url, data, onsuccess, onfail) {
79 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 79 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
80 success: function (_data) { 80 success: function (_data) {
81 if (_data.error != "ok") { 81 if (_data.error != "ok") {
82 alert(_data.error); 82 console.warn(_data.error);
83 } else { 83 } else {
84 if (onsuccess != undefined) onsuccess(_data); 84 if (onsuccess != undefined) onsuccess(_data);
85 } 85 }
86 }, 86 },
87 error: function (_data) { 87 error: function (_data) {
88 alert("Call failed"); 88 console.warn("Call failed");
89 console.log(_data); 89 console.warn(_data);
90 if (onfail) onfail(data); 90 if (onfail) onfail(data);
91 } }); 91 } });
92} 92}
93 93
94 94
95function scheduleBuild(url, projectName, buildlist) { 95function scheduleBuild(url, projectName, buildlist) {
96 console.log("scheduleBuild"); 96 console.warn("scheduleBuild");
97 _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) { 97 _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) {
98 98
99 $('#latest-builds').prepend('<div class="alert alert-info" style="padding-top:0px">' + '<span class="label label-info" style="font-weight: normal; margin-bottom: 5px; margin-left:-15px; padding-top:5px;">'+projectName+'</span><div class="row-fluid">' + 99 $('#latest-builds').prepend('<div class="alert alert-info" style="padding-top:0px">' + '<span class="label label-info" style="font-weight: normal; margin-bottom: 5px; margin-left:-15px; padding-top:5px;">'+projectName+'</span><div class="row-fluid">' +
diff --git a/bitbake/lib/toaster/toastergui/templates/targets.html b/bitbake/lib/toaster/toastergui/templates/targets.html
index f4313f92b2..cc339fbbb7 100644
--- a/bitbake/lib/toaster/toastergui/templates/targets.html
+++ b/bitbake/lib/toaster/toastergui/templates/targets.html
@@ -119,15 +119,15 @@ function _makeXHREditCall(data, onsuccess, onfail) {
119 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 119 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
120 success: function (_data) { 120 success: function (_data) {
121 if (_data.error != "ok") { 121 if (_data.error != "ok") {
122 alert(_data.error); 122 console.warn(_data.error);
123 } else { 123 } else {
124 updateButtons(_data.layers.map(function (e) {return e.id})); 124 updateButtons(_data.layers.map(function (e) {return e.id}));
125 if (onsuccess != undefined) onsuccess(_data); 125 if (onsuccess != undefined) onsuccess(_data);
126 } 126 }
127 }, 127 },
128 error: function (_data) { 128 error: function (_data) {
129 alert("Call failed"); 129 console.warn("Call failed");
130 console.log(_data); 130 console.warn(_data);
131 } 131 }
132 }); 132 });
133} 133}
@@ -202,7 +202,7 @@ function layerAdd(layerId, layerName, layerURL, pressedButtonId) {
202 data: {'type': 'layerdeps','value':layerId}, 202 data: {'type': 'layerdeps','value':layerId},
203 success: function(_data) { 203 success: function(_data) {
204 if (_data.error != "ok") { 204 if (_data.error != "ok") {
205 alert(_data.error); 205 console.warn(_data.error);
206 } else { 206 } else {
207 updateLayerCountLabels(_data.list.length+1); 207 updateLayerCountLabels(_data.list.length+1);
208 208
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 679c1e9430..420b37cb73 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1898,7 +1898,8 @@ if toastermain.settings.MANAGED:
1898 def managedcontextprocessor(request): 1898 def managedcontextprocessor(request):
1899 ret = { 1899 ret = {
1900 "projects": Project.objects.all(), 1900 "projects": Project.objects.all(),
1901 "MANAGED" : toastermain.settings.MANAGED 1901 "MANAGED" : toastermain.settings.MANAGED,
1902 "DEBUG" : toastermain.settings.DEBUG
1902 } 1903 }
1903 if 'project_id' in request.session: 1904 if 'project_id' in request.session:
1904 try: 1905 try:
@@ -2923,7 +2924,8 @@ else:
2923 def managedcontextprocessor(request): 2924 def managedcontextprocessor(request):
2924 return { 2925 return {
2925 "projects": [], 2926 "projects": [],
2926 "MANAGED" : toastermain.settings.MANAGED 2927 "MANAGED" : toastermain.settings.MANAGED,
2928 "DEBUG" : toastermain.settings.DEBUG
2927 } 2929 }
2928 2930
2929 def newproject(request): 2931 def newproject(request):