Skip to content

Commit

Permalink
Added a webbased representation of the DB tables and views
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Jendryke committed Dec 1, 2017
1 parent dcf04b8 commit 50bf8ab
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

*.cfg

website/config\.php
3 changes: 2 additions & 1 deletion nyx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def download(self):
SQL = "SELECT * FROM downloadimages" # all that are not finished
data = ('',)
rows = sql_c.select(SQL,data)
print('INFO: {d} images to download'.format(d = len(rows)))
for row in rows:
orderNumber = row[0]
filename = row[1]
Expand Down Expand Up @@ -65,7 +66,7 @@ def download(self):
sql_c.setImageStatus(orderNumber,filename,'FINISHED') # check in the database if the checksum was given, if not, it is non-verified download

if c_sql.ordercomplete(orderNumber) is True:
sql_c.setOrderStatus(orderNumber,'FINISHED')
c_sql.setOrderStatus(orderNumber,'FINISHED')


def checksumcheck(self,d,c):
Expand Down
7 changes: 7 additions & 0 deletions website/config.php.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$host = 'localhost';
$port = '5432';
$database = 'DATABASE';
$user = 'USER';
$password = 'PASSWORD';
?>
15 changes: 15 additions & 0 deletions website/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.hoverTable{
width:100%;
border-collapse:collapse;
}
.hoverTable td{
padding:7px; border:#4e95f4 1px solid;
}
/* Define the default color for all the table rows */
.hoverTable tr{
background: #b8d1f3;
}
/* Define the hover highlight color for the table row */
.hoverTable tr:hover {
background-color: #ffff99;
}
51 changes: 51 additions & 0 deletions website/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
#https://razorsql.com/articles/postgresql_column_names_values.html


include("config.php");

$connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database .
' user=' . $user . ' password=' . $password;


$link = pg_connect ($connectString);
if (!$link)
{
die('Error: Could not connect: ' . pg_last_error());
}


$query = 'select * from images';

$result = pg_query($query);

$i = 0;
echo '<table class="hoverTable"><tr>';
while ($i < pg_num_fields($result))
{
$fieldName = pg_field_name($result, $i);
echo '<td>' . $fieldName . '</td>';
$i = $i + 1;
}
echo '</tr>';
$i = 0;

while ($row = pg_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</tr>';
$i = $i + 1;
}
pg_free_result($result);

echo '</table>';
?>
51 changes: 51 additions & 0 deletions website/imagesummary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
#https://razorsql.com/articles/postgresql_column_names_values.html


include("config.php");

$connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database .
' user=' . $user . ' password=' . $password;


$link = pg_connect ($connectString);
if (!$link)
{
die('Error: Could not connect: ' . pg_last_error());
}


$query = 'select * from imagesummary';

$result = pg_query($query);

$i = 0;
echo '<table class="hoverTable"><tr>';
while ($i < pg_num_fields($result))
{
$fieldName = pg_field_name($result, $i);
echo '<td>' . $fieldName . '</td>';
$i = $i + 1;
}
echo '</tr>';
$i = 0;

while ($row = pg_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</tr>';
$i = $i + 1;
}
pg_free_result($result);

echo '</table>';
?>
26 changes: 26 additions & 0 deletions website/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>

<html lang="en">
<head>
<meta charset="utf-8">
<title>NyxHyperion Download Progress</title>
<meta name="description" content="PostgreSQL Tables and Views">
<link rel="stylesheet" href="css/style.css">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="#" id="overview">Overview</a>
<a href="#" id="orders">Orders</a>
<a href="#" id="imagesummary">Image Summary</a>
<a href="#" id="images">Images</a>
<div id="tabledata"></div>
<script src="js/script.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions website/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$("#overview").on("click", function(){
$("#tabledata").load("overview.php");
});
$("#orders").on("click", function(){
$("#tabledata").load("orders.php");
});
$("#imagesummary").on("click", function(){
$("#tabledata").load("imagesummary.php");
});
$("#images").on("click", function(){
$("#tabledata").load("images.php");
});
3 changes: 3 additions & 0 deletions website/js/script.js.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$( "#sample" ).load( "noaa.geoinsight.xyz/overview.php", function() {
alert( "Load was performed." );

51 changes: 51 additions & 0 deletions website/orders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
#https://razorsql.com/articles/postgresql_column_names_values.html


include("config.php");

$connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database .
' user=' . $user . ' password=' . $password;


$link = pg_connect ($connectString);
if (!$link)
{
die('Error: Could not connect: ' . pg_last_error());
}


$query = 'select * from orders';

$result = pg_query($query);

$i = 0;
echo '<table class="hoverTable"><tr>';
while ($i < pg_num_fields($result))
{
$fieldName = pg_field_name($result, $i);
echo '<td>' . $fieldName . '</td>';
$i = $i + 1;
}
echo '</tr>';
$i = 0;

while ($row = pg_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</tr>';
$i = $i + 1;
}
pg_free_result($result);

echo '</table>';
?>
49 changes: 49 additions & 0 deletions website/overview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

include("config.php");

$connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database .
' user=' . $user . ' password=' . $password;


$link = pg_connect ($connectString);
if (!$link)
{
die('Error: Could not connect: ' . pg_last_error());
}


$query = 'select * from overview';

$result = pg_query($query);

$i = 0;
echo '<table class="hoverTable"><tr>';
while ($i < pg_num_fields($result))
{
$fieldName = pg_field_name($result, $i);
echo '<td>' . $fieldName . '</td>';
$i = $i + 1;
}
echo '</tr>';
$i = 0;

while ($row = pg_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</tr>';
$i = $i + 1;
}
pg_free_result($result);

echo '</table>';
?>

0 comments on commit 50bf8ab

Please sign in to comment.