container.php 7.05 KB
Newer Older
jlopez's avatar
jlopez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php


session_start ();

require_once "./dao/DBquery.php";

$db = new DBquery();

$containers = $db->getContainers();

?>

<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
remy's avatar
remy committed
24
25
26
27
28
29
30

    <!-- local fallbacks -->
    <!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
    <link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->

    <link rel="stylesheet" href="./inc/css/style.css">
    <script src="./inc/js/jscolor.js"></script>
jlopez's avatar
jlopez committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    <title>wicopa</title>

</head>
<body>

<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
    <a class="navbar-brand" href="#">WICOPA</a>
    <div class="collapse navbar-collapse justify-content-between" id="navbar">
        <div class="navbar-nav">

        <?php

            echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';

            echo ' <a class="nav-item nav-link active" href="./container.php"> Containers </a>';

            if(isset($_SESSION['username']) && !empty($_SESSION['username']))
            {

                

                if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
                {
                    echo ' <a class="nav-item nav-link" href="./manage.php"> Manage </a>';
                }
            }
            ?>


        </div>
        <div class="navbar-nav">
            <?php
            if(isset($_SESSION['username']) && !empty($_SESSION['username']))
            {
                echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
            }
            else
            {
                echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
            }
            ?>
        </div>

</nav>


<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
92
93
                                <th>Date</th>
                                <th>Description</th>
jlopez's avatar
jlopez committed
94
95
96
97
98
99
100
101
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody id="TableSection">
                        <?php

                            foreach ($containers as $container) {

jlopez's avatar
jlopez committed
102
103
                                $container->escape2($db);

jlopez's avatar
jlopez committed
104
                                $visibility = "private";
jlopez's avatar
jlopez committed
105
106
                                $colorV = "e67e22";

jlopez's avatar
jlopez committed
107
108
109

                                if($container->visibility) {
                                    $visibility = "public";
jlopez's avatar
jlopez committed
110
                                    $colorV = "f1c40f";
jlopez's avatar
jlopez committed
111
112
113
114
                                }

                                if(!$container->visibility) {
                                    if($container->author != $_SESSION['username']) {
jlopez's avatar
jlopez committed
115
                                        if($db->getGradeWithLogin($_SESSION['username'])->name != $db->getMaxGrades()->name) {
jlopez's avatar
jlopez committed
116
117
                                            continue;
                                        }
jlopez's avatar
jlopez committed
118
119
120
                                    }
                                }

jlopez's avatar
jlopez committed
121
122
123
124
125
126
127
128
                                $typeC = "docker";
                                $colorT = "007bff";

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

jlopez's avatar
jlopez committed
129
130
131
                                echo '<tr>';
                                echo '<td>' . $container->name . '</td>';
                                echo '<td>' . $container->author . '</td>';
jlopez's avatar
jlopez committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151


                                $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
152
                                    }       
jlopez's avatar
jlopez committed
153
154
155
156
157
                                }
                                
                                echo '</td>';

                                echo '<td>' . $container->date . '</td>';
jlopez's avatar
jlopez committed
158
                                echo '<td>' . $container->description . '</td>';
jlopez's avatar
jlopez committed
159

jlopez's avatar
jlopez committed
160
                                echo '<td>';
jlopez's avatar
jlopez committed
161

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

jlopez's avatar
jlopez committed
164
                                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
165
166

                                if($container->author == $_SESSION['username'] || $_SESSION['manage'] ) {
jlopez's avatar
jlopez committed
167
                                    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
168
169
                                }
                    
jlopez's avatar
jlopez committed
170
                                echo '</td>';
jlopez's avatar
jlopez committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
                                echo '</tr>';
                            }

                        ?>

                        </tbody>

                    </table>
                </div>

    </div>

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

</div>

<!-- jQuery Version 1.11.1 -->
jlopez's avatar
jlopez committed
188
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
jlopez's avatar
jlopez committed
189
190
191
<!-- 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
192
193
194
195
<!-- 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
196
<script type="text/javascript">
jlopez's avatar
jlopez committed
197
198
199
200
201
</script>

</body>

</html>