summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-08 18:41:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-12 00:01:48 +0100
commit4a2a057130e877eae96d726bc86c6b9f48ed1ca3 (patch)
tree2cf8147a96e976333627cc52e7089b62e4748083 /bitbake/lib/toaster/toastergui/static
parentb1c91d06e0262e886154129fb1b6b4a12e3fc5fe (diff)
downloadpoky-4a2a057130e877eae96d726bc86c6b9f48ed1ca3.tar.gz
bitbake: toastergui: remove xhr_projectedit and xhr_projectinfo URLs
This patch removes the xhr_projectedit and xhr_projectinfo URLs in favour of REST calls to the Project page. The project page takes now the POST requests to modify project settings. All usages of removed URLs are now changed to point to the project page, using the json format. The interface call specs have not modified. (Bitbake rev: 6ad3078bd2be1a8cda99040acaa9bb81d77f0013) 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')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/base.js3
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js8
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectapp.js73
3 files changed, 66 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js
index 9424b6c328..9c8d01ef5a 100644
--- a/bitbake/lib/toaster/toastergui/static/js/base.js
+++ b/bitbake/lib/toaster/toastergui/static/js/base.js
@@ -29,7 +29,7 @@ function basePageInit (ctx) {
29 if (libtoaster.ctx.projectId == undefined) 29 if (libtoaster.ctx.projectId == undefined)
30 return; 30 return;
31 31
32 libtoaster.getProjectInfo(ctx.projectInfoUrl, libtoaster.ctx.projectId, 32 libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
33 function(data){ 33 function(data){
34 if (data.machine.name == undefined || data.layers.length == 0) { 34 if (data.machine.name == undefined || data.layers.length == 0) {
35 /* we can't build anything with out a machine and some layers */ 35 /* we can't build anything with out a machine and some layers */
@@ -102,7 +102,6 @@ function basePageInit (ctx) {
102 /* TBD: do we override even if we already have a context project ?? */ 102 /* TBD: do we override even if we already have a context project ?? */
103 /* TODO: replace global library context with references to the "selected" project */ 103 /* TODO: replace global library context with references to the "selected" project */
104 libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; 104 libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl;
105 libtoaster.ctx.xhrProjectEditUrl = selectedProject.xhrProjectEditUrl;
106 libtoaster.ctx.projectName = selectedProject.name; 105 libtoaster.ctx.projectName = selectedProject.name;
107 libtoaster.ctx.projectId = selectedProject.id; 106 libtoaster.ctx.projectId = selectedProject.id;
108 107
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 72fb0a93f5..87910299a5 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -120,11 +120,11 @@ var libtoaster = (function (){
120 } 120 }
121 121
122 /* Get a project's configuration info */ 122 /* Get a project's configuration info */
123 function _getProjectInfo(url, projectId, onsuccess, onfail){ 123 function _getProjectInfo(url, onsuccess, onfail){
124 $.ajax({ 124 $.ajax({
125 type: "POST", 125 type: "GET",
126 data : { format: "json" },
126 url: url, 127 url: url,
127 data: { project_id : projectId },
128 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 128 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
129 success: function (_data) { 129 success: function (_data) {
130 if (_data.error !== "ok") { 130 if (_data.error !== "ok") {
@@ -150,7 +150,7 @@ var libtoaster = (function (){
150 function _editCurrentProject(data, onSuccess, onFail){ 150 function _editCurrentProject(data, onSuccess, onFail){
151 $.ajax({ 151 $.ajax({
152 type: "POST", 152 type: "POST",
153 url: libtoaster.ctx.xhrProjectEditUrl, 153 url: libtoaster.ctx.projectPageUrl + "?format=json",
154 data: data, 154 data: data,
155 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 155 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
156 success: function (data) { 156 success: function (data) {
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
index a3309c76af..36c942fa29 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
@@ -156,6 +156,62 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
156 * Retrieves text suggestions for text-edit drop down autocomplete boxes 156 * Retrieves text suggestions for text-edit drop down autocomplete boxes
157 */ 157 */
158 158
159 $scope.getLayersAutocompleteSuggestions = function(currentValue) {
160 var deffered = $q.defer();
161
162 $http({method:"GET", url: $scope.urls.layers, params : { search: currentValue, format: "json" }})
163 .success(function (_data) {
164 if (_data.error != "ok") {
165 console.warn("error on data", _data.error);
166 deffered.reject(_data.error);
167 }
168 deffered.resolve(_data.rows);
169 });
170
171 return deffered.promise;
172 }
173
174 $scope.filterProjectLayerIds = function () {
175 return $scope.layers.map(function (e) { return e.id; });
176 }
177
178 $scope.getMachinesAutocompleteSuggestions = function(currentValue) {
179 var deffered = $q.defer();
180
181 $http({method:"GET", url: $scope.urls.machines, params : { search: currentValue, format: "json" }})
182 .success(function (_data) {
183 if (_data.error != "ok") {
184 console.warn("error on data", _data.error);
185 deffered.reject(_data.error);
186 }
187 deffered.resolve(_data.rows);
188 });
189
190 return deffered.promise;
191 }
192
193 $scope.getRecipesAutocompleteSuggestions = function(currentValue) {
194 var deffered = $q.defer();
195
196 $http({method:"GET", url: $scope.urls.targets, params : { search: currentValue, format: "json" }})
197 .success(function (_data) {
198 if (_data.error != "ok") {
199 console.warn("error on data", _data.error);
200 deffered.reject(_data.error);
201 }
202 deffered.resolve(_data.rows);
203 });
204 return deffered.promise;
205 }
206
207 $scope.values = function() {
208 var deffered = $q.defer();
209
210 deffered.resolve(["mama", "tata"]);
211
212 return deffered.promise;
213 };
214
159 $scope.getAutocompleteSuggestions = function(type, currentValue) { 215 $scope.getAutocompleteSuggestions = function(type, currentValue) {
160 var deffered = $q.defer(); 216 var deffered = $q.defer();
161 217
@@ -421,7 +477,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
421 477
422 478
423 $scope.onLayerSelect = function (item) { 479 $scope.onLayerSelect = function (item) {
424 $scope.layerAddId = item.id; 480 $scope.layerToAdd = item;
425 }; 481 };
426 482
427 $scope.machineSelect = function (machineName) { 483 $scope.machineSelect = function (machineName) {
@@ -443,14 +499,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
443 }; 499 };
444 500
445 501
446 $scope.layerAddById = function (id) {
447 $scope.layerAddId = id;
448 $scope.layerAdd();
449 };
450
451 $scope.layerAdd = function() { 502 $scope.layerAdd = function() {
452 503
453 $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }}) 504 $http({method:"GET", url: $scope.layerToAdd.layerdict.layerdetailurl, params : {}})
454 .success(function (_data) { 505 .success(function (_data) {
455 if (_data.error != "ok") { 506 if (_data.error != "ok") {
456 console.warn(_data.error); 507 console.warn(_data.error);
@@ -493,7 +544,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
493 }); 544 });
494 545
495 modalInstance.result.then(function (selectedArray) { 546 modalInstance.result.then(function (selectedArray) {
496 selectedArray.push($scope.layerAddId); 547 selectedArray.push($scope.layerToAdd.layerversion.id);
497 console.warn("TRC6: selected", selectedArray); 548 console.warn("TRC6: selected", selectedArray);
498 549
499 $scope._makeXHRCall({ 550 $scope._makeXHRCall({
@@ -512,7 +563,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
512 $scope._makeXHRCall({ 563 $scope._makeXHRCall({
513 method: "POST", url: $scope.urls.xhr_edit, 564 method: "POST", url: $scope.urls.xhr_edit,
514 data: { 565 data: {
515 layerAdd: $scope.layerAddId, 566 layerAdd: $scope.layerToAdd.layerversion.id,
516 } 567 }
517 }).then(function () { 568 }).then(function () {
518 $scope.layerAddName = undefined; 569 $scope.layerAddName = undefined;
@@ -768,10 +819,8 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
768 819
769 820
770 _cmdExecuteWithParam("/layeradd=", function (layer) { 821 _cmdExecuteWithParam("/layeradd=", function (layer) {
771 angular.forEach(layer.split(","), function (l) { 822 $scope.layerToAdd = layer;
772 $scope.layerAddId = l;
773 $scope.layerAdd(); 823 $scope.layerAdd();
774 });
775 }); 824 });
776 }; 825 };
777 826