container.php 6.69 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
24
25
26
27
28
29
30
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
<?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">
    <link rel="stylesheet" href="./css/style.css">
    <script src="./js/jscolor.js"></script>
    <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
87
88
                                <th>Date</th>
                                <th>Description</th>
jlopez's avatar
jlopez committed
89
90
91
92
93
94
95
96
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody id="TableSection">
                        <?php

                            foreach ($containers as $container) {

jlopez's avatar
jlopez committed
97
98
                                $container->escape2($db);

jlopez's avatar
jlopez committed
99
                                $visibility = "private";
jlopez's avatar
jlopez committed
100
101
                                $colorV = "e67e22";

jlopez's avatar
jlopez committed
102
103
104

                                if($container->visibility) {
                                    $visibility = "public";
jlopez's avatar
jlopez committed
105
                                    $colorV = "f1c40f";
jlopez's avatar
jlopez committed
106
107
108
109
                                }

                                if(!$container->visibility) {
                                    if($container->author != $_SESSION['username']) {
jlopez's avatar
jlopez committed
110
111
112
                                        if($_SESSION['username'] != "admin") {
                                            continue;
                                        }
jlopez's avatar
jlopez committed
113
114
115
                                    }
                                }

jlopez's avatar
jlopez committed
116
117
118
119
120
121
122
123
                                $typeC = "docker";
                                $colorT = "007bff";

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

jlopez's avatar
jlopez committed
124
125
126
                                echo '<tr>';
                                echo '<td>' . $container->name . '</td>';
                                echo '<td>' . $container->author . '</td>';
jlopez's avatar
jlopez committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146


                                $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
147
                                    }       
jlopez's avatar
jlopez committed
148
149
150
151
152
                                }
                                
                                echo '</td>';

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

jlopez's avatar
jlopez committed
155
                                echo '<td>';
jlopez's avatar
jlopez committed
156
                                
jlopez's avatar
jlopez committed
157
                                //echo '<div class="btn-group" mr-3><a class="btn btn-success btn-sm" href="#" >show</a></div>';
jlopez's avatar
jlopez committed
158

jlopez's avatar
jlopez committed
159
                                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
160
161

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

                        ?>

                        </tbody>

                    </table>
                </div>

    </div>

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

</div>

<!-- jQuery Version 1.11.1 -->
jlopez's avatar
jlopez committed
183
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
jlopez's avatar
jlopez committed
184
185
186
187

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

jlopez's avatar
jlopez committed
188
<script type="text/javascript">
jlopez's avatar
jlopez committed
189
190
191
192
193
</script>

</body>

</html>