--- trunk/lib/BackupPC/SearchLib.pm 2005/09/20 16:23:04 124 +++ trunk/lib/BackupPC/SearchLib.pm 2005/10/07 09:36:10 143 @@ -293,6 +293,34 @@ } +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 = $res->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(); @@ -309,8 +337,8 @@ 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 archive_backup.backup_id IS NULL GROUP BY backups.hostID, hosts.name, @@ -340,61 +368,310 @@ return @ret; } -sub displayBackupsGrid() - { - my $retHTML = ""; - - $retHTML .= < +sub displayBackupsGrid() { + + my $retHTML .= q{ +
+ }; + + $retHTML .= <<'EOF3'; + + +} + +/* progress bar */ + +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("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); +} + +function pbar_set(amount, max) { + debug('pbar_set('+amount+', '+max+')'); + + 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 p90 = 100 - _pbar_warn; + var pcol = pcnt - p90; + if (Math.round(pcnt) <= 100) { + if (pcol < 0) pcol = 0; + var e = element_id("submitBurner"); + 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; + } + 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; + + element_id("progressIndicator").innerHTML = pcnt + '%'; + //element_id("progressIndicator").innerHTML = amount; + + 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(); + sumiraj(); +}; + +// --> + +
+ +Size: kB + +
+
 
+
 
+
0%
+
+
+ +Note: + + + + +
+ EOF3 $retHTML .= q{ - @@ -405,9 +682,6 @@ - }; my @color = (' bgcolor="#e0e0e0"', ''); @@ -422,14 +696,21 @@ $host = $backup->{'host'}; } my $ftype = ""; - - $retHTML .= ""; - $retHTML .= ''; - + $retHTML .= + ' + ' . '' . '' . '' . @@ -437,16 +718,12 @@ '' . '' . '\n"; - + '' . + "\n"; } $retHTML .= "
- + Share Backup nogzip size
- -
'; + # FIXME + $backup->{'fs_size'} = int($backup->{'size'} * 1024); + if (($backup->{'fs_size'} || 0) > 0) { + $retHTML .= ' + '; + } + $retHTML .= + '' . $backup->{'host'} . ':' . $backup->{'share'} . '' . $backup->{'backupnum'} . '' . $backup->{'type'} . '' . $backup->{'age'} . '' . $backup->{'size'} . '' . $backup->{'fs_size'} . - '' . - "
"; - $retHTML .= "total gzip size:
"; - $retHTML .= "Note:"; $retHTML .= "
"; return $retHTML;