/[BackupPC]/trunk/lib/BackupPC/SearchLib.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/BackupPC/SearchLib.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 128 by dpavlin, Thu Sep 22 13:31:04 2005 UTC revision 146 by iklaric, Fri Oct 7 12:03:05 2005 UTC
# Line 293  sub getGzipName($$$) Line 293  sub getGzipName($$$)
293                    
294  }  }
295    
296    sub getGzipSize($$)
297    {
298            my ($hostID, $backupNum) = @_;
299            my $ret;
300            my $sql;
301            my $dbh = get_dbh();
302            
303            $sql = q{
304                                    SELECT hosts.name  as host,
305                                               shares.name as share,
306                                               backups.num as backupnum
307                                    FROM hosts, backups, shares
308                                    WHERE shares.id=backups.shareid AND
309                                              hosts.id =backups.hostid AND
310                                              hosts.id=? AND
311                                              backups.num=?
312                            };
313            my $sth = $dbh->prepare($sql);
314            $sth->execute($hostID, $backupNum);
315    
316            my $row = $sth->fetchrow_hashref();
317            
318            my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) =
319                            stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.
320                                    getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));
321            
322            return $ret;    
323    }
324    
325  sub getBackupsNotBurned() {  sub getBackupsNotBurned() {
326    
327          my $dbh = get_dbh();          my $dbh = get_dbh();
# Line 302  sub getBackupsNotBurned() { Line 331  sub getBackupsNotBurned() {
331                          backups.hostID AS hostID,                          backups.hostID AS hostID,
332                          hosts.name AS host,                          hosts.name AS host,
333                          shares.name AS share,                          shares.name AS share,
334                          backups.id AS backupnum,                          backups.num AS backupnum,
335                          backups.type AS type,                          backups.type AS type,
336                          backups.date AS date,                          backups.date AS date,
337                          backups.size AS size                          backups.size AS size,
338                            backups.id AS id
339                  FROM backups                  FROM backups
340                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
341                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
342                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id AND archive_backup.backup_id IS NULL                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id
343                  WHERE backups.size > 0                  WHERE backups.size > 0 AND archive_backup.backup_id IS NULL
344                  GROUP BY                  GROUP BY
345                          backups.hostID,                          backups.hostID,
346                          hosts.name,                          hosts.name,
# Line 343  sub getBackupsNotBurned() { Line 373  sub getBackupsNotBurned() {
373  sub displayBackupsGrid() {  sub displayBackupsGrid() {
374    
375          my $retHTML .= q{          my $retHTML .= q{
376                  <form id="forma" method="POST" action=};                  <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">
                 $retHTML .= "\"".$MyURL."\"";  
                 $retHTML .= q{?action=burn>  
377          };          };
378    
379          $retHTML .= <<'EOF3';          $retHTML .= <<'EOF3';
380  <style>  <style type="text/css">
381  <!--  <!--
382    DIV#fixedBox {
 div#fixedBox {  
383          position: absolute;          position: absolute;
384          bottom: 1em;          top: 50em;
385          left: 0.5em;          left: -24%;
386          padding: 0.5em;          padding: 0.5em;
387          width: 10em;          width: 20%;
388          background: #e0f0e0;          background-color: #E0F0E0;
389          border: 1px solid #00ff00;          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. */  
390  }  }
391    
392  #mContainer {  DIV#fixedBox, DIV#fixedBox INPUT, DIV#fixedBox TEXTAREA {
393          position: relative;          font-size: 10pt;
         width: 100%;  
         height: 1.1em;  
         padding: 0px;  
         border: 1px solid #000000;  
394  }  }
395    
396  #gradient {  FORM>DIV#fixedBox {
397          position: absolute;          position: fixed !important;
398          top: 0px;          left: 0.5em !important;
399          left: 0px;          top: auto !important;
400          width: 100%;          bottom: 1em !important;
401          height: 100%;          width: 15% !important;
402    }
403    
404    DIV#fixedBox INPUT[type=text], DIV#fixedBox TEXTAREA {
405            border: 1px solid #00C000;
406    }
407    
408    DIV#fixedBox #note {
409          display: block;          display: block;
410          background-color: #ffff00;          width: 100%;
411  }  }
412    
413  #mask {  DIV#fixedBox #submitBurner {
414          position: absolute;          display: block;
         top: 0px;  
         left: 0px;  
