From 2417ee0069fea37aeb4db53bc4b7483d49dba500 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 21 Jul 2019 17:13:53 +0200 Subject: [PATCH] Add progress bar for disk space --- .../src/main/resources/html/static/index.html | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/server/src/main/resources/html/static/index.html b/server/src/main/resources/html/static/index.html index 0131cff2..7ad5647b 100644 --- a/server/src/main/resources/html/static/index.html +++ b/server/src/main/resources/html/static/index.html @@ -109,6 +109,18 @@
+
+
+ Space left +
+
+
+
+
+

@@ -134,13 +146,13 @@ - + - + - + @@ -196,6 +208,12 @@ let onlineModels = []; let observableModelsArray = ko.observableArray(); let observableRecordingsArray = ko.observableArray(); + let space = { + free: ko.observable(0), + total: ko.observable(0), + percent: ko.observable(0) + }; + let ctbrec = { resume: function(model) { try { @@ -356,7 +374,8 @@ ko.applyBindings({ models : observableModelsArray, - recordings: observableRecordingsArray + recordings: observableRecordingsArray, + space }); function updateOnlineModels() { @@ -571,6 +590,7 @@ .done(function(data) { if (data.status === 'success') { syncRecordings(data.recordings); + updateDiskSpace(); } else { console.log('request failed', data); } @@ -583,6 +603,29 @@ } setTimeout(updateRecordings, 3000); } + + function updateDiskSpace() { + $.ajax({ + type : 'POST', + url : '/rec', + dataType : 'json', + async : true, + timeout : 60000, + data : '{"action": "space"}' + }) + .done(function(data) { + if (data.status === 'success') { + space.total(data.spaceTotal); + space.free(data.spaceFree); + space.percent( (data.spaceFree/data.spaceTotal*100).toFixed(2) ); + } else { + console.log('request failed', data); + } + }) + .fail(function(jqXHR, textStatus, errorThrown) { + console.log(textStatus, errorThrown); + }); + } updateOnlineModels(); updateRecordings();