Commit 0cf7f9e8 authored by Leigh Stoller's avatar Leigh Stoller

Add project accessible profiles to user dashboard. Closes issue #371

parent 4c27eb7f
<?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
#
......@@ -259,8 +259,6 @@ function ProfileList($which, $target)
$target_idx = $target->pid_idx();
$whereclause = "where v.pid_idx='$target_idx'";
}
$results = array();
$query_result =
DBQueryFatal("select p.*,v.*,DATE(v.created) as created ".
" from apt_profiles as p ".
......@@ -269,6 +267,42 @@ function ProfileList($which, $target)
" v.version=p.version ".
"$whereclause");
return ProfileListAux($query_result);
}
#
# Return list of profiles in all projects the user is a member of.
#
function ProjectProfileList($target_user)
{
global $urn_mapping, $TBBASE;
global $this_user;
$creator_idx = $target_user->uid_idx();
$query_result =
DBQueryFatal("select p.*,v.*,DATE(v.created) as created ".
" from apt_profiles as p ".
"left join apt_profile_versions as v on ".
" v.profileid=p.profileid and ".
" v.version=p.version ".
"left join group_membership as g on ".
" g.pid_idx=p.pid_idx and g.gid_idx=p.gid_idx ".
"where g.uid_idx='$creator_idx' ".
"order by p.pid");
return ProfileListAux($query_result);
}
#
# Helper function
#
function ProfileListAux($query_result)
{
global $urn_mapping, $TBBASE;
global $this_user;
$results = array();
while ($row = mysql_fetch_array($query_result)) {
$idx = $row["profileid"];
$uuid = $row["uuid"];
......
......@@ -197,11 +197,12 @@ $(function ()
$('#profiles_content')
.html(template({"profiles" : json.value,
"tablename" : "project-profiles",
"showCreator" : true,
"showProject" : false}));
// Format dates with moment before display.
$('#profiles_table .format-date').each(function() {
$('#project-profiles-table .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
......@@ -218,7 +219,7 @@ $(function ()
ShowTopology($(this).data("profile"));
});
var table = $('#profiles_table')
var table = $('#' + 'project-profiles-table')
.tablesorter({
theme : 'green',
widgets: ["filter"],
......@@ -239,7 +240,8 @@ $(function ()
filter_liveSearch : true,
},
});
$.tablesorter.filter.bindSearch(table, $('#profile_search'));
$.tablesorter.filter.bindSearch(table,
$('#' + 'project-profiles-search'));
}
var xmlthing = sup.CallServerMethod(null,
"show-project", "ProfileList",
......
......@@ -60,6 +60,7 @@ $(function ()
LoadClassicExperiments();
// Should we do these on demand?
LoadProfileListTab();
LoadProjectProfiles();
LoadClassicProfiles();
LoadProjectsTab();
LoadProfileTab();
......@@ -235,11 +236,12 @@ $(function ()
$('#profiles_content')
.html(template({"profiles" : json.value,
"tablename" : "user-profiles",
"showCreator" : false,
"showProject" : true}));
// Format dates with moment before display.
$('#profiles_table .format-date').each(function() {
$('#user-profiles-table .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
......@@ -256,7 +258,7 @@ $(function ()
ShowTopology($(this).data("profile"));
});
var table = $('#profiles_table')
var table = $('#' + 'user-profiles-table')
.tablesorter({
theme : 'green',
widgets: ["filter"],
......@@ -277,7 +279,8 @@ $(function ()
filter_liveSearch : true,
},
});
$.tablesorter.filter.bindSearch(table, $('#profile_search'));
$.tablesorter.filter.bindSearch(table,
$('#' + 'user-profiles-search'));
}
var xmlthing = sup.CallServerMethod(null,
"user-dashboard", "ProfileList",
......@@ -285,6 +288,75 @@ $(function ()
xmlthing.done(callback);
}
function LoadProjectProfiles()
{
var callback = function(json) {
console.info("LoadProjectProfiles", json);
if (json.code) {
console.info(json.value);
return;
}
if (json.value.length == 0) {
return;
}
var template = _.template(profileListString);
$('#projectprofiles_content')
.html(template({"profiles" : json.value,
"tablename" : "project-profiles",
"showCreator" : true,
"showProject" : true}));
// Format dates with moment before display.
$('#project-profiles-table .format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("ll"));
}
});
// This activates the tooltip subsystem.
$('[data-toggle="tooltip"]').tooltip({
delay: {"hide" : 500, "show" : 500},
placement: 'auto',
});
// Display the topo.
$('.showtopo_modal_button').click(function (event) {
event.preventDefault();
ShowTopology($(this).data("profile"));
});
var table = $('#' + 'project-profiles-table')
.tablesorter({
theme : 'green',
widgets: ["filter"],
widgetOptions: {
// include child row content while filtering, if true
filter_childRows : true,
// include all columns in the search.
filter_anyMatch : true,
// class name applied to filter row and each input
filter_cssFilter : 'form-control',
// 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,
},
});
$.tablesorter.filter.bindSearch(table,
$('#' + 'project-profiles-search'));
}
var xmlthing = sup.CallServerMethod(null,
"user-dashboard",
"ProjectProfileList",
{"uid" : window.TARGET_USER});
xmlthing.done(callback);
}
function LoadClassicProfiles()
{
var callback = function(json) {
......
<?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
#
......@@ -269,6 +269,8 @@ $routing = array("myprofiles" =>
"Do_UsageSummary",
"ProfileList" =>
"Do_ProfileList",
"ProjectProfileList" =>
"Do_ProjectProfileList",
"Toggle" =>
"Do_Toggle",
"SendTestMessage" =>
......
<div class="table-responsive">
<input class='form-control search' type='search' data-column='all'
id='profile_search' placeholder='Search'>
<table class='tablesorter' id='profiles_table'>
id='<%- tablename %>-search' placeholder='Search'>
<table class='tablesorter' id='<%- tablename %>-table'>
<thead>
<tr>
<th>Name</th>
......@@ -55,27 +55,3 @@
</tbody>
</table>
</div>
<!-- This is the topology view modal -->
<div id='quickvm_topomodal' class='modal fade'>
<div class='modal-dialog' id='showtopo_dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>
&times;</button>
<h3>Topology Viewer</h3>
</div>
<div class='modal-body'>
<!-- This topo diagram goes inside this div -->
<div class='panel panel-default'
id='showtopo_container'>
<div class='panel-body'>
<div id='showtopo_nopicker' class='jacks'></div>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -154,6 +154,28 @@
</div>
</div>
</div>
<!-- This is the topology view modal -->
<div id='quickvm_topomodal' class='modal fade'>
<div class='modal-dialog' id='showtopo_dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>
&times;</button>
<h3>Topology Viewer</h3>
</div>
<div class='modal-body'>
<!-- This topo diagram goes inside this div -->
<div class='panel panel-default'
id='showtopo_container'>
<div class='panel-body'>
<div id='showtopo_nopicker' class='jacks'></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id='waitwait_div'></div>
<div id='oops_div'></div>
<div id='conversion_help_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="#projectprofiles" role="tab" data-toggle="tab">
Project Profiles</a></li>
<li role="presentation">
<a href="#datasets" role="tab" data-toggle="tab">
Datasets</a></li>
......@@ -131,6 +134,9 @@
<br>
<div id="classic_profiles_content"></div>
</div>
<div role="tabpanel" class="tab-pane" id="projectprofiles">
<div id="projectprofiles_content">
</div>
<div role="tabpanel" class="tab-pane" id="datasets">
<div id="datasets_content">
<div class="hidden" id="datasets_nodatasets">
......
<?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
#
......@@ -114,6 +114,17 @@ function Do_ProfileList()
SPITAJAX_RESPONSE($results);
}
function Do_ProjectProfileList()
{
global $this_user, $target_user;
if (CheckPageArgs()) {
return;
}
$results = ProjectProfileList($target_user);
SPITAJAX_RESPONSE($results);
}
function Do_DatasetList()
{
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