units: {
size: [
{short: '', long: 'B', value: 1},
- {short: 'kb', long: 'KB', value: 1000},
+ {short: 'kb', long: 'kB', value: 1000},
{short: 'k', long: 'KiB', value: 1024},
{short: 'mb', long: 'MB', value: 1000},
{short: 'm', long: 'MiB', value: 1024},
{long: 'day', value: 24}
]
},
- get_decimal_size: function(size) {
+ get_size: function(size, unit_value) {
var dec_size;
var units = [];
for (var u in Units.units.size) {
- if ([1, 1000].indexOf(Units.units.size[u].value) !== -1) {
+ if ([1, unit_value].indexOf(Units.units.size[u].value) !== -1) {
units.push(Units.units.size[u].long);
}
}
size = parseInt(size, 10);
var unit;
dec_size = size.toString();
- while(size >= 1000) {
- size /= 1000;
+ while(size >= unit_value) {
+ size /= unit_value;
unit = units.shift();
}
if (unit) {
}
return dec_size;
},
+ get_decimal_size: function(size) {
+ return this.get_size(size, 1000);
+ },
+ get_binary_size: function(size) {
+ return this.get_size(size, 1024);
+ },
+ get_formatted_size: function(size) {
+ var value = '';
+ if (typeof(SIZE_VALUES_UNIT) === 'string') {
+ if (SIZE_VALUES_UNIT === 'decimal') {
+ value = this.get_decimal_size(size);
+ } else if (SIZE_VALUES_UNIT === 'binary') {
+ value = this.get_binary_size(size);
+ }
+ }
+ return value;
+ },
format_size: function(size_bytes, format) {
var reminder;
var f = this.units.size[0].long;
var Formatters = {
formatter: [
- {css_class: 'size', format_func: Units.get_decimal_size},
+ {css_class: 'size', format_func: function(val) { return Units.get_formatted_size(val); }},
{css_class: 'time', format_func: function(val) { return Units.format_time_period(val); }}
],
set_formatters: function() {
}
}
+function set_formatters() {
+ Formatters.set_formatters();
+}
+
var Cookies = {
default_exipration_time: 31536000000, // 1 year in miliseconds
set_cookie: function(name, value, expiration) {
document.getElementById(this.ids.jobs.most_count).textContent = occupancy;
},
update_jobtotals: function() {
- document.getElementById(this.ids.jobtotals.total_bytes).textContent = Units.get_decimal_size(this.stats.jobtotals.bytes);
+ document.getElementById(this.ids.jobtotals.total_bytes).textContent = Units.get_formatted_size(this.stats.jobtotals.bytes);
document.getElementById(this.ids.jobtotals.total_files).textContent = this.stats.jobtotals.files || 0;
},
update_database: function() {
if (this.stats.dbsize.dbsize) {
document.getElementById(this.ids.database.type).textContent = this.dbtype[this.stats.dbsize.dbtype];
- document.getElementById(this.ids.database.size).textContent = Units.get_decimal_size(this.stats.dbsize.dbsize);
+ document.getElementById(this.ids.database.size).textContent = Units.get_formatted_size(this.stats.dbsize.dbsize);
}
},
update_pools: function() {
msgid "Ready"
msgstr "Ready"
+
+msgid "Show size values as:"
+msgstr "Show size values as:"
+
+msgid "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+msgstr "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+
+msgid "Binary Bytes (1 mebi = 2<sup>20</sup>)"
+msgstr "Binary Bytes (1 mebi = 2<sup>20</sup>)"
msgid "Ready"
msgstr "Ready"
+
+msgid "Show size values as:"
+msgstr "Show size values as:"
+
+msgid "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+msgstr "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+
+msgid "Binary Bytes (1 mebi = 2<sup>20</sup>)"
+msgstr "Binary Bytes (1 mebi = 2<sup>20</sup>)"
msgid "Ready"
msgstr "Gotowy"
+
+msgid "Show size values as:"
+msgstr "Pokaż wartości rozmiaru jako:"
+
+msgid "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+msgstr "Dziesiętne Bajty (1 mega = 10<sup>6</sup>)"
+
+msgid "Binary Bytes (1 mebi = 2<sup>20</sup>)"
+msgstr "Binarne Bajty (1 mebi = 2<sup>20</sup>)"
msgid "Ready"
msgstr "Ready"
+
+msgid "Show size values as:"
+msgstr "Show size values as:"
+
+msgid "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+msgstr "Decimal Bytes (1 mega = 10<sup>6</sup>)"
+
+msgid "Binary Bytes (1 mebi = 2<sup>20</sup>)"
+msgstr "Binary Bytes (1 mebi = 2<sup>20</sup>)"
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 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
* Bacula(R) is a registered trademark of Kern Sibbald.
*/
-class Main extends TTemplateControl
-{
-
+class Main extends TTemplateControl {
+
+ public $web_config;
+
+ public function onPreRender($param) {
+ parent::onPreRender($param);
+ $this->web_config = $this->Application->getModule('web_config')->getConfig();
+ }
}
-?>
\ No newline at end of file
+?>
</div>
<script type="text/javascript">
var is_small = $('#small').is(':visible');
+var SIZE_VALUES_UNIT = '<%=(count($this->web_config) > 0 && key_exists('size_values_unit', $this->web_config['baculum'])) ? $this->web_config['baculum']['size_values_unit'] : 'decimal'%>';
var oMonitor;
var default_refresh_interval = 60000;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 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
* Bacula(R) is a registered trademark of Kern Sibbald.
*/
-class Wizard extends TTemplateControl
-{
-
+class Wizard extends TTemplateControl {
+
+ public $web_config;
+
+ public function onPreRender($param) {
+ parent::onPreRender($param);
+ $this->web_config = $this->Application->getModule('web_config')->getConfig();
+ }
}
-?>
\ No newline at end of file
+?>
<link rel="icon" href="<%=$this->getPage()->getTheme()->getBaseUrl()%>/favicon.ico" type="image/x-icon" />
</com:THead>
<body class="w3-light-grey">
+ <script type="text/javascript">
+ var SIZE_VALUES_UNIT = '<%=(count($this->web_config) > 0 && key_exists('size_values_unit', $this->web_config['baculum'])) ? $this->web_config['baculum']['size_values_unit'] : 'decimal'%>';
+ </script>
<com:TForm>
<com:TClientScript PradoScripts="ajax, effects" />
<com:BClientScript ScriptUrl=<%~ ../JavaScript/fontawesome-all.js %> />
/>
</div>
</div>
+ <div class="w3-container w3-row w3-padding">
+ <div class="w3-third w3-col"><%[ Show size values as: ]%></div>
+ <div class="w3-third w3-col">
+ <p><com:TRadioButton
+ ID="DecimalBytes"
+ CssClass="w3-radio"
+ GroupName="SizeBytes"
+ /> <com:TLabel ForControl="DecimalBytes"><%[ Decimal Bytes (1 mega = 10<sup>6</sup>) ]%></com:TLabel></p>
+ <p>
+ <com:TRadioButton
+ ID="BinaryBytes"
+ CssClass="w3-radio"
+ GroupName="SizeBytes"
+ /> <com:TLabel ForControl="BinaryBytes"><%[ Binary Bytes (1 mebi = 2<sup>20</sup>) ]%></com:TLabel></p>
+ </div>
+ </div>
<div class="w3-center">
<com:TActiveLinkButton
CssClass="w3-button w3-green"
* 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 onInit($param) {
parent::onInit($param);
$this->web_config = $this->getModule('web_config')->getConfig();
+ $this->DecimalBytes->Checked = true;
if(count($this->web_config) > 0) {
$this->Debug->Checked = ($this->web_config['baculum']['debug'] == 1);
$this->MaxJobs->Text = (key_exists('max_jobs', $this->web_config['baculum']) ? intval($this->web_config['baculum']['max_jobs']) : Monitor::DEFAULT_MAX_JOBS);
+ if (key_exists('size_values_unit', $this->web_config['baculum'])) {
+ $this->DecimalBytes->Checked = ($this->web_config['baculum']['size_values_unit'] === 'decimal');
+ $this->BinaryBytes->Checked = ($this->web_config['baculum']['size_values_unit'] === 'binary');
+ }
}
}
$this->web_config['baculum']['debug'] = ($this->Debug->Checked === true) ? 1 : 0;
$max_jobs = intval($this->MaxJobs->Text);
$this->web_config['baculum']['max_jobs'] = $max_jobs;
+ $this->web_config['baculum']['size_values_unit'] = $this->BinaryBytes->Checked ? 'binary' : 'decimal';
$this->getModule('web_config')->setConfig($this->web_config);
}
}
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
<div id="restore-browser-selected" class="w3-border">
<com:TJuiDroppable ID="SelectedVersionsDropper" Height="100%" Width="100%"
Options.accept=".draggable"
- OnLoad="refreshSelectedFiles"
OnDrop="addFileToRestore"
- OnCallback="refreshSelectedFiles"
OnDeactivate="callFormatters"
>
<com:TActiveDataGrid
* 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
$this->loadSelectedFiles();
}
- /**
- * Refresh/re-render selected files list.
- *
- * @param TDropContainer $sender sender object
- * @param TEventParameter $param param object
- * @return none
- */
- public function refreshSelectedFiles($sender, $param) {
- $this->loadSelectedFiles();
- if ($this->IsCallBack && is_object($param)) {
- $this->SelectedVersionsDropper->render($param->NewWriter);
- }
- }
-
/**
* Call formatters method.
*/
public function callFormatters($sender, $param) {
- $this->getCallbackClient()->callClientFunction('Formatters.set_formatters');
+ $this->getCallbackClient()->callClientFunction('set_formatters');
}
/*
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
render: function (data, type, row) {
var s;
if (type == 'display') {
- s = Units.get_decimal_size(data)
+ s = Units.get_formatted_size(data)
} else {
s = data;
}
private $size_formats = array(
array('format' => '', 'value' => 1, 'label' => 'B'),
- array('format' => 'kb', 'value' => 1000, 'label' => 'KB'),
+ array('format' => 'kb', 'value' => 1000, 'label' => 'kB'),
array('format' => 'k', 'value' => 1024, 'label' => 'KiB'),
array('format' => 'mb', 'value' => 1000000, 'label' => 'MB'),
array('format' => 'm', 'value' => 1048576, 'label' => 'MiB'),
private $speed_formats = array(
array('format' => '', 'value' => 1, 'label' => 'B/s'),
- array('format' => 'kb/s', 'value' => 1000, 'label' => 'KB/s'),
+ array('format' => 'kb/s', 'value' => 1000, 'label' => 'kB/s'),
array('format' => 'k/s', 'value' => 1024, 'label' => 'KiB/s'),
array('format' => 'mb/s', 'value' => 1000000, 'label' => 'MB/s'),
array('format' => 'm/s', 'value' => 1048576, 'label' => 'MiB/s')