From a8be6d4bb18232f13ffcaaf1a4137322db59fe48 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 8 Jun 2015 13:36:56 +0100 Subject: bitbake: toastergui: remove xhr_datatypeahead and xhr_XXXbuild We remove the endpoints for XHR on the toastergui application. The endpoints are now replaced with calls to the respective REST endpoints (i.e. projectlayers, projecttargets, projectmachines). (Bitbake rev: 8e7a2c3b125a34fd9d6fa0442ab13290137ecc51) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/contrib/tts/urllist.py | 2 - bitbake/lib/toaster/toastergui/static/js/base.js | 6 +- .../toaster/toastergui/static/js/importlayer.js | 6 +- .../toaster/toastergui/static/js/layerdetails.js | 4 +- .../lib/toaster/toastergui/static/js/libtoaster.js | 8 +- bitbake/lib/toaster/toastergui/templates/base.html | 2 - .../toaster/toastergui/templates/layerdetails.html | 4 +- .../toastergui/templates/managed_mrb_section.html | 2 +- .../lib/toaster/toastergui/templates/project.html | 52 ++++-- .../lib/toaster/toastergui/templates/runagain.html | 2 +- .../toaster/toastergui/templatetags/projecttags.py | 2 +- bitbake/lib/toaster/toastergui/tests.py | 6 +- bitbake/lib/toaster/toastergui/urls.py | 8 +- bitbake/lib/toaster/toastergui/views.py | 208 ++++++--------------- bitbake/lib/toaster/toastergui/widgets.py | 6 +- bitbake/lib/toaster/toastermain/settings.py | 2 +- 16 files changed, 119 insertions(+), 201 deletions(-) diff --git a/bitbake/lib/toaster/contrib/tts/urllist.py b/bitbake/lib/toaster/contrib/tts/urllist.py index 433ac9fe85..0226334f0b 100644 --- a/bitbake/lib/toaster/contrib/tts/urllist.py +++ b/bitbake/lib/toaster/contrib/tts/urllist.py @@ -40,9 +40,7 @@ URLS = [ 'toastergui/project/1/importlayer', 'toastergui/project/1/targets/', 'toastergui/project/1/machines/', -'toastergui/xhr_projectbuild/1/', 'toastergui/xhr_configvaredit/1', -'toastergui/xhr_datatypeahead/1', 'toastergui/xhr_importlayer/', 'toastergui/xhr_updatelayer/', 'toastergui/project/1/buildrequest/1', diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 9c8d01ef5a..747442cc9e 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js @@ -89,7 +89,7 @@ function basePageInit (ctx) { if (!selectedTarget) selectedTarget = { name: newBuildTargetInput.val() }; /* fire and forget */ - libtoaster.startABuild(ctx.projectBuildUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); + libtoaster.startABuild(ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); window.location.replace(libtoaster.ctx.projectPageUrl); }); @@ -105,13 +105,13 @@ function basePageInit (ctx) { libtoaster.ctx.projectName = selectedProject.name; libtoaster.ctx.projectId = selectedProject.id; - ctx.projectBuildUrl = selectedProject.projectBuildUrl; + ctx.projectBuildsUrl = selectedProject.projectBuildsUrl; /* we can create a target typeahead only after we have a project selected */ newBuildTargetInput.prop("disabled", false); newBuildTargetBuildBtn.prop("disabled", false); - libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.xhrProjectDataTypeaheadUrl, { type : "targets" }, function(item){ + libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function(item){ /* successfully selected a target */ selectedTarget = item; }); diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index beb2ede3dc..e1fc5c5187 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -18,7 +18,7 @@ function importLayerPageInit (ctx) { $("#new-project-button").hide(); - libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.xhrProjectDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" }, function(item){ + libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ currentLayerDepSelection = item; layerDepBtn.removeAttr("disabled"); @@ -28,7 +28,7 @@ function importLayerPageInit (ctx) { /* We automatically add "openembedded-core" layer for convenience as a * dependency as pretty much all layers depend on this one */ - $.getJSON(libtoaster.ctx.xhrProjectDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" , value: "openembedded-core" }, function(layer) { + $.getJSON(libtoaster.ctx.projectLayersUrl, { include_added: "true" , search: "openembedded-core" }, function(layer) { if (layer.list.length == 1) { currentLayerDepSelection = layer.list[0]; layerDepBtn.click(); @@ -211,7 +211,7 @@ function importLayerPageInit (ctx) { var name = $(this).val(); /* Check if the layer name exists */ - $.getJSON(libtoaster.ctx.xhrProjectDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" , value: name }, function(layer) { + $.getJSON(libtoaster.ctx.projectLayersUrl, { include_added: "true" , search: name }, function(layer) { if (layer.list.length > 0) { for (var i in layer.list){ if (layer.list[i].name == name) { diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index 8e14b8f277..ab781829cd 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js @@ -9,7 +9,7 @@ function layerDetailsPageInit (ctx) { var addRmLayerBtn = $("#add-remove-layer-btn"); /* setup the dependencies typeahead */ - libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.xhrProjectDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" }, function(item){ + libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ currentLayerDepSelection = item; layerDepBtn.removeAttr("disabled"); @@ -170,7 +170,7 @@ function layerDetailsPageInit (ctx) { $(".build-target-btn").click(function(){ /* fire a build */ var target = $(this).data('target-name'); - libtoaster.startABuild(ctx.projectBuildUrl, libtoaster.ctx.projectId, target, null, null); + libtoaster.startABuild(ctx.projectBuildsUrl, libtoaster.ctx.projectId, target, null, null); window.location.replace(libtoaster.ctx.projectPageUrl); }); }); diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 87910299a5..2a9a790693 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js @@ -93,7 +93,7 @@ var libtoaster = (function (){ } /* cancelABuild: - * url: xhr_projectbuild + * url: projectbuilds * builds_ids: space separated list of build request ids * onsuccess: callback for successful execution * onfail: callback for failed execution @@ -172,15 +172,15 @@ var libtoaster = (function (){ function _getLayerDepsForProject(projectId, layerId, onSuccess, onFail){ /* Check for dependencies not in the current project */ - $.getJSON(libtoaster.ctx.xhrProjectDataTypeaheadUrl, - { type: 'layerdeps', 'value': layerId , project_id: projectId }, + $.getJSON(libtoaster.ctx.projectLayersUrl, + { format: 'json', search: layerId }, function(data) { if (data.error != "ok") { console.log(data.error); if (onFail !== undefined) onFail(data); } else { - onSuccess(data); + onSuccess(data.layerdeps); } }, function() { console.log("E: Failed to make request"); diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index 5d51bc3c95..7fee26eb42 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -33,12 +33,10 @@ htmlUrl : "{% static 'html/' %}", projectsUrl : "{% url 'all-projects' %}", {% if project.id %} - xhrProjectDataTypeaheadUrl : "{% url 'xhr_datatypeahead' project.id %}", projectPageUrl : "{% url 'project' project.id %}", projectName : "{{project.name}}", projectId : {{project.id}}, {% else %} - xhrProjectDataTypeaheadUrl : undefined, projectPageUrl : undefined, projectName : undefined, projectId : undefined, diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html index c27d259a8c..ef1795c0e2 100644 --- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html +++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html @@ -3,7 +3,7 @@ {% load humanize %} {% load static %} {% block localbreadcrumb %} -
  • All compatible layers
  • +
  • All compatible layers
  • {{layerversion.layer.name}} ({{layerversion.get_vcs_reference|truncatechars:13}})
  • @@ -33,7 +33,7 @@ $(document).ready(function (){ var ctx = { - projectBuildUrl : "{% url 'xhr_projectbuild' project.id %}", + projectBuildsUrl : "{% url 'projectbuilds' project.id %}", layerDetailsUrl : "{% url 'base_layerdetails' project.id %}", xhrUpdateLayerUrl : "{% url 'xhr_updatelayer' %}", layerVersion : { diff --git a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html index c93c2af301..47e64eaaab 100644 --- a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html @@ -129,7 +129,7 @@
    Build queued
    - + {% elif buildrequest.state == buildrequest.REQ_CREATED %} diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index e598631304..63fbc40f55 100644 --- a/bitbake/lib/toaster/toastergui/templates/project.html +++ b/bitbake/lib/toaster/toastergui/templates/project.html @@ -30,7 +30,7 @@ vim: expandtab tabstop=2 {%else%} -
    +