415          width: 100%;          width: 100%;
416            margin-top: 0.5em;
417            cursor: pointer;
418    }
419    
420    * HTML {
421            overflow-y: hidden;
422    }
423    
424    * HTML BODY {
425            overflow-y: auto;
426          height: 100%;          height: 100%;
427          display: block;          font-size: 100%;
         font-size: 1px;  
         background-color: #FFFFFF;  
         overflow: hidden;  
428  }  }
429    
430  #progressIndicator {  * HTML DIV#fixedBox {
431          position: absolute;          position: absolute;
432          top: 0px;  }
433          left: 0px;  
434          width: 100%;  #mContainer, #gradient, #mask, #progressIndicator {
         height: 100%;  
435          display: block;          display: block;
436          font-weight: bold;          width: 100%;
         color: #404040;  
437          font-size: 10pt;          font-size: 10pt;
438            font-weight: bold;
439          text-align: center;          text-align: center;
440            vertical-align: middle;
441            padding: 1px;
442    }
443    
444    #gradient, #mask, #progressIndicator {
445            left: 0;
446            border-width: 1px;
447            border-style: solid;
448            border-color: #000000;
449            color: #404040;
450            margin: 0.4em;
451            position: absolute;
452            margin-left: -1px;
453            margin-top: -1px;
454            margin-bottom: -1px;
455            overflow: hidden;
456  }  }
457    
458    #mContainer {
459            display: block;
460            position: relative;
461            padding: 0px;
462            margin-top: 0.4em;
463            margin-bottom: 0.5em;
464    }
465    
466    #gradient {
467            z-index: 1;
468            background-color: #FFFF00;
469    }
470    
471    #mask {
472            z-index: 2;
473            background-color: #FFFFFF;
474    }
475    
476    #progressIndicator {
477            z-index: 3;
478            background-color: transparent;
479    }
480  -->  -->
481  </style>  </style>
482  <script language="javascript" type="text/javascript">  <script type="text/javascript">
483  <!--  <!--
484    
485  var debug_div = null;  var debug_div = null;
# Line 460  function element_id(name,element) { Line 513  function element_id(name,element) {
513  }  }
514    
515  function checkAll(location) {  function checkAll(location) {
516          var len = element_id('forma').elements.length;          var f = element_id('forma') || null;
517            if (!f) return false;
518    
519            var len = f.elements.length;
520          var check_all = element_id('allFiles');          var check_all = element_id('allFiles');
521            var suma = check_all.checked ? (parseInt(f.elements['totalsize'].value) || 0) : 0;
522    
523          for (var i = 0; i < len; i++) {          for (var i = 0; i < len; i++) {
524                    var e = f.elements[i];
525                  var e = element_id('forma').elements[i];                  if (e.name != 'all' && e.name.substr(0, 3) == 'fcb') {
                 if ((e.checked || !e.checked) && e.name != 'all') {  
526                          if (check_all.checked) {                          if (check_all.checked) {
527                                  e.checked = true;                                  if (e.checked) continue;
528                                    var el = element_id("fss" + e.name.substr(3));
529                                    var size = parseInt(el.value) || 0;
530                                    debug('suma: '+suma+' size: '+size);
531                                    if ((suma + size) < media_size) {
532                                            suma += size;
533                                            e.checked = true;
534                                    } else {
535                                            break;
536                                    }
537                          } else {                          } else {
538                                  e.checked = false;                                  e.checked = false;
539                          }                          }
540                  }                  }
541          }          }
542            update_sum(suma);
543    }
544    
545          sumiraj();  function update_sum(suma) {
546            element_id('forma').elements['totalsize'].value = suma;
547            pbar_set(suma, media_size);
548            debug('total size: ' + suma);
549  }  }
550        
551  function sumiraj(e) {  function sumiraj(e) {
552          var suma = parseInt(element_id('forma').totalsize.value) || 0;          var suma = parseInt(element_id('forma').elements['totalsize'].value) || 0;
553          var len = element_id('forma').elements.length;          var len = element_id('forma').elements.length;
554          if (e) {          if (e) {
555                  var size = parseInt( element_id("fss" + e.name.substr(3)).value );                  var size = parseInt( element_id("fss" + e.name.substr(3)).value);
556                  if (e.checked) {                  if (e.checked) {
557                          suma += size;                          suma += size;
558                  } else {                  } else {
# Line 498  function sumiraj(e) { Line 568  function sumiraj(e) {
568                          }                          }
569                  }                  }
570          }          }
571          element_id('forma').totalsize.value = suma;          update_sum(suma);
         pbar_set(suma, media_size);  
         debug('total size: '+suma);  
