From 4a2a057130e877eae96d726bc86c6b9f48ed1ca3 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 8 Jun 2015 18:41:46 +0100 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/static/js/base.js | 3 +- .../lib/toaster/toastergui/static/js/libtoaster.js | 8 +-- .../lib/toaster/toastergui/static/js/projectapp.js | 73 ++++++++++++++++++---- 3 files changed, 66 insertions(+), 18 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/static') 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) { if (libtoaster.ctx.projectId == undefined) return; - libtoaster.getProjectInfo(ctx.projectInfoUrl, libtoaster.ctx.projectId, + libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(data){ if (data.machine.name == undefined || data.layers.length == 0) { /* we can't build anything with out a machine and some layers */ @@ -102,7 +102,6 @@ function basePageInit (ctx) { /* TBD: do we override even if we already have a context project ?? */ /* TODO: replace global library context with references to the "selected" project */ libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; - libtoaster.ctx.xhrProjectEditUrl = selectedProject.xhrProjectEditUrl; libtoaster.ctx.projectName = selectedProject.name; libtoaster.ctx.projectId = selectedProject.id; 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 (){ } /* Get a project's configuration info */ - function _getProjectInfo(url, projectId, onsuccess, onfail){ + function _getProjectInfo(url, onsuccess, onfail){ $.ajax({ - type: "POST", + type: "GET", + data : { format: "json" }, url: url, - data: { project_id : projectId }, headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, success: function (_data) { if (_data.error !== "ok") { @@ -150,7 +150,7 @@ var libtoaster = (function (){ function _editCurrentProject(data, onSuccess, onFail){ $.ajax({ type: "POST", - url: libtoaster.ctx.xhrProjectEditUrl, + url: libtoaster.ctx.projectPageUrl + "?format=json", data: data, headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 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 * Retrieves text suggestions for text-edit drop down autocomplete boxes */ + $scope.getLayersAutocompleteSuggestions = function(currentValue) { + var deffered = $q.defer(); + + $http({method:"GET", url: $scope.urls.layers, params : { search: currentValue, format: "json" }}) + .success(function (_data) { + if (_data.error != "ok") { + console.warn("error on data", _data.error); + deffered.reject(_data.error); + } + deffered.resolve(_data.rows); + }); + + return deffered.promise; + } + + $scope.filterProjectLayerIds = function () { + return $scope.layers.map(function (e) { return e.id; }); + } + + $scope.getMachinesAutocompleteSuggestions = function(currentValue) { + var deffered = $q.defer(); + + $http({method:"GET", url: $scope.urls.machines, params : { search: currentValue, format: "json" }}) + .success(function (_data) { + if (_data.error != "ok") { + console.warn("error on data", _data.error); + deffered.reject(_data.error); + } + deffered.resolve(_data.rows); + }); + + return deffered.promise; + } + + $scope.getRecipesAutocompleteSuggestions = function(currentValue) { + var deffered = $q.defer(); + + $http({method:"GET", url: $scope.urls.targets, params : { search: currentValue, format: "json" }}) + .success(function (_data) { + if (_data.error != "ok") { + console.warn("error on data", _data.error); + deffered.reject(_data.error); + } + deffered.resolve(_data.rows); + }); + return deffered.promise; + } + + $scope.values = function() { + var deffered = $q.defer(); + + deffered.resolve(["mama", "tata"]); + + return deffered.promise; + }; + $scope.getAutocompleteSuggestions = function(type, currentValue) { var deffered = $q.defer(); @@ -421,7 +477,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc $scope.onLayerSelect = function (item) { - $scope.layerAddId = item.id; + $scope.layerToAdd = item; }; $scope.machineSelect = function (machineName) { @@ -443,14 +499,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc }; - $scope.layerAddById = function (id) { - $scope.layerAddId = id; - $scope.layerAdd(); - }; - $scope.layerAdd = function() { - $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }}) + $http({method:"GET", url: $scope.layerToAdd.layerdict.layerdetailurl, params : {}}) .success(function (_data) { if (_data.error != "ok") { console.warn(_data.error); @@ -493,7 +544,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc }); modalInstance.result.then(function (selectedArray) { - selectedArray.push($scope.layerAddId); + selectedArray.push($scope.layerToAdd.layerversion.id); console.warn("TRC6: selected", selectedArray); $scope._makeXHRCall({ @@ -512,7 +563,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc $scope._makeXHRCall({ method: "POST", url: $scope.urls.xhr_edit, data: { - layerAdd: $scope.layerAddId, + layerAdd: $scope.layerToAdd.layerversion.id, } }).then(function () { $scope.layerAddName = undefined; @@ -768,10 +819,8 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc _cmdExecuteWithParam("/layeradd=", function (layer) { - angular.forEach(layer.split(","), function (l) { - $scope.layerAddId = l; + $scope.layerToAdd = layer; $scope.layerAdd(); - }); }); }; -- cgit v1.2.3-54-g00ecf