mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 13:49:49 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
2e26745a13
commit
ed9fa17467
@@ -81,14 +81,14 @@ var libtoaster = (function (){
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (_data) {
|
||||
if (_data.error != "ok") {
|
||||
console.log(_data.error);
|
||||
console.warn(_data.error);
|
||||
} else {
|
||||
if (onsuccess != undefined) onsuccess(_data);
|
||||
}
|
||||
},
|
||||
error: function (_data) {
|
||||
console.log("Call failed");
|
||||
console.log(_data);
|
||||
console.warn("Call failed");
|
||||
console.warn(_data);
|
||||
if (onfail) onfail(data);
|
||||
} });
|
||||
};
|
||||
@@ -102,13 +102,13 @@ var libtoaster = (function (){
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (_data) {
|
||||
if (_data.error != "ok") {
|
||||
console.log(_data.error);
|
||||
console.warn(_data.error);
|
||||
} else {
|
||||
if (onsuccess != undefined) onsuccess(_data);
|
||||
}
|
||||
},
|
||||
error: function (_data) {
|
||||
console.log(_data);
|
||||
console.warn(_data);
|
||||
if (onfail) onfail(data);
|
||||
}
|
||||
});
|
||||
@@ -168,6 +168,7 @@ var libtoaster = (function (){
|
||||
getProjectInfo: _getProjectInfo,
|
||||
getLayerDepsForProject : _getLayerDepsForProject,
|
||||
editProject : _editProject,
|
||||
debug: false,
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -203,6 +204,15 @@ function reload_params(params) {
|
||||
/* Things that happen for all pages */
|
||||
$(document).ready(function() {
|
||||
|
||||
/* If we don't have a console object which might be the case in some
|
||||
* browsers, no-op it to avoid undefined errors.
|
||||
*/
|
||||
if (!window.console) {
|
||||
window.console = {};
|
||||
window.console.warn = function() {};
|
||||
window.console.error = function() {};
|
||||
}
|
||||
|
||||
/*
|
||||
* PrettyPrint plugin.
|
||||
*
|
||||
@@ -320,4 +330,23 @@ $(document).ready(function() {
|
||||
if (location.href.search('#warnings') > -1) {
|
||||
$('#collapse-warnings').addClass('in');
|
||||
}
|
||||
|
||||
function check_for_duplicate_ids () {
|
||||
/* warn about duplicate element ids */
|
||||
var ids = {};
|
||||
$("[id]").each(function() {
|
||||
if (this.id && ids[this.id]) {
|
||||
console.warn('Duplicate element id #'+this.id);
|
||||
}
|
||||
ids[this.id] = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (libtoaster.debug) {
|
||||
check_for_duplicate_ids();
|
||||
} else {
|
||||
/* Debug is false so supress warnings by overriding the functions */
|
||||
window.console.warn = function () {};
|
||||
window.console.error = function () {};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,7 +136,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
$http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, value: currentValue}})
|
||||
.success(function (_data) {
|
||||
if (_data.error != "ok") {
|
||||
alert(_data.error);
|
||||
console.warn(_data.error);
|
||||
deffered.reject(_data.error);
|
||||
}
|
||||
deffered.resolve(_data.list);
|
||||
@@ -152,12 +152,12 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
if (inXHRcall) {
|
||||
if (callparams.data === undefined) {
|
||||
// we simply skip the data refresh calls
|
||||
console.log("race on XHR, aborted");
|
||||
console.warn("race on XHR, aborted");
|
||||
return;
|
||||
} else {
|
||||
// we return a promise that we'll solve by reissuing the command later
|
||||
var delayed = $q.defer();
|
||||
console.log("race on XHR, delayed");
|
||||
console.warn("race on XHR, delayed");
|
||||
$interval(function () {$scope._makeXHRCall(callparams).then(function (d) { delayed.resolve(d); });}, 100, 1);
|
||||
|
||||
return delayed.promise;
|
||||
@@ -171,7 +171,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
|
||||
$http(callparams).success(function(_data, _status, _headers, _config) {
|
||||
if (_data.error != "ok") {
|
||||
alert("Failed XHR request (" + _status + "): " + _data.error);
|
||||
console.warn("Failed XHR request (" + _status + "): " + _data.error);
|
||||
console.error("Failed XHR request: ", _data, _status, _headers, _config);
|
||||
// stop refreshing hte page
|
||||
$interval.cancel($scope.pollHandle);
|
||||
@@ -267,7 +267,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
deffered.resolve(_data);
|
||||
}
|
||||
}).error(function(_data, _status, _headers, _config) {
|
||||
alert("Failed HTTP XHR request (" + _status + ")" + _data);
|
||||
console.warn("Failed HTTP XHR request (" + _status + ")" + _data);
|
||||
console.error("Failed HTTP XHR request: ", _data, _status, _headers, _config);
|
||||
inXHRcall = false;
|
||||
deffered.reject(_data.error);
|
||||
@@ -298,7 +298,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
|
||||
$scope.targetNamedBuild = function(target) {
|
||||
if ($scope.targetName === undefined && $scope.targetName1 === undefined){
|
||||
alert("No target defined, please type in a target name");
|
||||
console.warn("No target defined, please type in a target name");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
targets: $scope.safeTargetName,
|
||||
}
|
||||
}).then(function (data) {
|
||||
console.log("received ", data);
|
||||
console.warn("received ", data);
|
||||
$scope.targetName = undefined;
|
||||
$scope.targetName1 = undefined;
|
||||
$location.hash('buildslist');
|
||||
@@ -357,7 +357,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
$http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }})
|
||||
.success(function (_data) {
|
||||
if (_data.error != "ok") {
|
||||
alert(_data.error);
|
||||
console.warn(_data.error);
|
||||
} else {
|
||||
if (_data.list.length > 0) {
|
||||
// activate modal
|
||||
@@ -369,7 +369,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
$scope.selectedItems = (function () { s = {}; for (var i = 0; i < items.length; i++) { s[items[i].id] = true; };return s; })();
|
||||
|
||||
$scope.ok = function() {
|
||||
console.log("scope selected is ", $scope.selectedItems);
|
||||
console.warn("scope selected is ", $scope.selectedItems);
|
||||
$modalInstance.close(Object.keys($scope.selectedItems).filter(function (e) { return $scope.selectedItems[e];}));
|
||||
};
|
||||
|
||||
@@ -378,7 +378,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
};
|
||||
|
||||
$scope.update = function() {
|
||||
console.log("updated ", $scope.selectedItems);
|
||||
console.warn("updated ", $scope.selectedItems);
|
||||
};
|
||||
},
|
||||
resolve: {
|
||||
@@ -393,7 +393,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
|
||||
modalInstance.result.then(function (selectedArray) {
|
||||
selectedArray.push($scope.layerAddId);
|
||||
console.log("selected", selectedArray);
|
||||
console.warn("selected", selectedArray);
|
||||
|
||||
$scope._makeXHRCall({
|
||||
method: "POST", url: $scope.urls.xhr_edit,
|
||||
@@ -473,7 +473,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
|
||||
$scope.edit = function(elementid) {
|
||||
var data = {};
|
||||
console.log("edit with ", elementid);
|
||||
console.warn("edit with ", elementid);
|
||||
var alertText = undefined;
|
||||
var alertZone = undefined;
|
||||
var oldLayers = [];
|
||||
@@ -675,7 +675,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
|
||||
*/
|
||||
|
||||
function test_diff_arrays() {
|
||||
_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);})
|
||||
_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);})
|
||||
}
|
||||
|
||||
// test_diff_arrays();
|
||||
@@ -685,6 +685,6 @@ var s = undefined;
|
||||
function test_set_alert(text) {
|
||||
s = angular.element("div#main").scope();
|
||||
s.displayAlert(s.zone3alerts, text);
|
||||
console.log(s.zone3alerts);
|
||||
console.warn(s.zone3alerts);
|
||||
s.$digest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user