summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-02-04 18:06:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-10 23:07:50 +0000
commitd6868d5d9db132b2634e1f7c94fbefe907cab086 (patch)
tree5014f13d78069b2621611692a61d14f14bf03f4c /bitbake/lib
parent50719afbc2f3484173fa0a2acfda9ece46894bcd (diff)
downloadpoky-d6868d5d9db132b2634e1f7c94fbefe907cab086.tar.gz
bitbake: toaster: All machines Add filtering based on layer in project
Add a filter so that we can filter machines which are already being provided by a layer in the current project. Also make sure that we're only showing layers which are compatible with the current project. Also handle no results returned and page heading reflecting the number of results returned from a search. AlexD solved conflicts while merging the patch. (Bitbake rev: b0ae4d2bb71e897d8a846a3cf14b7151baa09bd2) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/toastergui/templates/machines.html67
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py48
2 files changed, 86 insertions, 29 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/machines.html b/bitbake/lib/toaster/toastergui/templates/machines.html
index 650c47bd66..9930a94f4d 100644
--- a/bitbake/lib/toaster/toastergui/templates/machines.html
+++ b/bitbake/lib/toaster/toastergui/templates/machines.html
@@ -30,38 +30,57 @@
30{% include "layers_dep_modal.html" %} 30{% include "layers_dep_modal.html" %}
31<div class="page-header"> 31<div class="page-header">
32 <h1> 32 <h1>
33 {% if request.GET.search %}
34 {% if objects.paginator.count != 0 %}
35 {{objects.paginator.count}} machines found
36 {% else %}
37 No Machines found
38 {% endif %}
39 {% else %}
40
33 All machines 41 All machines
34 <i class="icon-question-sign get-help heading-help" title="This page lists all the machines compatible with the current project that Toaster knows about. They include community-created targets suitable for use on top of OpenEmbedded Core and any targets you have imported"></i> 42 <i class="icon-question-sign get-help heading-help" title="This page lists all the machines compatible with the current project that Toaster knows about. They include community-created targets suitable for use on top of OpenEmbedded Core and any targets you have imported"></i>
43 {% endif %}
35 </h1> 44 </h1>
36</div> 45</div>
37
38<div class="alert alert-info lead" id="alert-area" style="display:none"> 46<div class="alert alert-info lead" id="alert-area" style="display:none">
39 <button type="button" class="close" id="dismiss-alert">&times;</button> 47 <button type="button" class="close" id="dismiss-alert">&times;</button>
40 <span id="alert-msg"></span> 48 <span id="alert-msg"></span>
41</div> 49</div>
50{% if request.GET.search and objects.paginator.count == 0 %}
51<div class="alert row-fluid">
52<form class="navbar-search input-append pull-left" id="searchform">
53 <input class="input-xxlarge" id="search" name="search" type="text" placeholder="Search machines" value="{{request.GET.search}}"><a href="javascript:$('#search').val('');searchform.submit()" class="add-on btn" tabindex="-1"><i class="icon-remove"></i></a>
54 <input type="hidden" name="orderby" value="">
55 <input type="hidden" name="page" value="1">
56 <button class="btn" type="submit" value="Search">Search</button>
57 <button type="submit" class="btn btn-link"><a href="{%url 'machines' %}">Show all machines</a></button>
58 </form>
59 </div>
60{% else %}
61 {% include "basetable_top.html" %}
62 {% for o in objects %}
63 <tr class="data">
64 <td class="machine">{{o.name}}</td>
65 <td class="description">{{o.description}}</td>
66 <td class="layer"><a href="{%url "layerdetails" o.layer_version.id %}">{{o.layer_version.layer.name}}</a></td>
67 <td class="source">{{o.layer_source.name}}</td>
68 <td class="branch">{{o.layer_version.get_vcs_reference}}</td>
69 <td class="machinefile"><code>/machine/conf/{{o.name}}.conf</code><a href="{{o.get_vcs_machine_file_link_url}}" target="_blank"><i class="icon-share get-info"></i></a></td>
70 <td class="select-or-add">
71 <a href="#" class="btn btn-block select-machine-btn" data-machine-name="{{o.name}}" data-layer-version-id="{{o.layer_version.id}}"
72 {%if o.layer_version.id not in project_layers %}style="display:none" {%endif%} >Select machine</a>
73 <a href="#" class="btn btn-block nopop add-layer" data-layer-version-id="{{o.layer_version.id}}" data-layer-name="{{o.layer_version.layer.name}}" {%if o.layer_version.id in project_layers %}style="display:none" {%endif%}
74 >
75 <i class="icon-plus"></i>
76 Add layer
77 <i class="icon-question-sign get-help" title="To build this machine, you must first add the {{o.layer_version.layer.name}} layer to your project"></i>
78 </a>
79 </td>
80 </tr>
81 {% endfor %}
42 82
43{% include "basetable_top.html" %} 83 {% include "basetable_bottom.html" %}
44{% for o in objects %} 84{% endif %}
45<tr class="data">
46 <td class="machine">{{o.name}}</td>
47 <td class="description">{{o.description}}</td>
48 <td class="layer"><a href="{%url "layerdetails" o.layer_version.id %}">{{o.layer_version.layer.name}}</a></td>
49 <td class="source">{{o.layer_source.name}}</td>
50 <td class="branch">{{o.layer_version.commit}}</td>
51 <td class="machinefile"><code>/machine/conf/{{o.name}}.conf</code><a href="{{o.get_vcs_machine_file_link_url}}" target="_blank"><i class="icon-share get-info"></i></a></td>
52 <td class="select-or-add">
53 <a href="#" class="btn btn-block select-machine-btn" data-machine-name="{{o.name}}" data-layer-version-id="{{o.layer_version.id}}"
54 {%if o.layer_version.id not in project_layers %}style="display:none" {%endif%} >Select machine</a>
55 <a href="#" class="btn btn-block nopop add-layer" data-layer-version-id="{{o.layer_version.id}}" data-layer-name="{{o.layer_version.layer.name}}" {%if o.layer_version.id in project_layers %}style="display:none" {%endif%}
56 >
57 <i class="icon-plus"></i>
58 Add layer
59 <i class="icon-question-sign get-help" title="To build this machine, you must first add the {{o.layer_version.layer.name}} layer to your project"></i>
60 </a>
61 </td>
62</tr>
63{% endfor %}
64
65{% include "basetable_bottom.html" %}
66 85
67{% endblock %} 86{% endblock %}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 2e52d2bff9..7dc4bbd5a2 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2789,11 +2789,38 @@ if toastermain.settings.MANAGED:
2789 2789
2790 queryset_all = Machine.objects.all() 2790 queryset_all = Machine.objects.all()
2791 2791
2792 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name') 2792 prj = Project.objects.get(pk = request.session['project_id'])
2793 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name') 2793 compatible_layers = prj.compatible_layerversions()
2794 # Make sure we only show machines / layers which are compatible with the current project
2795 queryset_all = queryset_all.filter(layer_version__in=compatible_layers)
2794 2796
2795 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True) 2797 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True)
2796 2798
2799 by_pass_filter_string = False
2800 # "special" filters identified by these valid filter strings we
2801 # by pass the usual filter applying method because we're filtering using
2802 # a subquery done by project_layers
2803 if "name:inprj" in filter_string:
2804 queryset_all = queryset_all.filter(layer_version__in=project_layers)
2805 by_pass_filter_string = True
2806
2807 if "name:notinprj" in filter_string:
2808 queryset_all = queryset_all.exclude(layer_version__in=project_layers)
2809 by_pass_filter_string = True
2810
2811 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2812
2813 if by_pass_filter_string:
2814 queryset = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2815 else:
2816 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name')
2817
2818 selected_filter_count = {
2819 'inprj' : queryset.filter(layer_version__in=project_layers).count(),
2820 'notinprj' : queryset.exclude(layer_version__in=project_layers).count()
2821 }
2822
2823
2797 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display 2824 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display
2798 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 2825 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2799 2826
@@ -2802,7 +2829,7 @@ if toastermain.settings.MANAGED:
2802 'project_layers' : project_layers, 2829 'project_layers' : project_layers,
2803 'objectname' : "machines", 2830 'objectname' : "machines",
2804 'default_orderby' : 'name:+', 2831 'default_orderby' : 'name:+',
2805 'total_count': queryset_with_search.count(), 2832 'total_count': machine_info.paginator.count,
2806 2833
2807 'tablecols' : [ 2834 'tablecols' : [
2808 { 'name': 'Machine', 2835 { 'name': 'Machine',
@@ -2840,12 +2867,23 @@ if toastermain.settings.MANAGED:
2840 'hidden' : 1, 2867 'hidden' : 1,
2841 }, 2868 },
2842 { 'name': 'Select', 2869 { 'name': 'Select',
2843 'dclass': 'span2', 2870 'dclass': 'select span2',
2844 'qhelp': "Add or delete machines to / from your project ", 2871 'qhelp': "Sets the selected machine as the project machine. You can only have one machine per project",
2872 'filter': {
2873 'class': 'select',
2874 'label': 'Show:',
2875 'options': [
2876 (u'Machines provided by layers added to this project', 'name:inprj', selected_filter_count['inprj']),
2877 (u'Machines provided by layers not added to this project', 'name:notinprj', selected_filter_count['notinprj']),
2878
2879 ],
2880 }
2881
2845 }, 2882 },
2846 2883
2847 ] 2884 ]
2848 } 2885 }
2886
2849 response = render(request, template, context) 2887 response = render(request, template, context)
2850 _save_parameters_cookies(response, pagesize, orderby, request) 2888 _save_parameters_cookies(response, pagesize, orderby, request)
2851 2889