Skip to contentSkip to conversation

Toaster bugfixing patchset

PATCH In review Alex DAMIAN 1 participant 10 messages Apr 16, 2015 – Apr 27, 2015

lore
Share & tools
lore
#0 lore raw

cover Toaster bugfixing patchset

From: Alexandru DAMIAN <[email protected]>

Hello,

This is a Toaster bugfixing patchset that has been reviewed on the toaster mailinglist. Can you please pull whenever convenient ?

Cheers,
Alex

The following changes since commit c4172fe33f0c63eda7f4af2bd36a5e9738e13595:

bitbake-layers: ensure non-extended recipe name is preferred (2015-04-11 16:14:30 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib adamian/20150416-submission-bb
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=adamian/20150416-submission-bb

Belen Barros Pena (2):
toasterui: correct terminology in landing page
toasterui: remove 'targets' from project notification

David Reyna (4):
toaster: add layer source in admin throws an error
toaster: searching all projects table resets page count
toaster: recipe path broken in recipe detail page
toaster: date range filter for project builds page

Michael Wood (2):
toaster: base.js minor jshint fixes
toaster: BuildButton target input allow building targets with tasks

 lib/toaster/orm/models.py                          | 28 ++++++++++++++++------
 lib/toaster/toastergui/static/js/base.js           | 24 +++++++++----------
 lib/toaster/toastergui/static/js/libtoaster.js     |  9 ++++---
 lib/toaster/toastergui/static/js/projectapp.js     |  2 +-
 lib/toaster/toastergui/templates/landing.html      |  2 +-
 .../toastergui/templates/projectbuilds.html        | 16 +++++++++++++
 lib/toaster/toastergui/templates/recipes.html      |  2 +-
 lib/toaster/toastergui/views.py                    |  5 +++-
 8 files changed, 59 insertions(+), 29 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/8 toaster: base.js minor jshint fixes

From: Michael Wood <[email protected]>

Fixing errors identified by jshint, some missing semicolons and preference for === operator. Also pass the urldata in libtoaster as an object rather than constructing a query string.

---
 lib/toaster/toastergui/static/js/base.js       | 19 +++++++++----------
 lib/toaster/toastergui/static/js/libtoaster.js |  9 ++++-----
 2 files changed, 13 insertions(+), 15 deletions(-)
lib/toaster/toastergui/static/js/base.js +9 -10
index 777ab43..241c5d2 100644
@@ -6,7 +6,7 @@ function basePageInit (ctx) {
   /* Hide the button if we're on the project,newproject or importlyaer page
    * or if there are no projects yet defined
    */
-  if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
+  if (ctx.numProjects === 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
       newBuildButton.hide();
       return;
   }
@@ -18,17 +18,17 @@ function basePageInit (ctx) {
 
   newBuildButton.show().removeAttr("disabled");
 
-  _checkProjectBuildable()
+  _checkProjectBuildable();
   _setupNewBuildButton();
 
 
   function _checkProjectBuildable(){
-    if (ctx.projectId == undefined)
+    if (ctx.projectId === undefined)
       return;
 
     libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId,
       function(data){
-        if (data.machine.name == undefined || data.layers.length == 0) {
+        if (data.machine.name === undefined || data.layers.length === 0) {
           /* we can't build anything with out a machine and some layers */
           $("#new-build-button #targets-form").hide();
           $("#new-build-button .alert").show();
@@ -51,7 +51,7 @@ function basePageInit (ctx) {
     /* If we don't have a current project then present the set project
      * form.
      */
-    if (ctx.projectId == undefined) {
+    if (ctx.projectId === undefined) {
       $('#change-project-form').show();
       $('#project .icon-pencil').hide();
     }
@@ -72,13 +72,13 @@ function basePageInit (ctx) {
      * the value that has been set by selecting a suggestion from the typeahead
      */
     newBuildProjectInput.on('input', function(event) {
-        if (event.keyCode == 13)
+        if (event.keyCode === 13)
           return;
         newBuildProjectSaveBtn.attr("disabled", "disabled");
     });
 
     newBuildTargetInput.on('input', function() {
-      if ($(this).val().length == 0)
+      if ($(this).val().length === 0)
         newBuildTargetBuildBtn.attr("disabled", "disabled");
       else
         newBuildTargetBuildBtn.removeAttr("disabled");
@@ -96,7 +96,7 @@ function basePageInit (ctx) {
     });
 
     newBuildProjectSaveBtn.click(function() {
-      ctx.projectId = selectedProject.id
+      ctx.projectId = selectedProject.id;
       /* Update the typeahead project_id paramater */
       _checkProjectBuildable();
       newBuildTargetInput.data('typeahead').options.xhrParams.project_id = ctx.projectId;
@@ -131,6 +131,5 @@ function basePageInit (ctx) {
     $(".new-build").click (function(event) {
       event.stopPropagation();
     });
-  };
-
+  }
 }
lib/toaster/toastergui/static/js/libtoaster.js +4 -5
index fcf82ac..ae9e455 100644
@@ -67,12 +67,11 @@ var libtoaster = (function (){
   /*
    * url - the url of the xhr build */
   function _startABuild (url, project_id, targets, onsuccess, onfail) {
-    var data;
 
-    if (project_id)
-      data = 'project_id='+project_id+'&targets='+targets;
-    else
-      data = 'targets='+targets;
+    var data = {
+      project_id : project_id,
+      targets : targets,
+    }
 
     $.ajax( {
         type: "POST",
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/8 toaster: BuildButton target input allow building targets with tasks

From: Michael Wood <[email protected]>

Allow the input for targets to contain tasks in the form target:task

[YOCTO #7501]

---
 lib/toaster/toastergui/static/js/base.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/toaster/toastergui/static/js/base.js +2 -3
index 241c5d2..667c5df 100644
@@ -88,10 +88,9 @@ function basePageInit (ctx) {
       if (!newBuildTargetInput.val())
         return;
 
-      if (!selectedTarget)
-        selectedTarget = { name: newBuildTargetInput.val() };
+      var selectedTargetName = newBuildTargetInput.val();
       /* fire and forget */
-      libtoaster.startABuild(ctx.projectBuildUrl, ctx.projectId, selectedTarget.name, null, null);
+      libtoaster.startABuild(ctx.projectBuildUrl, ctx.projectId, selectedTargetName, null, null);
       window.location.replace(ctx.projectPageUrl+ctx.projectId);
     });
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/8 toasterui: correct terminology in landing page

In reply to Alex DAMIAN

From: Belen Barros Pena <[email protected]>

Change the introductory description of Toaster
we provide on first use, to make sure it mentions
all the bits that make up the build system, and
not just BitBake.

---
 lib/toaster/toastergui/templates/landing.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/toaster/toastergui/templates/landing.html +1 -1
index 5bbe694..4af849c 100644
@@ -15,7 +15,7 @@
        <h1>
         This is Toaster
        </h1>
-       <p>A web interface to <a href="http://www.yoctoproject.org/tools-resources/projects/bitbake">BitBake</a>, the <a href="http://www.yoctoproject.org">Yocto Project</a> build system.</p>
+       <p>A web interface to <a href="http://www.openembedded.org">OpenEmbedded</a> and <a href="http://www.yoctoproject.org/tools-resources/projects/bitbake">BitBake</a>, the <a href="http://www.yoctoproject.org">Yocto Project</a> build system.</p>
 
 	{% if MANAGED %}
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/8 toaster: add layer source in admin throws an error

In reply to Alex DAMIAN

From: David Reyna <[email protected]>

Preset uninitialized object members to bootstrap new layer source creation.

[YOCTO #7437]

---
 lib/toaster/orm/models.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
lib/toaster/orm/models.py +14 -6
index 625eb1e..4a6ca8f 100644
@@ -640,17 +640,25 @@ class LayerSource(models.Model):
         raise Exception("Abstract, update() must be implemented by all LayerSource-derived classes (object is %s)" % str(vars(self)))
 
     def save(self, *args, **kwargs):
-        if isinstance(self, LocalLayerSource):
-            self.sourcetype = LayerSource.TYPE_LOCAL
-        elif isinstance(self, LayerIndexLayerSource):
-            self.sourcetype = LayerSource.TYPE_LAYERINDEX
-        elif isinstance(self, ImportedLayerSource):
-            self.sourcetype = LayerSource.TYPE_IMPORTED
+        if self.sourcetype == LayerSource.TYPE_LOCAL:
+            self.__class__ = LocalLayerSource
+        elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
+            self.__class__ = LayerIndexLayerSource
+        elif self.sourcetype == LayerSource.TYPE_IMPORTED:
+            self.__class__ = ImportedLayerSource
         elif self.sourcetype == None:
             raise Exception("Unknown LayerSource-derived class. If you added a new layer source type, fill out all code stubs.")
         return super(LayerSource, self).save(*args, **kwargs)
 
     def get_object(self):
+        # preset an un-initilized object
+        if None == self.name:
+            self.name=""
+        if None == self.apiurl:
+            self.apiurl=""
+        if None == self.sourcetype:
+            self.sourcetype=LayerSource.TYPE_LOCAL
+
         if self.sourcetype == LayerSource.TYPE_LOCAL:
             self.__class__ = LocalLayerSource
         elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH 4/8] toaster: add layer source in admin throws an error

Hello,

I am going to revert this patch because it messes up the class instantiation for layer sources saved through the admin. We need a better solution for 7437.

Alex

Quoted 53 lines · Alex DAMIAN

From: David Reyna <[email protected]>

Preset uninitialized object members to bootstrap new layer source creation.

[YOCTO #7437]

---
 lib/toaster/orm/models.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
lib/toaster/orm/models.py +14 -6
index 625eb1e..4a6ca8f 100644
@@ -640,17 +640,25 @@ class LayerSource(models.Model):
         raise Exception("Abstract, update() must be implemented by all
 LayerSource-derived classes (object is %s)" % str(vars(self)))
 
     def save(self, *args, **kwargs):
-        if isinstance(self, LocalLayerSource):
-            self.sourcetype = LayerSource.TYPE_LOCAL
-        elif isinstance(self, LayerIndexLayerSource):
-            self.sourcetype = LayerSource.TYPE_LAYERINDEX
-        elif isinstance(self, ImportedLayerSource):
-            self.sourcetype = LayerSource.TYPE_IMPORTED
+        if self.sourcetype == LayerSource.TYPE_LOCAL:
+            self.__class__ = LocalLayerSource
+        elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
+            self.__class__ = LayerIndexLayerSource
+        elif self.sourcetype == LayerSource.TYPE_IMPORTED:
+            self.__class__ = ImportedLayerSource
         elif self.sourcetype == None:
             raise Exception("Unknown LayerSource-derived class. If you
 added a new layer source type, fill out all code stubs.")
         return super(LayerSource, self).save(*args, **kwargs)
 
     def get_object(self):
+        # preset an un-initilized object
+        if None == self.name:
+            self.name=""
+        if None == self.apiurl:
+            self.apiurl=""
+        if None == self.sourcetype:
+            self.sourcetype=LayerSource.TYPE_LOCAL
+
         if self.sourcetype == LayerSource.TYPE_LOCAL:

self.__class__ = LocalLayerSource
elif self.sourcetype == LayerSource.TYPE_LAYERINDEX:
--
1.9.1

Signature · 3 lines
Alex Damian
Yocto Project
SSG / OTC
#6 lore raw

PATCH 5/8 toaster: searching all projects table resets page count

In reply to Alex DAMIAN

From: David Reyna <[email protected]>

Add missing '_save_parameters_cookies' to preserve page count.

[YOCTO #7483]

---
 lib/toaster/toastergui/views.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/toaster/toastergui/views.py +4 -1
index be59c83..500834c 100755
@@ -3330,7 +3330,10 @@ if toastermain.settings.MANAGED:
                     },
                     ]
             }
-        return render(request, template, context)
+
+        response = render(request, template, context)
+        _save_parameters_cookies(response, pagesize, orderby, request)
+        return response
 
     def buildrequestdetails(request, pid, brid):
         template = "buildrequestdetails.html"
Signature · 1 line
1.9.1
#7 lore raw

PATCH 6/8 toasterui: remove 'targets' from project notification

In reply to Alex DAMIAN

From: Belen Barros Pena <[email protected]>

Remove the last remnant of the "targets" wording, which was lurking in the notification we show you when you create a project.

---
 lib/toaster/toastergui/static/js/projectapp.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/toaster/toastergui/static/js/projectapp.js +1 -1
index 0b6e012..d52ba73 100644
@@ -692,7 +692,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
                     "Your project <strong>" + $scope.project.name +
                     "</strong> has been created. You can now <a href=\""+ $scope.urls.layers +
                     "\">add layers</a> and <a href=\""+ $scope.urls.targets +
-                    "\">select targets</a> you want to build.", "alert-success");
+                    "\">select recipes</a> you want to build.", "alert-success");
         });
 
         _cmdExecuteWithParam("/machineselected", function () {
Signature · 1 line
1.9.1
#8 lore raw

PATCH 7/8 toaster: recipe path broken in recipe detail page

In reply to Alex DAMIAN

From: David Reyna <[email protected]>

The recipe paths in managed mode are not processed correctly. They need any prefix tags removed, and then any build path prefix removed only if present.

[YOCTO #7523]

---
 lib/toaster/orm/models.py                     | 8 +++++++-
 lib/toaster/toastergui/templates/recipes.html | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
lib/toaster/orm/models.py +7 -1
index 4a6ca8f..b9bb896 100644
@@ -557,7 +557,13 @@ class Recipe(models.Model):
 
     def get_local_path(self):
         if settings.MANAGED and self.layer_version.build.project is not None:
-            return self.file_path[len(self.layer_version.layer.local_path)+1:]
+            # strip any tag prefixes ('virtual:native:')
+            layer_path=self.layer_version.layer.local_path.split(":")[-1]
+            recipe_path=self.file_path.split(":")[-1]
+            if 0 == recipe_path.find(layer_path):
+                return recipe_path[len(layer_path)+1:]
+            else:
+                return recipe_path
 
         return self.file_path
 
lib/toaster/toastergui/templates/recipes.html +1 -1
index 889e676..458d724 100644
@@ -80,7 +80,7 @@
             {% endwith %}
         </td>
         <!-- Recipe file -->
-        <td class="recipe_file">{{recipe.file_path}}</td>
+        <td class="recipe_file">{{recipe.get_local_path}}</td>
         <!-- Section -->
         <td class="recipe_section">{{recipe.section}}</td>
         <!-- License -->
Signature · 1 line
1.9.1
#9 lore raw

PATCH 8/8 toaster: date range filter for project builds page

In reply to Alex DAMIAN

From: David Reyna <[email protected]>

Port date range filter initialization code to the project builds page.

[YOCTO #7578]

---
 lib/toaster/toastergui/templates/projectbuilds.html | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/toaster/toastergui/templates/projectbuilds.html +16 -0
index 07595f23..18b2495 100644
@@ -6,8 +6,24 @@
 <li>Project builds</li>
 {% endblock %}
 
+{% block extraheadcontent %}
+<link rel="stylesheet" href="/static/css/jquery-ui.min.css" type='text/css'>
+<link rel="stylesheet" href="/static/css/jquery-ui.structure.min.css" type='text/css'>
+<link rel="stylesheet" href="/static/css/jquery-ui.theme.min.css" type='text/css'>
+<script src="/static/js/jquery-ui.min.js"></script>
+<script src="/static/js/filtersnippet.js"></script>
+{% endblock %}
+
 {% block projectinfomain %}
 
+<script>
+    // initialize the date range controls
+    $(document).ready(function () {
+        date_init('created','{{last_date_from}}','{{last_date_to}}','{{dateMin_created}}','{{dateMax_created}}','{{daterange_selected}}');
+        date_init('updated','{{last_date_from}}','{{last_date_to}}','{{dateMin_updated}}','{{dateMax_updated}}','{{daterange_selected}}');
+    });
+</script>
+
     <div class="page-header">
       <h1>
         {% if request.GET.filter and objects.paginator.count > 0 or request.GET.search and objects.paginator.count > 0 %}
Signature · 1 line
1.9.1