572          return suma;          return suma;
573  }  }
574    
575  /* progress bar */  /* progress bar */
576    
577  var _pbar_width = 0;  var _pbar_width = null;
578  var _pbar_warn = 10;    // change color in last 10%  var _pbar_warn = 10;    // change color in last 10%
579    
580  function pbar_reset() {  function pbar_reset() {
581          element_id("mask").style.left = "0px";          element_id("mask").style.left = "0px";
582          _pbar_width = element_id("mContainer").offsetWidth - 2;          _pbar_width = element_id("mContainer").offsetWidth - 2;
583          element_id("mask").style.width = _pbar_width + "px";          element_id("mask").style.width = _pbar_width + "px";
         element_id("progressIndicator").style.zIndex  = 10;  
584          element_id("mask").style.display = "block";          element_id("mask").style.display = "block";
585            element_id("progressIndicator").style.zIndex  = 10;
586          element_id("progressIndicator").innerHTML = "0";          element_id("progressIndicator").innerHTML = "0";
587  }  }
588    
589  function dec2hex(d) {  function dec2hex(d) {
590          var hch="0123456789ABCDEF";          var hch = '0123456789ABCDEF';
591          var a=d%16;          var a = d % 16;
592          var q=(d-a)/16;          var q = (d - a) / 16;
593          return hch.charAt(q)+hch.charAt(a);          return hch.charAt(q) + hch.charAt(a);
594  }  }
595    
   
596  function pbar_set(amount, max) {  function pbar_set(amount, max) {
597            debug('pbar_set('+amount+', '+max+')');
598    
599          debug('pbar_set( '+amount+' , '+max+' )');          if (_pbar_width == null) {
600                    var _mc = element_id("mContainer");
601          curWidth = parseInt(element_id("mask").offsetWidth);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.offsetWidth ? (_mc.offsetWidth - 2) : 0) || null;
602          curLeft = parseInt(element_id("mask").offsetLeft);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.clientWidth ? (_mc.clientWidth + 2) : 0) || null;
603                    if (_pbar_width == null) _pbar_width = 0;
604            }
605    
606          var pcnt = Math.floor( amount * 100 / max );          var pcnt = Math.floor(amount * 100 / max);
607          var p90 = 100 - _pbar_warn;          var p90 = 100 - _pbar_warn;
608          var pcol = pcnt - p90;          var pcol = pcnt - p90;
609          if (pcol < _pbar_warn) {          if (Math.round(pcnt) <= 100) {
610                  if (pcol < 0) pcol = 0;                  if (pcol < 0) pcol = 0;
611                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
612                  if (e && e.disabled) {                  debug('enable_button');
613                          debug('enable_button');                  e.disabled = false;
614                          var a = e.getAttributeNode('disabled') || null;                  var a = e.getAttributeNode('disabled') || null;
615                          if (a) e.removeAttributeNode(a);                  if (a) e.removeAttributeNode(a);
616                  }          } else {
         } else if (pcol > _pbar_warn) {  
617                  debug('disable button');                  debug('disable button');
618                  pcol = _pbar_warn;                  pcol = _pbar_warn;
619                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
620                  if (! e.disabled) e.disabled = true;                  if (!e.disabled) e.disabled = true;
621          }          }
622          var col_g = Math.floor( ( _pbar_warn - pcol ) * 255 / _pbar_warn );          var col_g = Math.floor((_pbar_warn - pcol) * 255 / _pbar_warn);
623          var col = '#ff' + dec2hex( col_g ) + '00';          var col = '#FF' + dec2hex(col_g) + '00';
624    
625          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);
626          element_id("gradient").style.backgroundColor = col;          element_id("gradient").style.backgroundColor = col;
627    
         var size = parseInt( _pbar_width * amount / max );  
   
         curWidth = _pbar_width - size;  
         curLeft = size ;  
   
         //debug('size: '+size+' curWidth '+curWidth+' curLeft: '+curLeft);  
   
