Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jlopez
wicopa
Commits
04703607
Commit
04703607
authored
Jun 19, 2019
by
root
Browse files
Merge branch 'master' of
https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa
parents
7c5b7ab7
5627fe49
Changes
6
Hide whitespace changes
Inline
Side-by-side
container.php
View file @
04703607
...
...
@@ -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"
><h
2
>
Docker public
</h
2
></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"
><h
4
>
Docker public
</h
4
></div>
<div
class=
"card-body text-primary"
>
<h
3
class=
"card-title"
>
<?php
echo
$db
->
getNumberDockerContainer
()
?>
Files
</h
3
>
<h
5
class=
"card-title"
>
<?php
echo
$db
->
getNumberDockerContainer
()
?>
Files
</h
5
>
</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"
><h
2
>
Singularity public
</h
2
></div>
<div
class=
"col-sm-
2
"
>
<div
class=
"card border-success
sm-2
"
>
<div
class=
"card-header font-weight-bold text-white bg-success"
><h
4
>
Singularity public
</h
4
></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
->
visibil
ity
)
{
$visibility
=
"public
"
;
$color
V
=
"
f1c40f
"
;
}
if
(
$container
->
type
==
"Singular
ity
"
)
{
$typeC
=
"singularity
"
;
$color
T
=
"
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
'<t
r
>'
;
echo
'<td>'
.
$container
->
name
.
'</td
>'
;
echo
'<td>'
.
$container
->
author
.
'</td
>'
;
echo
'<t
d
>'
;
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"
>
×
</button>
<h4
class=
"modal-title"
>
Container file
</h4>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
>
×
</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"
>
<button
type=
"submit"
class=
"btn btn-success"
>
Submit
</button>
</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>
...
...
dao/DBquery.php
View file @
04703607
...
...
@@ -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
;
...
...
inc/php/printPanel.php
View file @
04703607
<?php
function
printPanel
(
$name
)
{
function
printSection
(
$name
,
$db
)
{
if
(
$name
==
"Python"
)
{
echo
'
<br/>
<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>
'
;
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">
'
;