From 7f0b98c5977f416a9a85ff7374ffc663f1b1b872 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Fri, 15 Sep 2017 05:03:17 -0500 Subject: [PATCH] Re-UI Snapshots page --- .../js/glass-pages/dhcp-config-snapshots.js | 11 +++--- public/templates/dhcp_config_snapshots.html | 35 +++++++++++++++++-- routes/dhcp_config_snapshots.js | 29 ++++++++++++++- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/public/assets/js/glass-pages/dhcp-config-snapshots.js b/public/assets/js/glass-pages/dhcp-config-snapshots.js index 146e582..b2a6237 100644 --- a/public/assets/js/glass-pages/dhcp-config-snapshots.js +++ b/public/assets/js/glass-pages/dhcp-config-snapshots.js @@ -1,13 +1,16 @@ function view_snapshot(snapshot) { $.post( "/dhcp_config_snapshot_view", "snapshot=" + encodeURIComponent(snapshot), function( data ) { - $('#modal-title').html("Snapshot '" + snapshot + "'"); - $('#modal-body').html('
' + data + '
'); + $('#snapshot_grid').fadeOut(100).fadeIn(100); + $('#snapshot_name').html("Snapshot '" + snapshot + "'"); + $('#snapshot_body').html('
' + data + '
'); + + $('html, body').animate({ + scrollTop: $("#snapshot_grid").offset().top + }, 500); config_snapshot = ace.edit("snapshot"); config_snapshot.setTheme("ace/theme/terminal"); config_snapshot.$blockScrolling = Infinity; - - $('#mdModal').modal('show'); }); } \ No newline at end of file diff --git a/public/templates/dhcp_config_snapshots.html b/public/templates/dhcp_config_snapshots.html index 016d801..fde6c56 100644 --- a/public/templates/dhcp_config_snapshots.html +++ b/public/templates/dhcp_config_snapshots.html @@ -7,8 +7,30 @@
- [c_content] -
+ + + + + + + + + + [c_content] + +
FileTime
+
+ + + @@ -18,3 +40,12 @@ + \ No newline at end of file diff --git a/routes/dhcp_config_snapshots.js b/routes/dhcp_config_snapshots.js index 1960394..249537c 100644 --- a/routes/dhcp_config_snapshots.js +++ b/routes/dhcp_config_snapshots.js @@ -4,6 +4,30 @@ var fs = require('fs'); var template_render = require('../lib/render_template.js'); var authorize = require('../lib/authorize.js'); +function human_time (time){ + var time = new Date(time); + var year = time.getFullYear(); + var month = time.getMonth()+1; + var date1 = time.getDate(); + var hour = time.getHours(); + var minutes = time.getMinutes(); + var seconds = time.getSeconds(); + + var hour = time.getHours(); + var minute = time.getMinutes(); + var amPM = (hour > 11) ? "PM" : "AM"; + if(hour > 12) { + hour -= 12; + } else if(hour == 0) { + hour = "12"; + } + if(minute < 10) { + minute = "0" + minute; + } + + return year + "-" + month+"-"+date1+" "+hour + ":" + minute + ' ' + amPM; +} + router.get('/', authorize.auth, function(req, res, next) { var content = ""; @@ -18,7 +42,10 @@ router.get('/', authorize.auth, function(req, res, next) { var backups = ''; fs.readdirSync("./config_backups").forEach(function(file) { - backups = backups + "
  • " + file + '
  • '; + var stats = fs.statSync("./config_backups/" + file); + var mtime = human_time(stats.mtime); + + backups = backups + "" + file + '' + mtime + ''; }); if(backups == ''){