mirror of
https://github.com/cytopia/devilbox.git
synced 2025-06-16 14:18:23 +00:00
Restructure web pages
This commit is contained in:
120
.devilbox/www/htdocs/db_postgres.php
Normal file
120
.devilbox/www/htdocs/db_postgres.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php require '../config.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php require '../include/head.php'; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php require '../include/navbar.php'; ?>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h1>PostgreSQL Databases</h1>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<table class="table table-striped ">
|
||||
<thead class="thead-inverse ">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Charset</th>
|
||||
<th>Collation</th>
|
||||
<th>Tables</th>
|
||||
<th>Size</th>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$len_table = 4;
|
||||
$len_size = 9;
|
||||
?>
|
||||
<?php foreach ($Postgres->getDatabases() as $name => $database): ?>
|
||||
<tr class="table-info">
|
||||
<th>
|
||||
<?php echo $name;?>
|
||||
</th>
|
||||
<td><?php echo $database['charset'];?></td>
|
||||
<td><?php echo $database['collation'];?></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<?php foreach ($database['schemas'] as $schema => $data): ?>
|
||||
<tr>
|
||||
<td><?php echo $schema;?></td>
|
||||
<td colspan="2"></td>
|
||||
<td><code><span class="table" id="table-<?php echo $name.'-'.$schema;?>"><?php echo str_repeat(' ', $len_table);?></span></code></td>
|
||||
<td><code><span class="size" id="size-<?php echo $name.'-'.$schema;?>"><?php echo str_repeat(' ', $len_size);?></span></code></td>
|
||||
</tr>
|
||||
<input type="hidden" name="schema[]" data-database="<?php echo $name;?>" class="schema" value="<?php echo $schema;?>" />
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
<?php require '../include/footer.php'; ?>
|
||||
<script>
|
||||
// self executing function here
|
||||
(function() {
|
||||
// your page initialization code here
|
||||
// the DOM will be available here
|
||||
|
||||
function updateData(database, schema) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
var res = null;
|
||||
var size = 0;
|
||||
var tables = 0;
|
||||
var i;
|
||||
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
res = JSON.parse(this.response);
|
||||
|
||||
// Normalize size output
|
||||
size = res.size == 0 ? '0sss MB' : res.size + ' MB';
|
||||
if (size.length < <?php echo $len_size;?>) {
|
||||
for (i = size.length; i < <?php echo $len_size;?>; ++i) {
|
||||
size = ' ' + size;
|
||||
}
|
||||
}
|
||||
size = size.replace('sss', ' ');
|
||||
|
||||
// Normalize tables output
|
||||
tables = res.table;
|
||||
if (tables.length < <?php echo $len_table;?>) {
|
||||
for (i = tables.length; i < <?php echo $len_table;?>; ++i) {
|
||||
tables = ' ' + tables;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('size-' + database + '-' + schema).innerHTML = size;
|
||||
document.getElementById('table-' + database + '-' + schema).innerHTML = tables;
|
||||
}
|
||||
};
|
||||
xhttp.open('GET', '_ajax_callback.php?type=postgres&database=' + database + '&schema=' + schema, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
var schemas = document.getElementsByName('schema[]');
|
||||
var schema;
|
||||
var database;
|
||||
|
||||
for (i = 0; i < schemas.length; i++) {
|
||||
schema = schemas[i].value;
|
||||
database = schemas[i].getAttribute('data-database');
|
||||
updateData(database, schema);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user