recipes.html: Require keyword for recipe search
v3 cover recipes.html: Require keyword for recipe search
For v3, updated recipes.html to use bootstrap's error state and added the browse option for Classes.
The following changes since commit 78c2561181f07b1c39f1dc3516a9110a39d874f2:
templates/layerindex/classes.html: Add bbclass search (2017-11-07 16:54:46 +1300)
are available in the git repository at:
git://git.yoctoproject.org/layerindex-web abrindle/recipe_search
http://git.yoctoproject.org/cgit.cgi/layerindex-web/log/?h=abrindle/recipe_search
Amanda Brindle (1):
recipes.html: Require keyword for recipe search
layerindex/views.py | 15 ++++++++++++--- templates/layerindex/classes.html | 3 ++- templates/layerindex/distros.html | 3 ++- templates/layerindex/machines.html | 3 ++- templates/layerindex/recipes.html | 27 +++++++++++++++++++++------ 5 files changed, 39 insertions(+), 12 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/1 recipes.html: Require keyword for recipe search
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Add a browse button for the Machines, Classes, and Distros pages.
Fixes [YOCTO #11930]
--- layerindex/views.py | 15 ++++++++++++--- templates/layerindex/classes.html | 3 ++- templates/layerindex/distros.html | 3 ++- templates/layerindex/machines.html | 3 ++- templates/layerindex/recipes.html | 27 +++++++++++++++++++++------ 5 files changed, 39 insertions(+), 12 deletions(-)
layerindex/views.py +12 -3
@@ -656,7 +656,10 @@ class MachineSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = Machine.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name', 'description'])
@@ -705,7 +708,10 @@ class DistroSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = Distro.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name', 'description'])
@@ -730,7 +736,10 @@ class ClassSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name'])
templates/layerindex/classes.html +2 -1
@@ -35,7 +35,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'class_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search classes" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>
templates/layerindex/distros.html +2 -1
@@ -35,7 +35,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'distro_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search distros" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>
templates/layerindex/machines.html +2 -1
@@ -34,7 +34,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'machine_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search machines" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>
templates/layerindex/recipes.html +21 -6
@@ -32,14 +32,20 @@ <div class="row-fluid"> - <div class="input-append"> - <form id="filter-form" action="{% url 'recipe_search' url_branch %}" method="get"> - <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search recipes" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> - </form> - </div> + <form id="filter-form" action="{% url 'recipe_search' url_branch %}" method="get" onsubmit="return validate()"> + <div class="control-group" id="searchfield"> + <div class="controls"> + <div class="input-append"> + <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search recipes" name="q" value="{{ search_keyword }}" /> + <button class="btn" type="submit">search</button> + </div> + <span class="help-inline" id="errortext"></span> + </div> + </div> + </form> </div> + <div id="error"> </div> {% if recipe_list %} <table class="table table-striped table-bordered recipestable"> <thead>
@@ -88,5 +94,14 @@ $('.icon-hdd').tooltip({title:"Inherits image"}); $('.label-inverse').tooltip(); }); + + function validate(){ + if (!$("#appendedInputButtons").val()){ + $("#errortext").html("<p>Please specify search text</p>"); + $("#searchfield").addClass("error"); + return false; + } + } + </script> {% endblock %}
Signature · 1 line
2.7.4
Quoted 9 lines · Amanda Brindle
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Add a browse button for the Machines, Classes, and Distros pages.
There are reasons to view all of the recipes, machines, classes, distros, etc. (Not necessarily good reasons, but I know people do it.)
If the query is too long, it would be better to figure out a way to get a partial response and formulate the first page based on partial responses... having a multipage response that the user can look at.
--Mark
Quoted 140 lines
Fixes [YOCTO #11930]
Signed-off-by Amanda Brindle <[email protected]>--- layerindex/views.py | 15 ++++++++++++--- templates/layerindex/classes.html | 3 ++- templates/layerindex/distros.html | 3 ++- templates/layerindex/machines.html | 3 ++- templates/layerindex/recipes.html | 27 +++++++++++++++++++++------ 5 files changed, 39 insertions(+), 12 deletions(-)layerindex/views.py +12
-3@@ -656,7 +656,10 @@ class MachineSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = Machine.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name', 'description'])@@ -705,7 +708,10 @@ class DistroSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = Distro.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name', 'description'])@@ -730,7 +736,10 @@ class ClassSearchView(ListView): def get_queryset(self): _check_url_branch(self.kwargs) - query_string = self.request.GET.get('q', '') + if self.request.GET.get('search', ''): + query_string = self.request.GET.get('q', '') + else: + query_string = "" init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch']) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['name'])templates/layerindex/classes.html +2
-1@@ -35,7 +35,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'class_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search classes" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>templates/layerindex/distros.html +2
-1@@ -35,7 +35,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'distro_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search distros" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>templates/layerindex/machines.html +2
-1@@ -34,7 +34,8 @@ <div class="input-append"> <form id="filter-form" action="{% url 'machine_search' url_branch %}" method="get"> <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search machines" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> + <button class="btn" type="submit" name="search" value="1">search</button> + <button class="btn" type="submit" name="browse" value="1">browse</button> </form> </div> </div>templates/layerindex/recipes.html +21
-6@@ -32,14 +32,20 @@ <div class="row-fluid"> - <div class="input-append"> - <form id="filter-form" action="{% url 'recipe_search' url_branch %}" method="get"> - <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search recipes" name="q" value="{{ search_keyword }}" /> - <button class="btn" type="submit">search</button> - </form> - </div> + <form id="filter-form" action="{% url 'recipe_search' url_branch %}" method="get" onsubmit="return validate()"> + <div class="control-group" id="searchfield"> + <div class="controls"> + <div class="input-append"> + <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search recipes" name="q" value="{{ search_keyword }}" /> + <button class="btn" type="submit">search</button> + </div> + <span class="help-inline" id="errortext"></span> + </div> + </div> + </form> </div> + <div id="error"> </div> {% if recipe_list %} <table class="table table-striped table-bordered recipestable"> <thead>@@ -88,5 +94,14 @@ $('.icon-hdd').tooltip({title:"Inherits image"}); $('.label-inverse').tooltip(); }); + + function validate(){ + if (!$("#appendedInputButtons").val()){ + $("#errortext").html("<p>Please specify search text</p>"); + $("#searchfield").addClass("error"); + return false; + } + } + </script> {% endblock %}
Quoted 9 lines · NZDT Mark Hatle
Quoted 8 lines · Amanda Brindle
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Quoted 8 lines
Quoted 1 line
Add a browse button for the Machines, Classes, and Distros pages.
There are reasons to view all of the recipes, machines, classes, distros, etc. (Not necessarily good reasons, but I know people do it.)
If the query is too long, it would be better to figure out a way to get a partial response and formulate the first page based on partial responses... having a multipage response that the user can look at.
I'm willing to be proven wrong, but unfortunately it looks to me like this will require major re-engineering to sort out for a fairly weak use case. If you consider this important, would you be able to look into making it work?
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 15 lines · Paul Eggleton
Quoted 14 lines · NZDT Mark Hatle
Quoted 9 lines · Amanda Brindle
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Add a browse button for the Machines, Classes, and Distros pages.
There are reasons to view all of the recipes, machines, classes, distros, etc. (Not necessarily good reasons, but I know people do it.)
Quoted 7 lines
Quoted 3 lines
If the query is too long, it would be better to figure out a way to get a partial response and formulate the first page based on partial responses... having a multipage response that the user can look at.
I'm willing to be proven wrong, but unfortunately it looks to me like this will require major re-engineering to sort out for a fairly weak use case. If you consider this important, would you be able to look into making it work?
I suspect much of the display engine probably needs a rework as the contents of the layer index have grown. I can't promise anything, but I'll see if I can find anyone who can work on it.
For recipes, the use-case is very weak. I have talked with people though who have just wanted a list of what is available (one big list). Primarily so they can compare what is available to some magic spec sheet they are looking at.
For the Machines, Distros pages.. people do want a full list here, as they simply won't know what is available or what something is called. The scope of the machines and distros of course is nowhere near the scope for the full recipe list.
--Mark
Quoted 3 lines
Cheers,
Paul
Quoted 20 lines · NZDT Mark Hatle
Quoted 19 lines · Paul Eggleton
Quoted 17 lines · NZDT Mark Hatle
Quoted 9 lines · Amanda Brindle
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Add a browse button for the Machines, Classes, and Distros pages.
There are reasons to view all of the recipes, machines, classes, distros, etc. (Not necessarily good reasons, but I know people do it.)
If the query is too long, it would be better to figure out a way to get a partial response and formulate the first page based on partial responses... having a multipage response that the user can look at.
Quoted 8 lines
Quoted 4 lines
I'm willing to be proven wrong, but unfortunately it looks to me like this will require major re-engineering to sort out for a fairly weak use case. If you consider this important, would you be able to look into making it work?
I suspect much of the display engine probably needs a rework as the contents of the layer index have grown. I can't promise anything, but I'll see if I can find anyone who can work on it.
Could be yes, thanks.
Quoted 4 lines
For recipes, the use-case is very weak. I have talked with people though who have just wanted a list of what is available (one big list). Primarily so they can compare what is available to some magic spec sheet they are looking at.
If that's the use case though we should provide a proper export capability, because comparing big lists manually 50 items at a time isn't how you'd best support that. Theoretically the API could be used there but an explicit export function would be more accessible.
Quoted 4 lines
For the Machines, Distros pages.. people do want a full list here, as they simply won't know what is available or what something is called. The scope of the machines and distros of course is nowhere near the scope for the full recipe list.
Right, and this patch doesn't remove the ability to browse those - in fact it makes it easier to do so by adding an explicit browse button, so I think we're OK there.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 37 lines · Paul Eggleton
Quoted 20 lines · NZDT Mark Hatle
Quoted 19 lines · Paul Eggleton
Quoted 17 lines · NZDT Mark Hatle
Quoted 9 lines · Amanda Brindle
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole.
Add a browse button for the Machines, Classes, and Distros pages.
There are reasons to view all of the recipes, machines, classes, distros, etc. (Not necessarily good reasons, but I know people do it.)
If the query is too long, it would be better to figure out a way to get a partial response and formulate the first page based on partial responses... having a multipage response that the user can look at.
Quoted 8 lines
Quoted 4 lines
I'm willing to be proven wrong, but unfortunately it looks to me like this will require major re-engineering to sort out for a fairly weak use case. If you consider this important, would you be able to look into making it work?
I suspect much of the display engine probably needs a rework as the contents of the layer index have grown. I can't promise anything, but I'll see if I can find anyone who can work on it.
Could be yes, thanks.
Quoted 4 lines
For recipes, the use-case is very weak. I have talked with people though who have just wanted a list of what is available (one big list). Primarily so they can compare what is available to some magic spec sheet they are looking at.
Quoted 4 lines
If that's the use case though we should provide a proper export capability, because comparing big lists manually 50 items at a time isn't how you'd best support that. Theoretically the API could be used there but an explicit export function would be more accessible.
For my own uses, I export this using the restapi. So it can certainly be exported easily enough and processed externally. (Of course, few people know about the restapi or how to use it.)
Quoted 8 lines
Quoted 4 lines
For the Machines, Distros pages.. people do want a full list here, as they simply won't know what is available or what something is called. The scope of the machines and distros of course is nowhere near the scope for the full recipe list.
Right, and this patch doesn't remove the ability to browse those - in fact it makes it easier to do so by adding an explicit browse button, so I think we're OK there.
I misunderstood that. I though the machine/distro would be restricted like recipes.
Quoted 3 lines
Cheers,
Paul