Skip to content

Commit

Permalink
Initial GitHub version
Browse files Browse the repository at this point in the history
  • Loading branch information
ImpressionEngineering committed Mar 21, 2018
1 parent 17476dd commit cc5ce62
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# impeng_backupdash
Perch Runway dashboard widget that shows status of latest backups
# Perch Runway Backup Status Dashboard Widget


Perch Runway dashboard widget that shows status of latest backups. Not applicable to non-Runway Perch sites.

![Screenshot](images/impeng_backupdash-screenshot1.png)

Application name: impeng_backupdash

## Installation

copy the impeng_backupdash folder into the folder perch/addons/apps/
No other actions are needed.
Binary file added images/impeng_backupdash-screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added impeng_backupdash/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions impeng_backupdash/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
if ($CurrentUser->logged_in()) {
$this->register_app('impeng_backupdash', 'Backups Widget', 1, 'Dashboard Widget to show staus of recent Runway Backups', '1', true);
$this->require_version('impeng_backupdash', '0.1');
}
?>
74 changes: 74 additions & 0 deletions impeng_backupdash/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
$API = new PerchAPI(1.0, 'impeng_backupdash');
$HTML = $API->get('HTML');
$Lang = $API->get('Lang');
$DB = PerchDB::fetch();

// Change the number of backup results that are displayed
$numRunsDisplayed = 5;
?>
<div class="widget">
<div class="dash-content">
<header>
<h2>
<?php echo $Lang->get('Backup Status'); ?>
</h2>
</header>
<div class="body">
<?php
$sql = 'SELECT * FROM '.PERCH_DB_PREFIX.'backup_plans';
$result = $DB->get_count($sql);
if (($result) == 0) {
echo $Lang->get('No backup plans exist');
return;
}
?>
<ul class="dash-list">
<?php
$sql = 'SELECT * FROM '.PERCH_DB_PREFIX.'backup_runs';
$result = $DB->get_count($sql);
if ( $result == 0) {
echo $Lang->get('No backup runs');
} else {
$sql = 'SELECT *
FROM '.PERCH_DB_PREFIX.'backup_runs
ORDER BY runDateTime DESC
LIMIT '.$numRunsDisplayed ;
$result = $DB->get_rows($sql);
foreach ($result as $run) {
$sql = 'SELECT planTitle
FROM '.PERCH_DB_PREFIX.'backup_plans
WHERE planID='.$run['planID'].'
LIMIT 1 ';
$planName = $DB->get_rows($sql)[0]['planTitle'];
echo "<li>";
switch($run['runResult']) {
case 'OK':
echo PerchUI::icon('core/circle-check', 16, null, 'icon-status-success');
break;

case 'FAILED':
echo PerchUI::icon('core/circle-delete', 16, null, 'icon-status-alert');
break;

case 'WARNING':
echo PerchUI::icon('core/alert', 16, null, 'icon-status-warning');
break;

default:
echo PerchUI::icon('core/info-alt', 16, null, 'icon-status-info');
break;
}
$link = $HTML->encode(PERCH_LOGINPATH.'/core/settings/backup/?id='.($run['planID']));
echo '<a href="'.$link.'">'.$planName.'</a>';
echo '<span class="note">'.strftime(PERCH_DATE_SHORT .' @ '.PERCH_TIME_SHORT, strtotime($run['runDateTime'])).'</span>';
echo "</li>";
}
}
?>
</ul>
</div>
</div>
</div>


7 changes: 7 additions & 0 deletions impeng_backupdash/lang/en-gb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lang": "en-gb",
"Backups Widget": "Backups Widget",
"Backup Status": "Backup Status",
"No backup runs": "No backup runs",
"No backup plans exist": "No backup plans exist"
}

0 comments on commit cc5ce62

Please sign in to comment.