summaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/static/js
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-08 15:22:01 +0100
committerAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-10 15:31:12 +0100
commit33d2b87aca667d72262a3928deaf35414b46a7c1 (patch)
tree00e21c61d952f7cc09b736fc10ebaea52bc31a23 /lib/toaster/toastergui/static/js
parent8e7a2c3b125a34fd9d6fa0442ab13290137ecc51 (diff)
downloadbitbake-contrib-33d2b87aca667d72262a3928deaf35414b46a7c1.tar.gz
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. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib/toaster/toastergui/static/js')
-rw-r--r--lib/toaster/toastergui/static/js/importlayer.js8
-rw-r--r--lib/toaster/toastergui/static/js/layerdetails.js2
-rw-r--r--lib/toaster/toastergui/static/js/libtoaster.js9
-rw-r--r--lib/toaster/toastergui/static/js/projectapp.js61
4 files changed, 55 insertions, 25 deletions
diff --git a/lib/toaster/toastergui/static/js/importlayer.js b/lib/toaster/toastergui/static/js/importlayer.js
index e1fc5c518..e9d7ae8ef 100644
--- a/lib/toaster/toastergui/static/js/importlayer.js
+++ b/lib/toaster/toastergui/static/js/importlayer.js
@@ -48,7 +48,7 @@ function importLayerPageInit (ctx) {
newLayerDep.children("span").tooltip();
var link = newLayerDep.children("a");
- link.attr("href", ctx.layerDetailsUrl+String(currentLayerDepSelection.id));
+ link.attr("href", currentLayerDepSelection.layerDetailsUrl);
link.text(currentLayerDepSelection.name);
link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"});
@@ -63,11 +63,11 @@ function importLayerPageInit (ctx) {
$("#layer-deps-list").append(newLayerDep);
- libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, currentLayerDepSelection.id, function (data){
+ libtoaster.getLayerDepsForProject(currentLayerDepSelection.layerDetailsUrl, function (data){
/* These are the dependencies of the layer added as a dependency */
if (data.list.length > 0) {
- currentLayerDepSelection.url = ctx.layerDetailsUrl+currentLayerDepSelection.id;
- layerDeps[currentLayerDepSelection.id].deps = data.list
+ currentLayerDepSelection.url = currentLayerDepSelection.layerDetailsUrl;
+ layerDeps[currentLayerDepSelection.id].deps = data.list;
}
/* Clear the current selection */
diff --git a/lib/toaster/toastergui/static/js/layerdetails.js b/lib/toaster/toastergui/static/js/layerdetails.js
index ab781829c..0accd971d 100644
--- a/lib/toaster/toastergui/static/js/layerdetails.js
+++ b/lib/toaster/toastergui/static/js/layerdetails.js
@@ -65,7 +65,7 @@ function layerDetailsPageInit (ctx) {
newLayerDep.children("span").tooltip();
var link = newLayerDep.children("a");
- link.attr("href", ctx.layerDetailsUrl+String(currentLayerDepSelection.id));
+ link.attr("href", currentLayerDepSelection.layerDetailsUrl);
link.text(currentLayerDepSelection.name);
link.tooltip({title: currentLayerDepSelection.tooltip, placement: "right"});
diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index 2a9a79069..b1038cf61 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/lib/toaster/toastergui/static/js/libtoaster.js
@@ -170,10 +170,10 @@ var libtoaster = (function (){
});
}
- function _getLayerDepsForProject(projectId, layerId, onSuccess, onFail){
+ function _getLayerDepsForProject(url, onSuccess, onFail){
/* Check for dependencies not in the current project */
- $.getJSON(libtoaster.ctx.projectLayersUrl,
- { format: 'json', search: layerId },
+ $.getJSON(url,
+ { format: 'json' },
function(data) {
if (data.error != "ok") {
console.log(data.error);
@@ -225,8 +225,7 @@ var libtoaster = (function (){
function _addRmLayer(layerObj, add, doneCb){
if (add === true) {
/* If adding get the deps for this layer */
- libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId,
- layerObj.id,
+ libtoaster.getLayerDepsForProject(layerObj.url,
function (layers) {
/* got result for dependencies */
diff --git a/lib/toaster/toastergui/static/js/projectapp.js b/lib/toaster/toastergui/static/js/projectapp.js
index 36c942fa2..a91527844 100644
--- a/lib/toaster/toastergui/static/js/projectapp.js
+++ b/lib/toaster/toastergui/static/js/projectapp.js
@@ -16,7 +16,9 @@
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-angular_formpost = function($httpProvider) {
+'use strict';
+
+var angular_formpost = function($httpProvider) {
// Use x-www-form-urlencoded Content-Type
// By Ezekiel Victor, http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/, no license, with attribution
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
@@ -127,10 +129,10 @@ projectApp.filter('timediff', function() {
if (parseInt(j) < 10) {return "0" + j;}
return j;
}
- seconds = parseInt(input);
- minutes = Math.floor(seconds / 60);
+ var seconds = parseInt(input);
+ var minutes = Math.floor(seconds / 60);
seconds = seconds - minutes * 60;
- hours = Math.floor(seconds / 3600);
+ var hours = Math.floor(seconds / 3600);
seconds = seconds - hours * 3600;
return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds);
};
@@ -250,6 +252,31 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
}
var deffered = $q.defer();
+ /* we only talk in JSON to the server */
+ if (callparams.method == 'GET') {
+ if (callparams.data === undefined) {
+ callparams.data = {};
+ }
+ callparams.data.format = "json";
+ } else {
+ if (callparams.url.indexOf("?") > -1) {
+ callparams.url = callparams.url.split("?").map(function (element, index) {
+ if (index == 1) {
+ var elements = [];
+ if (element.indexOf("&")>-1) {
+ elements = element.split("&");
+ }
+ elements.push("format=json");
+ element = elements.join("&");
+ }
+ return element;
+ }).join("?");
+ } else {
+ callparams.url += "?format=json";
+ }
+ }
+
+
if (undefined === callparams.headers) { callparams.headers = {}; }
callparams.headers['X-CSRFToken'] = $cookies.csrftoken;
@@ -476,8 +503,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
};
- $scope.onLayerSelect = function (item) {
+ $scope.onLayerSelect = function (item, model, label) {
$scope.layerToAdd = item;
+ $scope.layerAddName = item.layer__name;
};
$scope.machineSelect = function (machineName) {
@@ -501,20 +529,22 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
$scope.layerAdd = function() {
- $http({method:"GET", url: $scope.layerToAdd.layerdict.layerdetailurl, params : {}})
+ $http({method:"GET", url: $scope.layerToAdd.layerDetailsUrl, params : {format: "json"}})
.success(function (_data) {
if (_data.error != "ok") {
console.warn(_data.error);
} else {
- if (_data.list.length > 0) {
+ console.log("got layer deps", _data.layerdeps.list);
+ if (_data.layerdeps.list.length > 0) {
// activate modal
+ console.log("listing modals");
var modalInstance = $modal.open({
templateUrl: 'dependencies_modal',
controller: function ($scope, $modalInstance, items, layerAddName) {
$scope.items = items;
$scope.layerAddName = layerAddName;
$scope.selectedItems = (function () {
- s = {};
+ var s = {};
for (var i = 0; i < items.length; i++)
{ s[items[i].id] = true; }
return s;
@@ -535,16 +565,18 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
},
resolve: {
items: function () {
- return _data.list;
+ return _data.layerdeps.list;
},
layerAddName: function () {
return $scope.layerAddName;
},
}
});
+ console.log("built modal instance", modalInstance);
modalInstance.result.then(function (selectedArray) {
- selectedArray.push($scope.layerToAdd.layerversion.id);
+ console.log("layer to add", $scope.layerToAdd)
+ selectedArray.push($scope.layerToAdd.id);
console.warn("TRC6: selected", selectedArray);
$scope._makeXHRCall({
@@ -563,7 +595,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
$scope._makeXHRCall({
method: "POST", url: $scope.urls.xhr_edit,
data: {
- layerAdd: $scope.layerToAdd.layerversion.id,
+ layerAdd: $scope.layerToAdd.id,
}
}).then(function () {
$scope.layerAddName = undefined;
@@ -772,8 +804,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
return;
if (imported.deps_added.length === 0) {
- text = "You have imported <strong><a href=\""+$scope.urls.layer+
- imported.imported_layer.id+"\">"+imported.imported_layer.name+
+ text = "You have imported <strong><a href=\""+imported.imported_layer.layerDetailsUrl+"\">"+imported.imported_layer.name+
"</a></strong> and added it to your project.";
} else {
var links = "<a href=\""+$scope.urls.layer+
@@ -781,7 +812,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
"</a>, ";
imported.deps_added.map (function(item, index){
- links +="<a href=\""+$scope.urls.layer+item.id+"\" >"+item.name+
+ links +="<a href=\""+item.layerDetailsUrl+"\" >"+item.name+
"</a>";
/*If we're at the last element we don't want the trailing comma */
if (imported.deps_added[index+1] !== undefined)
@@ -832,7 +863,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
if (zone.maxid === undefined) { zone.maxid = 0; }
var crtid = zone.maxid ++;
angular.forEach(zone, function (o) { o.close(); });
- o = {
+ var o = {
id: crtid, text: text, type: type,
close: function() {
zone.splice((function(id) {