All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit d0286324 authored by Leigh B Stoller's avatar Leigh B Stoller

List Classic Emulab images too. Only those created by the user. Might

want to have a project list on the project page.
parent 94a6d106
......@@ -459,6 +459,63 @@ function ClassicDatasetList($which, $target)
return $results;
}
#
# Classic images. For now, just one list. Maybe this will be per
# user/project/group in the future.
#
function ClassicImageList($target)
{
global $urn_mapping, $TBBASE, $ISEMULAB, $TBMAINSITE, $OURDOMAIN;
global $this_user;
$target_idx = $target->uid_idx();
$results = array();
$query =
"select distinct iv.*,ov.* from images as i ".
"left join image_versions as iv on ".
" iv.imageid=i.imageid and iv.version=i.version ".
"left join os_info_versions as ov on ".
" i.imageid=ov.osid and ov.vers=i.version ".
"left join osidtoimageid as map on map.osid=i.imageid ".
"where (iv.ezid = 1 and iv.isdataset=0) and ".
" iv.creator_urn is null and ".
" iv.creator_idx='$target_idx' ".
"order by i.imagename";
$query_result = DBQueryFatal($query);
$domain = $OURDOMAIN;
if ($TBMAINSITE) {
$domain = "emulab.net";
}
while ($row = mysql_fetch_array($query_result)) {
$imageid = $row["imageid"];
$name = $row["imagename"];
$pid = $row["pid"];
$urn = "urn:publicid:IDN+${domain}+image+${pid}//${name}";
$blob = array();
$blob["imageid"] = $imageid;
$blob["description"] = $row["description"];
$blob["imagename"] = $row["imagename"];
$blob["created"] = DateStringGMT($row["created"]);
$blob["pid"] = $row["pid"];
$blob["pid_idx"] = $row["pid_idx"];
$blob["global"] = $row["global"];
$blob["creator"] = $row["creator"];
$blob["creator_idx"] = $row["creator_idx"];
$blob["urn"] = $urn;
$blob["filter"] = implode(",", $filters);
$blob["url"] = $TBBASE . "/" .
CreateURL("showimageid",
URLARG_IMAGEID, $imageid);
$results[] = $blob;
}
return $results;
}
# Local Variables:
# mode:php
# End:
......
......@@ -24,6 +24,7 @@
chdir("..");
include_once("webtask.php");
chdir("apt");
include_once("ajax-routines.ajax");
# We set this in CheckPageArgs
$target_user = null;
......@@ -170,6 +171,22 @@ function Do_DeleteImage()
SPITAJAX_RESPONSE(0);
}
#
# Classic images on the local cluster.
#
function Do_ClassicImageList()
{
global $this_user, $target_user;
global $ajax_args;
global $TB_PROJECT_CREATEEXPT, $suexec_output;
if (CheckPageArgs()) {
return;
}
$images = ClassicImageList($target_user);
SPITAJAX_RESPONSE($images);
}
# Local Variables:
# mode:php
# End:
......
......@@ -2,10 +2,12 @@ $(function ()
{
'use strict';
var template_list = ["image-list", "oops-modal", "confirm-delete-image",
var template_list = ["image-list", "classic-image-list",
"oops-modal", "confirm-delete-image",
"waitwait-modal"];
var templates = APT_OPTIONS.fetchTemplateList(template_list);
var listTemplate = _.template(templates["image-list"]);
var classicTemplate = _.template(templates["classic-image-list"]);
var confirmTemplate = _.template(templates["confirm-delete-image"]);
var oopsString = templates["oops-modal"];
var waitwaitString = templates["waitwait-modal"];
......@@ -22,6 +24,7 @@ $(function ()
$('#waitwait_div').html(waitwaitString);
LoadData();
LoadClassic();
}
/*
......@@ -353,6 +356,84 @@ $(function ()
.unbind("click");
});
}
/*
* Load images from each am in the list and generate a table.
*/
function LoadClassic()
{
var callback = function (json) {
console.log("classic", json);
if (json.code) {
console.info("failed to get classic list: " + json.value);
return;
}
var html = classicTemplate({
"images" : json.value,
});
$('#classic-images-div').html(html);
// Format dates with moment before display.
$('#classic-images-table .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
// This activates the popover subsystem.
$('#classic-images-table [data-toggle="popover"]').popover({
placement: 'auto',
});
// Prevent shooting to the top of the page on clicking the popover.
$('#classic-images-table [data-toggle="popover"]')
.click(function (event) {
event.preventDefault();
});
// This is to make the URN popover go away on click outside.
$('body').on('click', function (e) {
$('[data-toggle="popover"]')
.each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that
//triggers a popup
if (!$(this).is(e.target) &&
$(this).has(e.target).length === 0 &&
$('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
$('#classic-images-div').removeClass("hidden");
var table = $('#classic-images-table')
.tablesorter({
theme : 'green',
widgets: ["zebra", "filter"],
widgetOptions: {
// include all columns in the search.
filter_anyMatch : true,
// search from beginning
filter_startsWith : false,
// Set this option to false for case sensitive search
filter_ignoreCase : true,
// Only one search box.
filter_columnFilters : false,
// Search as typing
filter_liveSearch : true,
},
headers: {
3: {sorter: false},
4: {sorter: false},
},
});
$.tablesorter.filter.bindSearch(table, $('#classic-images-search'));
}
var args = {"uid" : window.TARGET_USER};
var xmlthing = sup.CallServerMethod(null, "images",
"ClassicImages", args);
xmlthing.done(callback);
}
// Helper.
function decodejson(id) {
......
......@@ -93,6 +93,7 @@ echo "<div id='main-body'>
You have no images (clones or snapshots) yet.
</center>
</div>
<div id='classic-images-div' class='hidden'></div>
</div>\n";
# Place to hang the modals for now
......@@ -107,7 +108,8 @@ echo "</script>\n";
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
REQUIRE_MOMENT();
AddTemplateList(array("image-list", "confirm-delete-image",
AddTemplateList(array("image-list", "classic-image-list",
"confirm-delete-image",
"oops-modal", "waitwait-modal"));
SPITREQUIRE("js/list-images.js",
"<script src='js/lib/jquery.tablesorter.min.js'></script>\n".
......
......@@ -360,7 +360,9 @@ $routing = array("myprofiles" =>
"methods" => array("ListImages" =>
"Do_ListImages",
"DeleteImage" =>
"Do_DeleteImage")),
"Do_DeleteImage",
"ClassicImages" =>
"Do_ClassicImageList")),
"news" =>
array("file" => "news.ajax",
"guest" => true,
......
<style>
.panel-body-dashboard {
padding: 2px;
}
.table-dashboard {
margin: 1px;
}
.popover, .popover-content {
width:auto !important;
max-width: 700 !important;
min-width: 450 !important;
}
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
padding: 2px;
}
.panel-heading-list {
padding: 2px;
}
</style>
<div class='col-lg-10 col-lg-offset-1
col-md-12 col-md-offset-0
col-sm-12 col-sm-offset-0
col-xs-12 col-xs-offset-0'>
<div class='panel panel-default'>
<div class="panel-heading panel-heading-list">
<h5>
<center>Classic Emulab Images</center>
</h5>
</div>
<div class='panel-body panel-body-dashboard'>
<div>
<input class='form-control search' type='search' data-column='all'
id='classic-images-search' placeholder='Search'>
</div>
<div class="table-responsive">
<table class='tablesorter' id='classic-images-table'>
<thead>
<tr>
<th>Name</th>
<th>Project</th>
<th>Created</th>
<th class="sorter-false">Description</th>
<th class="sorter-false">URN</th>
</tr>
</thead>
<tbody>
<% _.each(images, function(value, index) { %>
<tr>
<td><a href="<%- value.url %>" target="_blank">
<%= value.imagename %></a></td>
<td><a href='show-project.php?pid=<%- value.pid_idx %>'>
<%= value.pid %></a></td>
<td class="format-date"><%- value.created %></td>
<td><%- value.description %></td>
<td align="center">
<a href="#"
data-toggle='popover'
data-html='true'
data-trigger='click'
data-title="URN for your geni-lib script or RSpec"
data-content="<input type=text readonly=readonly
class=form-control
onClick='this.select();'
value='<%- value.urn %>'>">
<span class="glyphicon glyphicon-link"></span>
</a>
</td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</div>
</div>
</div>
......@@ -5,8 +5,10 @@
.table-dashboard {
margin: 1px;
}
.popover{
max-width: 800px;
.popover, .popover-content {
width:auto !important;
max-width: 700 !important;
min-width: 450 !important;
}
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
......
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