]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: most-build-targets bug fixes
authorDave Lerner <dave.lerner@windriver.com>
Sat, 14 Mar 2015 14:00:15 +0000 (09:00 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 24 Mar 2015 22:54:38 +0000 (22:54 +0000)
Fixes for the following for the "Most built targets" section of the
project page:
1) limit the number of most built targets to 5,
2) order the list of most built targets by build count,
3) select only those builds that had build status of 'fail', 'success',
or a BuildRequest of 'failed',
4) if there are no layers in the project then (on refresh) all of the
checkboxes in the 'Most built targets' list are disabled.

Note that per agreement with UI designer, the only sort on the most
target list is build count as described in (3) above; secondary sorting
is random.

[YOCTO #7177]

Signed-off-by: Dave Lerner <dave.lerner@windriver.com>
lib/toaster/toastergui/static/js/projectapp.js
lib/toaster/toastergui/templates/project.html
lib/toaster/toastergui/views.py

index 26e054dc238562d0eda2f921ab5ae385acde80e9..0b6e0126ddfdb6715fbb56cb32a49d3f50feda0c 100644 (file)
@@ -484,11 +484,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
                                  layerAdd: selectedArray.join(","),
                              }
                          }).then(function () {
+                             $scope.adjustMostBuiltItems(selectedArray.length);
                              $scope.layerAddName = undefined;
                          });
                      });
                  }
                  else {
+                         $scope.adjustMostBuiltItems(1);
                          $scope._makeXHRCall({
                              method: "POST", url: $scope.urls.xhr_edit,
                              data: {
@@ -503,6 +505,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
     };
 
     $scope.layerDel = function(id) {
+        $scope.adjustMostBuiltItems(-1);
         $scope._makeXHRCall({
             method: "POST", url: $scope.urls.xhr_edit,
             data: {
@@ -511,6 +514,14 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
         });
     };
 
+    $scope.adjustMostBuiltItems = function(listDelta) {
+        $scope.layerCount += listDelta;
+        $scope.mutedtargets = ($scope.layerCount == 0 ? "muted" : "");
+    };
+
+/*
+*/
+
 
     /**
      * Verifies if a project settings change would trigger layer updates. If user confirmation is needed,
@@ -799,6 +810,14 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
         return keys.length === 0;
     };
 
+    $scope.disableBuildCheckbox = function(t) {
+        if ( $scope.layerCount == 0 ) {
+            $scope.mostBuiltTargets[t] = 0;
+            return true;
+        };
+        return false;
+    }
+
     $scope.buildSelectedTargets = function () {
         var keys = Object.keys($scope.mostBuiltTargets);
         keys = keys.filter(function (e) { if ($scope.mostBuiltTargets[e]) return e; });
index 40048c2f2c6e5ed3c4411474a9563d783b2032de..9d51a57208ea28ca339af0d0a1fd9012d9b16660 100644 (file)
@@ -328,10 +328,10 @@ vim: expandtab tabstop=2
         <h4 class="air">
             Most built targets
         </h4>
-        <ul class="unstyled configuration-list">
+          <ul class="unstyled configuration-list {[mutedtargets]}">
           <li ng-repeat="t in frequenttargets">
             <label class="checkbox">
-              <input type="checkbox" ng-model="mostBuiltTargets[t]">{[t]}
+              <input type="checkbox" ng-model="mostBuiltTargets[t]" ng-disabled="disableBuildCheckbox(t)" ng-checked="mostBuiltTargets[t] && !disableBuildCheckbox(t)">{[t]}
             </label>
           </li>
         </ul>
@@ -443,7 +443,8 @@ angular.element(document).ready(function() {
   scope.frequenttargets = {{freqtargets|json}};
   scope.machine = {{machine|json}};
   scope.releases = {{releases|json}};
-
+  scope.layerCount = scope.layers.length;
+  scope.mutedtargets = (scope.layerCount == 0 ? "muted" : "")
   var now = (new Date()).getTime();
   scope.todaydate = now - (now % 86400000);
 
index d9999594464597646479f3eff8a52008214298a9..fdd80222abc222dc5cbdfb2401a7640576f607d6 100755 (executable)
@@ -2204,11 +2204,11 @@ if toastermain.settings.MANAGED:
         freqtargets = []
         try:
             freqtargets += map(lambda x: x.target, reduce(lambda x, y: x + y,   map(lambda x: list(x.target_set.all()), Build.objects.filter(project = prj, outcome__lt = Build.IN_PROGRESS))))
-            freqtargets += map(lambda x: x.target, reduce(lambda x, y: x + y,   map(lambda x: list(x.brtarget_set.all()), BuildRequest.objects.filter(project = prj, state__lte = BuildRequest.REQ_QUEUED))))
+            freqtargets += map(lambda x: x.target, reduce(lambda x, y: x + y,   map(lambda x: list(x.brtarget_set.all()), BuildRequest.objects.filter(project = prj, state = BuildRequest.REQ_FAILED))))
         except TypeError:
             pass
         freqtargets = Counter(freqtargets)
-        freqtargets = sorted(freqtargets, key = lambda x: freqtargets[x])
+        freqtargets = sorted(freqtargets, key = lambda x: freqtargets[x], reverse=True)
 
         context = {
             "project" : prj,
@@ -2228,7 +2228,7 @@ if toastermain.settings.MANAGED:
                         "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}},
                     prj.projectlayer_set.all().order_by("id")),
             "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()),
-            "freqtargets": freqtargets,
+            "freqtargets": freqtargets[:5],
             "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()),
             "project_html": 1,
         }