diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-08 15:22:01 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-12 00:01:49 +0100 |
commit | 27f5137cd6143b523e9aea8eeba406337aa935c4 (patch) | |
tree | ca47f73fda5ca2b2fba99872fbfa4f7a64f57b9a /bitbake/lib/toaster/toastergui/static | |
parent | a8be6d4bb18232f13ffcaaf1a4137322db59fe48 (diff) | |
download | poky-27f5137cd6143b523e9aea8eeba406337aa935c4.tar.gz |
bitbake: toastergui: remove xhr_datatypeahaed layerdeps call
This patch removes the url-constructing calls to get the layer details
in favor of embedding the look-up URL in the JSON data on the
layer list page.
This allows further removal of the XHR-specific code for layer dependencies
in favor of REST calls to layer details data.
(Bitbake rev: 33d2b87aca667d72262a3928deaf35414b46a7c1)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static')
4 files changed, 55 insertions, 25 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index e1fc5c5187..e9d7ae8ef2 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js | |||
@@ -48,7 +48,7 @@ function importLayerPageInit (ctx) { | |||
48 | newLayerDep.children("span").tooltip(); | 48 | newLayerDep.children("span").tooltip(); |
49 | 49 | ||
50 | var link = newLayerDep.children("a"); | 50 | var link = newLayerDep.children("a"); |
51 | link.attr("href", ctx.layerDetailsUrl+String(currentLayerDepSelection.id)); | 51 | link.attr("href", currentLayerDepSelection.layerDetailsUrl); |
52 | link.text(currentLayerDepSelection.name); | 52 | link.text(currentLayerDepSelection.name); |
53 | link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"}); | 53 | link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"}); |
54 | 54 | ||
@@ -63,11 +63,11 @@ function importLayerPageInit (ctx) { | |||
63 | 63 | ||
64 | $("#layer-deps-list").append(newLayerDep); | 64 | $("#layer-deps-list").append(newLayerDep); |
65 | 65 | ||
66 | libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, currentLayerDepSelection.id, function (data){ | 66 | libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerDetailsUrl, function (data){ |
67 | /* These are the dependencies of the layer added as a dependency */ | 67 | /* These are the dependencies of the layer added as a dependency */ |
68 | if (data.list.length > 0) { | 68 | if (data.list.length > 0) { |
69 | currentLayerDepSelection.url = ctx.layerDetailsUrl+currentLayerDepSelection.id; | 69 | currentLayerDepSelection.url = currentLayerDepSelection.layerDetailsUrl; |
70 | layerDeps[currentLayerDepSelection.id].deps = data.list | 70 | layerDeps[currentLayerDepSelection.id].deps = data.list; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* Clear the current selection */ | 73 | /* Clear the current selection */ |
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index ab781829cd..0accd971d4 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js | |||
@@ -65,7 +65,7 @@ function layerDetailsPageInit (ctx) { | |||
65 | newLayerDep.children("span").tooltip(); | 65 | newLayerDep.children("span").tooltip(); |
66 | 66 | ||
67 | var link = newLayerDep.children("a"); | 67 | var link = newLayerDep.children("a"); |
68 | link.attr("href", ctx.layerDetailsUrl+String(currentLayerDepSelection.id)); | 68 | link.attr("href", currentLayerDepSelection.layerDetailsUrl); |
69 | link.text(currentLayerDepSelection.name); | 69 | link.text(currentLayerDepSelection.name); |
70 | link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"}); | 70 | link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"}); |
71 | 71 | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 2a9a790693..b1038cf618 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
@@ -170,10 +170,10 @@ var libtoaster = (function (){ | |||
170 | }); | 170 | }); |
171 | } | 171 | } |
172 | 172 | ||
173 | function _getLayerDepsForProject(projectId, layerId, onSuccess, onFail){ | 173 | function _getLayerDepsForProject(url, onSuccess, onFail){ |
174 | /* Check for dependencies not in the current project */ | 174 | /* Check for dependencies not in the current project */ |
175 | $.getJSON(libtoaster.ctx.projectLayersUrl, | 175 | $.getJSON(url, |
176 | { format: 'json', search: layerId }, | 176 | { format: 'json' }, |
177 | function(data) { | 177 | function(data) { |
178 | if (data.error != "ok") { | 178 | if (data.error != "ok") { |
179 | console.log(data.error); | 179 | console.log(data.error); |
@@ -225,8 +225,7 @@ var libtoaster = (function (){ | |||
225 | function _addRmLayer(layerObj, add, doneCb){ | 225 | function _addRmLayer(layerObj, add, doneCb){ |
226 | if (add === true) { | 226 | if (add === true) { |
227 | /* If adding get the deps for this layer */ | 227 | /* If adding get the deps for this layer */ |
228 | libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, | 228 | libtoaster.getLayerDepsForProject(layerObj.url, |
229 | layerObj.id, | ||
230 | function (layers) { | 229 | function (layers) { |
231 | 230 | ||
232 | /* got result for dependencies */ | 231 | /* got result for dependencies */ |
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index 36c942fa29..a915278444 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js | |||
@@ -16,7 +16,9 @@ | |||
16 | // with this program; if not, write to the Free Software Foundation, Inc., | 16 | // with this program; if not, write to the Free Software Foundation, Inc., |
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | 18 | ||
19 | angular_formpost = function($httpProvider) { | 19 | 'use strict'; |
20 | |||
21 | var angular_formpost = function($httpProvider) { | ||
20 | // Use x-www-form-urlencoded Content-Type | 22 | // Use x-www-form-urlencoded Content-Type |
21 | // By Ezekiel Victor, http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/, no license, with attribution | 23 | // By Ezekiel Victor, http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/, no license, with attribution |
22 | $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; | 24 | $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; |
@@ -127,10 +129,10 @@ projectApp.filter('timediff', function() { | |||
127 | if (parseInt(j) < 10) {return "0" + j;} | 129 | if (parseInt(j) < 10) {return "0" + j;} |
128 | return j; | 130 | return j; |
129 | } | 131 | } |
130 | seconds = parseInt(input); | 132 | var seconds = parseInt(input); |
131 | minutes = Math.floor(seconds / 60); | 133 | var minutes = Math.floor(seconds / 60); |
132 | seconds = seconds - minutes * 60; | 134 | seconds = seconds - minutes * 60; |
133 | hours = Math.floor(seconds / 3600); | 135 | var hours = Math.floor(seconds / 3600); |
134 | seconds = seconds - hours * 3600; | 136 | seconds = seconds - hours * 3600; |
135 | return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds); | 137 | return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds); |
136 | }; | 138 | }; |
@@ -250,6 +252,31 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
250 | } | 252 | } |
251 | var deffered = $q.defer(); | 253 | var deffered = $q.defer(); |
252 | 254 | ||
255 | /* we only talk in JSON to the server */ | ||
256 | if (callparams.method == 'GET') { | ||
257 | if (callparams.data === undefined) { | ||
258 | callparams.data = {}; | ||
259 | } | ||
260 | callparams.data.format = "json"; | ||
261 | } else { | ||
262 | if (callparams.url.indexOf("?") > -1) { | ||
263 | callparams.url = callparams.url.split("?").map(function (element, index) { | ||
264 | if (index == 1) { | ||
265 | var elements = []; | ||
266 | if (element.indexOf("&")>-1) { | ||
267 | elements = element.split("&"); | ||
268 | } | ||
269 | elements.push("format=json"); | ||
270 | element = elements.join("&"); | ||
271 | } | ||
272 | return element; | ||
273 | }).join("?"); | ||
274 | } else { | ||
275 | callparams.url += "?format=json"; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | |||
253 | if (undefined === callparams.headers) { callparams.headers = {}; } | 280 | if (undefined === callparams.headers) { callparams.headers = {}; } |
254 | callparams.headers['X-CSRFToken'] = $cookies.csrftoken; | 281 | callparams.headers['X-CSRFToken'] = $cookies.csrftoken; |
255 | 282 | ||
@@ -476,8 +503,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
476 | }; | 503 | }; |
477 | 504 | ||
478 | 505 | ||
479 | $scope.onLayerSelect = function (item) { | 506 | $scope.onLayerSelect = function (item, model, label) { |
480 | $scope.layerToAdd = item; | 507 | $scope.layerToAdd = item; |
508 | $scope.layerAddName = item.layer__name; | ||
481 | }; | 509 | }; |
482 | 510 | ||
483 | $scope.machineSelect = function (machineName) { | 511 | $scope.machineSelect = function (machineName) { |
@@ -501,20 +529,22 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
501 | 529 | ||
502 | $scope.layerAdd = function() { | 530 | $scope.layerAdd = function() { |
503 | 531 | ||
504 | $http({method:"GET", url: $scope.layerToAdd.layerdict.layerdetailurl, params : {}}) | 532 | $http({method:"GET", url: $scope.layerToAdd.layerDetailsUrl, params : {format: "json"}}) |
505 | .success(function (_data) { | 533 | .success(function (_data) { |
506 | if (_data.error != "ok") { | 534 | if (_data.error != "ok") { |
507 | console.warn(_data.error); | 535 | console.warn(_data.error); |
508 | } else { | 536 | } else { |
509 | if (_data.list.length > 0) { | 537 | console.log("got layer deps", _data.layerdeps.list); |
538 | if (_data.layerdeps.list.length > 0) { | ||
510 | // activate modal | 539 | // activate modal |
540 | console.log("listing modals"); | ||
511 | var modalInstance = $modal.open({ | 541 | var modalInstance = $modal.open({ |
512 | templateUrl: 'dependencies_modal', | 542 | templateUrl: 'dependencies_modal', |
513 | controller: function ($scope, $modalInstance, items, layerAddName) { | 543 | controller: function ($scope, $modalInstance, items, layerAddName) { |
514 | $scope.items = items; | 544 | $scope.items = items; |
515 | $scope.layerAddName = layerAddName; | 545 | $scope.layerAddName = layerAddName; |
516 | $scope.selectedItems = (function () { | 546 | $scope.selectedItems = (function () { |
517 | s = {}; | 547 | var s = {}; |
518 | for (var i = 0; i < items.length; i++) | 548 | for (var i = 0; i < items.length; i++) |
519 | { s[items[i].id] = true; } | 549 | { s[items[i].id] = true; } |
520 | return s; | 550 | return s; |
@@ -535,16 +565,18 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
535 | }, | 565 | }, |
536 | resolve: { | 566 | resolve: { |
537 | items: function () { | 567 | items: function () { |
538 | return _data.list; | 568 | return _data.layerdeps.list; |
539 | }, | 569 | }, |
540 | layerAddName: function () { | 570 | layerAddName: function () { |
541 | return $scope.layerAddName; | 571 | return $scope.layerAddName; |
542 | }, | 572 | }, |
543 | } | 573 | } |
544 | }); | 574 | }); |
575 | console.log("built modal instance", modalInstance); | ||
545 | 576 | ||
546 | modalInstance.result.then(function (selectedArray) { | 577 | modalInstance.result.then(function (selectedArray) { |
547 | selectedArray.push($scope.layerToAdd.layerversion.id); | 578 | console.log("layer to add", $scope.layerToAdd) |
579 | selectedArray.push($scope.layerToAdd.id); | ||
548 | console.warn("TRC6: selected", selectedArray); | 580 | console.warn("TRC6: selected", selectedArray); |
549 | 581 | ||
550 | $scope._makeXHRCall({ | 582 | $scope._makeXHRCall({ |
@@ -563,7 +595,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
563 | $scope._makeXHRCall({ | 595 | $scope._makeXHRCall({ |
564 | method: "POST", url: $scope.urls.xhr_edit, | 596 | method: "POST", url: $scope.urls.xhr_edit, |
565 | data: { | 597 | data: { |
566 | layerAdd: $scope.layerToAdd.layerversion.id, | 598 | layerAdd: $scope.layerToAdd.id, |
567 | } | 599 | } |
568 | }).then(function () { | 600 | }).then(function () { |
569 | $scope.layerAddName = undefined; | 601 | $scope.layerAddName = undefined; |
@@ -772,8 +804,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
772 | return; | 804 | return; |
773 | 805 | ||
774 | if (imported.deps_added.length === 0) { | 806 | if (imported.deps_added.length === 0) { |
775 | text = "You have imported <strong><a href=\""+$scope.urls.layer+ | 807 | text = "You have imported <strong><a href=\""+imported.imported_layer.layerDetailsUrl+"\">"+imported.imported_layer.name+ |
776 | imported.imported_layer.id+"\">"+imported.imported_layer.name+ | ||
777 | "</a></strong> and added it to your project."; | 808 | "</a></strong> and added it to your project."; |
778 | } else { | 809 | } else { |
779 | var links = "<a href=\""+$scope.urls.layer+ | 810 | var links = "<a href=\""+$scope.urls.layer+ |
@@ -781,7 +812,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
781 | "</a>, "; | 812 | "</a>, "; |
782 | 813 | ||
783 | imported.deps_added.map (function(item, index){ | 814 | imported.deps_added.map (function(item, index){ |
784 | links +="<a href=\""+$scope.urls.layer+item.id+"\" >"+item.name+ | 815 | links +="<a href=\""+item.layerDetailsUrl+"\" >"+item.name+ |
785 | "</a>"; | 816 | "</a>"; |
786 | /*If we're at the last element we don't want the trailing comma */ | 817 | /*If we're at the last element we don't want the trailing comma */ |
787 | if (imported.deps_added[index+1] !== undefined) | 818 | if (imported.deps_added[index+1] !== undefined) |
@@ -832,7 +863,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
832 | if (zone.maxid === undefined) { zone.maxid = 0; } | 863 | if (zone.maxid === undefined) { zone.maxid = 0; } |
833 | var crtid = zone.maxid ++; | 864 | var crtid = zone.maxid ++; |
834 | angular.forEach(zone, function (o) { o.close(); }); | 865 | angular.forEach(zone, function (o) { o.close(); }); |
835 | o = { | 866 | var o = { |
836 | id: crtid, text: text, type: type, | 867 | id: crtid, text: text, type: type, |
837 | close: function() { | 868 | close: function() { |
838 | zone.splice((function(id) { | 869 | zone.splice((function(id) { |