DHCP Config Backups - add modals to core code
This commit is contained in:
parent
8266e5f0c5
commit
ee90df1f3d
|
@ -11,6 +11,8 @@ pids
|
|||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
config_backups
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
* Created by cmiles on 8/9/2017.
|
||||
*/
|
||||
|
||||
function modal (title, content, buttons) {
|
||||
$('#modal-title').html(title);
|
||||
$('#modal-body').html(content);
|
||||
|
||||
// <button type="button" class="btn btn-link waves-effect">SAVE CHANGES</button>
|
||||
if(buttons != '') {
|
||||
$('#modal-buttons').html(buttons);
|
||||
}
|
||||
$('#mdModal').modal('show');
|
||||
}
|
||||
|
||||
function get_form_query_string(form_id){
|
||||
query_string = "";
|
||||
$('#' + form_id).find('input, select, textarea').each(function (key) {
|
||||
|
|
|
@ -33,3 +33,4 @@
|
|||
<script src="assets/js/ace_editor/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="assets/js/ace_editor/theme-terminal.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="assets/js/glass-pages/page-dhcp-config.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
|
|
|
@ -134,6 +134,24 @@
|
|||
</aside>
|
||||
<!-- #END# Left Sidebar -->
|
||||
|
||||
<!-- For Material Design Colors -->
|
||||
<div class="modal fade" id="mdModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modal-title">Modal title</h4>
|
||||
</div>
|
||||
<div class="modal-body" id="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div id="modal-buttons"></div>
|
||||
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
|
@ -182,7 +200,6 @@
|
|||
<script src="assets/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>
|
||||
<script src="assets/plugins/jquery-datatable/extensions/export/dataTables.buttons.min.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function get_dashboard() {
|
||||
|
|
|
@ -19,17 +19,36 @@ router.post('/', function(req, res, next) {
|
|||
|
||||
if (err) {
|
||||
output = output.replace("\n", "<br>");
|
||||
res.send('<script type="text/javascript">notification(\'There are errors!<br>See below for details...\');</script><br></b><b style="color:red">' + output + '</b>');
|
||||
output = output.replace(". ", "<br>");
|
||||
output = output.replace("line", "<br><br>line");
|
||||
output = output.replace("Configuration file errors encountered", "<br><br>Configuration file errors encountered");
|
||||
|
||||
res.send('<script type="text/javascript">modal (\'DHCP Config Syntax Validation\', ' + JSON.stringify('<span style="color:red">' + output + '</span>') + ', "");');
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
res.send('<script type="text/javascript">notification(' + JSON.stringify("<b>Syntax OK</b> <br><br>" + output) + ')</script>');
|
||||
|
||||
output = output.replace("\n", "<br>");
|
||||
res.send(
|
||||
'<script type="text/javascript">modal (\'DHCP Config Save\', ' + JSON.stringify('Syntax OK') + ', "");'
|
||||
);
|
||||
/* Read Config */
|
||||
var json_file = require('jsonfile');
|
||||
var glass_config = json_file.readFileSync('config/glass_config.json');
|
||||
|
||||
/* Make Dir if not exist */
|
||||
var dir = './config_backups';
|
||||
if (!fs.existsSync(dir)){
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
|
||||
//date +"%Y-%m-%d_%H:%M:%S"
|
||||
exec('cp ' + glass_config.config_file + ' ./config_backups/`basename ' + glass_config.config_file + '`_`date +"%Y-%m-%d_%H:%M:%S"`',
|
||||
function(err, stdout, stderr) {
|
||||
|
||||
});
|
||||
|
||||
fs.writeFileSync(glass_config.config_file, request.dhcp_config_data, 'utf8');
|
||||
|
||||
fs.unlinkSync("./verify_output");
|
||||
|
|
Loading…
Reference in New Issue