Commit 04703607 authored by root's avatar root
Browse files
parents 7c5b7ab7 5627fe49
......@@ -7,33 +7,57 @@ 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="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>
......@@ -43,9 +67,97 @@ require_once "./inc/php/buildHeader.php";
<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>
<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>
</div>
<br/><br/>
<div class="row">
<div class="col-12">
<table id="Table_Container" class="table table-striped table-bordered">
<thead>
<tr>
......@@ -126,13 +238,6 @@ require_once "./inc/php/buildHeader.php";
foreach ($tags as $tag) {
echo '<span class="badge" style="background:#'."30336b".'; color:#FFFFFF">'.$tag.'</span>';
/*if($index == 3) {
echo '<br/>';
$index = 0;
} else {
$index++;
} */
}
echo '</td>';
......@@ -141,14 +246,19 @@ require_once "./inc/php/buildHeader.php";
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-1" ><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-3><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-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-3"><a class="btn btn-danger btn-sm" href="./action/action_container.php?action=delete&containerid='.$container->ID.'" >delete</a></div>';
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>';
}
......@@ -156,55 +266,40 @@ require_once "./inc/php/buildHeader.php";
?>
</tbody>
</table>
</div>
</div>
<!-- Start Modal Publish -->
<!-- Start Modal Publish -->
<div class="modal" id="modalShowContainer">
<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>
</div>
<!-- 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">
<button type="submit" class="btn btn-success">Submit</button>
<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> <!-- End Modal Publish -->
</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 '';
echo 'FILE_CONTAINER["'.$container->ID.'"] = "'.$container->value.'";
';
}
?>
});
});
</script>
......
......@@ -73,6 +73,16 @@ class DBquery
return $results;
}
public function getActiveDistributionsFullName() {
$sql = "SELECT name,version FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
array_push($results, $row['name'].":".$row['version']);
}
return $results;
}
public function getManagers() {
$sql = "SELECT * FROM `Manager`;";
$result = mysqli_query($this->dbh, $sql);
......@@ -170,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)){
......@@ -263,6 +317,16 @@ class DBquery
return $results;
}
public function getNameSectionWhithParent($parent) {
$sql = "SELECT name FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
array_push($results,$row['name']);
}
return $results;
}
public function getAllSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......@@ -323,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;
......
<?php
function printPanel($name) {
function printSection($name, $db) {
if($name == "Python") {
echo '
<div class="form-group">
<label for="selectedPython" class="font-weight-bold">Python version :</label>
<select class="custom-select" id="selectedPython">
<option value="0" selected="selected">None</option>
<option value="3.7" >3.7</option>
<option value="3.6" >3.6</option>
<option value="3.5" >3.5</option>
<option value="2.7" >2.7</option>
</select>
</div>
';
<br/>
printPanel($name);
} else if($name == "R") {
$subsection = $db->getNameSectionWhithParent("R");
echo '
<div class="form-group">
<label for="selectedR" class="font-weight-bold">R version :</label>
<select class="custom-select" id="selectedR">
<option value="0" >None</option>
<option value="3.5" selected="selected">3.5</option>
</select>
</div>
<nav>
<div class="nav nav-tabs" id="nav-tab-R" role="tablist">
';
echo '<a class="nav-item nav-link active" id="nav-'.$subsection[0].'-tab-R" data-toggle="tab" href="#nav-'.$subsection[0].'-R" role="tab" aria-controls="nav-'.$subsection[0].'-R" aria-selected="false">'.$subsection[0].'</a>';
for ($i = 1; $i < sizeof($subsection); $i++) {
echo '<a class="nav-item nav-link" id="nav-'.$subsection[$i].'-tab-R" data-toggle="tab" href="#nav-'.$subsection[$i].'-R" role="tab" aria-controls="nav-'.$subsection[$i].'-R" aria-selected="false">'.$subsection[$i].'</a>';
}
echo '
</div>
</nav>
<div class="tab-content" id="nav-tabContent-R">
';
$indexSub = 0;
foreach ($subsection as $sub) {
if ($indexSub == 0) {
echo '<div class="tab-pane fade show active" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
} else {
echo '<div class="tab-pane fade" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
}
printPanel($sub);
echo '</div>';
$indexSub++;
}
echo '</div>';
} else {
printPanel($name);
}
}
function printPanel($name) {
echo '
<label for="find'.$name.'Packages">Find packages with pattern :</label>
<input type="email" class="form-control" id="find'.$name.'Packages">
<input type="email" class="form-control" id="find'.$name.'Packages">
<div class="form-check">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Name" checked>
<label class="form-check-label" for="pattern'.$name.'Name">Pattern on name</label>
</div>
......@@ -16,6 +81,7 @@ function printPanel($name) {
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Description" checked>
<label class="form-check-label" for="pattern'.$name.'Description">Pattern on description</label>
</div>
<br/>
<div class="form-group">
......@@ -30,12 +96,13 @@ function printPanel($name) {
<option value="1000000000">all</option>
</select>
</div>
<br/>
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="showPackage(\''.$name.'\')">Search</button>
<br/><br/>
</div>
<div id="containPackages'.$name.'">
</div>
';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 11/12/18
* Time: 14:30
*/
//$content = file_get_contents("container.json", FILE_USE_INCLUDE_PATH);
//$tools = json_decode($content)->containers;
session_start ();
......@@ -17,31 +7,7 @@ require_once "./inc/php/printPanel.php";
$db = new DBquery();
$distribs = [];
$data_distribs = $db->getActiveDistributions();
foreach($data_distribs as $value){
array_push($distribs,$value->name.":".$value->version);
}
$managers = $db->getManagers();
$data_section = $db->getActiveSection();
$section = array();
$section_visual = array();
$grade = $db->getGradeWithLogin($_SESSION['username']);
$labels = $db->getLabelsWithGrade($grade);
foreach ($db->getAllActiveSectionParent() as $s){
if($s->active == 1) {
array_push($section, $s->name);
array_push($section_visual, $s->visual);
}
}
$section = $db->getAllActiveSectionParent();
require_once "./inc/php/buildHeader.php";
......@@ -78,8 +44,8 @@ require_once "./inc/php/buildHeader.php";
<select class="custom-select" id="selectedOS" onchange="hide_os_rows()">
<?php
foreach ($distribs as $d){
echo ' <option value="'.$d.'">'.$d.'</option>';
foreach ($db->getActiveDistributionsFullName() as $name){
echo ' <option value="'.$name.'">'.$name.'</option>';
}
?>
......@@ -91,7 +57,7 @@ require_once "./inc/php/buildHeader.php";
<select class="custom-select" id="selectedInstaller">
<?php
foreach ($managers as $manager){
foreach ($db->getManagers() as $manager){
echo '<option value="'.$manager->value.'">'.$manager->value.'</option>';
}
?>
......@@ -188,9 +154,9 @@ require_once "./inc/php/buildHeader.php";
$index = 0;
foreach ($section as $s) {
if($index == 0) {
echo '<a class="nav-item nav-link active" id="nav-'.$s.'-tab" data-toggle="tab" href="#nav-'.$s.'" role="tab" aria-controls="nav-'.$s.'" aria-selected="false">'.$section_visual[$index].'</a>';
echo '<a class="nav-item nav-link active" id="nav-'.$s->name.'-tab" data-toggle="tab" href="#nav-'.$s->name.'" role="tab" aria-controls="nav-'.$s->name.'" aria-selected="false">'.$s->visual.'</a>';
} else {
echo '<a class="nav-item nav-link" id="nav-'.$s.'-tab" data-toggle="tab" href="#nav-'.$s.'" role="tab" aria-controls="nav-'.$s.'" aria-selected="false">'.$section_visual[$index].'</a>';
echo '<a class="nav-item nav-link" id="nav-'.$s->name.'-tab" data-toggle="tab" href="#nav-'.$s->name.'" role="tab" aria-controls="nav-'.$s->name.'" aria-selected="false">'.$s->visual.'</a>';
}
$index++;
}
......@@ -202,97 +168,11 @@ require_once "./inc/php/buildHeader.php";
$index = 0;
foreach ($section as $s) {
if($index == 0) {
echo '<div class="tab-pane fade show active" id="nav-'.$s.'" role="tabpanel" aria-labelledby="nav-'.$s.'-tab">';
echo '<div class="tab-pane fade show active" id="nav-'.$s->name.'" role="tabpanel" aria-labelledby="nav-'.$s->name.'-tab">';
}else {
echo '<div class="tab-pane fade" id="nav-'.$s.'" role="tabpanel" aria-labelledby="nav-'.$s.'-tab">';
}
if($s == "R") {
$subsection = array();
foreach ($db->getSectionWhithParent("R") as $value){
if($value[1]) {
array_push($subsection, $value[0]);
}
}
echo '
<div class="form-group">
<label for="selectedR" class="font-weight-bold">R version :</label>
<select class="custom-select" id="selectedR">
<option value="0" >None</option>
<option value="3.5" selected="selected">3.5</option>
</select>
</div>
<nav>
<div class="nav nav-tabs" id="nav-tab-R" role="tablist">
';
$indexSub = 0;
foreach ($subsection as $sub) {
if($indexSub == 0) {
echo '<a class="nav-item nav-link active" id="nav-'.$sub.'-tab-R" data-toggle="tab" href="#nav-'.$sub.'-R" role="tab" aria-controls="nav-'.$sub.'-R" aria-selected="false">'.$sub.'</a>';
} else {