summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-08-04 22:46:34 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-06 16:04:45 -0500
commitaff29d2cd837df90a2897b9b75753e4af30f132e (patch)
treeed512f81667282dd478b43f3f90c06b05bbcb06f /bitbake/lib/toaster/toastergui
parent73367c2ca82143c618a22f9faaa101761f192397 (diff)
downloadpoky-aff29d2cd837df90a2897b9b75753e4af30f132e.tar.gz
bitbake: toastergui: Switch to using the new toaster typeahead widget
Switch the existing typeahead inputs to use the new typeahead widget. This means we have a defined mechanism and end point for typeaheads which meets the design specification. (Bitbake rev: 31a8ae7909347f7b6edde5bbdf02b86dc1b32ed0) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/base.js26
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/importlayer.js12
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerdetails.js2
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js5
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectpage.js4
-rw-r--r--bitbake/lib/toaster/toastergui/templates/base.html8
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py6
7 files changed, 37 insertions, 26 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js
index f25336110a..eba9c16783 100644
--- a/bitbake/lib/toaster/toastergui/static/js/base.js
+++ b/bitbake/lib/toaster/toastergui/static/js/base.js
@@ -89,8 +89,8 @@ function basePageInit(ctx) {
89 } 89 }
90 90
91 /* If we have a project setup the typeahead */ 91 /* If we have a project setup the typeahead */
92 if (selectedProject.projectTargetsUrl){ 92 if (selectedProject.recipesTypeAheadUrl){
93 libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { 93 libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
94 selectedTarget = item; 94 selectedTarget = item;
95 newBuildTargetBuildBtn.removeAttr("disabled"); 95 newBuildTargetBuildBtn.removeAttr("disabled");
96 }); 96 });
@@ -156,7 +156,7 @@ function basePageInit(ctx) {
156 $('#project .icon-pencil').hide(); 156 $('#project .icon-pencil').hide();
157 } 157 }
158 158
159 libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) { 159 libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsTypeAheadUrl, { format : "json" }, function (item) {
160 /* successfully selected a project */ 160 /* successfully selected a project */
161 newBuildProjectSaveBtn.removeAttr("disabled"); 161 newBuildProjectSaveBtn.removeAttr("disabled");
162 selectedProject = item; 162 selectedProject = item;
@@ -180,13 +180,21 @@ function basePageInit(ctx) {
180 180
181 newBuildTargetInput.removeAttr("disabled"); 181 newBuildTargetInput.removeAttr("disabled");
182 182
183 /* Update the typeahead to use the new selectedProject */ 183 /* We've got a new project so now we need to update the
184 libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { 184 * target urls. We can get this from the new project's info
185 /* successfully selected a target */ 185 */
186 selectedTarget = item; 186 $.getJSON(selectedProject.projectPageUrl, { format: "json" },
187 newBuildTargetBuildBtn.removeAttr("disabled"); 187 function(projectInfo){
188 }); 188 /* Update the typeahead to use the new selectedProject */
189 selectedProject = projectInfo;
190
191 libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
192 /* successfully selected a target */
193 selectedTarget = item;
194 newBuildTargetBuildBtn.removeAttr("disabled");
195 });
189 196
197 });
190 newBuildTargetInput.val(""); 198 newBuildTargetInput.val("");
191 199
192 /* set up new form aspect */ 200 /* set up new form aspect */
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
index 50bc4ddd7c..2fadbc0978 100644
--- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js
+++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
@@ -16,7 +16,7 @@ function importLayerPageInit (ctx) {
16 var currentLayerDepSelection; 16 var currentLayerDepSelection;
17 var validLayerName = /^(\w|-)+$/; 17 var validLayerName = /^(\w|-)+$/;
18 18
19 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ 19 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
20 currentLayerDepSelection = item; 20 currentLayerDepSelection = item;
21 21
22 layerDepBtn.removeAttr("disabled"); 22 layerDepBtn.removeAttr("disabled");
@@ -26,11 +26,11 @@ function importLayerPageInit (ctx) {
26 /* We automatically add "openembedded-core" layer for convenience as a 26 /* We automatically add "openembedded-core" layer for convenience as a
27 * dependency as pretty much all layers depend on this one 27 * dependency as pretty much all layers depend on this one
28 */ 28 */
29 $.getJSON(libtoaster.ctx.projectLayersUrl, 29 $.getJSON(libtoaster.ctx.layersTypeAheadUrl,
30 { include_added: "true" , search: "openembedded-core", format: "json" }, 30 { include_added: "true" , search: "openembedded-core" },
31 function(layer) { 31 function(layer) {
32 if (layer.rows.length > 0) { 32 if (layer.results.length > 0) {
33 currentLayerDepSelection = layer.rows[0]; 33 currentLayerDepSelection = layer.results[0];
34 layerDepBtn.click(); 34 layerDepBtn.click();
35 } 35 }
36 }); 36 });
@@ -211,7 +211,7 @@ function importLayerPageInit (ctx) {
211 var name = $(this).val(); 211 var name = $(this).val();
212 212
213 /* Check if the layer name exists */ 213 /* Check if the layer name exists */
214 $.getJSON(libtoaster.ctx.projectLayersUrl, 214 $.getJSON(libtoaster.ctx.layersTypeAheadUrl,
215 { include_added: "true" , search: name, format: "json" }, 215 { include_added: "true" , search: name, format: "json" },
216 function(layer) { 216 function(layer) {
217 if (layer.rows.length > 0) { 217 if (layer.rows.length > 0) {
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
index be6bbcd20f..96372f06f4 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) {
9 var addRmLayerBtn = $("#add-remove-layer-btn"); 9 var addRmLayerBtn = $("#add-remove-layer-btn");
10 10
11 /* setup the dependencies typeahead */ 11 /* setup the dependencies typeahead */
12 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){ 12 libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
13 currentLayerDepSelection = item; 13 currentLayerDepSelection = item;
14 14
15 layerDepBtn.removeAttr("disabled"); 15 layerDepBtn.removeAttr("disabled");
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 7edd0190f3..c9ff6507ef 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -19,14 +19,13 @@ var libtoaster = (function (){
19 jQElement.typeahead({ 19 jQElement.typeahead({
20 source: function(query, process){ 20 source: function(query, process){
21 xhrParams.search = query; 21 xhrParams.search = query;
22 xhrParams.format = "json";
23 $.getJSON(xhrUrl, this.options.xhrParams, function(data){ 22 $.getJSON(xhrUrl, this.options.xhrParams, function(data){
24 if (data.error !== "ok") { 23 if (data.error !== "ok") {
25 console.log("Error getting data from server "+data.error); 24 console.log("Error getting data from server "+data.error);
26 return; 25 return;
27 } 26 }
28 27
29 return process (data.rows); 28 return process(data.results);
30 }); 29 });
31 }, 30 },
32 updater: function(item) { 31 updater: function(item) {
@@ -40,7 +39,7 @@ var libtoaster = (function (){
40 return 0; 39 return 0;
41 } 40 }
42 41
43 return ~item.name.toLowerCase().indexOf(this.query.toLowerCase()); 42 return 1;
44 }, 43 },
45 highlighter: function (item) { 44 highlighter: function (item) {
46 if (item.hasOwnProperty('detail')) 45 if (item.hasOwnProperty('detail'))
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
index b7cb074f11..b82f7408e7 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
@@ -98,7 +98,7 @@ function projectPageInit(ctx) {
98 98
99 /* Add/Rm layer functionality */ 99 /* Add/Rm layer functionality */
100 100
101 libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.projectLayersUrl, { include_added: "false" }, function(item){ 101 libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "false" }, function(item){
102 currentLayerAddSelection = item; 102 currentLayerAddSelection = item;
103 layerAddBtn.removeAttr("disabled"); 103 layerAddBtn.removeAttr("disabled");
104 }); 104 });
@@ -251,7 +251,7 @@ function projectPageInit(ctx) {
251 machineNameTitle.text(machineName); 251 machineNameTitle.text(machineName);
252 } 252 }
253 253
254 libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.projectMachinesUrl, { }, function(item){ 254 libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.machinesTypeAheadUrl, { }, function(item){
255 currentMachineAddSelection = item; 255 currentMachineAddSelection = item;
256 machineChangeBtn.removeAttr("disabled"); 256 machineChangeBtn.removeAttr("disabled");
257 }); 257 });
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html
index 65367e20dd..d75bf16bf2 100644
--- a/bitbake/lib/toaster/toastergui/templates/base.html
+++ b/bitbake/lib/toaster/toastergui/templates/base.html
@@ -32,14 +32,16 @@
32 jsUrl : "{% static 'js/' %}", 32 jsUrl : "{% static 'js/' %}",
33 htmlUrl : "{% static 'html/' %}", 33 htmlUrl : "{% static 'html/' %}",
34 projectsUrl : "{% url 'all-projects' %}", 34 projectsUrl : "{% url 'all-projects' %}",
35 projectsTypeAheadUrl: {% url 'xhr_projectstypeahead' as prjurl%}{{prjurl|json}},
35 {% if project.id %} 36 {% if project.id %}
36 projectId : {{project.id}}, 37 projectId : {{project.id}},
37 projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}}, 38 projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}},
38 projectName : {{project.name|json}}, 39 projectName : {{project.name|json}},
39 projectTargetsUrl: {% url 'projectavailabletargets' project.id as paturl%}{{paturl|json}}, 40 recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}},
41 layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}},
42 machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}},
43
40 projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}}, 44 projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
41 projectLayersUrl: {% url 'projectlayers' project.id as plurl %}{{plurl|json}},
42 projectMachinesUrl: {% url 'projectmachines' project.id as pmurl %}{{pmurl|json}},
43 projectId : {{project.id}}, 45 projectId : {{project.id}},
44 {% else %} 46 {% else %}
45 projectId : undefined, 47 projectId : undefined,
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index b43a01e951..b7bfb9a69d 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2235,6 +2235,8 @@ if True:
2235 "freqtargets": freqtargets[:5], 2235 "freqtargets": freqtargets[:5],
2236 "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()), 2236 "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
2237 "project_html": 1, 2237 "project_html": 1,
2238 "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),
2239 "projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)),
2238 } 2240 }
2239 2241
2240 if prj.release is not None: 2242 if prj.release is not None:
@@ -2784,9 +2786,9 @@ if True:
2784 for p in project_info.object_list: 2786 for p in project_info.object_list:
2785 p.id = p.pk 2787 p.id = p.pk
2786 p.projectPageUrl = reverse('project', args=(p.id,)) 2788 p.projectPageUrl = reverse('project', args=(p.id,))
2787 p.projectLayersUrl = reverse('projectlayers', args=(p.id,)) 2789 p.layersTypeAheadUrl = reverse('xhr_layerstypeahead', args=(p.id,))
2790 p.recipesTypeAheadUrl = reverse('xhr_recipestypeahead', args=(p.id,))
2788 p.projectBuildsUrl = reverse('projectbuilds', args=(p.id,)) 2791 p.projectBuildsUrl = reverse('projectbuilds', args=(p.id,))
2789 p.projectTargetsUrl = reverse('projectavailabletargets', args=(p.id,))
2790 2792
2791 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) 2793 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
2792 build_mru = _get_latest_builds() 2794 build_mru = _get_latest_builds()