aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templates/mrb_section.html
blob: 79862bb800527841059e11521e2f82531dfed8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
{% load static %}
{% load projecttags %}
{% load project_url_tag %}
{% load humanize %}

{%if mru and mru.count > 0%}

  {%if mrb_type == 'project' %}
      <h2 class="page-header">
      Latest project builds

      {% if project.is_default %}
          <i class="icon-question-sign get-help heading-help" title="" data-original-title="Builds in this project cannot be started from Toaster: they are started from the command line"></i>
      {% endif %}
      </h2>
  {% else %}
    <div class="page-header top-air">
      <h1>
      Latest builds
      </h1>
    </div>
  {% endif %}
  <div id="latest-builds">
  {% for build in mru %}
  <div data-latest-build-result="{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}{% if mrb_type != 'project' %} project-name{% endif %}">
      {% if mrb_type != 'project' %}
        <span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
            <a href={% project_url build.project %}>
                {{build.project.name}}
            </a>
        </span>
      {% endif %}
        <div class="row-fluid">
          <div class="span3 lead">
    {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
              <a href="{%url 'builddashboard' build.pk%}" class="{%if build.outcome == build.SUCCEEDED %}success{%else%}error{%endif%}">
    {% endif %}
            {% if build.target_set.all.count > 0 %}
                <span data-toggle="tooltip"
                  {% if build.target_set.all.count > 1 %}
                    title="Targets:
                    {% for target in build.target_set.all %}
                        {% if target.task %}
                            {{target.target}}:{{target.task}}
                        {% else %}
                            {{target.target}}
                        {% endif %}
                    {% endfor %}"
                  {% endif %}
                >
                {% if build.target_set.all.0.task %}
                    {{build.target_set.all.0.target}}:{{build.target_set.all.0.task}}
                {% else %}
                    {{build.target_set.all.0.target}}
                {% endif %}
                {% if build.target_set.all.count > 1 %}
                    (+ {{build.target_set.all.count|add:"-1"}})
                {% endif %}
                </span>
             {% endif %}
    {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
                </a>
    {% endif %}
            </div>
    {% if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
            <div class="span2 lead">
                {% if build.completed_on|format_build_date  %}
                    {{ build.completed_on|date:'d/m/y H:i' }}
                {% else %}
                    {{ build.completed_on|date:'H:i' }}
                {% endif %}
            </div>
    {% endif %}
    {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
            <div class="span2 lead">
      {% if  build.errors.count %}
                <i class="icon-minus-sign red"></i> <a href="{%url 'builddashboard' build.pk%}#errors" class="error">{{build.errors.count}} error{{build.errors.count|pluralize}}</a>
      {% endif %}
            </div>
            <div class="span2 lead">
      {% if  build.warnings.count %}
                <i class="icon-warning-sign yellow"></i> <a href="{%url 'builddashboard' build.pk%}#warnings" class="warning">{{build.warnings.count}} warning{{build.warnings.count|pluralize}}</a>
      {% endif %}
            </div>
            <div class="lead ">
              <span class="lead">
                  Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent_seconds|sectohms }}</a>
              </span>
              {% if build.project.is_default %}
                  <i class="pull-right icon-question-sign get-help
                  {% if build.outcome == build.SUCCEEDED %}
                      get-help-green
                  {% elif build.outcome == build.FAILED %}
                      get-help-red
                  {% else %}
                      get-help-blue
                  {% endif %}
                  " title="Builds in this project cannot be started from Toaster: they are started from the command line">
                  </i>
              {% else %}
                  <button class="btn
                      {% if build.outcome == build.SUCCEEDED %}
                          btn-success
                      {% elif build.outcome == build.FAILED %}
                          btn-danger
                      {% else %}
                          btn-info
                      {%endif%}
                      pull-right"
                      onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
                        {{build.project.name|json}},
                        {% url 'project' build.project.id as purl %}{{purl|json}},
                        {{build.target_set.all|get_tasks|json}})'>

                        Run again
                  </button>
              {% endif %}
            </div>
    {%endif%}
    {%if build.outcome == build.IN_PROGRESS %}
            <div id="buildProgress" class="span4 offset1">
                <div id="progressBar" class="progress" style="margin-top:5px;" data-toggle="tooltip" title="{{build.completeper}}% of tasks complete">
                    <div style="width: {{build.completeper}}%;" class="bar"></div>
                </div>
            </div>
            <div id="progressMessage" class="lead pull-right">{{build.completeper}}% of tasks complete</div>
	    {%if not build.project.name == "Command line builds" %}
	         {%if build.get_tasks.0 %}
                         <button id="cancel-build-btn" class="btn btn-info"
                                 onclick='cancelBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
                                 {{build.project.name|json}},
                                 {% url 'project' build.project.id as purl %}{{purl|json}},
                                 {{build.target_set.all|get_tasks|json}}, {{build.id|json}})'>
                          Cancel
                         </button>
	         {%endif%}
	    </div>
	    {%else%}
		<i class="icon-question-sign get-help heading-help pull-right" data-placement="left" title="" data-original-title="Builds in this projects cannot be cancelled from Toaster: they can only be cancelled from the command line"></i>
            {%endif%}
    {%endif%}
    {% if build.outcome == build.CANCELLED %}
        <div class="span6 lead">
            <p class="text-center">Build cancelled</p>
        </div>
        <div class="span3">
            {% if build.project.is_default %}
                <i class="pull-right icon-question-sign get-help get-help-blue" title="Builds in this project cannot be started from Toaster: they are started from the command line"></i>
            {% else %}
                <button class="btn btn-info pull-right"
                    onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
                    {{build.project.name|json}},
                    {% url 'project' build.project.id as purl %}{{purl|json}},
                    {{build.target_set.all|get_tasks|json}})'>
                    Run again
                </button>
            {% endif %}
        </div>
    {% endif %}
        </div>
    </div>

  {% endfor %}
  </div>

<script>

function scheduleBuild(url, projectName, projectUrl, buildlist) {
  console.log("scheduleBuild");
  libtoaster.startABuild(url, null, buildlist.join(" "), function(){
    console.log("reloading page");
    window.location.reload();
  }, null);
}

function cancelBuild(url, projectName, projectUrl, buildlist, buildId) {
  console.log("cancelBuild");
  $('#progressBar').remove();
  $('#progressMessage').remove();
  $('#buildProgress').append('<div class="lead " align="center"> Cancelling the build ...</div>');
  libtoaster.cancelABuild(url, buildId, function(){
    console.log("reloading page");
    window.location.reload();
  }, null);
}

</script>

{%endif%}