Commit 06723bcf authored by Franco Fichtner's avatar Franco Fichtner

config manager: convert to submenu entries, overall UX improvements

parent 617f7f43
...@@ -406,10 +406,10 @@ class Config extends Singleton ...@@ -406,10 +406,10 @@ class Config extends Singleton
$xmlNode = simplexml_load_file($filename, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE); $xmlNode = simplexml_load_file($filename, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE);
if (isset($xmlNode->revision)) { if (isset($xmlNode->revision)) {
$result[$filename] = $this->toArray(null, $xmlNode->revision); $result[$filename] = $this->toArray(null, $xmlNode->revision);
} $result[$filename]['version'] = $xmlNode->version->__toString();
// append filesize to revision info object
$result[$filename]['filesize'] = filesize($filename); $result[$filename]['filesize'] = filesize($filename);
} }
}
return $result; return $result;
} }
......
...@@ -10,8 +10,11 @@ ...@@ -10,8 +10,11 @@
<CertificateAuthority VisibleName="Certificate Authority" url="/system_camanager.php*"/> <CertificateAuthority VisibleName="Certificate Authority" url="/system_camanager.php*"/>
<CertificationRevocation VisibleName="Certification Revocation" url="/system_crlmanager.php*"/> <CertificationRevocation VisibleName="Certification Revocation" url="/system_crlmanager.php*"/>
</Certificates> </Certificates>
<ConfigManager VisibleName="Config Manager" url="/diag_confbak.php"> <ConfigManager VisibleName="Config Manager" cssClass="fa fa-history">
<ConfigBackup url="/diag_backup.php"/> <History url="/diag_confbak.php">
<none url="/diag_confbak.php*"/>
</History>
<Backups url="/diag_backup.php"/>
</ConfigManager> </ConfigManager>
<CrashReporter VisibleName="Crash Reporter" url="/crash_reporter.php"/> <CrashReporter VisibleName="Crash Reporter" url="/crash_reporter.php"/>
<Firmware url="/ui/core/firmware/"/> <Firmware url="/ui/core/firmware/"/>
......
...@@ -591,17 +591,6 @@ function backuparea_change(obj) { ...@@ -591,17 +591,6 @@ function backuparea_change(obj) {
<section class="col-xs-12"> <section class="col-xs-12">
<?php
$tab_array = array();
$tab_array[0] = array(gettext("History"), false, "diag_confbak.php");
$tab_array[1] = array(gettext("Backups"), true, "diag_backup.php");
display_top_tabs($tab_array);
?>
<div class="tab-content content-box col-xs-12">
<div class="container-fluid tab-content"> <div class="container-fluid tab-content">
<div class="tab-pane active" id="system"> <div class="tab-pane active" id="system">
...@@ -610,7 +599,7 @@ function backuparea_change(obj) { ...@@ -610,7 +599,7 @@ function backuparea_change(obj) {
<div class="content-box"> <div class="content-box">
<header class="content-box-head container-fluid"> <header class="content-box-head container-fluid">
<h3>Backup configuration</h3> <h3><?=gettext('Download')?></h3>
</header> </header>
<div class="content-box-main "> <div class="content-box-main ">
...@@ -680,7 +669,7 @@ function backuparea_change(obj) { ...@@ -680,7 +669,7 @@ function backuparea_change(obj) {
<div class="content-box"> <div class="content-box">
<header class="content-box-head container-fluid"> <header class="content-box-head container-fluid">
<h3><?=gettext("Restore configuration"); ?></h3> <h3><?=gettext("Restore"); ?></h3>
</header> </header>
<div class="content-box-main "> <div class="content-box-main ">
...@@ -742,7 +731,7 @@ function backuparea_change(obj) { ...@@ -742,7 +731,7 @@ function backuparea_change(obj) {
<section class="__mb"> <section class="__mb">
<div class="content-box"> <div class="content-box">
<header class="content-box-head container-fluid"> <header class="content-box-head container-fluid">
<h3><?=gettext("Remote backup (using Google drive)"); ?></h3> <h3><?=gettext("Google Drive"); ?></h3>
</header> </header>
<div class="content-box-main "> <div class="content-box-main ">
...@@ -769,16 +758,10 @@ function backuparea_change(obj) { ...@@ -769,16 +758,10 @@ function backuparea_change(obj) {
</div> </div>
</section> </section>
</div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
...@@ -799,7 +782,6 @@ decrypt_change(); ...@@ -799,7 +782,6 @@ decrypt_change();
<?php <?php
if (is_subsystem_dirty('restore')) if (is_subsystem_dirty('restore')) {
system_reboot(); system_reboot();
}
?>
...@@ -92,6 +92,14 @@ if($_GET['getcfg'] != "") { ...@@ -92,6 +92,14 @@ if($_GET['getcfg'] != "") {
} }
} }
$newcheck = 'current';
$oldcheck = '';
foreach ($confvers as $revision) {
/* grab first entry if any */
$oldcheck = $revision['time'];
break;
}
if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime']) if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime'])
&& is_numeric($_GET['oldtime']) && (is_numeric($_GET['newtime']) || ($_GET['newtime'] == 'current'))) { && is_numeric($_GET['oldtime']) && (is_numeric($_GET['newtime']) || ($_GET['newtime'] == 'current'))) {
$oldfile = ''; $oldfile = '';
...@@ -109,11 +117,15 @@ if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime ...@@ -109,11 +117,15 @@ if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime
$diff = ''; $diff = '';
$oldtime = $_GET['oldtime']; $oldtime = $_GET['oldtime'];
$oldcheck = $oldtime;
if ($_GET['newtime'] == 'current') { if ($_GET['newtime'] == 'current') {
$newfile = '/conf/config.xml'; $newfile = '/conf/config.xml';
$newtime = $config['revision']['time']; $newtime = $config['revision']['time'];
$newcheck = 'current';
} else { } else {
$newtime = $_GET['newtime']; $newtime = $_GET['newtime'];
$newcheck = $newtime;
} }
if (file_exists($oldfile) && file_exists($newfile)) { if (file_exists($oldfile) && file_exists($newfile)) {
...@@ -138,62 +150,8 @@ include("head.inc"); ...@@ -138,62 +150,8 @@ include("head.inc");
<div class="row"> <div class="row">
<section class="col-xs-12"> <section class="col-xs-12">
<?php
$tab_array = array();
$tab_array[0] = array(gettext("History"), true, "diag_confbak.php");
$tab_array[1] = array(gettext("Backups"), false, "diag_backup.php");
display_top_tabs($tab_array);
?>
<div class="tab-content content-box col-xs-12">
<div class="container-fluid tab-content"> <div class="container-fluid tab-content">
<div class="tab-pane active" id="system"> <div class="tab-pane active" id="system">
<?php if ($diff): ?>
<section class="__mb">
<div classs="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext("Configuration diff from");?> <?php echo date(gettext("n/j/y H:i:s"), $oldtime); ?> <?=gettext("to");?> <?php echo date(gettext("n/j/y H:i:s"), $newtime); ?></h3>
</header>
<div class="content-box-main">
<div class="table-responsive">
<table summary="diag confbak">
<tr><td></td></tr>
<?php foreach ($diff as $line) {
switch (substr($line, 0, 1)) {
case '+':
$color = '#3bbb33';
break;
case '-':
$color = '#c13928';
break;
case '@':
$color = '#3bb9c3';
break;
default:
$color = '#000000';
}
?>
<tr>
<td valign="middle" style="color: <?=$color;?>; white-space: pre-wrap; font-family: monospace;"><?php echo htmlentities($line);?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?PHP if ($_GET["newver"] || $_GET["rmver"]): ?> <?PHP if ($_GET["newver"] || $_GET["rmver"]): ?>
<form action="<?=explode("?", $_SERVER['REQUEST_URI'])[0];?>" method="post"> <form action="<?=explode("?", $_SERVER['REQUEST_URI'])[0];?>" method="post">
<section> <section>
...@@ -233,7 +191,7 @@ include("head.inc"); ...@@ -233,7 +191,7 @@ include("head.inc");
<div class="content-box"> <div class="content-box">
<header class="content-box-head container-fluid"> <header class="content-box-head container-fluid">
<h3>Config history</h3> <h3><?=gettext('Settings');?></h3>
</header> </header>
<div class="content-box-main"> <div class="content-box-main">
...@@ -259,11 +217,54 @@ include("head.inc"); ...@@ -259,11 +217,54 @@ include("head.inc");
</section> </section>
</form> </form>
<?php if ($diff): ?>
<section style="margin-bottom:15px;">
<div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext("Configuration diff from");?> <?php echo date(gettext("n/j/y H:i:s"), $oldtime); ?> <?=gettext("to");?> <?php echo date(gettext("n/j/y H:i:s"), $newtime); ?></h3>
</header>
<div class="content-box-main">
<div class="container-fluid __mb">
<div class="table-responsive">
<table summary="Differences">
<tr><td></td></tr>
<?php foreach ($diff as $line) {
switch (substr($line, 0, 1)) {
case '+':
$color = '#3bbb33';
break;
case '-':
$color = '#c13928';
break;
case '@':
$color = '#3bb9c3';
break;
default:
$color = '#000000';
}
?>
<tr>
<td valign="middle" style="color: <?=$color;?>; white-space: pre-wrap; font-family: monospace;"><?php echo htmlentities($line);?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php if (is_array($confvers)): ?> <?php if (is_array($confvers)): ?>
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="get"> <form action="<?=$_SERVER['REQUEST_URI'];?>" method="get">
<section> <section>
<div class="content-box"> <div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext('History');?></h3>
</header>
<div class="content-box-main"> <div class="content-box-main">
<div class="container-fluid __mb"> <div class="container-fluid __mb">
...@@ -288,38 +289,34 @@ include("head.inc"); ...@@ -288,38 +289,34 @@ include("head.inc");
<tr valign="top"> <tr valign="top">
<td valign="middle" class="list nowrap"></td> <td valign="middle" class="list nowrap"></td>
<td class="list"> <td class="list">
<input type="radio" name="newtime" value="current" checked="checked"/> <input type="radio" name="newtime" value="current" <?= $newcheck == 'current' ? 'checked="checked"' : '' ?>/>
</td> </td>
<td class="listlr"> <?= date(gettext("n/j/y H:i:s"), $config['revision']['time']) ?></td> <td class="listlr"> <?= date(gettext("n/j/y H:i:s"), $config['revision']['time']) ?></td>
<td class="listr"> <?= $config['version'] ?></td> <td class="listr"> <?= $config['version'] ?></td>
<td class="listr"> <?= format_bytes(filesize("/conf/config.xml")) ?></td> <td class="listr"> <?= format_bytes(filesize("/conf/config.xml")) ?></td>
<td class="listr"> <?= $config['revision']['description'] ?></td> <td class="listr"> <?= "{$config['revision']['username']}: {$config['revision']['description']}" ?></td>
<td valign="middle" class="list nowrap"><b><?=gettext("Current");?></b></td> <td valign="middle" class="list nowrap"><b><?=gettext("Current");?></b></td>
</tr> </tr>
<?php <?php
$c = 0; $c = 0;
foreach($confvers as $version): foreach($confvers as $version):
if($version['time'] != 0)
$date = date(gettext("n/j/y H:i:s"), $version['time']);
else
$date = gettext("Unknown");
?> ?>
<tr valign="top"> <tr valign="top">
<td class="list"> <td class="list">
<input type="radio" name="oldtime" value="<?php echo $version['time'];?>" <?= ($c == 0) ? 'checked="checked"' : ''; ?>/> <input type="radio" name="oldtime" value="<?php echo $version['time'];?>" <?= $oldcheck == $version['time'] ? 'checked="checked"' : '' ?>/>
</td> </td>
<td class="list"> <td class="list">
<?php if ($c < (count($confvers) - 1)) { ?> <?php if ($c < (count($confvers) - 1)) { ?>
<input type="radio" name="newtime" value="<?php echo $version['time'];?>"/> <input type="radio" name="newtime" value="<?php echo $version['time'];?>" <?= $newcheck == $version['time'] ? 'checked="checked"' : ''?>/>
<?php } else { ?> <?php } else { ?>
&nbsp; &nbsp;
<?php } <?php }
$c++; ?> $c++; ?>
</td> </td>
<td class="listlr"> <?= $date ?></td> <td class="listlr"> <?= date(gettext("n/j/y H:i:s"), $version['time']) ?></td>
<td class="listr"> <?= $version['version'] ?></td> <td class="listr"> <?= $version['version'] ?></td>
<td class="listr"> <?= format_bytes($version['filesize']) ?></td> <td class="listr"> <?= format_bytes($version['filesize']) ?></td>
<td class="listr"> <?= $version['description'] ?></td> <td class="listr"> <?= "{$version['username']}: {$version['description']}" ?></td>
<td class="btn-group-table"> <td class="btn-group-table">
<a href="diag_confbak.php?newver=<?=$version['time'];?>" class="btn btn-default btn-xs" title="<?=gettext("Revert to this configuration");?>"><span class="glyphicon glyphicon-log-in"></span></a> <a href="diag_confbak.php?newver=<?=$version['time'];?>" class="btn btn-default btn-xs" title="<?=gettext("Revert to this configuration");?>"><span class="glyphicon glyphicon-log-in"></span></a>
...@@ -335,16 +332,8 @@ include("head.inc"); ...@@ -335,16 +332,8 @@ include("head.inc");
</section> </section>
</form> </form>
<? endif; endif; ?> <? endif; endif; ?>
</div>
</div> </div>
</section> </section>
</div> </div>
</div> </div>
</section> </section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment