2016-08-17 01:50:55 +00:00
|
|
|
// The Docker API often returns a list of JSON object.
|
2016-08-10 03:14:10 +00:00
|
|
|
// This handler wrap the JSON objects in an array.
|
2016-08-17 01:50:55 +00:00
|
|
|
// Used by the API in: Image push, Image create, Events query.
|
|
|
|
function jsonObjectsToArrayHandler(data) {
|
2016-08-17 00:27:54 +00:00
|
|
|
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
|
|
|
return angular.fromJson(str);
|
|
|
|
}
|
|
|
|
|
2016-08-10 03:14:10 +00:00
|
|
|
// Image delete API returns an array on success and an object on error.
|
|
|
|
// This handler creates an array from an object in case of error.
|
|
|
|
function deleteImageHandler(data) {
|
|
|
|
var response = angular.fromJson(data);
|
|
|
|
if (!Array.isArray(response)) {
|
|
|
|
var arr = [];
|
|
|
|
arr.push(response);
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|