From 42afeb422ea0a5e226cef586353d194d0339bbd7 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Thu, 2 Oct 2014 17:58:15 +0100 Subject: bitbake: toastergui: Various fixes for projects, layers and targets page This is a combined set of fixes for the project, layers and targets pages in the project section of toaster. The fixes correct behaviour and look in various parts of the page, including submitting XHR commands and updating the DOM with the correct info. (Bitbake rev: 96d7738f964784871c928c376cb9fbc9a275cf00) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/bldcontrol/models.py | 33 +- .../lib/toaster/toastergui/static/css/default.css | 4 +- .../lib/toaster/toastergui/static/js/projectapp.js | 24 +- bitbake/lib/toaster/toastergui/templates/base.html | 3 +- .../toastergui/templates/basetable_bottom.html | 13 +- .../lib/toaster/toastergui/templates/layers.html | 124 +++++--- .../toaster/toastergui/templates/mrb_section.html | 11 +- .../lib/toaster/toastergui/templates/project.html | 48 +-- .../lib/toaster/toastergui/templates/targets.html | 340 +++++++++++++-------- bitbake/lib/toaster/toastergui/views.py | 157 +++++----- 10 files changed, 458 insertions(+), 299 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index f72fb8fbc9..e643d08603 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py @@ -42,11 +42,34 @@ class BuildEnvironment(models.Model): def get_artifact_type(self, path): if self.betype == BuildEnvironment.TYPE_LOCAL: - import magic - m = magic.open(magic.MAGIC_MIME_TYPE) - m.load() - return m.file(path) - raise Exception("FIXME: not implemented") + try: + import magic + + # fair warning: this is a mess; there are multiple competeing and incompatible + # magic modules floating around, so we try some of the most common combinations + + try: # we try ubuntu's python-magic 5.4 + m = magic.open(magic.MAGIC_MIME_TYPE) + m.load() + return m.file(path) + except AttributeError: + pass + + try: # we try python-magic 0.4.6 + m = magic.Magic(magic.MAGIC_MIME) + return m.from_file(path) + except AttributeError: + pass + + try: # we try pip filemagic 1.6 + m = magic.Magic(flags=magic.MAGIC_MIME_TYPE) + return m.id_filename(path) + except AttributeError: + pass + + return "binary/octet-stream" + except ImportError: + return "binary/octet-stream" def get_artifact(self, path): if self.betype == BuildEnvironment.TYPE_LOCAL: diff --git a/bitbake/lib/toaster/toastergui/static/css/default.css b/bitbake/lib/toaster/toastergui/static/css/default.css index 9e62c6c8e7..fb20fc9241 100644 --- a/bitbake/lib/toaster/toastergui/static/css/default.css +++ b/bitbake/lib/toaster/toastergui/static/css/default.css @@ -61,8 +61,8 @@ dd p { line-height: 20px; } /* Override default Twitter Boostrap styles for anchor tags inside tables */ td a, td a > code { color: #333333; } -td a > code { white-space: normal; } -td a:hover { color: #000000; text-decoration: underline; } +td code { white-space: normal; } +td a:hover, td a > code:hover { color: #000000; text-decoration: underline; } /* Override default Twitter Bootstrap styles for tr.error */ .table tbody tr.error > td { background-color: transparent; } /* override default Bootstrap behaviour */ diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index e674d8ffd1..b347451e88 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js @@ -92,6 +92,24 @@ projectApp.config(function($interpolateProvider) { $interpolateProvider.endSymbol("]}"); }); + +// add time interval to HH:mm filter +projectApp.filter('timediff', function() { + return function(input) { + function pad(j) { + if (parseInt(j) < 10) {return "0" + j} + return j; + } + seconds = parseInt(input); + minutes = Math.floor(seconds / 60); + seconds = seconds - minutes * 60; + hours = Math.floor(seconds / 3600); + seconds = seconds - hours * 3600; + return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds); + } +}); + + // main controller for the project page projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $location, $cookies, $q, $sce) { @@ -150,7 +168,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc // identify canceled builds here, so we can display them. _diffArrays(oldbuilds, $scope.builds, - function (e,f) { return e.status == f.status && e.id == f.id }, // compare + function (e,f) { return e.id == f.id }, // compare undefined, // added function (e) { // deleted if (e.status == "deleted") return; @@ -421,7 +439,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc }).then( function () { $scope.toggle(elementid); if (data['projectVersion'] != undefined) { - alertText += "" + $scope.release.name + ""; + alertText += "" + $scope.project.release.name + ""; } $scope.displayAlert(alertZone, alertText, "alert-info"); }); @@ -506,7 +524,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc // init code // $scope.init = function() { - $scope.pollHandle = $interval(function () { $scope._makeXHRCall({method: "POST", url: $scope.urls.xhr_edit, data: undefined});}, 4000, 0); + $scope.pollHandle = $interval(function () { $scope._makeXHRCall({method: "GET", url: $scope.urls.xhr_edit, data: undefined});}, 4000, 0); } $scope.init(); diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index d414bfbbde..f377081849 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -1,6 +1,6 @@ {% load static %} - + {% if objectname %} {{objectname|title}} - {% endif %}Toaster @@ -9,6 +9,7 @@ + diff --git a/bitbake/lib/toaster/toastergui/templates/layers.html b/bitbake/lib/toaster/toastergui/templates/layers.html index 51f4dd96e7..db34fe4818 100644 --- a/bitbake/lib/toaster/toastergui/templates/layers.html +++ b/bitbake/lib/toaster/toastergui/templates/layers.html @@ -9,67 +9,66 @@ {% block projectinfomain %}
-
- - - {% include "basetable_top_layers.html" %} - {% for lv in objects %} + {% for o in objects %} - {{lv.layer.name}} - {{lv.layer.summary}} - {{lv.layer_source.name}} - {{lv.layer.vcs_url}} - {% if lv.get_vcs_link_url %} - + {{o.layer.name}} + {% if o.layer.summary %}{{o.layer.summary}}{%endif%} + {{o.layer_source.name}} + {{o.layer.vcs_url}} + {% if o.get_vcs_link_url %} + {% endif %} - {{lv.dirpath}} - {% if lv.dirpath and lv.get_vcs_dirpath_link_url %} - + {{o.dirpath}} + {% if o.dirpath and o.get_vcs_dirpath_link_url %} + {% endif %} - {% if lv.branch %}{{lv.branch}}{% else %}{{lv.up_branch.name}}{% endif %} + {% if o.branch %}{{o.branch}}{% else %}{{o.up_branch.name}}{% endif %} - {% with lvds=lv.dependencies.all%} - {% if lvds.count %} + {% with ods=o.dependencies.all%} + {% if ods.count %} {{lv.layer.name}} dependencies" + title="{{o.layer.name}} dependencies" data-content=""> - {{lvds.count}} + {{ods.count}} {% endif %} {% endwith %} - - - + {% endif %} {% endfor %} {% include "basetable_bottom.html" %} @@ -78,7 +77,7 @@ {%endif%} @@ -81,19 +81,18 @@ function _makeXHRBuildCall(url, data, onsuccess, onfail) { alert("Call failed"); console.log(_data); if (onfail) onfail(data); - } - }); + } }); } function scheduleBuild(url, projectName, buildlist) { console.log("scheduleBuild"); -// _makeXHRBuildCall(url , {targets: buildlist.join(" ")}, function (_data) { + _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) { - $('#latest-builds').prepend('
' + ''+projectName+'
' + + $('#latest-builds').prepend('
' + ''+projectName+'
' + '
' + buildlist.join(" ") + '
Build queued. Your build will start shortly.
'); -// } + }); } diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index 9399b312ca..6a812834d3 100644 --- a/bitbake/lib/toaster/toastergui/templates/project.html +++ b/bitbake/lib/toaster/toastergui/templates/project.html @@ -76,6 +76,14 @@ vim: expandtab tabstop=2
+ + +
@@ -99,11 +107,11 @@ vim: expandtab tabstop=2

