Commit 13bb57a9 authored by Leigh Stoller's avatar Leigh Stoller

Work on issue #399; show image format in the listings, but only if

there is more then one format in the list (most users will not see
this column).
parent d9ea19f0
......@@ -558,6 +558,7 @@ function ClassicImageList($target)
$blob["global"] = $row["global"];
$blob["creator"] = $row["creator"];
$blob["creator_idx"] = $row["creator_idx"];
$blob["format"] = $row["format"];
$blob["urn"] = $urn;
$blob["url"] = $TBBASE . "/" .
CreateURL("showimageid",
......
<?php
#
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -177,6 +177,7 @@ if ($ISCLOUD) {
$blob["creator"] = $creator;
$blob["creator_idx"] = $creator_idx;
$blob["project_urn"] = $row["project_urn"];
$blob["format"] = $row["format"];
$blob["urn"] = $row["urn"];
if (isset($url)) {
$blob["url"] = $url;
......@@ -243,6 +244,7 @@ else {
$blob["global"] = $row["global"];
$blob["creator"] = $row["creator"];
$blob["creator_idx"] = $row["creator_idx"];
$blob["format"] = $row["format"];
$blob["urn"] = $urn;
$blob["url"] = $TBBASE . "/" .
CreateURL("showimageid",
......
......@@ -4,6 +4,8 @@ $(function ()
var templates = APT_OPTIONS.fetchTemplateList(['images']);
var mainTemplate = _.template(templates['images']);
var filterindex = 7;
var showformat = false;
function initialize()
{
......@@ -13,12 +15,23 @@ $(function ()
var images = JSON.parse(_.unescape($('#images-json')[0].textContent));
console.info("images", images);
// We show the format only if there is more then one format type.
var formats = {};
_.each(images, function(value, index) {
formats[value.format] = 1;
});
if (Object.keys(formats).length > 1) {
showformat = true;
filterindex++;
}
// Generate the main template.
var html = mainTemplate({
"images" : images,
"all" : window.ISADMIN && window.ALL,
"isadmin" : window.ISADMIN,
"manual" : window.MANUAL,
"showformat" : showformat,
});
$('#main-body').html(html);
......@@ -80,10 +93,6 @@ $(function ()
// Search as typing
filter_liveSearch : true,
},
headers: {
4: {sorter: false},
5: {sorter: false},
},
});
/*
......@@ -100,7 +109,7 @@ $(function ()
search_timeout =
window.setTimeout(function() {
var filters = $.tablesorter.getFilters($('#images-table'));
filters[7] = userInput;
filters[filterindex] = userInput;
console.info("Search", filters);
$.tablesorter.setFilters($('#images-table'), filters, true);
}, 500);
......@@ -114,8 +123,8 @@ $(function ()
var filters = $.tablesorter.getFilters($('#images-table'));
// The "any" filter needs a value or everything disappears.
// If there is a term in the search box, it will have a value.
if (filters[7] === undefined) {
filters[7] = "";
if (filters[filterindex] === undefined) {
filters[filterindex] = "";
}
if ($('#my-images').is(":checked")) {
tmp.push("creator");
......@@ -136,11 +145,11 @@ $(function ()
}
if (tmp.length) {
// regex search, plain | does not work.
filters[6] = "/" + tmp.join("|") + "/";
filters[filterindex - 1] = "/" + tmp.join("|") + "/";
}
else {
// Hmm, an empty string will get everything.
filters[6] = "WHY";
filters[filterindex - 1] = "WHY";
}
console.info("SetFilters", filters);
$.tablesorter.setFilters($('#images-table'), filters, true);
......
......@@ -38,6 +38,7 @@ $(function ()
var callback = function(json) {
var error = null;
var images = null;
var showformat = false;
console.info(name, json);
......@@ -63,6 +64,17 @@ $(function ()
// Save for later
imagelist[name] = images;
}
// We show the format only if there is more then one
// format type.
var formats = {};
_.each(images, function(value, index) {
_.each(value.versions, function(image, index) {
formats[image.format] = 1;
});
});
if (Object.keys(formats).length > 1) {
showformat = true;
}
// Generate the main template.
var html = listTemplate({
"images" : images,
......@@ -70,6 +82,7 @@ $(function ()
"showuser" : false,
"name" : name,
"error" : error,
"showformat" : showformat,
});
html =
"<div class='row' id='" + name + "'>" +
......@@ -380,8 +393,15 @@ $(function ()
if (json.value.length == 0) {
return;
}
// We show the format only if there is more then one format type.
var formats = {};
_.each(json.value, function(value, index) {
formats[value.format] = 1;
});
var html = classicTemplate({
"images" : json.value,
"showformat" : Object.keys(formats).length > 1,
});
$('#classic-images-div').html(html);
// Format dates with moment before display.
......@@ -431,10 +451,6 @@ $(function ()
// Search as typing
filter_liveSearch : true,
},
headers: {
3: {sorter: false},
4: {sorter: false},
},
});
$.tablesorter.filter.bindSearch(table, $('#classic-images-search'));
}
......
$(function () {
window.sup = (function () {
function ParseURN(urn)
{
var parser = /^urn:publicid:idn\+([^\+]*)\+([^\+]*)\+(.*)$/i;
var matches = parser.exec(urn);
if (!matches) {
return null;
}
var hrn = {"domain" : matches[1],
"type" : matches[2],
"id" : matches[3]};
if (hrn.type == "image") {
parser = /^(.*)(::|\/\/)(.*)$/;
matches = parser.exec(hrn.id);
if (matches) {
hrn["project"] = matches[1];
hrn["image"] = matches[3];
}
}
return hrn;
}
function ShowModal(which, hidefunction)
{
var callback = function() {
......@@ -338,6 +361,7 @@ function VerifySpeaksfor(speaksfor, signature)
// Exports from this module for use elsewhere
return {
ParseURN: ParseURN,
ShowModal: ShowModal,
HideModal: HideModal,
ShowWaitWait: ShowWaitWait,
......
......@@ -45,6 +45,9 @@
<th>Name</th>
<th>Project</th>
<th>Created</th>
<% if (showformat) { %>
<th>Format</th>
<% } %>
<th class="sorter-false">Description</th>
<th class="sorter-false">URN</th>
</tr>
......@@ -57,6 +60,9 @@
<td><a href='show-project.php?pid=<%- value.pid_idx %>'>
<%= value.pid %></a></td>
<td class="format-date"><%- value.created %></td>
<% if (showformat) { %>
<td><%- value.format %></td>
<% } %>
<td><%- value.description %></td>
<td align="center">
<a href="#"
......
......@@ -65,6 +65,9 @@
<tr>
<th class="col-md-5">Image URN</th>
<th class="col-md-2">Created</th>
<% if (showformat) { %>
<th>Format</th>
<% } %>
<th>File Size</th>
</tr>
</thead>
......@@ -84,6 +87,9 @@
<% } %>
</td>
<td class="format-date"><%- image.versions[0].created %></td>
<% if (showformat) { %>
<td><%- image.versions[0].format %></td>
<% } %>
<td class="image-filesize"></td>
</tr>
<% _.each(image.versions, function(version, versionindex) { %>
......@@ -102,6 +108,9 @@
<% } %>
</td>
<td class="format-date"><%- version.created %></td>
<% if (showformat) { %>
<td><%- version.format %></td>
<% } %>
<td class="version-filesize"><%- version.filesize %></td>
</tr>
<% }); %>
......@@ -146,6 +155,9 @@
<th class="col-md-5">Image URN</th>
<th class="col-md-2">Created</th>
<th>File Size</th>
<% if (showformat) { %>
<th>Format</th>
<% } %>
<th class="sorter-false">Profile</th>
</tr>
</thead>
......@@ -167,6 +179,9 @@
<%- image.urn %>
</td>
<td class="format-date"><%- image.versions[0].created %></td>
<% if (showformat) { %>
<td><%- image.versions[0].format %></td>
<% } %>
<td class="image-filesize"></td>
<td></td>
</tr>
......@@ -185,6 +200,9 @@
style='color: red; margin-left: 3px;'></span></a>
</td>
<td class="format-date"><%- version.created %></td>
<% if (showformat) { %>
<td><%- version.format %></td>
<% } %>
<td class="version-filesize"><%- version.filesize %></td>
<td class="delete-profile"
data-uuid="<%- version.using[0].uuid %>">
......@@ -235,6 +253,9 @@
<tr>
<th class="col-md-5">Image URN</th>
<th class="col-md-2">Created</th>
<% if (showformat) { %>
<th>Format</th>
<% } %>
<th>File Size</th>
</tr>
</thead>
......@@ -255,6 +276,9 @@
<%- image.urn %>
</td>
<td class="format-date"><%- image.versions[0].created %></td>
<% if (showformat) { %>
<td><%- image.versions[0].format %></td>
<% } %>
<td class="image-filesize"></td>
</tr>
<% _.each(image.versions, function(version, versionindex) { %>
......@@ -269,6 +293,9 @@
Profiles</a>
</td>
<td class="format-date"><%- version.created %></td>
<% if (showformat) { %>
<td><%- version.format %></td>
<% } %>
<td class="version-filesize"><%- version.filesize %></td>
</tr>
<tr class="hidden tablesorter-childRow-versions
......
......@@ -81,6 +81,9 @@
<th>Creator</th>
<th>Project</th>
<th>Created</th>
<% if (showformat) { %>
<th>Format</th>
<% } %>
<th class="sorter-false">Description</th>
<th class="sorter-false">URN</th>
<th class="hidden-column">Filters</th>
......@@ -109,6 +112,9 @@
<td><%= value.pid %></td>
<% } %>
<td class="format-date"><%- value.created %></td>
<% if (showformat) { %>
<td><%- value.format %></td>
<% } %>
<td><%- value.description %></td>
<td align="center">
<a href="#"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment