summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-08-12 10:56:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-29 13:56:49 +0100
commit565f69205f130644dee136c8296dd0dc979e492b (patch)
tree7b4588b88656c13401e8f0341e73fcb8e8045321 /bitbake/lib/toaster
parent3a4356dbfea07088b38881abe2c2b5d6bb6c7cf7 (diff)
downloadpoky-565f69205f130644dee136c8296dd0dc979e492b.tar.gz
bitbake: toaster: add all layers page
We add a page where the user can browse and import layers from all the layers known by Toaster. [YOCTO #6590] (Bitbake rev: 59f4a9750a6c4f5360a91e3a4d1c03ceb42da086) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rwxr-xr-xbitbake/lib/toaster/toastergui/templates/layers.html173
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py74
2 files changed, 246 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/layers.html b/bitbake/lib/toaster/toastergui/templates/layers.html
new file mode 100755
index 0000000000..d7d159e1e6
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/templates/layers.html
@@ -0,0 +1,173 @@
1{% extends "base.html" %}
2{% load projecttags %}
3{% load humanize %}
4{% block pagecontent %}
5 <div class="page-header">
6 <h1>
7 All layers
8 <i class="icon-question-sign get-help heading-help" title="This page lists all the layers compatible with Yocto Project 1.7 'Dxxxx' that Toaster knows about. They include community-created layers suitable for use on top of OpenEmbedded Core and any layers you have imported"></i>
9 </h1>
10 </div>
11 <!--div class="alert">
12 <div class="input-append" style="margin-bottom:0px;">
13 <input class="input-xxlarge" type="text" placeholder="Search layers" value="browser" />
14 <a class="add-on btn">
15 <i class="icon-remove"></i>
16 </a>
17 <button class="btn" type="button">Search</button>
18 <a class="btn btn-link" href="#">Show all layers</a>
19 </div>
20 </div-->
21 <div id="layer-added" class="alert alert-info lead" style="display:none;"></div>
22 <div id="layer-removed" class="alert alert-info lead" style="display:none;">
23 <button type="button" class="close" data-dismiss="alert">&times;</button>
24 <strong>1</strong> layer deleted from <a href="project-with-targets.html">your project</a>: <a href="#">meta-aarch64</a>
25 </div>
26
27
28{% include "basetable_top.html" %}
29 {% for lv in objects %}
30 <tr class="data">
31 <td class="layer">{{lv.layer.name}}</td>
32 <td class="description">{{lv.layer.summary}}</td>
33 <td class="source"><a href="{% url 'layerdetails' lv.pk %}">{{lv.layer_source.name}}</a></td>
34 <td class="git-repo"><a href="{% url 'layerdetails' lv.pk %}"><code>{{lv.layer.layer_index_url}}</code></a></td>
35 <td class="git-subdir" style="display: table-cell;"><a href="{% url 'layerdetails' lv.pk %}"><code>{{lv.dirpath}}</code></a></td>
36 <td class="branch">{% if lv.branch %}{{lv.branch}}{% else %}{{lv.up_branch.name}}{% endif %}</td>
37 <td class="dependencies">{% for lvs in lv.dependencies.all %}{{lvs.layer.name}}<br/>{%endfor%}</td>
38 <td class="add-layers">
39 <button id="remove-layer-{{lv.pk}}" class="btn btn-danger btn-block remove-layer" title="1 layer deleted" style="display:none;">
40 <i class="icon-trash"></i>
41 Delete layer
42 </button>
43 <button id="add-layer-{{lv.pk}}" class="btn btn-block add-layer" title="1 layer added">
44 <i class="icon-plus"></i>
45 Add layer
46 </button>
47 </td>
48 </tr>
49 {% endfor %}
50{% include "basetable_bottom.html" %}
51
52 <!-- Modals -->
53
54 <!-- 'Layer dependencies modal' -->
55 <div id="dependencies-message" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
56 <div class="modal-header">
57 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
58 <h3>meta-acer dependencies</h3>
59 </div>
60 <div class="modal-body">
61 <p><strong>meta-acer</strong> depends on some layers that are not added to your project. Select the ones you want to add:</p>
62 <ul class="unstyled">
63 <li>
64 <label class="checkbox">
65 <input type="checkbox" checked="checked">
66 meta-android
67 </label>
68 </li>
69 <li>
70 <label class="checkbox">
71 <input type="checkbox" checked="checked">
72 meta-oe
73 </label>
74 </li>
75 </ul>
76 </div>
77 <div class="modal-footer">
78 <button id="add-layer-dependencies" type="submit" class="btn btn-primary" data-dismiss="modal" >Add layers</button>
79 <button class="btn" data-dismiss="modal">Cancel</button>
80 </div>
81 </div>
82
83 <script src="assets/js/jquery-1.9.1.min.js" type='text/javascript'></script>
84 <script src="assets/js/jquery.tablesorter.min.js" type='text/javascript'></script>
85 <script src="assets/js/jquery-ui-1.10.3.custom.min.js"></script>
86 <script src="assets/js/bootstrap.min.js" type='text/javascript'></script>
87 <script src="assets/js/prettify.js" type='text/javascript'></script>
88 <script src="assets/js/jit.js" type='text/javascript'></script>
89 <script src="assets/js/main.js" type='text/javascript'></script>
90
91 <script>
92 $(document).ready(function() {
93
94 //show or hide selected columns on load
95 $("input:checkbox").each(function(){
96 var selectedType = $(this).val();
97 if($(this).is(":checked")){
98 $("."+selectedType).show();
99 }
100 else{
101 $("."+selectedType).hide();
102 }
103 });
104
105 // enable add layer button
106 $('#add-layer-with-deps').removeAttr('disabled');
107
108 //edit columns functionality (show / hide table columns)
109 $("input:checkbox").change();
110 $("input:checkbox").change(function(){
111 var selectedType = $(this).val();
112 if($(this).is(":checked")){
113 $("."+selectedType).show();
114 }
115 else{
116 $("."+selectedType).hide();
117 }
118 });
119
120 //turn edit columns dropdown into a multi-select menu
121 $('.dropdown-menu input, .dropdown-menu label').click(function(e) {
122 e.stopPropagation();
123 });
124
125 //show tooltip with applied filter
126 $('#filtered').tooltip({container:'table', placement:'bottom', delay:{hide:1500}, html:true});
127
128 $('#filtered').click(function() {
129 $(this).tooltip('hide');
130 });
131
132 //show layer added tooltip
133 $("#remove-layer, #add-layer, #add-layer-with-deps2").tooltip({ trigger: 'manual' });
134
135 // add layer without dependencies
136 $("#add-layer").click(function(){
137 $('#layer-removed').hide();
138 $('#layer-added').html('<button type="button" class="close" data-dismiss="alert">&times;</button><strong>1</strong> layer added to <a href="project-with-targets.html">your project</a>: <a href="#">meta-aarch64</a>').fadeIn();
139 $('#add-layer').tooltip('show');
140 $("#add-layer").hide();
141 $(".add-layers .tooltip").delay(2000).fadeOut(function(){
142 $("#remove-layer").delay(300).fadeIn();
143 });
144 });
145
146 // add layer with dependencies
147 $(document).on("click", "#add-layer-dependencies", function() {
148 $('#layer-removed').hide();
149 $('#layer-added').html('<button type="button" class="close" data-dismiss="alert">&times;</button><strong>3</strong> layers added to <a href="project-with-targets.html">your project</a>: <a href="#">meta-acer</a> and its dependencies <a href="#">meta-android</a> and <a href="#">meta-oe</a>').delay(400).fadeIn(function(){
150 $('#add-layer-with-deps').tooltip('show');
151 $("#add-layer-with-deps, #add-layer-with-deps").hide();
152 $(".add-layers .tooltip").delay(2000).fadeOut(function(){
153 $("#remove-layer-with-deps").delay(300).fadeIn();
154 });
155 });
156 });
157
158 // delete layer
159 $("#remove-layer").click(function(){
160 $('#layer-added').hide();
161 $('#layer-removed').show();
162 $('#remove-layer').tooltip('show');
163 $("#remove-layer").hide();
164 $(".add-layers .tooltip").delay(2000).fadeOut(function(){
165 $("#add-layer").delay(300).fadeIn();
166 });
167 });
168
169 });
170
171</script>
172
173{% endblock %}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index cad23570f8..5b2336509a 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1849,6 +1849,9 @@ if toastermain.settings.MANAGED:
1849 except User.DoesNotExist: 1849 except User.DoesNotExist:
1850 puser = None 1850 puser = None
1851 1851
1852 # we use implicit knowledge of the current user's project to filter layer information, e.g.
1853 request.session['project'] = prj
1854
1852 context = { 1855 context = {
1853 "project" : prj, 1856 "project" : prj,
1854 #"buildrequests" : prj.buildrequest_set.filter(state=BuildRequest.REQ_QUEUED), 1857 #"buildrequests" : prj.buildrequest_set.filter(state=BuildRequest.REQ_QUEUED),
@@ -1926,7 +1929,76 @@ if toastermain.settings.MANAGED:
1926 raise Exception("TODO: implement page #6595") 1929 raise Exception("TODO: implement page #6595")
1927 1930
1928 def layers(request): 1931 def layers(request):
1929 raise Exception("TODO: implement page #6590") 1932 # "TODO: implement page #6590"
1933 template = "layers.html"
1934 # define here what parameters the view needs in the GET portion in order to
1935 # be able to display something. 'count' and 'page' are mandatory for all views
1936 # that use paginators.
1937 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'layer__name:-' };
1938 retval = _verify_parameters( request.GET, mandatory_parameters )
1939 if retval:
1940 return _redirect_parameters( 'layers', request.GET, mandatory_parameters)
1941
1942 # boilerplate code that takes a request for an object type and returns a queryset
1943 # for that object type. copypasta for all needed table searches
1944 (filter_string, search_term, ordering_string) = _search_tuple(request, Layer_Version)
1945
1946 queryset_all = Layer_Version.objects.all()
1947 if 'project' in request.session:
1948 queryset_all = queryset_all.filter(up_branch = request.session['project'].branch)
1949
1950 queryset_with_search = _get_queryset(Layer_Version, queryset_all, None, search_term, ordering_string, '-layer__name')
1951 queryset = _get_queryset(Layer_Version, queryset_all, filter_string, search_term, ordering_string, '-layer__name')
1952
1953 # retrieve the objects that will be displayed in the table; layers a paginator and gets a page range to display
1954 layer_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
1955
1956
1957 context = {
1958 'objects' : layer_info,
1959 'objectname' : "layers",
1960 'default_orderby' : 'completed_on:-',
1961
1962 'tablecols' : [
1963 { 'name': 'Layer',
1964 'orderfield': _get_toggle_order(request, "layer__name"),
1965 'ordericon' : _get_toggle_order_icon(request, "layer__name"),
1966 },
1967 { 'name': 'Description',
1968 'dclass': 'span4',
1969 },
1970 { 'name': 'Layer source',
1971 'qhelp': "Where the layer is coming from, for example, if it's part of the OpenEmbedded collection of layers or if it's a layer you have imported",
1972 'orderfield': _get_toggle_order(request, "layer_source__name"),
1973 'ordericon': _get_toggle_order_icon(request, "layer_source__name"),
1974 'filter': {
1975 'class': 'layer',
1976 'label': 'Show:',
1977 'options': map(lambda x: (x.name, 'layer_source__pk:' + str(x.id), queryset_with_search.filter(layer_source__pk = x.id).count() ), LayerSource.objects.all()),
1978 }
1979 },
1980 { 'name': 'Git repository URL',
1981 'dclass': 'span6',
1982 'qhelp': "The Git repository for the layer source code",
1983 },
1984 { 'name': 'Subdirectory',
1985 'qhelp': "The layer directory within the Git repository",
1986 },
1987 { 'name': 'Branch, tag o commit',
1988 'qhelp': "The Git branch of the layer. For the layers from the OpenEmbedded source, the branch matches the Yocto Project version you selected for this project",
1989 },
1990 { 'name': 'Dependencies',
1991 'qhelp': "Other layers a layer depends upon",
1992 },
1993 { 'name': 'Add | Delete',
1994 'dclass': 'span2',
1995 'qhelp': "Add or delete layers to / from your project ",
1996 },
1997
1998 ]
1999 }
2000
2001 return render(request, template, context)
1930 2002
1931 def layerdetails(request, layerid): 2003 def layerdetails(request, layerid):
1932 raise Exception("TODO: implement page #6591") 2004 raise Exception("TODO: implement page #6591")