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>
This commit is contained in:
parent
73367c2ca8
commit
aff29d2cd8
|
@ -89,8 +89,8 @@ function basePageInit(ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have a project setup the typeahead */
|
/* If we have a project setup the typeahead */
|
||||||
if (selectedProject.projectTargetsUrl){
|
if (selectedProject.recipesTypeAheadUrl){
|
||||||
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) {
|
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
|
||||||
selectedTarget = item;
|
selectedTarget = item;
|
||||||
newBuildTargetBuildBtn.removeAttr("disabled");
|
newBuildTargetBuildBtn.removeAttr("disabled");
|
||||||
});
|
});
|
||||||
|
@ -156,7 +156,7 @@ function basePageInit(ctx) {
|
||||||
$('#project .icon-pencil').hide();
|
$('#project .icon-pencil').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) {
|
libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsTypeAheadUrl, { format : "json" }, function (item) {
|
||||||
/* successfully selected a project */
|
/* successfully selected a project */
|
||||||
newBuildProjectSaveBtn.removeAttr("disabled");
|
newBuildProjectSaveBtn.removeAttr("disabled");
|
||||||
selectedProject = item;
|
selectedProject = item;
|
||||||
|
@ -180,13 +180,21 @@ function basePageInit(ctx) {
|
||||||
|
|
||||||
newBuildTargetInput.removeAttr("disabled");
|
newBuildTargetInput.removeAttr("disabled");
|
||||||
|
|
||||||
/* Update the typeahead to use the new selectedProject */
|
/* We've got a new project so now we need to update the
|
||||||
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) {
|
* target urls. We can get this from the new project's info
|
||||||
/* successfully selected a target */
|
*/
|
||||||
selectedTarget = item;
|
$.getJSON(selectedProject.projectPageUrl, { format: "json" },
|
||||||
newBuildTargetBuildBtn.removeAttr("disabled");
|
function(projectInfo){
|
||||||
});
|
/* Update the typeahead to use the new selectedProject */
|
||||||
|
selectedProject = projectInfo;
|
||||||
|
|
||||||
|
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) {
|
||||||
|
/* successfully selected a target */
|
||||||
|
selectedTarget = item;
|
||||||
|
newBuildTargetBuildBtn.removeAttr("disabled");
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
newBuildTargetInput.val("");
|
newBuildTargetInput.val("");
|
||||||
|
|
||||||
/* set up new form aspect */
|
/* set up new form aspect */
|
||||||
|
|
|
@ -16,7 +16,7 @@ function importLayerPageInit (ctx) {
|
||||||
var currentLayerDepSelection;
|
var currentLayerDepSelection;
|
||||||
var validLayerName = /^(\w|-)+$/;
|
var validLayerName = /^(\w|-)+$/;
|
||||||
|
|
||||||
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){
|
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
|
||||||
currentLayerDepSelection = item;
|
currentLayerDepSelection = item;
|
||||||
|
|
||||||
layerDepBtn.removeAttr("disabled");
|
layerDepBtn.removeAttr("disabled");
|
||||||
|
@ -26,11 +26,11 @@ function importLayerPageInit (ctx) {
|
||||||
/* We automatically add "openembedded-core" layer for convenience as a
|
/* We automatically add "openembedded-core" layer for convenience as a
|
||||||
* dependency as pretty much all layers depend on this one
|
* dependency as pretty much all layers depend on this one
|
||||||
*/
|
*/
|
||||||
$.getJSON(libtoaster.ctx.projectLayersUrl,
|
$.getJSON(libtoaster.ctx.layersTypeAheadUrl,
|
||||||
{ include_added: "true" , search: "openembedded-core", format: "json" },
|
{ include_added: "true" , search: "openembedded-core" },
|
||||||
function(layer) {
|
function(layer) {
|
||||||
if (layer.rows.length > 0) {
|
if (layer.results.length > 0) {
|
||||||
currentLayerDepSelection = layer.rows[0];
|
currentLayerDepSelection = layer.results[0];
|
||||||
layerDepBtn.click();
|
layerDepBtn.click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,7 +211,7 @@ function importLayerPageInit (ctx) {
|
||||||
var name = $(this).val();
|
var name = $(this).val();
|
||||||
|
|
||||||
/* Check if the layer name exists */
|
/* Check if the layer name exists */
|
||||||
$.getJSON(libtoaster.ctx.projectLayersUrl,
|
$.getJSON(libtoaster.ctx.layersTypeAheadUrl,
|
||||||
{ include_added: "true" , search: name, format: "json" },
|
{ include_added: "true" , search: name, format: "json" },
|
||||||
function(layer) {
|
function(layer) {
|
||||||
if (layer.rows.length > 0) {
|
if (layer.rows.length > 0) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ function layerDetailsPageInit (ctx) {
|
||||||
var addRmLayerBtn = $("#add-remove-layer-btn");
|
var addRmLayerBtn = $("#add-remove-layer-btn");
|
||||||
|
|
||||||
/* setup the dependencies typeahead */
|
/* setup the dependencies typeahead */
|
||||||
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.projectLayersUrl, { include_added: "true" }, function(item){
|
libtoaster.makeTypeahead(layerDepInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "true" }, function(item){
|
||||||
currentLayerDepSelection = item;
|
currentLayerDepSelection = item;
|
||||||
|
|
||||||
layerDepBtn.removeAttr("disabled");
|
layerDepBtn.removeAttr("disabled");
|
||||||
|
|
|
@ -19,14 +19,13 @@ var libtoaster = (function (){
|
||||||
jQElement.typeahead({
|
jQElement.typeahead({
|
||||||
source: function(query, process){
|
source: function(query, process){
|
||||||
xhrParams.search = query;
|
xhrParams.search = query;
|
||||||
xhrParams.format = "json";
|
|
||||||
$.getJSON(xhrUrl, this.options.xhrParams, function(data){
|
$.getJSON(xhrUrl, this.options.xhrParams, function(data){
|
||||||
if (data.error !== "ok") {
|
if (data.error !== "ok") {
|
||||||
console.log("Error getting data from server "+data.error);
|
console.log("Error getting data from server "+data.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process (data.rows);
|
return process(data.results);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updater: function(item) {
|
updater: function(item) {
|
||||||
|
@ -40,7 +39,7 @@ var libtoaster = (function (){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ~item.name.toLowerCase().indexOf(this.query.toLowerCase());
|
return 1;
|
||||||
},
|
},
|
||||||
highlighter: function (item) {
|
highlighter: function (item) {
|
||||||
if (item.hasOwnProperty('detail'))
|
if (item.hasOwnProperty('detail'))
|
||||||
|
|
|
@ -98,7 +98,7 @@ function projectPageInit(ctx) {
|
||||||
|
|
||||||
/* Add/Rm layer functionality */
|
/* Add/Rm layer functionality */
|
||||||
|
|
||||||
libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.projectLayersUrl, { include_added: "false" }, function(item){
|
libtoaster.makeTypeahead(layerAddInput, libtoaster.ctx.layersTypeAheadUrl, { include_added: "false" }, function(item){
|
||||||
currentLayerAddSelection = item;
|
currentLayerAddSelection = item;
|
||||||
layerAddBtn.removeAttr("disabled");
|
layerAddBtn.removeAttr("disabled");
|
||||||
});
|
});
|
||||||
|
@ -251,7 +251,7 @@ function projectPageInit(ctx) {
|
||||||
machineNameTitle.text(machineName);
|
machineNameTitle.text(machineName);
|
||||||
}
|
}
|
||||||
|
|
||||||
libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.projectMachinesUrl, { }, function(item){
|
libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.machinesTypeAheadUrl, { }, function(item){
|
||||||
currentMachineAddSelection = item;
|
currentMachineAddSelection = item;
|
||||||
machineChangeBtn.removeAttr("disabled");
|
machineChangeBtn.removeAttr("disabled");
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,14 +32,16 @@
|
||||||
jsUrl : "{% static 'js/' %}",
|
jsUrl : "{% static 'js/' %}",
|
||||||
htmlUrl : "{% static 'html/' %}",
|
htmlUrl : "{% static 'html/' %}",
|
||||||
projectsUrl : "{% url 'all-projects' %}",
|
projectsUrl : "{% url 'all-projects' %}",
|
||||||
|
projectsTypeAheadUrl: {% url 'xhr_projectstypeahead' as prjurl%}{{prjurl|json}},
|
||||||
{% if project.id %}
|
{% if project.id %}
|
||||||
projectId : {{project.id}},
|
projectId : {{project.id}},
|
||||||
projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}},
|
projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}},
|
||||||
projectName : {{project.name|json}},
|
projectName : {{project.name|json}},
|
||||||
projectTargetsUrl: {% url 'projectavailabletargets' project.id as paturl%}{{paturl|json}},
|
recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}},
|
||||||
|
layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}},
|
||||||
|
machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}},
|
||||||
|
|
||||||
projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
|
projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
|
||||||
projectLayersUrl: {% url 'projectlayers' project.id as plurl %}{{plurl|json}},
|
|
||||||
projectMachinesUrl: {% url 'projectmachines' project.id as pmurl %}{{pmurl|json}},
|
|
||||||
projectId : {{project.id}},
|
projectId : {{project.id}},
|
||||||
{% else %}
|
{% else %}
|
||||||
projectId : undefined,
|
projectId : undefined,
|
||||||
|
|
|
@ -2235,6 +2235,8 @@ if True:
|
||||||
"freqtargets": freqtargets[:5],
|
"freqtargets": freqtargets[:5],
|
||||||
"releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
|
"releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
|
||||||
"project_html": 1,
|
"project_html": 1,
|
||||||
|
"recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),
|
||||||
|
"projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if prj.release is not None:
|
if prj.release is not None:
|
||||||
|
@ -2784,9 +2786,9 @@ if True:
|
||||||
for p in project_info.object_list:
|
for p in project_info.object_list:
|
||||||
p.id = p.pk
|
p.id = p.pk
|
||||||
p.projectPageUrl = reverse('project', args=(p.id,))
|
p.projectPageUrl = reverse('project', args=(p.id,))
|
||||||
p.projectLayersUrl = reverse('projectlayers', args=(p.id,))
|
p.layersTypeAheadUrl = reverse('xhr_layerstypeahead', args=(p.id,))
|
||||||
|
p.recipesTypeAheadUrl = reverse('xhr_recipestypeahead', args=(p.id,))
|
||||||
p.projectBuildsUrl = reverse('projectbuilds', args=(p.id,))
|
p.projectBuildsUrl = reverse('projectbuilds', args=(p.id,))
|
||||||
p.projectTargetsUrl = reverse('projectavailabletargets', args=(p.id,))
|
|
||||||
|
|
||||||
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
|
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
|
||||||
build_mru = _get_latest_builds()
|
build_mru = _get_latest_builds()
|
||||||
|
|
Loading…
Reference in New Issue