[3/5] toaster: Switch front end to use Layer get REST API

Submitted by Michael Wood on Dec. 8, 2016, 6:42 p.m. | Patch ID: 134895

Details

Message ID 1481222571-17651-4-git-send-email-michael.g.wood@intel.com
State New
Headers show

Commit Message

Michael Wood Dec. 8, 2016, 6:42 p.m.
Switch the front end to use the proper REST API for retrieving layer
information.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/toastergui/static/js/libtoaster.js    |  6 +++++-
 bitbake/lib/toaster/toastergui/templates/layer_btn.html   | 15 ++++++++++++---
 .../lib/toaster/toastergui/templates/layerdetails.html    |  1 +
 bitbake/lib/toaster/toastergui/templates/machine_btn.html |  7 ++++++-
 bitbake/lib/toaster/toastergui/templates/recipe_btn.html  |  8 +++++++-
 5 files changed, 31 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 86662b7..e7d6a95 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -274,9 +274,13 @@  var libtoaster = (function () {
   }
 
   function _addRmLayer(layerObj, add, doneCb){
+    if (layerObj.xhrLayerUrl === undefined){
+      throw("xhrLayerUrl is undefined")
+    }
+
     if (add === true) {
       /* If adding get the deps for this layer */
-      libtoaster.getLayerDepsForProject(layerObj.layerdetailurl,
+      libtoaster.getLayerDepsForProject(layerObj.xhrLayerUrl,
         function (layers) {
 
         /* got result for dependencies */
diff --git a/bitbake/lib/toaster/toastergui/templates/layer_btn.html b/bitbake/lib/toaster/toastergui/templates/layer_btn.html
index b2f73eb..1580991 100644
--- a/bitbake/lib/toaster/toastergui/templates/layer_btn.html
+++ b/bitbake/lib/toaster/toastergui/templates/layer_btn.html
@@ -1,4 +1,9 @@ 
-<a class="btn btn-danger btn-block layer-exists-{{data.pk}} layerbtn"  data-layer='{ "id": {{data.pk}}, "name":  "{{data.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.pk%}"}' data-directive="remove"
+<a class="btn btn-danger btn-block layer-exists-{{data.pk}} layerbtn"  data-layer='{
+   "id": {{data.pk}},
+   "name":  "{{data.layer.name}}",
+   "xhrLayerUrl": "{% url "xhr_layer" extra.pid data.pk %}",
+   "layerdetailurl": "{% url 'layerdetails' extra.pid data.pk %}"
+   }' data-directive="remove"
     {% if data.pk not in extra.current_layers %}
     style="display:none;"
     {% endif %}
@@ -6,7 +11,12 @@ 
   <span class="glyphicon glyphicon-trash"></span>
   Remove layer
 </a>
-<a class="btn btn-default btn-block layer-add-{{data.pk}} layerbtn" data-layer='{ "id": {{data.pk}}, "name":  "{{data.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.pk%}"}' data-directive="add"
+<a class="btn btn-default btn-block layer-add-{{data.pk}} layerbtn"
+   data-layer='{ "id": {{data.pk}},
+   "name":  "{{data.layer.name}}",
+   "xhrLayerUrl": "{% url "xhr_layer" extra.pid data.pk %}",
+   "layerdetailurl": "{%url "layerdetails" extra.pid data.pk %}"
+   }' data-directive="add"
     {% if data.pk in extra.current_layers %}
     style="display:none;"
     {% endif %}
@@ -14,4 +24,3 @@ 
   <span class="glyphicon glyphicon-plus"></span>
   Add layer
 </a>
-
diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
index f1569bd..e0069db 100644
--- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html
+++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
@@ -71,6 +71,7 @@ 
           inCurrentPrj : false,
           {% endif %}
           layerdetailurl : "{% url 'layerdetails' project.id layerversion.id  %}",
+          xhrLayerUrl: "{% url 'xhr_layer' project.id layerversion.id  %}",
           layer_source: {{layerversion.layer_source|json}},
         },
         layerSourceTypes: {{layer_source|json}},
diff --git a/bitbake/lib/toaster/toastergui/templates/machine_btn.html b/bitbake/lib/toaster/toastergui/templates/machine_btn.html
index 5d93d7a..12b5c96 100644
--- a/bitbake/lib/toaster/toastergui/templates/machine_btn.html
+++ b/bitbake/lib/toaster/toastergui/templates/machine_btn.html
@@ -4,7 +4,12 @@ 
     {% endif %}
 >
   Select machine</a>
-<a class="btn btn-default btn-block layerbtn layer-add-{{data.layer_version.id}}" data-layer='{ "id": {{data.layer_version.id}}, "name":  "{{data.layer_version.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.id %}"}' data-directive="add"
+<a class="btn btn-default btn-block layerbtn
+layer-add-{{data.layer_version.id}}" data-layer='{ "id":
+   {{data.layer_version.id}}, "name":  "{{data.layer_version.layer.name}}",
+   "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.id %},
+   "xhrLayerUrl": "{% url "xhr_layer" extra.pid data.pk %}",
+   }' data-directive="add"
     {% if data.layer_version.pk in extra.current_layers %}
     style="display:none;"
     {% endif %}
diff --git a/bitbake/lib/toaster/toastergui/templates/recipe_btn.html b/bitbake/lib/toaster/toastergui/templates/recipe_btn.html
index e372964..0ee0ba5 100644
--- a/bitbake/lib/toaster/toastergui/templates/recipe_btn.html
+++ b/bitbake/lib/toaster/toastergui/templates/recipe_btn.html
@@ -5,7 +5,13 @@ 
  >
   Build recipe
 </a>
-<a class="btn btn-default btn-block layerbtn layer-add-{{data.layer_version.pk}}" data-layer='{ "id": {{data.layer_version.pk}}, "name":  "{{data.layer_version.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.pk%}"}' data-directive="add"
+<a class="btn btn-default btn-block layerbtn layer-add-{{data.layer_version.pk}}" 
+  data-layer='{
+  "id": {{data.layer_version.pk}},
+  "name":  "{{data.layer_version.layer.name}}",
+  "layerdetailurl": "{%url "layerdetails" extra.pid data.layer_version.pk%}",
+   "xhrLayerUrl": "{% url "xhr_layer" extra.pid data.layer_version.pk %}"
+   }' data-directive="add"
     {% if data.layer_version.pk in extra.current_layers %}
      style="display:none;"
     {% endif %}