],
speed: [
{short: '', long: 'B/s', value: 1},
- {short: 'kb/s', long: 'KB/s', value: 1000},
+ {short: 'kb/s', long: 'kB/s', value: 1000},
{short: 'k/s', long: 'KiB/s', value: 1024},
{short: 'mb/s', long: 'MB/s', value: 1000},
{short: 'm/s', long: 'MiB/s', value: 1024}
if (decimal && [1, 1000].indexOf(this.units.speed[i].value) == -1) {
continue;
}
- reminder = speed_bytes % this.units.speed[i].value
+ reminder = speed_bytes % this.units.speed[i].value;
if (reminder === 0 || (float_val && speed_bytes >= this.units.speed[i].value)) {
speed_bytes /= this.units.speed[i].value;
f = this.units.speed[i].long;
break;
}
}
- var ret = {value: speed_bytes, format: f};
- return ret;
+ return {value: speed_bytes, format: f};
},
+ get_short_unit_by_long: function(unit_type, unit_long) {
+ var unit_short = '';
+ for (var i = 0; i < this.units[unit_type].length; i++) {
+ if (this.units[unit_type][i].long === unit_long) {
+ unit_short = this.units[unit_type][i].short;
+ break;
+ }
+ }
+ return unit_short;
+ }
}
var Strings = {
}
}
+function show_element(element, show) {
+ if (show === true) {
+ $(element).show('fast');
+ } else {
+ $(element).hide('fast');
+ }
+}
+
/**
* Set compatibility with Send Bacula Backup Report tool.
* @see https://giunchi.net/send-bacula-backup-report
msgid "Component restart finished successfully."
msgstr "Component restart finished successfully."
+
+msgid "Set bandwidth"
+msgstr "Set bandwidth"
+
+msgid "Set client bandwidth limit"
+msgstr "Set client bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+
+msgid "Bandwidth limit"
+msgstr "Bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+
+msgid "Setting 0 (zero) value disables bandwidth limitation."
+msgstr "Setting 0 (zero) value disables bandwidth limitation."
msgid "Component restart finished successfully."
msgstr "Component restart finished successfully."
+
+msgid "Set bandwidth"
+msgstr "Set bandwidth"
+
+msgid "Set client bandwidth limit"
+msgstr "Set client bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+
+msgid "Bandwidth limit"
+msgstr "Bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+
+msgid "Setting 0 (zero) value disables bandwidth limitation."
+msgstr "Setting 0 (zero) value disables bandwidth limitation."
msgid "Component restart finished successfully."
msgstr "Restart komponentu zakończył się pomyślnie."
+
+msgid "Set bandwidth"
+msgstr "Ustaw limit transferu"
+
+msgid "Set client bandwidth limit"
+msgstr "Ustaw limit transferu klienta"
+
+msgid "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+msgstr "Tutaj możesz ustawić limit transferu na kliencie. Ta zmiana is zastosowana na uruchomionym kliencie. Nie ma żadnej potrzeby restartowania go."
+
+msgid "Bandwidth limit"
+msgstr "Limit transferu"
+
+msgid "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+msgstr "Tutaj możesz ustawić limit transferu dla klienta. Ta zmiana jest zastosowana na działającym kliencie. Nie ma żadnej potrzeby restartowania go."
+
+msgid "Setting 0 (zero) value disables bandwidth limitation."
+msgstr "Ustawienie wartości 0 (zero) wyłącza limitowanie transferu."
msgid "Component restart finished successfully."
msgstr "Component restart finished successfully."
+
+msgid "Set bandwidth"
+msgstr "Set bandwidth"
+
+msgid "Set client bandwidth limit"
+msgstr "Set client bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This changes is applied on running client. There is no need to restart it."
+
+msgid "Bandwidth limit"
+msgstr "Bandwidth limit"
+
+msgid "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+msgstr "Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it."
+
+msgid "Setting 0 (zero) value disables bandwidth limitation."
+msgstr "Setting 0 (zero) value disables bandwidth limitation."
<div class="w3-container tab_item" id="client_actions">
<com:TActiveLinkButton
ID="ClientStatusBtn"
- OnClick="status"
+ OnCallback="status"
CssClass="w3-button w3-green w3-margin-bottom"
CausesValidation="false"
ClientSide.OnLoading="$('#status_client_loading').show();$('#status_client_error').hide();"
</tr>
<tr>
<td><%[ Bandwidth limit: ]%></td>
- <td id="status_client_bwlimit"></td>
+ <td><span id="status_client_bwlimit"></span><com:Application.Web.Portlets.ClientBandwidthLimit ID="BWLimit" OnCallback="status" /></td>
</tr>
<tr>
<td><%[ Debug: ]%></td>
var img = document.createElement('I');
img.className = 'fa';
if (value == 1) {
- img.className += ' fa-check w3-text-green';
+ img.className += ' fa-check';
} else {
img.className += ' fa-times w3-text-red';
}
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
*/
public function setClientId($clientid) {
$clientid = intval($clientid);
+ $this->BWLimit->setClientId($clientid);
$this->setViewState(self::CLIENTID, $clientid, 0);
}
* @return none;
*/
public function setClientName($client_name) {
+ $this->BWLimit->setClientName($client_name);
$this->setViewState(self::CLIENT_NAME, $client_name);
}
);
if ($graph_status->error === 0) {
$client_status['header'] = $graph_status->output;
+ if (!$this->BWLimit->BandwidthLimit->getDirectiveValue()) {
+ $this->BWLimit->setBandwidthLimit($client_status['header']->bwlimit);
+ $this->getCallbackClient()->callClientFunction(
+ 'oClientBandwidthLimit.set_value',
+ array($client_status['header']->bwlimit)
+ );
+ }
}
$query_str = '?name=' . rawurlencode($this->getClientName()) . '&type=running';
--- /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 client bandwidth limit control.
+ */
+class ClientBandwidthLimit extends Portlets {
+
+ const CLIENTID = 'ClientId';
+ const CLIENT_NAME = 'ClientName';
+
+ /**
+ * Set up bandwidth limit value.
+ *
+ * @param TActiveLinkButton $sender sender
+ * @param TCallbackEventParameter $param callback parameter
+ * @return none
+ */
+ public function setupBandwidthLimit($sender, $param) {
+ $clientid = $this->getClientId();
+
+ $result = $this->getModule('api')->set(
+ array('clients', $clientid, '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('#client_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 client clientid.
+ *
+ * @return none;
+ */
+ public function setClientId($clientid) {
+ $clientid = intval($clientid);
+ $this->setViewState(self::CLIENTID, $clientid, 0);
+ }
+
+ /**
+ * Get client clientid.
+ *
+ * @return integer clientid
+ */
+ public function getClientId() {
+ return $this->getViewState(self::CLIENTID, 0);
+ }
+
+ /**
+ * Set client name.
+ *
+ * @return none;
+ */
+ public function setClientName($client_name) {
+ $this->setViewState(self::CLIENT_NAME, $client_name);
+ }
+
+ /**
+ * Get client name.
+ *
+ * @return string client name
+ */
+ public function getClientName() {
+ return $this->getViewState(self::CLIENT_NAME);
+ }
+
+ /**
+ * 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
+ <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>
+<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">
+ <span onclick="oClientBandwidthLimit.close_popup();" class="w3-button w3-display-topright">×</span>
+ <h2><%[ Set client bandwidth limit ]%> - <%[ Client: ]%> <%=$this->getClientName()%></h2>
+ </header>
+ <div class="w3-container w3-margin-left w3-margin-right">
+ <p><%[ Here you can set bandwidth limit on client. This change is applied on running client. There is no need to restart it. ]%></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="oClientBandwidthLimit.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('bandwidth_limit_loading').style.visibility = 'visible';
+ </prop:ClientSide.OnLoading>
+ <prop:ClientSide.OnComplete>
+ document.getElementById('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>
+ </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">
+ <pre><com:TActiveLabel ID="BandwidthLog" /></pre>
+ </div>
+ </div>
+ </div>
+</div>
+<script>
+var oClientBandwidthLimit = {
+ ids: {
+ popup: 'client_bandwidth_limit_popup',
+ log: 'client_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>