container.php 8.59 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();

12
13


jlopez's avatar
jlopez committed
14
require_once "./inc/php/buildHeader.php";
jlopez's avatar
jlopez committed
15

jlopez's avatar
jlopez committed
16
?>
jlopez's avatar
jlopez committed
17
18
19

<div class="container-fluid">

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<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="card-body text-primary">
                <h3 class="card-title"><?php echo $db->getNumberDockerContainer() ?> Files</h3>
            </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="card-body text-success">
                <h3 class="card-title"><?php echo $db->getNumberSingularityContainer() ?> Files</h3>
            
            </div>
            </div>
        </div>
        </div>

jlopez's avatar
jlopez committed
42
43
44
45
46
47
48
49
50
51
52
53
54
    <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
55
                                <th>Tags</th>
jlopez's avatar
jlopez committed
56
57
                                <th>Date</th>
                                <th>Description</th>
jlopez's avatar
jlopez committed
58
59
60
61
62
63
64
65
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody id="TableSection">
                        <?php

                            foreach ($containers as $container) {

jlopez's avatar
jlopez committed
66
67
                                $container->escape2($db);

jlopez's avatar
jlopez committed
68
                                $visibility = "private";
jlopez's avatar
jlopez committed
69
70
                                $colorV = "e67e22";

jlopez's avatar
jlopez committed
71
72
73

                                if($container->visibility) {
                                    $visibility = "public";
jlopez's avatar
jlopez committed
74
                                    $colorV = "f1c40f";
jlopez's avatar
jlopez committed
75
76
77
78
                                }

                                if(!$container->visibility) {
                                    if($container->author != $_SESSION['username']) {
jlopez's avatar
jlopez committed
79
                                        if($db->getGradeWithLogin($_SESSION['username'])->name != $db->getMaxGrades()->name) {
jlopez's avatar
jlopez committed
80
81
                                            continue;
                                        }
jlopez's avatar
jlopez committed
82
83
84
                                    }
                                }

jlopez's avatar
jlopez committed
85
86
87
88
89
90
91
92
                                $typeC = "docker";
                                $colorT = "007bff";

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

jlopez's avatar
jlopez committed
93
94
95
                                echo '<tr>';
                                echo '<td>' . $container->name . '</td>';
                                echo '<td>' . $container->author . '</td>';
jlopez's avatar
jlopez committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115


                                $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
116
                                    }       
jlopez's avatar
jlopez committed
117
118
119
120
                                }
                                
                                echo '</td>';

jlopez's avatar
jlopez committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
                                $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
139
                                echo '<td>' . $container->date . '</td>';
jlopez's avatar
jlopez committed
140
                                echo '<td>' . $container->description . '</td>';
jlopez's avatar
jlopez committed
141

jlopez's avatar
jlopez committed
142
                                echo '<td>';
jlopez's avatar
jlopez committed
143

144
                                echo '<div class="btn-group" mr-3><button class="btn btn-success btn-sm" onclick="showFileContainer(\''.$container->ID.'\')">show</button></div>';
jlopez's avatar
jlopez committed
145

jlopez's avatar
jlopez committed
146
                                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
147
148

                                if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
jlopez's avatar
jlopez committed
149
                                    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
150
151
                                }
                    
jlopez's avatar
jlopez committed
152
                                echo '</td>';
jlopez's avatar
jlopez committed
153
154
155
156
157
158
159
160
161
                                echo '</tr>';
                            }

                        ?>

                        </tbody>

                    </table>
                </div>
162
            
jlopez's avatar
jlopez committed
163
164
    </div>

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!-- 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="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                    </div>

                
            </div>
            </div>
        </div>  <!-- End Modal Publish -->

jlopez's avatar
jlopez committed
193
194
195
196
197
    <br/><br/><br/><br/><br/><br/>

</div>


198
199
200
201
202
203
204
205
206

<!-- 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>


remy's avatar
remy committed
207

jlopez's avatar
jlopez committed
208
<script type="text/javascript">
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

function showFileContainer(id ) {
    var value = FILE_CONTAINER[id];

    document.getElementById('valueContainerFile').value = value;

    var size = value.split(/\r\n|\r|\n/).length;

    document.getElementById("valueContainerFile").rows = size; 

    $('#modalShowContainer').modal();
}

var FILE_CONTAINER = [];

$(function()
        {

            <?php
                foreach ($containers as $container) {
                    echo 'FILE_CONTAINER["'.$container->ID.'"] = "'.$container->value.'";';
                    echo '';
                }

            ?>


        });

jlopez's avatar
jlopez committed
238
239
240
241
242
</script>

</body>

</html>