Commit f973a66a authored by jlopez's avatar jlopez
Browse files

Clean + add filter on container

parent a9d7056f
......@@ -7,204 +7,299 @@ require_once "./dao/DBquery.php";
$db = new DBquery();
$containers = $db->getContainers();
$type = "all";
$author = NULL;
$labels = array();
$tags = array();
$descriptions = array();
if(isset($_GET['type'])) {
$type = $_GET['type'];
}
if(isset($_GET['mycontainer'])) {
$author = $_SESSION['username'];
}
if(isset($_GET['labels'])) {
foreach( $_GET['labels'] as $n) {
array_push($labels, $n);
}
}
require_once "./inc/php/buildHeader.php";
if(isset($_GET['tags'])) {
$tags = explode(" ", $_GET['tags']);
}
if(isset($_GET['descriptions'])) {
$descriptions = explode(" ", $_GET['descriptions']);
}
$containers = $db->getContainers($type, $author, $labels, $tags, $descriptions);
require_once "./inc/php/buildHeader.php";
?>
<div class="container-fluid">
<br/><br/>
<br/><br/>
<div class="row justify-content-md-center text-center">
<div class="col-sm-3">
<div class="card border-primary mb-3">
<div class="card-header font-weight-bold text-white bg-primary"><h2>Docker public</h2></div>
<div class="row justify-content-md-center text-center">
<div class="col-sm-2">
<div class="card border-primary sm-2">
<div class="card-header font-weight-bold text-white bg-primary"><h4>Docker public</h4></div>
<div class="card-body text-primary">
<h3 class="card-title"><?php echo $db->getNumberDockerContainer() ?> Files</h3>
<h5 class="card-title"><?php echo $db->getNumberDockerContainer() ?> Files</h5>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="card border-success mb-3">
<div class="card-header font-weight-bold text-white bg-success"><h2>Singularity public</h2></div>
<div class="col-sm-2">
<div class="card border-success sm-2">
<div class="card-header font-weight-bold text-white bg-success"><h4>Singularity public</h4></div>
<div class="card-body text-success">
<h3 class="card-title"><?php echo $db->getNumberSingularityContainer() ?> Files</h3>
<h5 class="card-title"><?php echo $db->getNumberSingularityContainer() ?> Files</h5>
</div>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-12">
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-info" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Filter
</button>
<a href="./container.php" class="btn btn-success">
Reset
</a>
</h5>
</div>
<table id="Table_Container" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Author</th>
<th>Labels</th>
<th>Tags</th>
<th>Date</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody id="TableSection">
<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body col-12">
<form method="get">
<div class="form-inline form-group">
<label for="containerType">Container type :</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" id="containerType0" value="All" checked>
<label class="form-check-label" for="containerType0">
All
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" id="containerType1" value="Singularity">
<label class="form-check-label" for="containerType1">
Singularity
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" id="containerType2" value="Docker">
<label class="form-check-label" for="containerType2">
Docker
</label>
</div>
</div>
<div class="form-group">
<label for="labels">Labels :</label>
<select multiple class="form-control col-12" id="labels[]" name="labels[]">
<?php
foreach ($db->getLabels() as $label) {
echo '<option value="'.$label->ID.'">'.$label->name.'</option>';
}
?>
</select>
<small id="emailHelp" class="form-text text-muted">Multiple choises is possible.</small>
</div>
<div class="form-group">
<label for="tags">Tags :</label>
<input type="text" class="form-control" id="tags" name="tags">
</div>
<div class="form-group">
<label for="tags">Description :</label>
<input type="text" class="form-control" id="descriptions" name="descriptions">
</div>
<?php
if(isset($_SESSION['username'])) {
echo '
<div class="form-check">
<input type="checkbox" class="form-check-input" id="mycontainer" name="mycontainer">
<label class="form-check-label" for="mycontainer">Only my containers</label>
<br/><br/>
</div>
';
}
?>
<div class="form-inline form-group">
<label for="containerType">Order by :</label>
<div class="form-check">
<input type="radio" class="form-check-input" id="order" name="order" checked>
<label class="form-check-label" for="order">Date</label>
<br/><br/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Find</button>
</div>
</form>
</div>
</div>
</div>
</div>
foreach ($containers as $container) {
</div>
$container->escape2($db);
<br/><br/>
$visibility = "private";
$colorV = "e67e22";
<div class="row">
<div class="col-12">
<table id="Table_Container" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Author</th>
<th>Labels</th>
<th>Tags</th>
<th>Date</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody id="TableSection">
<?php
foreach ($containers as $container) {
$container->escape2($db);
$visibility = "private";
$colorV = "e67e22";
if($container->visibility) {
$visibility = "public";
$colorV = "f1c40f";
}
if(!$container->visibility) {
if($container->author != $_SESSION['username']) {
if($db->getGradeWithLogin($_SESSION['username'])->name != $db->getMaxGrades()->name) {
continue;
}
}
}
$typeC = "docker";
$colorT = "007bff";
if($container->visibility) {
$visibility = "public";
$colorV = "f1c40f";
}
if($container->type == "Singularity") {
$typeC = "singularity";
$colorT = "28a745";
}
if(!$container->visibility) {
if($container->author != $_SESSION['username']) {
if($db->getGradeWithLogin($_SESSION['username'])->name != $db->getMaxGrades()->name) {
continue;
}
}
}
echo '<tr>';
echo '<td>' . $container->name . '</td>';
echo '<td>' . $container->author . '</td>';
$typeC = "docker";
$colorT = "007bff";
if($container->type == "Singularity") {
$typeC = "singularity";
$colorT = "28a745";
}
$labels = $db->getLabelWithContainerId($container->ID);
echo '<tr>';
echo '<td>' . $container->name . '</td>';
echo '<td>' . $container->author . '</td>';
echo '<td>';
echo '<span class="badge" style="background:#'.$colorT.'">'.$typeC.'</span>';
echo '<span class="badge" style="background:#'.$colorV.'">'.$visibility.'</span>';
echo '<br/>';
$labels = $db->getLabelWithContainerId($container->ID);
$index = 0;
echo '<td>';
echo '<span class="badge" style="background:#'.$colorT.'">'.$typeC.'</span>';
echo '<span class="badge" style="background:#'.$colorV.'">'.$visibility.'</span>';
foreach ($labels as $label) {
echo '<span class="badge" style="background:#'.$label->color.'">'.$label->name.'</span>';
if($index == 1) {
echo '<br/>';
$index = 0;
} else {
$index++;
}
}
echo '</td>';
foreach ($labels as $label) {
echo '<span class="badge" style="background:#'.$label->color.'">'.$label->name.'</span>';
if($index == 1) {
echo '<br/>';
$index = 0;
} else {
$index++;
}
}
echo '</td>';
$tags = explode( ' ', $container->tags );
$index = 0;
$tags = explode( ' ', $container->tags );
echo '<td>';
$index = 0;
foreach ($tags as $tag) {
echo '<span class="badge" style="background:#'."30336b".'; color:#FFFFFF">'.$tag.'</span>';
echo '<td>';
/*if($index == 3) {
echo '<br/>';
$index = 0;
} else {
$index++;
} */
}
foreach ($tags as $tag) {
echo '<span class="badge" style="background:#'."30336b".'; color:#FFFFFF">'.$tag.'</span>';
}
echo '</td>';
echo '<td>' . $container->date . '</td>';
echo '<td>' . $container->description . '</td>';
echo '</td>';
echo '<td>' . $container->date . '</td>';
echo '<td>' . $container->description . '</td>';
echo '<td>';
echo '<td>';
echo '<div class="btn-group" mr-3><button class="btn btn-success btn-sm" onclick="showFileContainer(\''.$container->ID.'\')">show</button></div>';
echo '<div class="btn-group mr-1" ><button class="btn btn-success btn-sm" onclick="showFileContainer(\''.$container->ID.'\')">show</button></div>';
echo '<div class="btn-group" mr-3><a class="btn btn-primary btn-sm" href="./action/action_container.php?action=download&containerid='.$container->ID.'">dowload</a></div>';
echo '<div class="btn-group mr-1" ><a class="btn btn-primary btn-sm" href="./action/action_container.php?action=download&containerid='.$container->ID.'">dowload</a></div>';
if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
echo '<div class="btn-group mr-3"><a class="btn btn-danger btn-sm" href="./action/action_container.php?action=delete&containerid='.$container->ID.'" >delete</a></div>';
}
echo '</td>';
echo '</tr>';
}
if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
//echo '<div class="btn-group mr-1"><a class="btn btn-warning btn-sm" href="./action/action_container.php?action=update&containerid='.$container->ID.'" >update</a></div>';
}
?>
if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
echo '<div class="btn-group mr-1"><a class="btn btn-danger btn-sm" href="./action/action_container.php?action=delete&containerid='.$container->ID.'" >delete</a></div>';
}
echo '</td>';
echo '</tr>';
}
</tbody>
?>
</table>
</div>
</tbody>
</table>
</div>
</div>
<!-- Start Modal Publish -->
<!-- Start Modal Publish -->
<div class="modal" id="modalShowContainer">
<div class="modal-dialog modal-xl">
<div class="modal-dialog modal-xl">
<div class="modal-content modal-xl">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Container file</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Container file</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="modal-body">
<textarea type="text" class="form-control" id="valueContainerFile" name="value" value=""></textarea>
</div>
<!-- Modal footer -->
<div class="modal-footer">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success">Import</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div> <!-- End Modal Publish -->
</div>
</div>
<!-- End Modal Publish -->
<br/><br/><br/><br/><br/><br/>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
function showFileContainer(id ) {
......@@ -222,18 +317,14 @@ function showFileContainer(id ) {
var FILE_CONTAINER = [];
$(function()
{
<?php
foreach ($containers as $container) {
echo 'FILE_CONTAINER["'.$container->ID.'"] = "'.$container->value.'";';
echo '';
}
?>
});
{
<?php
foreach ($containers as $container) {
echo 'FILE_CONTAINER["'.$container->ID.'"] = "'.$container->value.'";
';
}
?>
});
</script>
......
......@@ -180,8 +180,52 @@ class DBquery
return $results;
}
public function getContainers() {
$sql = "SELECT * FROM `Container`;";
public function getContainers($type, $author, $labels, $tags, $descriptions) {
$sql = "SELECT * FROM `Container`";
if($type == "Singularity" || $type == "Docker") {
$sql .= " WHERE `type` = '$type'";
} else {
$sql .= " WHERE 1";
}
if($author != NULL) {
$sql .= " AND `author` = '$author'";
}
if(sizeof($labels) > 0) {
$subsql = "(SELECT DISTINCT containerId FROM `ContainerLabel` WHERE labelId IN (";
$index = 0;
foreach ($labels as $label) {
if($index != 0) {
$subsql .= ",";
}
$subsql .= $label;
$index++;
}
$subsql .= "))";
$sql .= " AND ID IN " . $subsql;
}
if(sizeof($tags) > 0) {
foreach ($tags as $tag) {
$sql .= " AND tags LIKE '%".$tag."%'";
}
}
if(sizeof($descriptions) > 0) {
foreach ($descriptions as $d) {
$sql .= " AND description LIKE '%".$d."%'";
}
}
$sql .= " ORDER BY `Container`.`date` DESC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
......@@ -343,27 +387,7 @@ class DBquery
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
/*if($distrib == "CRAN") {
$package = array($row['name'], $row['version'], $row['description'], $row['depends'], "https://cran.r-project.org/web/packages/".$row['name']."/index.html");
}
else if($distrib == "CPAN") {
$package = array($row['name'], $row['version'], $row['description'], "https://metacpan.org/pod/".$row['name'], "http://www.cpan.org/authors/id/".$row['download']);
}
else if($distrib == "NPM") {
$package = array($row['name'], $row['version'], $row['description'],$row['doc']);
}
else if($distrib == "Bioconductor" || $distrib == "Conda" || $distrib == "Ruby") {
$package = array($row['name'], $row['version'], $row['description'], $row['doc']);
}
else if($distrib == "Python") {
$package = array($row['name'], $row['version'], $row['description'], $row['doc'], $row['python_depends']);
}
else {
$package = array($row['name'], $row['version'], $row['description'], $row['doc'], $row['rpm']);
}*/
$package = new Package($row['name'], $row['version'], $row['description'], $row['doc'], $row['other']);
array_push($results,$package);
}
return $results;
......
......@@ -2,36 +2,28 @@
require_once "./inc/php/buildHeader.php";
?>
<div class="container-fluid">
<?php
echo '<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1> Login </h1>
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1> Login </h1>
</div>
<div class="col-lg-12">
<form action="./action/action_login.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="texte" class="form-control" id="username" name="username" placeholder="username">
</div>
<div class="col-lg-12">
<form action="./action/action_login.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="texte" class="form-control" id="username" name="username" placeholder="username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="password">
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<br/><br/><br/><br/>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="password">
</div>
</div>
</div>
';
?>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<br/><br/><br/><br/>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
......@@ -26,7 +26,6 @@ $grades = $db->getGrades();
$max_arrangement = 0;
foreach ($sections_parent as $section) {
if($section->arrangement > $max_arrangement) {
$max_arrangement = $section->arrangement;
}
......@@ -35,7 +34,6 @@ foreach ($sections_parent as $section) {
$max_grade = 0;
foreach ($grades as $grade) {
if($grade->level > $max_grade) {
$max_grade = $grade->level;
}
......
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