summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/machines.js89
-rw-r--r--bitbake/lib/toaster/toastergui/templates/machines.html99
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py12
3 files changed, 146 insertions, 54 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/machines.js b/bitbake/lib/toaster/toastergui/static/js/machines.js
new file mode 100644
index 0000000000..a3ea43baed
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/static/js/machines.js
@@ -0,0 +1,89 @@
1"use strict"
2
3function machinesPageInit (ctx) {
4
5
6 function setLayerInCurrentPrj(addLayerBtn, depsList){
7 var alertMsg = $("#alert-msg");
8
9 $(".select-or-add").each(function(){
10 /* If we have added a layer it may also enable other machines so search
11 * for other machines that have that layer and enable them */
12 var selectMachineBtn = $(this).children(".select-machine-btn");
13 var otherAddLayerBtns = $(this).children(".add-layer");
14
15 if (addLayerBtn.data('layer-version-id') == selectMachineBtn.data('layer-version-id')) {
16 otherAddLayerBtns.fadeOut(function(){
17 selectMachineBtn.fadeIn();
18 });
19 }
20 });
21
22 /* Reset alert message */
23 alertMsg.text("");
24
25 /* If we have added layer dependencies */
26 if (depsList) {
27 alertMsg.append("You have added <strong>"+(depsList.length+1)+"</strong> layers: <span id=\"layer-affected-name\"></span> and its dependencies ");
28
29 /* Build the layer deps list */
30 depsList.map(function(layer, i){
31 var link = $("<a></a>");
32
33 link.attr("href", layer.layerdetailurl);
34 link.text(layer.name);
35 link.tooltip({title: layer.tooltip});
36
37 if (i != 0)
38 alertMsg.append(", ");
39
40 alertMsg.append(link);
41 });
42 } else {
43 alertMsg.append("You have added <strong>1</strong> layer: <span id=\"layer-affected-name\"></span>");
44 }
45
46 var layerName = addLayerBtn.data('layer-name');
47 alertMsg.children("#layer-affected-name").text(layerName);
48 $("#alert-area").show();
49 }
50
51 /* Add or remove this layer from the project */
52 $(".add-layer").click(function() {
53 var btn = $(this);
54 /* If adding get the deps for this layer */
55 var layer = {
56 id : $(this).data('layer-version-id'),
57 name : $(this).data('layer-name'),
58 };
59
60 libtoaster.getLayerDepsForProject(ctx.xhrDataTypeaheadUrl, ctx.projectId, layer.id, function (data) {
61 /* got result for dependencies */
62 if (data.list.length == 0){
63 var editData = { layerAdd : layer.id };
64 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, editData,
65 function() {
66 setLayerInCurrentPrj(btn);
67 });
68 return;
69 } else {
70 /* The add deps will include this layer so no need to add it
71 * separately.
72 */
73 show_layer_deps_modal(ctx.projectId, layer, data.list, null, null, true, function () {
74 /* Success add deps and layer */
75 setLayerInCurrentPrj(btn, data.list);
76 console.log ("TODO SUCCESS");
77 });
78 }
79 }, null);
80 });
81
82 $(".select-machine-btn").click(function(){
83 var data = { machineName : $(this).data('machine-name') };
84 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, data,
85 function (){
86 window.location.replace(ctx.projectPageUrl);
87 }, null);
88 });
89}
diff --git a/bitbake/lib/toaster/toastergui/templates/machines.html b/bitbake/lib/toaster/toastergui/templates/machines.html
index e0bda51cf5..c0d4c6cc33 100644
--- a/bitbake/lib/toaster/toastergui/templates/machines.html
+++ b/bitbake/lib/toaster/toastergui/templates/machines.html
@@ -1,62 +1,65 @@
1{% extends "baseprojectpage.html" %} 1{% extends "baseprojectpage.html" %}
2{% load projecttags %} 2{% load projecttags %}
3{% load humanize %} 3{% load humanize %}
4 4{% load static %}
5{% block localbreadcrumb %} 5{% block localbreadcrumb %}
6<li>All compatible machines</li> 6<li>All compatible machines</li>
7{% endblock %} 7{% endblock %}
8 8
9{% block projectinfomain %} 9{% block projectinfomain %}
10 <div class="page-header"> 10<script src="{% static 'js/machines.js' %}"></script>
11 <h1> 11<script>
12 All compatible machines 12
13 <i class="icon-question-sign get-help heading-help" title="This page lists all the machines compatible with the release selected for this project, which is {{project.release.description}}"></i> 13 $(document).ready(function (){
14 </h1> 14 var ctx = {
15 </div> 15 projectPageUrl : "{% url 'project' project.id %}",
16 <!--div class="alert"> 16 xhrEditProjectUrl : "{% url 'xhr_projectedit' project.id %}",
17 <div class="input-append" style="margin-bottom:0px;"> 17 projectId : {{project.id}},
18 <input class="input-xxlarge" type="text" placeholder="Search targets" value="browser" /> 18 xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' %}",
19 <a class="add-on btn"> 19 };
20 <i class="icon-remove"></i> 20
21 </a> 21 try {
22 <button class="btn" type="button">Search</button> 22 machinesPageInit(ctx);
23 <a class="btn btn-link" href="#">Show all targets</a> 23 } catch (e) {
24 </div> 24 document.write("Sorry, An error has occurred loading this page");
25 </div--> 25 console.warn(e);
26 <div id="target-added" class="alert alert-info lead" style="display:none;"></div> 26 }
27 <div id="target-removed" class="alert alert-info lead" style="display:none;"> 27 });
28 <button type="button" class="close" data-dismiss="alert">&times;</button> 28</script>
29 <strong>1</strong> target deleted from <a href="project-with-targets.html">your project</a>: <a href="#">meta-aarch64</a> 29{% include "layers_dep_modal.html" %}
30 </div> 30<div class="page-header">
31 <h1>
32 All machines
33 <i class="icon-question-sign get-help heading-help" title="This page lists all the machines compatible with Yocto Project 1.7 'Dxxxx' that Toaster knows about. They include community-created targets suitable for use on top of OpenEmbedded Core and any targets you have imported"></i>
34 </h1>
35</div>
31 36
37<div class="alert alert-info lead" id="alert-area" style="display:none">
38 <button type="button" class="close" id="dismiss-alert" data-dismiss="alert">&times;</button>
39 <span id="alert-msg"></span>
40 <p style="margin-top:10px;"><a href="{% url 'project' project.id %}">Go to project configuration</a></p>
41</div>
32 42
33{% include "basetable_top.html" %} 43{% include "basetable_top.html" %}
34 {% for o in objects %} 44{% for o in objects %}
35 <tr class="data"> 45<tr class="data">
36 <td class="machine"> 46 <td class="machine">{{o.name}}</td>
37 {{o.name}} 47 <td class="description">{{o.description}}</td>
38 <a machine="_blank" href="http://layers.openembedded.org/layerindex/branch/master/machines/?q=3g-router-image"><i class="icon-share get-info"></i></a> 48 <td class="layer"><a href="{%url "layerdetails" o.layer_version.id %}">{{o.layer_version.layer.name}}</a></td>
39 </td> 49 <td class="source">{{o.layer_source.name}}</td>
40 <td class="description">{{o.description}}</td> 50 <td class="branch">{{o.layer_version.commit}}</td>
41 <td class="machine-file"> 51 <td class="select-or-add">
42 <code>{{o.file_path}}</code> 52 <a href="#" class="btn btn-block select-machine-btn" data-machine-name="{{o.name}}" data-layer-version-id="{{o.layer_version.id}}"
43 <a href="http://github.com/embeddedgeeks/meta-embeddedgeeks/blob/master/machines-core/images/3g-router-image.bb" machine="_blank"><i class="icon-share get-info"></i></a> 53 {%if o.layer_version.id not in project_layers %}style="display:none" {%endif%} >Select machine</a>
44 </td> 54 <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%}
45 <td class="layer"><a href="#">{{o.layer_version.layer.name}}</a></td> 55 >
46 <td class="source">{{o.layer_source.name}}</td> 56 <i class="icon-plus"></i>
47 <td class="branch">{{o.layer_version.commit}}</td> 57 Add layer
48 <td class="build"> 58 <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>
49 <a id="build-machine" href="project-with-machines.html?machine=3g-router-image" class="btn btn-block" style="display:none;"> 59 </a>
50 Build machine 60 </td>
51 </a> 61</tr>
52 <a id="add-layer" href="#" class="btn btn-block nopop" title="1 layer added"> 62{% endfor %}
53 <i class="icon-plus"></i>
54 Add layer
55 <i class="icon-question-sign get-help" title="To build this machine, you must first add the meta-embeddedgeeks layer to your project"></i>
56 </a>
57 </td>
58 </tr>
59 {% endfor %}
60 63
61{% include "basetable_bottom.html" %} 64{% include "basetable_bottom.html" %}
62 65
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 73a5c7e99f..641170e639 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2770,6 +2770,9 @@ if toastermain.settings.MANAGED:
2770 return response 2770 return response
2771 2771
2772 def machines(request): 2772 def machines(request):
2773 if not 'project_id' in request.session:
2774 raise Exception("invalid page: cannot show page without a project")
2775
2773 template = "machines.html" 2776 template = "machines.html"
2774 # define here what parameters the view needs in the GET portion in order to 2777 # define here what parameters the view needs in the GET portion in order to
2775 # be able to display something. 'count' and 'page' are mandatory for all views 2778 # be able to display something. 'count' and 'page' are mandatory for all views
@@ -2785,18 +2788,19 @@ if toastermain.settings.MANAGED:
2785 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine) 2788 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine)
2786 2789
2787 queryset_all = Machine.objects.all() 2790 queryset_all = Machine.objects.all()
2788# if 'project_id' in request.session:
2789# queryset_all = queryset_all.filter(Q(layer_version__up_branch__name = Project.objects.get(request.session['project_id']).release.branch_name) | Q(layer_version__build__in = Project.objects.get(request.session['project_id']).build_set.all()))
2790 2791
2791 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name') 2792 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2792 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name') 2793 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name')
2793 2794
2795 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True)
2796
2794 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display 2797 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display
2795 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 2798 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2796 2799
2797 2800
2798 context = { 2801 context = {
2799 'objects' : machine_info, 2802 'objects' : machine_info,
2803 'project_layers' : project_layers,
2800 'objectname' : "machines", 2804 'objectname' : "machines",
2801 'default_orderby' : 'name:+', 2805 'default_orderby' : 'name:+',
2802 'total_count': queryset_with_search.count(), 2806 'total_count': queryset_with_search.count(),
@@ -2810,10 +2814,6 @@ if toastermain.settings.MANAGED:
2810 'dclass': 'span5', 2814 'dclass': 'span5',
2811 'clclass': 'description', 2815 'clclass': 'description',
2812 }, 2816 },
2813 { 'name': 'Machine file',
2814 'clclass': 'machine-file',
2815 'hidden': 1,
2816 },
2817 { 'name': 'Layer', 2817 { 'name': 'Layer',
2818 'clclass': 'layer', 2818 'clclass': 'layer',
2819 }, 2819 },