From afe06e313eac61f598f65e622ceb5951a9fabc9a Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Tue, 19 May 2015 16:14:29 +0100 Subject: bitbake: toaster: move project data typeahead to the REST API This patch enables JSON requests on the project REST endpoint, and replaces the universal queries "xhr_datatypeahead" with the `project` type to the REST project endpoint. The patch adds a decorator that takes a context returned by a view and either renders the template specified as the decorator argument, or converts the context to JSON. Normal "search", "filter" and "order" options for view work as normal on the JSON API format. To enable the JSON return, set the "format" GET parameter to "json". In order to demonstrate the functionality, the "New build" button is switched from using the xhr_datatypeahead to the project REST API with JSON formatting. Additionally, the XHR APIs that perform actions with the project id passed as parameter are removed, and the needed URLs are populated from the project JSON API returns after the project has been selected. (Bitbake rev: 15a2274eba13d19b864f337057d61c75ff7849cc) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/templates/base.html | 24 ++++++++++++++-------- .../toastergui/templates/basetable_bottom.html | 2 +- .../templates/detail_pagination_bottom.html | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/templates') diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index 230dee49d6..e10dc11673 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -31,11 +31,19 @@ projectId : {{project.id|default:'undefined'}}, jsUrl : "{% static 'js/' %}", htmlUrl : "{% static 'html/' %}", + projectsUrl : "{% url 'all-projects' %}", {% if project.id %} - xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' project.id %}", - xhrProjectEditUrl : "{% url 'xhr_projectedit' project.id %}", - projectPageUrl : "{% url 'project' project.id %}", - projectName : "{{project.name}}", + xhrProjectDataTypeaheadUrl : "{% url 'xhr_datatypeahead' project.id %}", + xhrProjectEditUrl : "{% url 'xhr_projectedit' project.id %}", + projectPageUrl : "{% url 'project' project.id %}", + projectName : "{{project.name}}", + projectId : {{project.id}}, + {% else %} + xhrProjectDataTypeaheadUrl : undefined, + xhrProjectEditUrl : undefined, + projectPageUrl : undefined, + projectName : undefined, + projectId : undefined, {% endif %} }; @@ -45,8 +53,6 @@ $(document).ready(function () { /* Vars needed for base.js */ var ctx = {}; - ctx.projectBuildUrl = "{% url 'xhr_build' %}"; - ctx.projectBasePageUrl = "{% url 'base_project' %}"; ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}"; ctx.numProjects = {{projects|length}}; ctx.currentUrl = "{{request.path|escapejs}}"; @@ -99,7 +105,7 @@
- Cancel +

View all projects

@@ -111,9 +117,9 @@
  • Recipe(s):
    - +
    - Build +
  • diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html index 4c28cae810..ce023f51af 100644 --- a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html +++ b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html @@ -57,7 +57,7 @@ } } - // load cookie for number of entries to be displayed on page + // load data for number of entries to be displayed on page if ({{request.GET.count}} != "") { pagesize = {{request.GET.count}}; } diff --git a/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html b/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html index 434facba93..f40c21d99f 100644 --- a/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html +++ b/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html @@ -38,7 +38,7 @@