Latest builds

-
+
-
{[t.target]}
+
{[e.type]}:
{[e.msg]}
@@ -111,53 +119,51 @@ vim: expandtab tabstop=2
-
{[t.target]}
+
Build queued
-
{[t.target]}
+
Creating build
-
{[t.target]}
+
Build deleted
-
{[t.target]}
-
-
-
Build starting shortly
-
- +
-
-
+
+
-
ETA: at {[b.eta]}
+
ETA: at {[b.build[0].eta|date:"shortDate"]}
- - + +
- {[b.completed_on|date:'dd/MM/yy HH:mm']} + {[b.build[0].completed_on|date:'dd/MM/yy HH:mm']}
-
{[b.errors.len]}
-
{[b.warnings.len]}
-
Build time: {[b.build_time|date:"HH:mm"]} -
+ +
Build time: {[b.build[0].build_time|timediff]} +
+ +
FIXME!
+
diff --git a/bitbake/lib/toaster/toastergui/templates/targets.html b/bitbake/lib/toaster/toastergui/templates/targets.html index 3afdf0a5e9..32a644a743 100644 --- a/bitbake/lib/toaster/toastergui/templates/targets.html +++ b/bitbake/lib/toaster/toastergui/templates/targets.html @@ -9,55 +9,74 @@ {% block projectinfomain %} - - - +
+ +
+ +{% if objects.paginator.count == 0 %} +
+
+ + {% if request.GET.search %}{% endif %} + + + +
+
+ +{% else %} {% include "basetable_top.html" %} {% for o in objects %} - - {{o.name}} ({{o.id}}, {{o.up_id}}) - - - {{o.version}} - {{o.description}} - - {{o.file_path}} - - - {{o.section}} - {{o.license}} - {{o.layer_version.layer.name}} - {{o.layer_source.name}} - {{o.layer_version.commit}} - - - - - Add layer - - - + + {{o.name}} + + + {{o.version}} + {% if o.description %}{{o.description}}{% else %}{{o.summary}}{%endif%} + + {{o.file_path}} + + + {{o.section}} + {{o.license}} + {{o.layer_version.layer.name}} + {{o.layer_source.name}} + + {% if o.layer_version.up_branch %} + {{o.layer_version.up_branch.name}} + {% else %} + + {{o.layer_version.commit|truncatechars:13}} + + {% endif %} + + + + + + {% endfor %} {% include "basetable_bottom.html" %} @@ -65,122 +84,177 @@ -