Commit c7214f6b authored by jlopez's avatar jlopez
Browse files

Merge branch 'develop' into 'master'

New version

Closes #16, #20, and #18

See merge request !11
parents eed362d0 25d0858e
Pipeline #214 failed with stage
in 44 seconds
......@@ -57,25 +57,34 @@ class DBquery
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
$d = new Distribution($row['ID'], $row['name'], $row['version'], $row['manager'], $row['active']);
$d = new Distribution($row['ID'], $row['name'], $row['version'], $row['manager'], $row['active'], $row['vname']);
array_push($results, $d);
}
return $results;
}
public function getVName($name, $version) {
$sql = "SELECT vname FROM `Distrib` WHERE active = 1 AND `name`='$name' AND `version`='$version';";
$result = mysqli_query($this->dbh, $sql);
while($row = mysqli_fetch_assoc($result)){
return $row['vname'];
}
return "";
}
public function getActiveDistributions() {
$sql = "SELECT * FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
$d = new Distribution($row['ID'], $row['name'], $row['version'], $row['manager'], $row['active']);
$d = new Distribution($row['ID'], $row['name'], $row['version'], $row['manager'], $row['active'], $row['vname']);
array_push($results, $d);
}
return $results;
}
public function getActiveDistributionsFullName() {
$sql = "SELECT name,version FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$sql = "SELECT name,version,vname FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
......
<?php
session_start ();
require_once "./inc/php/buildHeader.php";
?>
<div class="container">
<br/>
<div class="row justify-content-center">
<h1> FAQ </h1>
</div>
</div>
</body>
</html>
......@@ -8,6 +8,7 @@
require_once "./dao/DBquery.php";
require_once "./package.php";
$db = new DBquery();
......@@ -29,9 +30,10 @@ if(isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
$patternName = false;
$patternDescription = false;
$patternName = true;
$patternDescription = true;
/*
if(isset($_GET['patternName'])) {
if($_GET['patternName'] == "true") {
$patternName = true;
......@@ -42,16 +44,44 @@ if(isset($_GET['patternDescription'])) {
if($_GET['patternDescription'] == "true") {
$patternDescription = true;
}
}
$limit = "25";
}*/
if(isset($_GET['limit'])) {
$limit = $_GET['limit'];
}
$result = $db->getPackages($distrib, $filter, $patternName, $patternDescription, $limit);
$result = array();
if(strpos($distrib, ':') !== false) {
$os = explode (":", $distrib);
$os_name = $os[0];
$version_num = $os[1];
$version_name = $db->getVName($os_name, $version_num);
$result = findDistributionPackage($os_name, $version_num, $version_name, $filter, $limit, false);
} else {
if($distrib == "Conda") {
$result = findCondaPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else if($distrib == "Rubygems") {
$result = findRubyPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else if($distrib == "NPM") {
$result = findNPMPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else if($distrib == "CPAN") {
$result = findCPANPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else if($distrib == "CRAN" || $distrib == "Bioconductor") {
$result = findRPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else if($distrib == "Python") {
$result = findPythonPackage($distrib, $version_num, $version_name, $filter, $limit, false);
}
else {
$result = $db->getPackages($distrib, $filter, $patternName, $patternDescription, $limit);
}
}
echo '
<div class="container">
......
......@@ -19,7 +19,7 @@ $( "#generateButton" ).click(function() {
});
function buildRecipe() {
function buildCommand() {
var filename = document.getElementById("imageNameInput").value;
......@@ -263,6 +263,39 @@ function generate_container() {
}
var timezone = document.getElementById("timezonePreview").value;
if(isSingularity) {
PREVIEW += "\t"+ timezone + "\n";
nrow += 1;
}
else {
PREVIEW += "RUN " + timezone + "\n";
nrow += 1;
}
PREVIEW += "\n";
var locale = document.getElementById("localePreview").value;
if(isSingularity) {
PREVIEW += "\t"+ locale + "\n";
nrow += 1;
}
else {
PREVIEW += "RUN " + locale + "\n";
nrow += 1;
}
PREVIEW += "\n";
if(isSingularity) {
PREVIEW += "\t" + manager + " update\n";
}
else {
PREVIEW += "RUN " + manager + " update\n";
}
nrow += 1;
PREVIEW += "\n";
for(var i = 0; i < SELECTED_PACKAGES["Distribution"].length; i++) {
if(isSingularity) {
......@@ -281,6 +314,13 @@ function generate_container() {
PREVIEW += "\n############### Install R ##############\n";
if(isSingularity) {
PREVIEW += "\t"+manager+" install -y " + "make" + "\n";
} else {
PREVIEW += "RUN "+manager+" install -y " + "make" + "\n";
}
if(isSingularity) {
PREVIEW += '\tcd $HOME';
PREVIEW += '\n\twget https://cran.rstudio.com/src/base/R-3/R-'+ rversion+ '.tar.gz';
......@@ -299,6 +339,24 @@ function generate_container() {
PREVIEW += "\t&& make install "+ "\n";
}
nrow += 8;
var localeR = document.getElementById("localeR").value;
if(localeR != "") {
localeR = "echo 'Sys.setlocale(\"LC_ALL\", \"" + localeR + "\")' | R --slave";
if(isSingularity) {
PREVIEW += "\t"+ localeR + "\n";
nrow += 1;
}
else {
PREVIEW += "RUN " + localeR + "\n";
nrow += 1;
}
PREVIEW += "\n";
}
}
for(var i = 0; i < SELECTED_PACKAGES["CRAN"].length; i++) {
......@@ -353,7 +411,10 @@ function generate_container() {
PREVIEW += "\t"+manager+" -y install curl bzip2 \\" + "\n";
PREVIEW += "\t&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \\" + "\n";
PREVIEW += "\t&& bash /tmp/miniconda.sh -bfp /usr/local/ \\" + "\n";
PREVIEW += "\t&& conda install -y python=3 \\" + "\n";
//PREVIEW += "\t&& conda install -y python=3 \\" + "\n";
PREVIEW += "\t&& conda config --add channels bioconda \\" + "\n";
PREVIEW += "\t&& conda config --add channels anaconda \\" + "\n";
PREVIEW += "\t&& conda config --add channels conda-forge \\" + "\n";
PREVIEW += "\t&& conda update conda \\" + "\n";
PREVIEW += "\t&& conda clean --all --yes " + "\n";
......@@ -366,13 +427,16 @@ function generate_container() {
PREVIEW += "&& "+manager+" -y install curl bzip2 \\" + "\n";
PREVIEW += "&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \\" + "\n";
PREVIEW += "&& bash /tmp/miniconda.sh -bfp /usr/local/ \\" + "\n";
PREVIEW += "&& conda install -y python=3 \\" + "\n";
//PREVIEW += "&& conda install -y python=3 \\" + "\n";
PREVIEW += "&& conda config --add channels bioconda \\" + "\n";
PREVIEW += "&& conda config --add channels anaconda \\" + "\n";
PREVIEW += "&& conda config --add channels conda-forge \\" + "\n";
PREVIEW += "&& conda update conda \\" + "\n";
PREVIEW += "&& conda clean --all --yes " + "\n";
}
nrow += 10;
nrow += 11;
for(var i = 0; i < SELECTED_PACKAGES["Conda"].length; i++) {
......@@ -511,13 +575,27 @@ function generate_container() {
PREVIEW += "\nRUN curl -L https://cpanmin.us | perl - App::cpanminus\n";
}
var localePerl = document.getElementById("localePerl").value;
if(localePerl != "") {
if(isSingularity) {
PREVIEW += "\t"+ localePerl + "\n";
nrow += 1;
}
else {
PREVIEW += "RUN " + localePerl + "\n";
nrow += 1;
}
PREVIEW += "\n";
}
nrow += 3;
for(var i = 0; i < SELECTED_PACKAGES["CPAN"].length; i++) {
var version = "@"+SELECTED_PACKAGES["CPAN"][i][1];
//var version = "@"+SELECTED_PACKAGES["CPAN"][i][1];
var version = "";
if(version === "@undef") {
version = ""
......@@ -694,7 +772,8 @@ function showPackage(distribName) {
var str = document.getElementById("find"+distribName+"Packages").value;
var limit = document.getElementById("limit"+distribName).value;
//var limit = document.getElementById("limit"+distribName).value;
var limit = 30;
if (str == "") {
document.getElementById("containPackages"+distribName).innerHTML = "";
......@@ -711,11 +790,15 @@ function showPackage(distribName) {
}
};
var patternName = document.getElementById("pattern"+distribName+"Name").checked;
var patternDescription = document.getElementById("pattern"+distribName+"Description").checked;
//var patternName = document.getElementById("pattern"+distribName+"Name").checked;
//var patternDescription = document.getElementById("pattern"+distribName+"Description").checked;
var patternName = true;
var patternDescription = true;
//xmlhttp.open("GET","get"+distribName+"Packages.php?distrib="+distrib+"&filter="+str+"&patternName="+patternName+"&patternDescription="+patternDescription+"&limit="+limit,true);
xmlhttp.open("GET","getPackages.php?distrib="+distrib+"&filter="+str+"&patternName="+patternName+"&patternDescription="+patternDescription+"&limit="+limit,true);
console.log("getPackages.php?distrib="+distrib+"&filter="+str+"&patternName="+patternName+"&patternDescription="+patternDescription+"&limit="+limit);
xmlhttp.send();
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ echo '
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="navbar-brand">WICOPA</div>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
';
......@@ -34,7 +34,7 @@ echo '
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./container.php"> Containers </a>';
echo ' <a class="nav-item nav-link" href="./container.php"> Contributed Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
......@@ -46,6 +46,9 @@ echo '
}
}
echo ' <a class="nav-item nav-link" href="./faq.php"> FAQ </a>';
echo '
</div>
......
......@@ -16,6 +16,15 @@ function printSection($name, $db) {
</div>
';
printPanel($name);
} else if($name == "CPAN") {
echo '
<div class="form-group">
<label for="localePerl" class="font-weight-bold">Perl locale :</label>
<input type="text" class="form-control" id="localePerl" value="locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US:en">
</div>
';
printPanel($name);
} else if($name == "R") {
$subsection = $db->getNameSectionWhithParent("R");
......@@ -24,10 +33,16 @@ function printSection($name, $db) {
<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>
<option value="0" selected="selected" >None</option>
<option value="3.6.3">3.6.3</option>
<option value="3.5">3.5</option>
</select>
</div>
<div class="form-group">
<label for="localeR" class="font-weight-bold">R locale :</label>
<input type="text" class="form-control" id="localeR" value="en_US.UTF-8">
</div>
<nav>
<div class="nav nav-tabs" id="nav-tab-R" role="tablist">
......@@ -69,9 +84,36 @@ function printSection($name, $db) {
function printPanel($name) {
echo '
<label for="find'.$name.'Packages">Find packages with pattern :</label>
<input type="email" class="form-control" id="find'.$name.'Packages">
<label for="find'.$name.'Packages">Find packages containing substring :</label>
<input type="email" class="form-control" id="find'.$name.'Packages">';
if($name == "CRAN") {
echo '<small class="form-text text-muted">exemple: genepop</small>';
}
else if($name == "Bioconductor") {
echo '<small class="form-text text-muted">exemple: GenomicFeatures</small>';
}
else if($name == "CPAN") {
echo '<small class="form-text text-muted">exemple: cpanminus</small>';
}
else if ($name == "Rubygems") {
echo '<small class="form-text text-muted">exemple: math-api</small>';
}
else if ($name == "Python") {
echo '<small class="form-text text-muted">exemple: math3d</small>';
}
else if ($name == "NPM") {
echo '<small class="form-text text-muted">exemple: math</small>';
}
else {
echo '<small class="form-text text-muted">exemple: python</small>';
}
echo '
<!--
<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>
......@@ -80,10 +122,11 @@ function printPanel($name) {
<div class="form-check">
<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>
</div> -->
<br/>
<!--
<div class="form-group">
<label for="limit'.$name.'" class="font-check-label">Max found :</label>
<select class="custom-select" id="limit'.$name.'">
......@@ -95,7 +138,7 @@ function printPanel($name) {
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
</div>
</div> -->
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="showPackage(\''.$name.'\')">Search</button>
......
......@@ -31,30 +31,44 @@ require_once "./inc/php/buildHeader.php";
<input type="text" class="form-control" id="imageNameInput">
</div>
<div class="form-group">
<label for="baseNameInput" class="font-weight-bold">From :</label>
<input type="text" class="form-control" id="baseNameInput">
<small id="help0" class="form-text text-muted">You can find images name on <a href="https://hub.docker.com/search?q=&type=image" >docker hub </a>.</small>
<small id="help1" class="form-text text-muted">If the above "From" field is empty, then <a href="https://docs.docker.com/engine/reference/builder/#from">"From"</a> is chosen from distribution bellow. </small>
<small id="help2" class="form-text text-muted">You must make sure that the OS of your base container is compatible with the chosen distribution. </small>
</div>
<div class="form-group">
<label for="selectedOS" class="font-weight-bold">Distribution <span style="font-size:20px;" class="status text-danger">*</span>:</label>
<label for="selectedOS" class="font-weight-bold">From Distribution <span style="font-size:20px;" class="status text-danger">*</span>:</label>
<select class="custom-select" id="selectedOS" onchange="hide_os_rows()">
<?php
foreach ($db->getActiveDistributionsFullName() as $name){
echo ' <option value="'.$name.'">'.$name.'</option>';
if(strpos($name, "ubuntu") !== false) {
echo ' <option value="'.$name.'" selected="selected">'.$name.'</option>';
}
else {
echo ' <option value="'.$name.'">'.$name.'</option>';
}
}
?>
</select>
</div>
<div class="form-group">
<p class="font-weight-bold">OR</p>
</div>
<div class="form-group">
<label for="baseNameInput" class="font-weight-bold">From Image :</label>
<input type="text" class="form-control" id="baseNameInput">
<small id="help0" class="form-text text-muted">You can find images name on <a href="https://hub.docker.com/search?q=&type=image" >docker hub </a>.</small>
<small id="help1" class="form-text text-muted">If the above "From Image" field is empty, then <a href="https://docs.docker.com/engine/reference/builder/#from">"From Distribution"</a> is chosen from distribution bellow. </small>
<small id="help2" class="form-text text-muted">You must make sure that the OS of your base container is compatible with the chosen distribution. </small>
</div>
<div class="form-group">
<label for="selectedOS" class="font-weight-bold">Package manager :</label>
<select class="custom-select" id="selectedInstaller">
<label for="selectedOS" class="font-weight-bold" hidden >Package manager :</label>
<select class="custom-select" id="selectedInstaller" hidden>
<?php
foreach ($db->getManagers() as $manager){
......@@ -79,8 +93,8 @@ require_once "./inc/php/buildHeader.php";
<div class="form-group">
<button type="button" id="generateButton" class="btn btn-primary">Generate recipe</button>
<button type="button" id="downloadButton" class="btn btn-primary" onclick="downloadFile()">Download recipe</button>
<button type="button" id="generateButton" class="btn btn-primary" onclick="buildRecipe()">Build recipe</button>
<button type="button" id="generateButton" class="btn btn-primary">Push recipe</button>
<button type="button" id="generateButton" class="btn btn-primary" onclick="buildCommand()">Build command</button>
<!--<button type="button" id="generateButton" class="btn btn-primary">Push recipe</button>-->
</div>
<div class="form-group">
......@@ -126,7 +140,7 @@ require_once "./inc/php/buildHeader.php";
<div class="col-12">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Environment configs :
Local Environment configs :
</div>
<div class="card-body">
<table id="Table_EnvConfig" class="table table-striped table-bordered">
......@@ -165,7 +179,7 @@ require_once "./inc/php/buildHeader.php";
<div class="col-12">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Post configs :
Local Post configs :
</div>
<div class="card-body">
<table id="Table_PostConfig" class="table table-striped table-bordered">
......@@ -202,16 +216,42 @@ require_once "./inc/php/buildHeader.php";
</div>
</div>
<br/>
<div class="col-12">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Timezone :
</div>
<div class="card-body">
<input type="text" class="form-control" id="timezonePreview" value='TZ=Europe/Paris; ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone'>
</div>
</div>
</div>
<br/>
<br/>
<div class="col-12">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Locale :
</div>
<div class="card-body">
<input type="text" class="form-control" id="localePreview" value="sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen && echo 'LANG=&quot;en_US.UTF-8&quot;' >> /etc/default/locale">
</div>
</div>
</div>
<br/>
<div class="col-12">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Exec line (%Runscript / CMD) :
The default command line executed when you run the container :
</div>
<div class="card-body">
<div class="form-group">
<label for="ExecLineInput" class="font-weight-bold">Exec Line :</label>
<label for="ExecLineInput" class="font-weight-bold">Exec Line (<a href="https://singularity.lbl.gov/docs-docker#how-does-the-runscript-work">%Runscript</a> / <a href="https://docs.docker.com/engine/reference/builder/#cmd">CMD</a>) :</label>
<input type="text" class="form-control" id="ExecLineInput" value='exec /bin/bash "$@"'>
</div>
......@@ -224,7 +264,7 @@ require_once "./inc/php/buildHeader.php";
<div class="col-8">
<div class="card border border-dark">
<div class="card-header bg-dark text-light">
Tools :
Tools from packages manager :
</div>
<div class="card-body">
<nav>
......@@ -234,7 +274,7 @@ 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->name.'-tab" data-toggle="tab" href="#nav-'.$s->name.'" role="tab" aria-controls="nav-'.$s->name.'" aria-selected="false">'.$s->visual.'</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.' packages manager</a>';
} else {
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>';
}
......
......@@ -70,7 +70,6 @@ require_once "./inc/php/buildHeader.php";
<th>Parent</th>
<th>Packages</th>
<th>Save</th>
<th>Update</th>
</tr>
</thead>
<tbody id="TableSection">
......@@ -97,7 +96,6 @@ require_once "./inc/php/buildHeader.php";
echo '<td>' . $section->parent . '</td>';
echo '<td>' . $db->getNumberPackage($section->name). '</td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '<td>' . '<a href="#" class="btn btn-warning btn-sm">update</button>' . '</td>';
echo '</tr></form>';
foreach ($db->getAllSectionWhithParent($section->name) as $subsection) {
......@@ -117,9 +115,7 @@ require_once "./inc/php/buildHeader.php";
echo '<td>' . '<input id="number" name="arrangement" class="form-control" type="number" value="'.$subsection->arrangement.'">' . '</td>';
echo '<td>' . $subsection->parent . '</td>';
echo '<td>' . $db->getNumberPackage($subsection->name). '</td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '<td>' . '<a href="#" class="btn btn-warning btn-sm">update</button>' . '</td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '</tr></form>';
}
}
......
......@@ -17,6 +17,7 @@ class Distribution
var $manager = "";
var $active = 0;
var $state = 0;
var $vname = "";
/**
* Section constructor.
......@@ -24,13 +25,14 @@ class Distribution