Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B2384E008C9; Wed, 5 Nov 2014 16:33:52 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.44 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id CB9E0E0080D for ; Wed, 5 Nov 2014 16:33:39 -0800 (PST) Received: by mail-wg0-f44.google.com with SMTP id x12so2223639wgg.31 for ; Wed, 05 Nov 2014 16:33:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oqw8qWjAdVkxWualmTgrRFWKrHPAoDmLlJgLrKmrNHQ=; b=BrqTn3sSjw9A2gPTpxDIskfDvB5qnOfPols4FIaNmdBiuVaaTDMyJULmXK/+fd80T1 nz/HqzV3X1Re/wy2X/Pq7OMS/gB9U41lZqBIIYouKkgWIozyBGf11srpBV21hkXl3zo0 PTmvH7lJD4F3RY2HlXFER/yGtr2UU0FZ+EMQsVMFRV7Z1nAhhbmOhpDyqoX4kPRtMULN ybAcxDVIdxNdeo58DEUAaaIqHlwrICGacdPNXUrvWRmIg/KHGMoMYjeG3+MsvMPnI1Yh yb5DqXFJfJnKR6chMyjn0DjU8J7IdYdq1GSrWz+64X2WLjt3bVR8PvImcOpWSyhS66O+ wtTw== X-Gm-Message-State: ALoCoQl7VSAN4RsvPhGEqYN3hm98Pkhbz73PmJacy4sZ2aShW9XDYu+t2jvqj/vVXzH9YsiojTBh X-Received: by 10.195.13.114 with SMTP id ex18mr694457wjd.111.1415234018712; Wed, 05 Nov 2014 16:33:38 -0800 (PST) Received: from adamian-desk.corp.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id rx8sm5831147wjb.30.2014.11.05.16.33.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 16:33:37 -0800 (PST) Received: by adamian-desk.corp.intel.com (Postfix, from userid 1000) id 7AFC9561E06; Wed, 5 Nov 2014 18:42:06 +0000 (GMT) From: Alex DAMIAN To: poky@yoctoproject.org Date: Wed, 5 Nov 2014 18:42:05 +0000 Message-Id: <1415212925-10184-1-git-send-email-alexandru.damian@intel.com> X-Mailer: git-send-email 1.9.1 Cc: Alexandru DAMIAN Subject: [PATCH 1/1] bitbake: toastergui: Various fixes for projects, layers and targets page X-BeenThere: poky@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Poky build system developer discussion & patch submission for meta-yocto List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 00:33:52 -0000 From: Alexandru DAMIAN 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. Signed-off-by: Alexandru DAMIAN --- 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 | 113 ++++--- .../toaster/toastergui/templates/mrb_section.html | 17 +- .../lib/toaster/toastergui/templates/project.html | 48 +-- .../lib/toaster/toastergui/templates/targets.html | 337 +++++++++++++-------- bitbake/lib/toaster/toastergui/views.py | 157 +++++----- 10 files changed, 453 insertions(+), 296 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index 15270c3..23d9905 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 9e62c6c..fb20fc9 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 e674d8f..b347451 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 d414bfb..f377081 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 51f4dd9..3dd2b1f 100644 --- a/bitbake/lib/toaster/toastergui/templates/layers.html +++ b/bitbake/lib/toaster/toastergui/templates/layers.html @@ -9,14 +9,14 @@ {% block projectinfomain %} @@ -25,51 +25,51 @@ - - - {% 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}} + {{o.layer.summary}} + {{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" %} @@ -95,8 +95,11 @@ +{% if project %} +{%endif%} {% endblock %} diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html index 5ba0b08..586c47b 100644 --- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html @@ -44,7 +44,7 @@ Build time: {{ build.timespent|sectohms }} {% if build.project %} - Run again + Run again {% endif %} {%endif%} @@ -64,10 +64,10 @@ diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index 9399b31..6a81283 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 3afdf0a..042d0fc 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,174 @@ -