$ret =~ s/\\h/$host/ge;
$ret =~ s/\\s/$share/ge;
$ret =~ s/\\n/$backupnum/ge;
-
+
+ $ret =~ s/__+/_/g;
+
return $ret;
}
+sub getGzipSize($$)
+{
+ my ($hostID, $backupNum) = @_;
+ my $ret;
+ my $sql;
+ my $dbh = get_dbh();
+
+ $sql = q{
+ SELECT hosts.name as host,
+ shares.name as share,
+ backups.num as backupnum
+ FROM hosts, backups, shares
+ WHERE shares.id=backups.shareid AND
+ hosts.id =backups.hostid AND
+ hosts.id=? AND
+ backups.num=?
+ };
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($hostID, $backupNum);
+
+ my $row = $sth->fetchrow_hashref();
+
+ my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) =
+ stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.
+ getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));
+
+ return $ret;
+}
+
sub getBackupsNotBurned() {
my $dbh = get_dbh();
backups.hostID AS hostID,
hosts.name AS host,
shares.name AS share,
- backups.id AS backupnum,
+ backups.num AS backupnum,
backups.type AS type,
backups.date AS date,
- backups.size AS size
+ backups.size AS size,
+ backups.id AS id,
+ backups.inc_size AS inc_size
FROM backups
INNER JOIN shares ON backups.shareID=shares.ID
INNER JOIN hosts ON backups.hostID = hosts.ID
- LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id AND archive_backup.backup_id IS NULL
- WHERE backups.size > 0
+ LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id
+ WHERE backups.size > 0 AND backups.inc_size > 0 AND archive_backup.backup_id IS NULL
GROUP BY
backups.hostID,
hosts.name,
backups.id,
backups.type,
backups.date,
- backups.size
+ backups.size,
+ backups.inc_size
ORDER BY backups.date
};
my $sth = $dbh->prepare( $sql );
while ( my $row = $sth->fetchrow_hashref() ) {
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024);
- my (undef,undef,undef,undef,undef,undef,undef,$fs_size,undef,undef,undef,undef,undef) =
- stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.
- getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));
- $row->{'fs_size'} = $fs_size;
+
+ # do some cluster calculation (approximate) and convert to kB
+ $row->{'inc_size'} = int($row->{'inc_size'} / ( 2 * 1024) * 2);
push @ret, $row;
}
sub displayBackupsGrid() {
my $retHTML .= q{
- <form id="forma" method="POST" action=};
- $retHTML .= "\"".$MyURL."\"";
- $retHTML .= q{?action=burn>
+ <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">
};
$retHTML .= <<'EOF3';
-<style>
+<style type="text/css">
<!--
-
-div#fixedBox {
+DIV#fixedBox {
position: absolute;
- bottom: 1em;
- left: 0.5em;
+ top: 50em;
+ left: -24%;
padding: 0.5em;
- width: 10em;
- background: #e0f0e0;
- border: 1px solid #00ff00;
+ width: 20%;
+ background-color: #E0F0E0;
+ border: 1px solid #00C000;
}
-@media screen {
- div#fixedBox {
- position: fixed;
- }
- /* Don't do this at home */
- * html {
- overflow-y: hidden;
- }
- * html body {
- overflow-y: auto;
- height: 100%;
- padding: 0 1em 0 12em;
- font-size: 100%;
- }
- * html div#fixedBox {
- position: absolute;
- }
- /* All done. */
+
+DIV#fixedBox, DIV#fixedBox INPUT, DIV#fixedBox TEXTAREA {
+ font-size: 10pt;
}
-#mContainer {
- position: relative;
- width: 100%;
- height: 1.1em;
- padding: 0px;
- border: 1px solid #000000;
+FORM>DIV#fixedBox {
+ position: fixed !important;
+ left: 0.5em !important;
+ top: auto !important;
+ bottom: 1em !important;
+ width: 15% !important;
}
-#gradient {
- position: absolute;
- top: 0px;
- left: 0px;
- width: 100%;
- height: 100%;
+DIV#fixedBox INPUT[type=text], DIV#fixedBox TEXTAREA {
+ border: 1px solid #00C000;
+}
+
+DIV#fixedBox #note {
display: block;
- background-color: #ffff00;
+ width: 100%;
}
-#mask {
- position: absolute;
- top: 0px;
- left: 0px;
+DIV#fixedBox #submitBurner {
+ display: block;
width: 100%;
+ margin-top: 0.5em;
+ cursor: pointer;
+}
+
+* HTML {
+ overflow-y: hidden;
+}
+
+* HTML BODY {
+ overflow-y: auto;
height: 100%;
- display: block;
- font-size: 1px;
- background-color: #FFFFFF;
- overflow: hidden;
+ font-size: 100%;
}
-#progressIndicator {
+* HTML DIV#fixedBox {
position: absolute;
- top: 0px;
- left: 0px;
- width: 100%;
- height: 100%;
+}
+
+#mContainer, #gradient, #mask, #progressIndicator {
display: block;
- font-weight: bold;
- color: #404040;
+ width: 100%;
font-size: 10pt;
+ font-weight: bold;
text-align: center;
+ vertical-align: middle;
+ padding: 1px;
}
+#gradient, #mask, #progressIndicator {
+ left: 0;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+ color: #404040;
+ margin: 0.4em;
+ position: absolute;
+ margin-left: -1px;
+ margin-top: -1px;
+ margin-bottom: -1px;
+ overflow: hidden;
+}
+
+#mContainer {
+ display: block;
+ position: relative;
+ padding: 0px;
+ margin-top: 0.4em;
+ margin-bottom: 0.5em;
+}
+
+#gradient {
+ z-index: 1;
+ background-color: #FFFF00;
+}
+
+#mask {
+ z-index: 2;
+ background-color: #FFFFFF;
+}
+
+#progressIndicator {
+ z-index: 3;
+ background-color: transparent;
+}
-->
</style>
-<script language="javascript" type="text/javascript">
+<script type="text/javascript">
<!--
var debug_div = null;
-var media_size = 4400 * 1024;
+EOF3
+
+ # take maximum archive size from configuration
+ $retHTML .= 'var media_size = '. $Conf{MaxArchiveSize} .';';
+
+ $retHTML .= <<'EOF3';
function debug(msg) {
// return; // Disable debugging
}
function checkAll(location) {
- var len = element_id('forma').elements.length;
+ var f = element_id('forma') || null;
+ if (!f) return false;
+
+ var len = f.elements.length;
var check_all = element_id('allFiles');
- var suma = 0;
+ var suma = check_all.checked ? (parseInt(f.elements['totalsize'].value) || 0) : 0;
for (var i = 0; i < len; i++) {
-
- var e = element_id('forma').elements[i];
- if (e.name != 'all' && e.name.substr(0,3) == 'fcb') {
+ var e = f.elements[i];
+ if (e.name != 'all' && e.name.substr(0, 3) == 'fcb') {
if (check_all.checked) {
+ if (e.checked) continue;
var el = element_id("fss" + e.name.substr(3));
var size = parseInt(el.value) || 0;
debug('suma: '+suma+' size: '+size);
}
function update_sum(suma) {
- element_id('forma').totalsize.value = suma;
+ element_id('forma').elements['totalsize'].value = suma;
pbar_set(suma, media_size);
- debug('total size: '+suma);
+ debug('total size: ' + suma);
}
function sumiraj(e) {
- var suma = parseInt(element_id('forma').totalsize.value) || 0;
+ var suma = parseInt(element_id('forma').elements['totalsize'].value) || 0;
var len = element_id('forma').elements.length;
if (e) {
- var size = parseInt( element_id("fss" + e.name.substr(3)).value );
+ var size = parseInt( element_id("fss" + e.name.substr(3)).value);
if (e.checked) {
suma += size;
} else {
/* progress bar */
-var _pbar_width = 0;
+var _pbar_width = null;
var _pbar_warn = 10; // change color in last 10%
function pbar_reset() {
element_id("mask").style.left = "0px";
_pbar_width = element_id("mContainer").offsetWidth - 2;
element_id("mask").style.width = _pbar_width + "px";
- element_id("progressIndicator").style.zIndex = 10;
element_id("mask").style.display = "block";
+ element_id("progressIndicator").style.zIndex = 10;
element_id("progressIndicator").innerHTML = "0";
}
function dec2hex(d) {
- var hch="0123456789ABCDEF";
- var a=d%16;
- var q=(d-a)/16;
- return hch.charAt(q)+hch.charAt(a);
+ var hch = '0123456789ABCDEF';
+ var a = d % 16;
+ var q = (d - a) / 16;
+ return hch.charAt(q) + hch.charAt(a);
}
-
function pbar_set(amount, max) {
+ debug('pbar_set('+amount+', '+max+')');
- debug('pbar_set( '+amount+' , '+max+' )');
-
- curWidth = parseInt(element_id("mask").offsetWidth);
- curLeft = parseInt(element_id("mask").offsetLeft);
-
+ if (_pbar_width == null) {
+ var _mc = element_id("mContainer");
+ if (_pbar_width == null) _pbar_width = parseInt(_mc.offsetWidth ? (_mc.offsetWidth - 2) : 0) || null;
+ if (_pbar_width == null) _pbar_width = parseInt(_mc.clientWidth ? (_mc.clientWidth + 2) : 0) || null;
+ if (_pbar_width == null) _pbar_width = 0;
+ }
- var pcnt = Math.floor( amount * 100 / max );
+ var pcnt = Math.floor(amount * 100 / max);
var p90 = 100 - _pbar_warn;
var pcol = pcnt - p90;
- if (pcol < _pbar_warn) {
+ if (Math.round(pcnt) <= 100) {
if (pcol < 0) pcol = 0;
var e = element_id("submitBurner");
- if (e && e.disabled) {
- debug('enable_button');
- var a = e.getAttributeNode('disabled') || null;
- if (a) e.removeAttributeNode(a);
- }
- } else if (pcol > _pbar_warn) {
+ debug('enable_button');
+ e.disabled = false;
+ var a = e.getAttributeNode('disabled') || null;
+ if (a) e.removeAttributeNode(a);
+ } else {
debug('disable button');
pcol = _pbar_warn;
var e = element_id("submitBurner");
- if (! e.disabled) e.disabled = true;
+ if (!e.disabled) e.disabled = true;
}
- var col_g = Math.floor( ( _pbar_warn - pcol ) * 255 / _pbar_warn );
- var col = '#ff' + dec2hex( col_g ) + '00';
+ var col_g = Math.floor((_pbar_warn - pcol) * 255 / _pbar_warn);
+ var col = '#FF' + dec2hex(col_g) + '00';
//debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);
element_id("gradient").style.backgroundColor = col;
- var size = parseInt( _pbar_width * amount / max );
-
- curWidth = _pbar_width - size;
- curLeft = size ;
-
- //debug('size: '+size+' curWidth '+curWidth+' curLeft: '+curLeft);
-
element_id("progressIndicator").innerHTML = pcnt + '%';
//element_id("progressIndicator").innerHTML = amount;
- if (curLeft > _pbar_width) {
- element_id("mask").style.display = "none";
- return;
- } else {
- element_id("mask").style.display = "";
- }
-
- //if(parseInt(element_id("mask").offsetWidth)>10)
- element_id("mask").style.width = curWidth + "px";
- element_id("mask").style.left = curLeft + "px";
-
+ element_id("mask").style.clip = 'rect(' + Array(
+ '0px',
+ element_id("mask").offsetWidth + 'px',
+ element_id("mask").offsetHeight + 'px',
+ Math.round(_pbar_width * amount / max) + 'px'
+ ).join(' ') + ')';
}
if (!self.body) self.body = new Object();
self.onload = self.document.onload = self.body.onload = function() {
- pbar_reset();
+ //pbar_reset();
sumiraj();
-}
+};
-//-->
+// -->
</script>
<div id="fixedBox">
-Size:
-<input type="text" name="totalsize" size="7" readonly>
+Size: <input type="text" name="totalsize" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB
<div id="mContainer">
- <div id="gradient"></div>
- <div id="mask"></div>
- <div id="progressIndicator"> </div>
+ <div id="gradient"> </div>
+ <div id="mask"> </div>
+ <div id="progressIndicator">0%</div>
</div>
-
<br/>
+
Note:
-<br/>
-<textarea name="note" cols="10" rows="5">
-</textarea>
-<br/>
-<input type="submit" id="submitBurner" value="Burn selected" name="submitBurner">
+<textarea name="note" cols="10" rows="5" id="note"></textarea>
+
+<input type="submit" id="submitBurner" value="Burn selected" name="submitBurner" />
</div>
+<!--
<div id="debug" style="float: right; width: 10em; border: 1px #ff0000 solid; background-color: #ffe0e0; -moz-opacity: 0.7;">
no debug output yet
</div>
+-->
EOF3
$retHTML .= q{
<input type="hidden" value="burn" name="action">
<td align="center">date</td>
<td align="center">age/days</td>
<td align="center">size/MB</td>
- <td align="center">gzip size</td>
+ <td align="center">gzip size/kB</td>
</tr>
};
}
my $ftype = "";
+ my $checkbox_key = $backup->{'hostid'}. '_' .$backup->{'backupnum'} . '_' . $backup->{'id'};
+
$retHTML .=
'<tr' . $color[$i %2 ] . '>
<td class="fview">';
- # FIXME
- $backup->{'fs_size'} = int($backup->{'size'} * 1024);
- if (($backup->{'fs_size'} || 0) > 0) {
+
+ if (($backup->{'inc_size'} || 0) > 0) {
$retHTML .= '
- <input type="checkbox" name="fcb' .
- $backup->{'hostid'}.'_'.$backup->{'backupnum'} .
- '" value="' . $backup->{'hostid'}.'_'.$backup->{'backupnum'} .
- '" onClick="sumiraj(this);">';
+ <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
}
+
$retHTML .=
'</td>' .
'<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
'<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' .
'<td align="center">' . $backup->{'age'} . '</td>' .
'<td align="right">' . $backup->{'size'} . '</td>' .
- '<td align="right">' . $backup->{'fs_size'} .
- '<input type="hidden" iD="fss'.$backup->{'hostid'}.'_'.$backup->{'backupnum'} . '" value="'. $backup->{'fs_size'} .'"></td>' .
+ '<td align="right">' . $backup->{'inc_size'} .
+ '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .
"</tr>\n";
}