Commit bb8b7421 authored by Leigh Stoller's avatar Leigh Stoller

Address Mike's UI nits in issue #168. This closes issue #168.

parent 250a91ca
......@@ -21,6 +21,12 @@
#
# }}}
#
chdir("..");
include("lease_defs.php");
include("blockstore_defs.php");
include("imageid_defs.php");
chdir("apt");
include("dataset_defs.php");
function ClassicExperimentList($which, $target, $state = "active")
{
......@@ -300,6 +306,147 @@ function ProfileList($which, $target)
return $results;
}
function DatasetList($which, $target)
{
global $urn_mapping, $TBBASE, $ISEMULAB;
global $this_user;
if ($which == "user") {
$target_idx = $target->uid_idx();
$whereclause = "where v.creator_idx='$target_idx'";
$orderclause = "order by v.dataset_id";
}
elseif ($which == "group") {
$target_pid = $target->pid();
$target_gid = $target->gid();
$whereclause = "where v.pid='$target_pid' and v.gid='$target_gid'";
$orderclause = "order by v.creator_uid";
}
else {
$target_idx = $target->pid_idx();
$whereclause = "where v.pid_idx='$target_idx'";
$orderclause = "order by v.creator_uid";
}
#
# In the main portal, we show only those datasets on the local cluster.
#
if ($ISEMULAB) {
$whereclause .= "and agg.urn='$DEFAULT_AGGREGATE_URN'";
}
$results = array();
$query_result =
DBQueryFatal("select v.* from apt_datasets as v ".
"left join apt_aggregates as agg ".
"on agg.urn=v.aggregate_urn ".
"$whereclause $orderclause");
while ($row = mysql_fetch_array($query_result)) {
$uuid = $row["uuid"];
$name = $row["dataset_id"];
$type = $row["type"];
$pid = $row["pid"];
$pid_idx = $row["pid_idx"];
$gid = $row["gid"];
$gid_idx = $row["gid_idx"];
$creator_uid = $row["creator_uid"];
$creator_idx = $row["creator_idx"];
$aggregate_urn= $row["aggregate_urn"];
$created = $row["created"];
$expires = $row["expires"];
$blob = array();
$blob["uuid"] = $uuid;
$blob["name"] = $name;
$blob["type"] = $type;
$blob["pid"] = $pid;
$blob["pid_idx"] = $pid_idx;
$blob["gid"] = $gid;
$blob["gid_idx"] = $gid_idx;
$blob["creator_uid"] = $creator_uid;
$blob["creator_idx"] = $creator_idx;
$blob["created"] = $created;
$blob["expires"] = ($type != "imdataset" ? $expires : "");
$blob["aggregate_urn"]= $aggregate_urn;
$results[$uuid] = $blob;
}
return $results;
}
function ClassicDatasetList($which, $target)
{
global $urn_mapping, $TBBASE, $ISEMULAB;
global $this_user;
if ($which == "user") {
$target_uid = $target->uid();
$whereclause1 = "where l.owner_uid='$target_uid' and ad.uuid is null";
$whereclause2 = "where v.creator='$target_uid' and ".
"ad.uuid is null and v.isdataset=1";
$orderclause = "order by name";
}
elseif ($which == "group") {
$target_pid = $target->pid();
$target_gid = $target->gid();
$whereclause1 = "where l.pid='$target_pid' and ".
"where l.gid='$target_gid' and ad.uuid is null";
$whereclause2 = "where v.pid='$target_pid' and ad.uuid is null and ".
"v.gid='$target_gid' and v.isdataset=1";
$orderclause = "order by creator";
}
else {
$target_pid = $target->pid();
$whereclause1 = "where l.pid='$target_pid' and ad.uuid is null";
$whereclause2 = "where v.pid='$target_pid' and ".
"ad.uuid is null and v.isdataset=1 ";
$orderclause = "order by creator";
}
$results = array();
$query_result =
DBQueryFatal(
"select uuid,type,name,creator from ".
" ((select l.uuid as uuid,'lease' as type, ".
" l.lease_id as name,l.owner_uid as creator ".
" from project_leases as l ".
" left join apt_datasets as ad on ad.remote_uuid=l.uuid ".
" $whereclause1) ".
" union ".
" (select i.uuid as uuid,'image' as type, ".
" i.imagename as name,v.creator as creator ".
" from images as i ".
" left join image_versions as v on ".
" v.imageid=i.imageid and v.version=i.version ".
" left join apt_datasets as ad on ad.remote_uuid=i.uuid ".
" $whereclause2)) as foo $orderclause");
while ($row = mysql_fetch_array($query_result)) {
$uuid = $row["uuid"];
$type = $row["type"];
if ($type == "image") {
$dataset = ImageDataset::Lookup($uuid);
}
elseif ($type == "lease") {
$dataset = Lease::Lookup($uuid);
}
$blob = array();
$blob["uuid"] = $uuid;
$blob["name"] = $dataset->id();
$blob["type"] = $dataset->type();
$blob["pid"] = $dataset->pid();
$blob["gid"] = $dataset->gid();
$blob["creator_uid"] = $dataset->owner_uid();
$blob["created"] = $dataset->created();
$blob["expires"] = $dataset->expires();
$results[$uuid] = $blob;
}
return $results;
}
# Local Variables:
# mode:php
# End:
......
......@@ -38,8 +38,6 @@ function (sup, moment)
// Only one search box.
filter_columnFilters : false,
},
headers: { 1: { sorter: false}, 2: {sorter: false} }
});
return table;
};
......
......@@ -4,6 +4,7 @@ require(window.APT_OPTIONS.configObject,
'js/lib/text!template/experiment-list.html',
'js/lib/text!template/profile-list.html',
'js/lib/text!template/member-list.html',
'js/lib/text!template/dataset-list.html',
'js/lib/text!template/project-profile.html',
'js/lib/text!template/classic-explist.html',
'js/lib/text!template/group-list.html',
......@@ -11,8 +12,8 @@ require(window.APT_OPTIONS.configObject,
'js/lib/text!template/oops-modal.html',
],
function (_, sup, moment, mainString,
experimentString, profileString, memberString, detailsString,
classicString, groupsString, waitString, oopsString)
experimentString, profileString, memberString, datasetString,
detailsString, classicString, groupsString, waitString, oopsString)
{
'use strict';
var mainTemplate = _.template(mainString);
......@@ -57,6 +58,8 @@ function (_, sup, moment, mainString,
LoadMembersTab();
LoadGroupsTab();
LoadProjectTab();
LoadDatasetTab();
LoadClassicDatasets();
}
function LoadUsage()
......@@ -510,6 +513,80 @@ function (_, sup, moment, mainString,
xmlthing.done(callback);
}
function LoadDatasetTab()
{
var callback = function(json) {
console.info("datasets", json);
if (json.code) {
console.info(json.value);
return;
}
var template = _.template(datasetString);
$('#datasets_content')
.html(template({"datasets" : json.value,
"showuser" : true,
"showproject" : false}));
// Format dates with moment before display.
$('#datasets_content .tablesorter .format-date').each(function(){
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
var table = $('#datasets_content .tablesorter')
.tablesorter({
theme : 'blue',
});
}
var xmlthing =
sup.CallServerMethod(null,
"show-project", "DatasetList",
{"pid" : window.TARGET_PROJECT});
xmlthing.done(callback);
}
function LoadClassicDatasets()
{
var callback = function(json) {
console.info("classic datasets", json);
if (json.code) {
console.info(json.value);
return;
}
if (json.value.length == 0) {
return
}
$('#classic_datasets_content').removeClass("hidden");
var template = _.template(datasetString);
$('#classic_datasets_content_div')
.html(template({"datasets" : json.value,
"showuser" : true,
"showproject" : false}));
$('#classic_datasets_content .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
var table = $('#classic_datasets_content .tablesorter')
.tablesorter({
theme : 'blue',
});
};
var xmlthing =
sup.CallServerMethod(null,
"show-project", "ClassicDatasetList",
{"pid" : window.TARGET_PROJECT});
xmlthing.done(callback);
}
$(document).ready(initialize);
});
......
......@@ -4,13 +4,14 @@ require(window.APT_OPTIONS.configObject,
'js/lib/text!template/experiment-list.html',
'js/lib/text!template/profile-list.html',
'js/lib/text!template/project-list.html',
'js/lib/text!template/dataset-list.html',
'js/lib/text!template/user-profile.html',
'js/lib/text!template/oops-modal.html',
'js/lib/text!template/waitwait-modal.html',
'js/lib/text!template/classic-explist.html',
],
function (_, sup, moment, mainString,
experimentString, profileListString, projectString,
experimentString, profileListString, projectString, datasetString,
profileString, oopsString, waitwaitString, classicString)
{
'use strict';
......@@ -56,6 +57,8 @@ function (_, sup, moment, mainString,
LoadClassicProfiles();
LoadProjectsTab();
LoadProfileTab();
LoadDatasetTab();
LoadClassicDatasets();
/*
* Handlers for inline operations.
......@@ -376,6 +379,83 @@ function (_, sup, moment, mainString,
xmlthing.done(callback);
}
function LoadDatasetTab()
{
var callback = function(json) {
console.info("datasets", json);
if (json.code) {
console.info(json.value);
return;
}
if (json.value.length == 0) {
$('#datasets_nodatasets').removeClass("hidden");
return;
}
var template = _.template(datasetString);
$('#datasets_content')
.html(template({"datasets" : json.value,
"showuser" : false,
"showproject" : true}));
// Format dates with moment before display.
$('#datasets_content .tablesorter .format-date').each(function(){
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
var table = $('#datasets_content .tablesorter')
.tablesorter({
theme : 'green',
});
}
var xmlthing =
sup.CallServerMethod(null,
"user-dashboard", "DatasetList",
{"uid" : window.TARGET_USER});
xmlthing.done(callback);
}
function LoadClassicDatasets()
{
var callback = function(json) {
console.info("classic datasets", json);
if (json.code) {
console.info(json.value);
return;
}
if (json.value.length == 0) {
return
}
$('#classic_datasets_content').removeClass("hidden");
var template = _.template(datasetString);
$('#classic_datasets_content_div')
.html(template({"datasets" : json.value,
"showuser" : false,
"showproject" : true}));
$('#classic_datasets_content .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
var table = $('#classic_datasets_content .tablesorter')
.tablesorter({
theme : 'green',
});
};
var xmlthing =
sup.CallServerMethod(null,
"user-dashboard", "ClassicDatasetList",
{"uid" : window.TARGET_USER});
xmlthing.done(callback);
}
//
// Toggle flags.
//
......
......@@ -64,9 +64,6 @@ echo "<link rel='stylesheet'
$whereclause1 = "where l.owner_uid='$target_uid' and ad.uuid is null";
$whereclause2 = "where v.creator='$target_uid' and v.isdataset=1";
$whereclause3 = "where d.creator_uid='$target_uid'";
$orderclause1 = "order by l.owner_uid";
$orderclause2 = "order by v.creator";
$orderclause3 = "order by d.creator_uid";
$joinclause1 = "";
$joinclause2 = "left join image_versions as v on ".
" v.imageid=i.imageid and v.version=i.version ";
......@@ -110,20 +107,24 @@ if ($ISEMULAB) {
}
$classic_result =
DBQueryFatal("(select l.uuid,'lease' as type from project_leases as l ".
" $joinclause1 ".
" left join apt_datasets as ad on ad.remote_uuid=l.uuid ".
" $whereclause1 $orderclause1) ".
"union ".
"(select i.uuid,'image' as type from images as i ".
" $joinclause2 ".
" $whereclause2 $orderclause2)");
DBQueryFatal(
"select uuid,type,name from ".
" ((select l.uuid as uuid,'lease' as type,l.lease_id as name ".
" from project_leases as l ".
" $joinclause1 ".
" left join apt_datasets as ad on ad.remote_uuid=l.uuid ".
" $whereclause1) ".
" union ".
" (select i.uuid as uuid,'image' as type,i.imagename as name ".
" from images as i ".
" $joinclause2 ".
" $whereclause2)) as foo order by name");
$portal_result =
DBQueryFatal("select d.uuid,'dataset' as type from apt_datasets as d ".
"left join apt_aggregates as agg on agg.urn=d.aggregate_urn ".
"$joinclause3 ".
"$whereclause3 $orderclause3");
"$whereclause3 order by d.dataset_id");
echo "<div class='row'>
<div class='col-lg-12 col-lg-offset-0
......@@ -179,9 +180,10 @@ function SPITTABLE($which, $results) {
$name</a></td>\n";
if (isset($all) && ISADMIN()) {
echo "<td>$creator</td>";
echo "<td><a href='user-dashboard.php?user=$creator'>
$creator</a></td>";
}
echo " <td style='white-space:nowrap'>$pid</td>
echo "<td><a href='show-project.php?project=$pid'>$pid</a></td>
<td>$dtype</td>
<td class='format-date'>$expires</td>
<td>$urn</td>
......
......@@ -270,7 +270,8 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
<li><a href='signup.php'>Start/Join Project</a></li>";
if ($login_user->IsActive()) {
echo " <li class='divider'></li>
<li><a href='list-datasets.php'>List Datasets</a></li>
<li><a href='user-dashboard.php#datasets'>
My Datasets</a></li>
<li><a href='create-dataset.php'>Create Dataset</a></li>
<li><a href='images.php'>List Images</a></li>";
echo " <li class='divider'></li>\n";
......
......@@ -217,6 +217,10 @@ $routing = array("myprofiles" =>
"Do_ClassicExperimentList",
"ClassicProfileList" =>
"Do_ClassicProfileList",
"DatasetList" =>
"Do_DatasetList",
"ClassicDatasetList" =>
"Do_ClassicDatasetList",
"ProjectList" =>
"Do_ProjectList",
"UsageSummary" =>
......@@ -246,6 +250,10 @@ $routing = array("myprofiles" =>
"Do_ClassicExperimentList",
"ClassicProfileList" =>
"Do_ClassicProfileList",
"DatasetList" =>
"Do_DatasetList",
"ClassicDatasetList" =>
"Do_ClassicDatasetList",
"ProfileList" =>
"Do_ProfileList",
"MemberList" =>
......
......@@ -108,6 +108,28 @@ function Do_ProfileList()
SPITAJAX_RESPONSE($results);
}
function Do_DatasetList()
{
global $this_user, $target_project;
if (CheckPageArgs()) {
return;
}
$results = DatasetList("project", $target_project);
SPITAJAX_RESPONSE($results);
}
function Do_ClassicDatasetList()
{
global $this_user, $target_project;
if (CheckPageArgs()) {
return;
}
$results = ClassicDatasetList("project", $target_project);
SPITAJAX_RESPONSE($results);
}
function Do_MemberList()
{
global $this_user, $target_project;
......
<div>
<table class='tablesorter' class='dataset_table'>
<thead>
<tr>
<th>Name</th>
<% if (showuser) { %><th>Creator</th><% } %>
<% if (showproject) { %><th>Project</th><% } %>
<th>Type</th>
<th>Created</th>
<th>Expires</th>
</tr>
</thead>
<tbody>
<% _.each(datasets, function(value, name) { %>
<tr>
<td><a href='show-dataset.php?uuid=<%- value.uuid %>'>
<%= value.name %></a></td>
<% if (showuser) { %>
<td style='white-space: nowrap;'>
<a href='user-dashboard.php?user=<%- value.creator_uid %>'>
<%- value.creator_uid %></a></td>
<% } %>
<% if (showproject) { %>
<td style='white-space: nowrap;'>
<a href='show-project.php?project=<%- value.pid %>'>
<%- value.pid %></a></td>
<% } %>
<td><%- value.type %></td>
<td class="format-date"><%- value.created %></td>
<td class="format-date"><%- value.expires %></td>
</tr>
<% }); %>
</tbody>
</table>
</div>
......@@ -54,6 +54,9 @@
<li role="presentation">
<a href="#profiles" role="tab"
data-toggle="tab">Profiles</a></li>
<li role="presentation">
<a href="#datasets" role="tab"
data-toggle="tab">Datasets</a></li>
<li role="presentation">
<a href="#members" role="tab"
data-toggle="tab">Members</a></li>
......@@ -100,9 +103,20 @@
No profiles to show you.
</div>
</div>
<br>
<div id="classic_profiles_content"></div>
</div>
<div role="tabpanel" class="tab-pane" id="datasets">
<div id="datasets_content">
<div class="hidden" id="datasets_nodatasets">
<br>
No datasets to show you.
</div>
</div>
<div id="classic_datasets_content" class="hidden">
<center><h4>Classic Datasets</h4></center>
<div id="classic_datasets_content_div"></div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="members">
<div id="members_content"></div>
</div>
......
......@@ -51,6 +51,9 @@
<li role="presentation">
<a href="#profiles" role="tab" data-toggle="tab">
Profiles</a></li>
<li role="presentation">
<a href="#datasets" role="tab" data-toggle="tab">
Datasets</a></li>
<li role="presentation">
<a href="#membership" role="tab" data-toggle="tab">
Membership</a></li>
......@@ -121,6 +124,19 @@
<br>
<div id="classic_profiles_content"></div>
</div>
<div role="tabpanel" class="tab-pane" id="datasets">
<div id="datasets_content">
<div class="hidden" id="datasets_nodatasets">
<br>
No datasets to show you. Maybe you want to
<b><a href='create-dataset.php'>create one?</a></b>
</div>
</div>
<div id="classic_datasets_content" class="hidden">
<center><h4>Classic Datasets</h4></center>
<div id="classic_datasets_content_div"></div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="membership">
<div id="membership_content"></div>
</div>
......
......@@ -111,6 +111,28 @@ function Do_ProfileList()
SPITAJAX_RESPONSE($results);
}
function Do_DatasetList()
{
global $this_user, $target_user;
if (CheckPageArgs()) {
return;
}
$results = DatasetList("user", $target_user);
SPITAJAX_RESPONSE($results);
}
function Do_ClassicDatasetList()
{
global $this_user, $target_user;
if (CheckPageArgs()) {
return;
}
$results = ClassicDatasetList("user", $target_user);
SPITAJAX_RESPONSE($results);
}
function Do_ProjectList()
{
global $this_user, $target_user;
......
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