msgid "Setting 0 (zero) value disables bandwidth limitation."
msgstr "Setting 0 (zero) value disables bandwidth limitation."
+
+msgid "Set job bandwidth limit"
+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 "Setting 0 (zero) value disables bandwidth limitation."
msgstr "Setting 0 (zero) value disables bandwidth limitation."
+
+msgid "Set job bandwidth limit"
+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 "Setting 0 (zero) value disables bandwidth limitation."
msgstr "Ustawienie wartości 0 (zero) wyłącza limitowanie transferu."
+
+msgid "Set job bandwidth limit"
+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 "Setting 0 (zero) value disables bandwidth limitation."
msgstr "Setting 0 (zero) value disables bandwidth limitation."
+
+msgid "Set job bandwidth limit"
+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."
<h5 id="status_client_no_jobs_running" style="display: none"><%[ No jobs running ]%></h5>
<div id="status_client_running_jobs"></div>
</div>
+<com:Application.Web.Portlets.JobBandwidthLimit
+ ID="JobBandwidth"
+ OnCallback="status"
+/>
+<com:TCallback ID="JobBandwidthCb"
+ OnCallback="setBandwidthControl"
+ ClientSide.OnComplete="oJobBandwidthLimit.open_popup();"
+/>
<script type="text/javascript">
var oGraphicalClientStatus = {
data: {},
// Bandwidth limit
var bwlimit = '<%[ No limit ]%>';
+ var span = document.createElement('SPAN');
var l = parseInt(job.bwlimit, 10);
if (l > 0) {
- var fl = Units.format_speed(l, null, true, true);
+ fl = Units.format_speed(l, null, true, true);
bwlimit = fl.value.toFixed(2) + ' ' + fl.format;
}
- this.add_job_row(table, '<%[ Bandwidth limit: ]%>', bwlimit);
+ var text = document.createTextNode(bwlimit + '\u00A0\u00A0');
+ span.appendChild(text);
+ var a = document.createElement('A');
+ a.className = 'w3-hover-opacity';
+ a.href = 'javascript:void(0)';
+ a.addEventListener('click', function(e) {
+ oJobBandwidthLimit.set_value(job.bwlimit);
+ var param = job.jobid + '|' + job.job;
+ var cb = <%=$this->JobBandwidthCb->ActiveControl->Javascript%>;
+ cb.setCallbackParameter(param);
+ cb.dispatch();
+ });
+ a.title = '<%[ Set job bandwidth limit ]%>';
+ var i = document.createElement('I');
+ i.className = 'fas fa-tachometer-alt w3-large';
+ a.appendChild(i);
+ span.appendChild(a);
+
+ this.add_job_row(table, '<%[ Bandwidth limit: ]%>', span);
var running_jobs_el = document.getElementById(this.ids.running_jobs);
if (full_refresh) {
var tdl = document.createElement('TD');
var tdr = document.createElement('TD');
tdl.textContent = key;
- tdr.innerHTML = value;
+ if (value instanceof HTMLElement) {
+ tdr.appendChild(value);
+ } else {
+ tdr.innerHTML = value;
+ }
tr.appendChild(tdl);
tr.appendChild(tdr);
table.appendChild(tr);
Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+Prado::using('System.Web.UI.ActiveControls.TCallback');
Prado::using('Application.Web.Class.BaculumWebPage');
class ClientView extends BaculumWebPage {
$this->getCallbackClient()->callClientFunction('init_graphical_client_status', array($client_status));
}
+ public function setBandwidthControl($sender, $param) {
+ if ($param instanceof Prado\Web\UI\ActiveControls\TCallbackEventParameter) {
+ list($jobid, $job_uname) = explode('|', $param->getCallbackParameter(), 2);
+ $this->JobBandwidth->setJobId($jobid);
+ $this->JobBandwidth->setJobUname($job_uname);
+ }
+ }
+
private function getClientVersion($output) {
$version = array('major' => 0, 'minor' => 0, 'release' => 0);
for ($i = 0; $i < count($output); $i++) {
- <a class="w3-hover-opacity" href="javascript:void(0)" onclick="oClientBandwidthLimit.open_popup();" title="<%[ Set bandwidth ]%>"><i class="fas fa-tachometer-alt w3-large"></i></a>
+ <a class="w3-hover-opacity" href="javascript:void(0)" onclick="oClientBandwidthLimit.open_popup();" title="<%[ Set client bandwidth limit ]%>"><i class="fas fa-tachometer-alt w3-large"></i></a>
<div id="client_bandwidth_limit_popup" class="w3-modal">
<div class="w3-modal-content w3-animate-top w3-card-4">
<header class="w3-container w3-teal">
CssClass="w3-button w3-section w3-green w3-padding"
>
<prop:ClientSide.OnLoading>
- document.getElementById('bandwidth_limit_loading').style.visibility = 'visible';
+ document.getElementById('client_bandwidth_limit_loading').style.visibility = 'visible';
</prop:ClientSide.OnLoading>
<prop:ClientSide.OnComplete>
- document.getElementById('bandwidth_limit_loading').style.visibility = 'hidden';
+ document.getElementById('client_bandwidth_limit_loading').style.visibility = 'hidden';
</prop:ClientSide.OnComplete>
<i class="fa fa-check"></i> <%[ Set bandwidth ]%>
</com:TActiveLinkButton>
- <i id="bandwidth_limit_loading" class="fa fa-sync w3-spin" style="visibility: hidden;"></i>
+ <i id="client_bandwidth_limit_loading" class="fa fa-sync w3-spin" style="visibility: hidden;"></i>
</footer>
<div id="client_bandwidth_limit_log" class="w3-panel w3-card w3-light-grey" style="display: none; max-height: 200px; overflow-x: auto;">
<div class="w3-code">
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+Prado::using('Application.Web.Portlets.DirectiveSpeed');
+Prado::using('Application.Web.Portlets.Portlets');
+
+/**
+ * Set job bandwidth limit control.
+ */
+class JobBandwidthLimit extends Portlets {
+
+ const JOBID = 'JobId';
+ const JOB_UNAME = 'JobUname';
+
+ /**
+ * Set up bandwidth limit value.
+ *
+ * @param TActiveLinkButton $sender sender
+ * @param TCallbackEventParameter $param callback parameter
+ * @return none
+ */
+ public function setupBandwidthLimit($sender, $param) {
+ $jobid = $this->getJobId();
+
+ $result = $this->getModule('api')->set(
+ array('jobs', $jobid, 'bandwidth'),
+ array('limit' => $this->BandwidthLimit->getValue())
+ );
+
+ // this setting to empty string is required to not cache outputs for the same values
+ $this->BandwidthLog->Text = '';
+ if ($result->error === 0) {
+ $this->BandwidthLog->Text = implode(PHP_EOL, $result->output);
+ } else {
+ $this->BandwidthLog->Text = $result->output;
+ }
+
+ $this->getPage()->getCallbackClient()->callClientFunction(
+ 'show_element',
+ array('#job_bandwidth_limit_log', true)
+ );
+
+ $this->onCallback(null);
+ }
+
+ /**
+ * Callback event method.
+ *
+ * @param mixed $param callback parameter or null
+ * @return none
+ */
+ public function onCallback($param) {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Set job jobid.
+ *
+ * @return none;
+ */
+ public function setJobId($jobid) {
+ $jobid = intval($jobid);
+ $this->setViewState(self::JOBID, $jobid, 0);
+ $this->JobIdLabel->Text = $jobid;
+ }
+
+ /**
+ * Get job jobid.
+ *
+ * @return integer jobid
+ */
+ public function getJobId() {
+ return $this->getViewState(self::JOBID, 0);
+ }
+
+ /**
+ * Set job uname.
+ *
+ * @return none;
+ */
+ public function setJobUname($job_uname) {
+ $this->setViewState(self::JOB_UNAME, $job_uname);
+ $this->JobUnameLabel->Text = $job_uname;
+ }
+
+ /**
+ * Get job uname.
+ *
+ * @return string job uname
+ */
+ public function getJobUname() {
+ return $this->getViewState(self::JOB_UNAME);
+ }
+
+ /**
+ * Get bandwidth limit value from field.
+ *
+ * @return mixed bandwidth limit integer value or null if bandwidth not set
+ */
+ public function getBandwidthLimit() {
+ return $this->BandwidthLimit->getValue();
+ }
+
+ /**
+ * Set bandwidth limit value in field.
+ *
+ * @param integer $bwlimit bandiwdth limit in bytes
+ * @return none
+ */
+ public function setBandwidthLimit($bwlimit) {
+ $this->BandwidthLimit->setDirectiveValue($bwlimit);
+ }
+}
+?>
--- /dev/null
+<div id="job_bandwidth_limit_popup" class="w3-modal">
+ <div class="w3-modal-content w3-animate-top w3-card-4">
+ <header class="w3-container w3-teal">
+ <span onclick="oJobBandwidthLimit.close_popup();" class="w3-button w3-display-topright">×</span>
+ <h2><%[ Set job bandwidth limit ]%> - <%[ JobId: ]%> <com:TActiveLabel ID="JobIdLabel" /></h2>
+ </header>
+ <div class="w3-container w3-margin-left w3-margin-right">
+ <p><%[ Job: ]%> <strong><com:TActiveLabel ID="JobUnameLabel" /></strong></p>
+ <p><%[ Here you can set bandwidth limit for job. This change is applied on running job. ]%></p>
+ <p><%[ Setting 0 (zero) value disables bandwidth limitation. ]%></p>
+ <div class="w3-row w3-section w3-medium">
+ <com:Application.Web.Portlets.DirectiveSpeed
+ ID="BandwidthLimit"
+ DirectiveName="BandwidthLimit"
+ DefaultValue="0"
+ Show="true"
+ Label="<%[ Bandwidth limit ]%>"
+ UnitType="decimal"
+ />
+ </div>
+ </div>
+ <footer class="w3-container w3-center">
+ <a class="w3-button w3-red" href="javascript:void(0)" onclick="oJobBandwidthLimit.close_popup()"><i class="fas fa-times"></i>  <%[ Cancel ]%></a>
+ <com:TActiveLinkButton
+ ID="SetBandwidthLimit"
+ OnCallback="setupBandwidthLimit"
+ CssClass="w3-button w3-section w3-green w3-padding"
+ >
+ <prop:ClientSide.OnLoading>
+ document.getElementById('job_bandwidth_limit_loading').style.visibility = 'visible';
+ </prop:ClientSide.OnLoading>
+ <prop:ClientSide.OnComplete>
+ document.getElementById('job_bandwidth_limit_loading').style.visibility = 'hidden';
+ </prop:ClientSide.OnComplete>
+ <i class="fa fa-check"></i> <%[ Set bandwidth ]%>
+ </com:TActiveLinkButton>
+ <i id="job_bandwidth_limit_loading" class="fas fa-sync w3-spin" style="visibility: hidden;"></i>
+ </footer>
+ <div id="job_bandwidth_limit_log" class="w3-panel w3-card w3-light-grey" style="display: none; max-height: 200px; overflow-x: auto;">
+ <div class="w3-code">
+ <pre><com:TActiveLabel ID="BandwidthLog" /></pre>
+ </div>
+ </div>
+ </div>
+</div>
+<script>
+var oJobBandwidthLimit = {
+ ids: {
+ popup: 'job_bandwidth_limit_popup',
+ log: 'job_bandwidth_limit_log'
+ },
+ open_popup: function() {
+ document.getElementById(this.ids.popup).style.display = 'block';
+ },
+ close_popup: function() {
+ document.getElementById(this.ids.popup).style.display = 'none';
+ this.cleanup_log();
+ },
+ cleanup_log: function() {
+ document.getElementById(this.ids.log).style.display = 'none';
+ document.getElementById('<%=$this->BandwidthLog->ClientID%>').textContent = '';
+ },
+ set_value: function(value) {
+ var bwlimit_val = document.getElementById('<%=$this->BandwidthLimit->Directive->ClientID%>');
+ var bwlimit_unit = document.getElementById('<%=$this->BandwidthLimit->SpeedFormat->ClientID%>');
+ var val = Units.format_speed(value, null, false, true);
+ bwlimit_val.value = val.value;
+ bwlimit_unit.value = Units.get_short_unit_by_long('speed', val.format) || val.format;
+ }
+};
+</script>