From 58cd4a14ea81b72dcd9679608e5e2231ec3d3631 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 8 Jun 2015 18:33:44 +0100 Subject: bitbake: toaster: fixes after refactoring This patch fixes issues brought in by refactoring: * the New Build button is working with pre-set projects * the xhr_datatypeahead is exposed for calls that are not mapable to the REST objects * a new table returing recipes provided by layers currently selected in the project is used to provide recipe suggestions * the field names in json are switched from "list" to "rows" as to maintain consistency with the ToasterTables * the "value" field in xhr_ calls is now named "search" to maintain consistency (Bitbake rev: a5bc29083d4f85a5695f3f62d5badb783c6f7224) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- .../lib/toaster/toastergui/static/js/projectapp.js | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/static/js/projectapp.js') diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index a915278444..44e244d302 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js @@ -217,13 +217,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc $scope.getAutocompleteSuggestions = function(type, currentValue) { var deffered = $q.defer(); - $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, value: currentValue}}) + $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, search: currentValue}}) .success(function (_data) { if (_data.error != "ok") { console.warn(_data.error); deffered.reject(_data.error); } - deffered.resolve(_data.list); + deffered.resolve(_data.rows); }); return deffered.promise; @@ -534,8 +534,17 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc if (_data.error != "ok") { console.warn(_data.error); } else { - console.log("got layer deps", _data.layerdeps.list); - if (_data.layerdeps.list.length > 0) { + /* filter out layers that are already in the project */ + var filtered_list = []; + var projectlayers_ids = $scope.layers.map(function (e) { return e.id }); + for (var i = 0; i < _data.layerdeps.list.length; i++) { + if (projectlayers_ids.indexOf(_data.layerdeps.list[i].id) == -1) { + filtered_list.push( _data.layerdeps.list[i]); + } + } + + _data.layerdeps.list = filtered_list; + if (_data.layerdeps.list.length > 0) { // activate modal console.log("listing modals"); var modalInstance = $modal.open({ @@ -575,7 +584,6 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc console.log("built modal instance", modalInstance); modalInstance.result.then(function (selectedArray) { - console.log("layer to add", $scope.layerToAdd) selectedArray.push($scope.layerToAdd.id); console.warn("TRC6: selected", selectedArray); @@ -634,13 +642,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc $scope.testProjectSettingsChange = function(elementid) { if (elementid != '#change-project-version') throw "Not implemented"; - $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "versionlayers", value: $scope.projectVersion }}). + $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "versionlayers", search: $scope.projectVersion }}). success(function (_data) { if (_data.error != "ok") { alert (_data.error); } else { - if (_data.list.length > 0) { + if (_data.rows.length > 0) { // activate modal var modalInstance = $modal.open({ templateUrl: 'change_version_modal', @@ -660,7 +668,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc }, resolve: { items: function () { - return _data.list; + return _data.rows; }, releaseName: function () { return $scope.releases.filter(function (e) { if (e.id == $scope.projectVersion) return e;})[0].name; -- cgit v1.2.3-54-g00ecf