628          element_id("progressIndicator").innerHTML = pcnt + '%';          element_id("progressIndicator").innerHTML = pcnt + '%';
629          //element_id("progressIndicator").innerHTML = amount;          //element_id("progressIndicator").innerHTML = amount;
630    
631          if (curLeft > _pbar_width) {          element_id("mask").style.clip = 'rect(' + Array(
632                  element_id("mask").style.display = "none";                  '0px',
633                  return;                  element_id("mask").offsetWidth + 'px',
634          } else {                  element_id("mask").offsetHeight + 'px',
635                  element_id("mask").style.display = "";                  Math.round(_pbar_width * amount / max) + 'px'
636          }          ).join(' ') + ')';
   
         //if(parseInt(element_id("mask").offsetWidth)>10)  
         element_id("mask").style.width = curWidth + "px";  
         element_id("mask").style.left = curLeft + "px";  
   
637  }  }
638    
639  if (!self.body) self.body = new Object();  if (!self.body) self.body = new Object();
640  self.onload = self.document.onload = self.body.onload = function() {  self.onload = self.document.onload = self.body.onload = function() {
641          pbar_reset();          //pbar_reset();
642          sumiraj();          sumiraj();
643  }  };
644    
645  //-->  // -->
646  </script>  </script>
647  <div id="fixedBox">  <div id="fixedBox">
648    
649  Size:  Size: <input type="text" name="totalsize" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB
 <input type="text" name="totalsize" size="7" readonly>  
650    
651  <div id="mContainer">  <div id="mContainer">
652          <div id="gradient"></div>          <div id="gradient">&nbsp;</div>
653          <div id="mask"></div>          <div id="mask">&nbsp;</div>
654          <div id="progressIndicator">&nbsp;</div>          <div id="progressIndicator">0%</div>
655  </div>  </div>
   
656  <br/>  <br/>
657    
658  Note:  Note:
659  <br/>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
660  <textarea name="note" cols="10" rows="5">  
661  </textarea>  <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner" />
 <br/>  
 <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner">  
662    
663  </div>  </div>
664    <!--
665  <div id="debug" style="float: right; width: 10em; border: 1px #ff0000 solid; background-color: #ffe0e0; -moz-opacity: 0.7;">  <div id="debug" style="float: right; width: 10em; border: 1px #ff0000 solid; background-color: #ffe0e0; -moz-opacity: 0.7;">
666  no debug output yet  no debug output yet
667  </div>  </div>
668    -->
669  EOF3  EOF3
670          $retHTML .= q{          $retHTML .= q{
671                          <input type="hidden" value="burn" name="action">                          <input type="hidden" value="burn" name="action">
# Line 644  EOF3 Line 699  EOF3
699                  }                  }
700                  my $ftype = "";                  my $ftype = "";
701    
702                    my $checkbox_key = $backup->{'hostid'}. '_' .$backup->{'backupnum'} . '_' . $backup->{'id'};
703    
704                  $retHTML .=                  $retHTML .=
705                          '<tr' . $color[$i %2 ] . '>                          '<tr' . $color[$i %2 ] . '>
706                          <td class="fview">';                          <td class="fview">';
707    
708                  # FIXME                  # FIXME
709                  $backup->{'fs_size'} = int($backup->{'size'} * 1024);                  $backup->{'fs_size'} = int($backup->{'size'} * 1024);
710    
711                  if (($backup->{'fs_size'} || 0) > 0) {                  if (($backup->{'fs_size'} || 0) > 0) {
712                          $retHTML .= '                          $retHTML .= '
713                          <input type="checkbox" name="fcb' .                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
                         $backup->{'hostid'}.'_'.$backup->{'backupnum'} .  
                         '" value="' . $backup->{'hostid'}.'_'.$backup->{'backupnum'} .  
                         '" onClick="sumiraj(this);">';  
714                  }                  }
715    
716                  $retHTML .=                  $retHTML .=
717                          '</td>' .                          '</td>' .
718                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
# Line 665  EOF3 Line 722  EOF3
722                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
723                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
724                          '<td align="right">' . $backup->{'fs_size'} .                          '<td align="right">' . $backup->{'fs_size'} .
725                          '<input type="hidden" iD="fss'.$backup->{'hostid'}.'_'.$backup->{'backupnum'} . '" value="'. $backup->{'fs_size'} .'"></td>' .                          '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'fs_size'} .'"></td>' .
726    
727                          "</tr>\n";                          "</tr>\n";
728          }          }

Legend:
Removed from v.128  
changed lines
  Added in v.146

  ViewVC Help
Powered by ViewVC 1.1.26