]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add progress bars to backup jobs displaying on status client page
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 18 Aug 2019 06:36:56 +0000 (08:36 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:55:58 +0000 (15:55 +0100)
12 files changed:
gui/baculum/protected/Web/JavaScript/misc.js
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Pages/ClientView.page
gui/baculum/protected/Web/Pages/ClientView.php
gui/baculum/themes/Baculum-v2/css/baculum.css

index 408528b9009f038d06fbcf21656d3e901a5bdb49..8668281147c6222b357145c6b9f747792a6fde3b 100644 (file)
@@ -842,7 +842,44 @@ W3SubTabs = {
        open: function(btn_id, item_id) {
                W3TabsCommon.open.call(this, btn_id, item_id);
        }
-}
+};
+
+function estimate_job(jobs, job, level) {
+       var bytes = 0;
+       var files = 0;
+       var time = 0;
+       var bytes_xy = 0;
+       var files_xy = 0;
+       var x2 = 0;
+       var counter = 0;
+       for (var i = 0; i < jobs.length; i++) {
+               if (jobs[i].name === job && jobs[i].level === level) {
+                       if (jobs[i].jobbytes === 0 || jobs[i].jobfies === 0 || jobs[i].jobstatus !== 'T') {
+                               continue;
+                       }
+                       if (counter === 20) {
+                               break;
+                       }
+                       time += jobs[i].jobtdate;
+                       bytes += jobs[i].jobbytes;
+                       files += jobs[i].jobfiles;
+                       bytes_xy += jobs[i].jobtdate * jobs[i].jobbytes;
+                       files_xy += jobs[i].jobtdate * jobs[i].jobfiles;
+                       x2 += Math.pow(jobs[i].jobtdate, 2);
+                       counter++;
+               }
+       }
+       var bytes_slope = ((counter * bytes_xy) - (time * bytes)) / (counter * x2 - Math.pow(time, 2));
+       var files_slope = ((counter * files_xy) - (time * files)) / (counter * x2 - Math.pow(time, 2));
+       var bytes_intercept = (bytes / counter) - (bytes_slope * (time / counter));
+       var files_intercept = (files / counter) - (files_slope * (time / counter));
+       var est_bytes = bytes_intercept + (bytes_slope * parseInt((new Date).getTime() / 1000, 10));
+       var est_files = files_intercept + (files_slope * parseInt((new Date).getTime() / 1000, 10));
+       return {
+               est_bytes: est_bytes,
+               est_files: est_files
+       };
+};
 
 function get_url_param (name) {
        var url = window.location.href;
index 117c15440a41da5ac55390eb14c0292bd4184e76..8d30002aeccc9e8a2f2bf5ba6194c0de2bd45d86 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index e2c11a04c68320253102020e8e66592e0dd678cf..049f87f07c4ccb095713a735fc93a6d843617203 100644 (file)
@@ -2228,8 +2228,8 @@ msgstr "Go to job %job"
 msgid "Graphical status"
 msgstr "Graphical status"
 
-msgid "Text status"
-msgstr "Text status"
+msgid "Raw status"
+msgstr "Raw status"
 
 msgid "Uname:"
 msgstr "Uname:"
@@ -2338,3 +2338,24 @@ msgstr "Set job bandwidth limit"
 
 msgid "Here you can set bandwidth limit for job. This change is applied on running job."
 msgstr "Here you can set bandwidth limit for job. This change is applied on running job."
+
+msgid "est."
+msgstr "est."
+
+msgid "Progress bar displays estimated values"
+msgstr "Progress bar displays estimated values"
+
+msgid "Byte progress bar:"
+msgstr "Byte progress bar:"
+
+msgid "File progress bar:"
+msgstr "File progress bar:"
+
+msgid "Running job status"
+msgstr "Running job status"
+
+msgid "Raw job log"
+msgstr "Raw job log"
+
+msgid "Not available"
+msgstr "Not available"
index b9922366d38eef979ae5b31927b63b14d5667172..609319933f92be7784b9c4ea3c638cfce9cd4fef 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 5f774110656696032cca13a5324bf21bfc229284..09ef8e794dfa98e3927d5295d2fe030b0362ce0d 100644 (file)
@@ -2314,8 +2314,8 @@ msgstr "Go to job %job"
 msgid "Graphical status"
 msgstr "Graphical status"
 
-msgid "Text status"
-msgstr "Text status"
+msgid "Raw status"
+msgstr "Raw status"
 
 msgid "Uname:"
 msgstr "Uname:"
@@ -2424,3 +2424,24 @@ msgstr "Set job bandwidth limit"
 
 msgid "Here you can set bandwidth limit for job. This change is applied on running job."
 msgstr "Here you can set bandwidth limit for job. This change is applied on running job."
+
+msgid "est."
+msgstr "est."
+
+msgid "Progress bar displays estimated values"
+msgstr "Progress bar displays estimated values"
+
+msgid "Byte progress bar:"
+msgstr "Byte progress bar:"
+
+msgid "File progress bar:"
+msgstr "File progress bar:"
+
+msgid "Running job status"
+msgstr "Running job status"
+
+msgid "Raw job log"
+msgstr "Raw job log"
+
+msgid "Not available"
+msgstr "Not available"
index 4209f147a9ff0674c56326e7ed80226a92b45d25..ef64e6a1757738471bf37b0b751cc28e0ec8cb3b 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index 5ec9a4b95328d94f7ac1e770061e9e86b6c9d247..aaffb3206f2be47bb8ada48221ff0ecaf07037a6 100644 (file)
@@ -2235,7 +2235,7 @@ msgstr "Przejdź do zadania %job"
 msgid "Graphical status"
 msgstr "Status graficzny"
 
-msgid "Text status"
+msgid "Raw status"
 msgstr "Status tekstowy"
 
 msgid "Uname:"
@@ -2345,3 +2345,24 @@ msgstr "Ustaw limit transferu dla zadania"
 
 msgid "Here you can set bandwidth limit for job. This change is applied on running job."
 msgstr "Tutaj możesz ustawić limit transferu dla zadania. Ta zmiana jest stosowana do uruchomionego zadania."
+
+msgid "est."
+msgstr "est."
+
+msgid "Progress bar displays estimated values"
+msgstr "Pasek postępu wyświetla szacunkowe wartości"
+
+msgid "Byte progress bar:"
+msgstr "Pasek postępu bajtów:"
+
+msgid "File progress bar:"
+msgstr "Pasek postępu plików:"
+
+msgid "Running job status"
+msgstr "Status uruchomionego zadania"
+
+msgid "Raw job log"
+msgstr "Surowy dziennik zadania"
+
+msgid "Not available"
+msgstr "Niedostępny"
index a7339727d4ec3ad4d27ad72ce3499abc7ce060ff..70994e23785d72e90a00c193a8b1e3d871f05ee1 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index 84126853ecda6bd69ea2f07d5e22c0c5b97bdb52..4df9ba859072617881574c4a2e41439d0e788d3f 100644 (file)
@@ -2243,8 +2243,8 @@ msgstr "Go to job %job"
 msgid "Graphical status"
 msgstr "Graphical status"
 
-msgid "Text status"
-msgstr "Text status"
+msgid "Raw status"
+msgstr "Raw status"
 
 msgid "Uname:"
 msgstr "Uname:"
@@ -2353,3 +2353,24 @@ msgstr "Set job bandwidth limit"
 
 msgid "Here you can set bandwidth limit for job. This change is applied on running job."
 msgstr "Here you can set bandwidth limit for job. This change is applied on running job."
+
+msgid "est."
+msgstr "est."
+
+msgid "Progress bar displays estimated values"
+msgstr "Progress bar displays estimated values"
+
+msgid "Byte progress bar:"
+msgstr "Byte progress bar:"
+
+msgid "File progress bar:"
+msgstr "File progress bar:"
+
+msgid "Running job status"
+msgstr "Running job status"
+
+msgid "Raw job log"
+msgstr "Raw job log"
+
+msgid "Not available"
+msgstr "Not available"
index 00ce35eed7b020bfc4cb3596b444070e525b7fe6..e90297273495a37efa3ab747cfdfa7cad44ccb67 100644 (file)
@@ -46,7 +46,7 @@
                                                <div id="status_client_subtab_graphical" class="subtab_btn w3-half w3-bottombar w3-hover-light-grey w3-border-red w3-padding"><%[ Graphical status ]%></div>
                                         </a>
                                        <a href="javascript:void(0)" onclick="W3SubTabs.open('status_client_subtab_text', 'status_client_text_output');">
-                                               <div id="status_client_subtab_text" class="subtab_btn w3-half w3-bottombar w3-hover-light-grey w3-padding"><%[ Text status ]%></div>
+                                               <div id="status_client_subtab_text" class="subtab_btn w3-half w3-bottombar w3-hover-light-grey w3-padding"><%[ Raw status ]%></div>
                                        </a>
                                </div>
                                <div id="status_client_graphical_output" class="subtab_item">
@@ -98,6 +98,7 @@
        OnCallback="setBandwidthControl"
        ClientSide.OnComplete="oJobBandwidthLimit.open_popup();"
 />
+<com:TJuiProgressbar Display="None" />
 <script type="text/javascript">
 var oGraphicalClientStatus = {
        data: {},
@@ -309,6 +310,55 @@ var oGraphicalClientStatus = {
                        this.add_job_row(table, '<%[ Processing file: ]%>', processing_file.outerHTML);
                }
 
+               var job_name = job.job.replace(/\.\d{4}-\d{2}-\d{2}_\d{2}.\d{2}.\d{2}_\d{2}$/, '');
+               var bytes = parseInt(job.jobbytes, 10);
+               var files = parseInt(job.jobfiles, 10);
+               files = files > 0 ? (files - 1) : 0;
+               var est = estimate_job(oData.jobs, job_name, job.level);
+
+               // Progress bar bytes
+               var bytes_progress;
+               if (job.type === 'B' && est.est_bytes > 0) {
+                       bytes_progress = document.createElement('DIV');
+                       bytes_progress.className = 'progressbar';
+                       bytes_progress.title = '<%[ Progress bar displays estimated values ]%>';
+                       var bytes_label = document.createElement('DIV');
+                       bytes_label.className = 'progressbar-label';
+                       bytes_label.textContent =  Units.get_formatted_size(bytes) + ' / <%[ est. ]%> ' +  Units.get_formatted_size(est.est_bytes) + ' (' + ((100 * bytes) / est.est_bytes).toFixed(1) + '%' + ')';
+                       bytes_progress.style.width = '70%';
+                       bytes_progress.appendChild(bytes_label);
+                       var bytes_bar = $(bytes_progress);
+                       bytes_bar.progressbar({
+                               max: est.est_bytes,
+                               value: bytes
+                       });
+               } else {
+                       bytes_progress = '<%[ Not available ]%>';
+               }
+               this.add_job_row(table, '<%[ Byte progress bar: ]%>', bytes_progress);
+
+
+               // Progress bar files
+               var files_progress;
+               if (job.type === 'B' && est.est_files > 0) {
+                       files_progress = document.createElement('DIV');
+                       files_progress.className = 'progressbar';
+                       files_progress.title = '<%[ Progress bar displays estimated values ]%>';
+                       var files_label = document.createElement('DIV');
+                       files_label.className = 'progressbar-label';
+                       files_label.textContent =  files + ' / <%[ est. ]%> ' +  parseInt(est.est_files, 10) + ' (' + ((100 * files) / est.est_files).toFixed(1) + '%' + ')';
+                       files_progress.style.width = '70%';
+                       files_progress.appendChild(files_label);
+                       var files_bar = $(files_progress);
+                       files_bar.progressbar({
+                               max: est.est_files,
+                               value: files
+                       });
+               } else {
+                       files_progress = '<%[ Not available ]%>';
+               }
+               this.add_job_row(table, '<%[ File progress bar: ]%>', files_progress);
+
                // Job errors
                this.add_job_row(table, '<%[ Job errors: ]%>', job.errors);
 
index fe60c28bd4e96c8cf8a138328fe9e8021acfcad7..bbe6a753d5e0b1aaf695e61b9b21d65225ddbb08 100644 (file)
@@ -23,6 +23,7 @@
 Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
 Prado::using('System.Web.UI.ActiveControls.TCallback');
+Prado::using('System.Web.UI.JuiControls.TJuiProgressbar');
 Prado::using('Application.Web.Class.BaculumWebPage'); 
 
 class ClientView extends BaculumWebPage {
@@ -135,7 +136,7 @@ class ClientView extends BaculumWebPage {
                );
                if ($graph_status->error === 0) {
                        $client_status['header'] = $graph_status->output;
-                       if (!$this->BWLimit->BandwidthLimit->getDirectiveValue()) {
+                       if (!$this->BWLimit->BandwidthLimit->getDirectiveValue() && is_object($client_status['header'])) {
                                $this->BWLimit->setBandwidthLimit($client_status['header']->bwlimit);
                                $this->getCallbackClient()->callClientFunction(
                                        'oClientBandwidthLimit.set_value',
index f0435413a93968a4f7326a2b95c95223b9664116..a5ea9ebc2c9fc630147292361d37105f0fd669be 100644 (file)
@@ -249,3 +249,16 @@ table.status_table td, table.status_table td i {
 .fa-ellipsis-v:hover {
        background-color: #efeff0;
 }
+
+.progressbar {
+       position: relative;
+}
+
+.progressbar-label {
+       position: absolute;
+       left: 50%;
+       transform: translateX(-50%);
+       top: 4px;
+       font-weight: bold;
+       text-shadow: 1px 1px 0 #fff;
+}