diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js
index 80e9ec2392..45c61848da 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -110,9 +110,13 @@ function tableInit(ctx){
setupTableChrome(tableData);
/* Add table data rows */
+ var column_index;
for (var i in tableData.rows){
+ /* only display if the column is display-able */
var row = $("
");
+ column_index = -1;
for (var key_j in tableData.rows[i]){
+
/* if we have a static: version of a key, prefer the static: version for rendering */
var orig_key_j = key_j;
@@ -125,6 +129,12 @@ function tableInit(ctx){
key_j = "static:" + key_j;
}
+ /* we skip over un-displayable column entries */
+ column_index += 1;
+ if (! tableData.columns[column_index].displayable) {
+ continue;
+ }
+
var td = $(" | ");
td.prop("class", orig_key_j);
if (tableData.rows[i][key_j]){
@@ -206,6 +216,9 @@ function tableInit(ctx){
/* Add table header and column toggle menu */
for (var i in tableData.columns){
var col = tableData.columns[i];
+ if (col.displayable === false) {
+ continue;
+ }
var header = $(" | ");
header.prop("class", col.field_name);
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index b75e565246..e540b91499 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -79,7 +79,7 @@ class LayersTable(ToasterTable):
self.add_column(title="Git repository URL",
help_text="The Git repository for the layer source code",
hidden=True,
- static_data_name="git_url",
+ static_data_name="layer__vcs_url",
static_data_template=git_url_template)
git_dir_template = '''
@@ -328,13 +328,17 @@ class RecipesTable(ToasterTable):
self.add_column(title="Revision",
field_name="layer_version__get_vcs_reference")
-
self.add_column(title="Build",
help_text="Add or delete recipes to and from your project",
hideable=False,
static_data_name="add-del-layers",
static_data_template='{% include "recipe_btn.html" %}')
+ self.add_column(title="Project compatible Layer ID",
+ displayable = False,
+ field_name = "projectcompatible_layer",
+ computation = lambda x: (x.layer_version.get_equivalents_wpriority(Project.objects.get(pk=kwargs['pid']))[0]))
+
class LayerRecipesTable(RecipesTable):
""" Smaller version of the Recipes table for use in layer details """
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 280159ad2c..c25c512a84 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -112,6 +112,9 @@ def objtojson(obj):
elif isinstance(d[di], int) and hasattr(obj, "get_%s_display" % di):
nd[di] = getattr(obj, "get_%s_display" % di)()
return nd
+ elif isinstance( obj, type(lambda x:x)):
+ import inspect
+ return inspect.getsourcelines(obj)[0]
else:
raise TypeError("Unserializable object %s (%s) of type %s" % ( obj, dir(obj), type(obj)))
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py
index 82b7514bd8..407a0fbe15 100644
--- a/bitbake/lib/toaster/toastergui/widgets.py
+++ b/bitbake/lib/toaster/toastergui/widgets.py
@@ -54,6 +54,13 @@ class ToasterTable(TemplateView):
self.empty_state = "Sorry - no data found"
self.default_orderby = ""
+ # add the "id" column, undisplayable, by default
+ self.add_column(title="Id",
+ displayable=False,
+ orderable=True,
+ field_name="id")
+
+
def get(self, request, *args, **kwargs):
if request.GET.get('format', None) == 'json':
@@ -142,6 +149,7 @@ class ToasterTable(TemplateView):
def add_column(self, title="", help_text="",
orderable=False, hideable=True, hidden=False,
field_name="", filter_name=None, static_data_name=None,
+ displayable=True, computation=None,
static_data_template=None):
"""Add a column to the table.
@@ -168,6 +176,8 @@ class ToasterTable(TemplateView):
'filter_name' : filter_name,
'static_data_name': static_data_name,
'static_data_template': static_data_template,
+ 'displayable': displayable,
+ 'computation': computation,
})
def render_static_data(self, template, row):
@@ -289,8 +299,11 @@ class ToasterTable(TemplateView):
col['field_name'] = col['static_data_name']
- if True: # we add the raw model data at all times
- model_data = row
+ # compute the computation on the raw data if needed
+ model_data = row
+ if col['computation']:
+ model_data = col['computation'](row)
+ else:
# Traverse to any foriegn key in the object hierachy
for subfield in field.split("__"):
if hasattr(model_data, subfield):
@@ -300,7 +313,7 @@ class ToasterTable(TemplateView):
if isinstance(model_data, types.MethodType):
model_data = model_data()
- required_data[field] = model_data
+ required_data[col['field_name']] = model_data
data['rows'].append(required_data)