container.php 5.79 KB
Newer Older
jlopez's avatar
jlopez committed
1
2
3
4
5
6
7
8
9
10
11
<?php


session_start ();

require_once "./dao/DBquery.php";

$db = new DBquery();

$containers = $db->getContainers();

jlopez's avatar
jlopez committed
12
require_once "./inc/php/buildHeader.php";
jlopez's avatar
jlopez committed
13

jlopez's avatar
jlopez committed
14
?>
jlopez's avatar
jlopez committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

<div class="container-fluid">

    <br/><br/>

    <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>
jlopez's avatar
jlopez committed
31
                                <th>Tags</th>
jlopez's avatar
jlopez committed
32
33
                                <th>Date</th>
                                <th>Description</th>
jlopez's avatar
jlopez committed
34
35
36
37
38
39
40
41
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody id="TableSection">
                        <?php

                            foreach ($containers as $container) {

jlopez's avatar
jlopez committed
42
43
                                $container->escape2($db);

jlopez's avatar
jlopez committed
44
                                $visibility = "private";
jlopez's avatar
jlopez committed
45
46
                                $colorV = "e67e22";

jlopez's avatar
jlopez committed
47
48
49

                                if($container->visibility) {
                                    $visibility = "public";
jlopez's avatar
jlopez committed
50
                                    $colorV = "f1c40f";
jlopez's avatar
jlopez committed
51
52
53
54
                                }

                                if(!$container->visibility) {
                                    if($container->author != $_SESSION['username']) {
jlopez's avatar
jlopez committed
55
                                        if($db->getGradeWithLogin($_SESSION['username'])->name != $db->getMaxGrades()->name) {
jlopez's avatar
jlopez committed
56
57
                                            continue;
                                        }
jlopez's avatar
jlopez committed
58
59
60
                                    }
                                }

jlopez's avatar
jlopez committed
61
62
63
64
65
66
67
68
                                $typeC = "docker";
                                $colorT = "007bff";

                                if($container->type == "Singularity") {
                                    $typeC = "singularity";
                                    $colorT = "28a745";
                                }

jlopez's avatar
jlopez committed
69
70
71
                                echo '<tr>';
                                echo '<td>' . $container->name . '</td>';
                                echo '<td>' . $container->author . '</td>';
jlopez's avatar
jlopez committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


                                $labels = $db->getLabelWithContainerId($container->ID);

                                echo '<td>';
                                echo '<span class="badge" style="background:#'.$colorT.'">'.$typeC.'</span>';
                                echo '<span class="badge" style="background:#'.$colorV.'">'.$visibility.'</span>';

                                echo '<br/>';

                                $index = 0;

                                foreach ($labels as $label) {
                                    echo '<span class="badge" style="background:#'.$label->color.'">'.$label->name.'</span>';

                                    if($index == 1) {
                                        echo '<br/>';
                                        $index = 0;
                                    } else {
                                        $index++;
jlopez's avatar
jlopez committed
92
                                    }       
jlopez's avatar
jlopez committed
93
94
95
96
                                }
                                
                                echo '</td>';

jlopez's avatar
jlopez committed
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                                $tags = explode( ' ', $container->tags );

                                $index = 0;

                                echo '<td>';

                                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>';
jlopez's avatar
jlopez committed
115
                                echo '<td>' . $container->date . '</td>';
jlopez's avatar
jlopez committed
116
                                echo '<td>' . $container->description . '</td>';
jlopez's avatar
jlopez committed
117

jlopez's avatar
jlopez committed
118
                                echo '<td>';
jlopez's avatar
jlopez committed
119

jlopez's avatar
jlopez committed
120
                                //echo '<div class="btn-group" mr-3><a class="btn btn-success btn-sm" href="#" >show</a></div>';
jlopez's avatar
jlopez committed
121

jlopez's avatar
jlopez committed
122
                                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>';
jlopez's avatar
jlopez committed
123
124

                                if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
jlopez's avatar
jlopez committed
125
                                    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>';
jlopez's avatar
jlopez committed
126
127
                                }
                    
jlopez's avatar
jlopez committed
128
                                echo '</td>';
jlopez's avatar
jlopez committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
                                echo '</tr>';
                            }

                        ?>

                        </tbody>

                    </table>
                </div>

    </div>

    <br/><br/><br/><br/><br/><br/>

</div>

<!-- jQuery Version 1.11.1 -->
jlopez's avatar
jlopez committed
146
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
jlopez's avatar
jlopez committed
147
148
149
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

remy's avatar
remy committed
150
151
152
153
<!-- local fallbacks -->
<!--script src="inc/js/jquery-latest.min.js" type="text/javascript"></script>
<script src="inc/js/bootstrap.min.js" type="text/javascript"></script-->

jlopez's avatar
jlopez committed
154
<script type="text/javascript">
jlopez's avatar
jlopez committed
155
156
157
158
159
</script>

</body>

</html>