/[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 137 by iklaric, Thu Sep 29 08:46:13 2005 UTC revision 149 by dpavlin, Fri Oct 7 12:27:07 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
# 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;
486  var media_size = 4400 * 1024;  EOF3
487    
488            # take maximum archive size from configuration
489            $retHTML .= 'var media_size = '. $Conf{MaxArchiveSize} .';';
490    
491            $retHTML .= <<'EOF3';
492    
493  function debug(msg) {  function debug(msg) {
494  //      return; // Disable debugging  //      return; // Disable debugging
# Line 460  function element_id(name,element) { Line 518  function element_id(name,element) {
518  }  }
519    
520  function checkAll(location) {  function checkAll(location) {
521          var len = element_id('forma').elements.length;          var f = element_id('forma') || null;
522            if (!f) return false;
523    
524            var len = f.elements.length;
525          var check_all = element_id('allFiles');          var check_all = element_id('allFiles');
526          var suma = 0;          var suma = check_all.checked ? (parseInt(f.elements['totalsize'].value) || 0) : 0;
527    
528          for (var i = 0; i < len; i++) {          for (var i = 0; i < len; i++) {
529                    var e = f.elements[i];
530                  var e = element_id('forma').elements[i];                  if (e.name != 'all' && e.name.substr(0, 3) == 'fcb') {
                 if (e.name != 'all' && e.name.substr(0,3) == 'fcb') {  
531                          if (check_all.checked) {                          if (check_all.checked) {
532                                    if (e.checked) continue;
533                                  var el = element_id("fss" + e.name.substr(3));                                  var el = element_id("fss" + e.name.substr(3));
534                                  var size = parseInt(el.value) || 0;                                  var size = parseInt(el.value) || 0;
535                                  debug('suma: '+suma+' size: '+size);                                  debug('suma: '+suma+' size: '+size);
# Line 487  function checkAll(location) { Line 548  function checkAll(location) {
548  }  }
549    
550  function update_sum(suma) {  function update_sum(suma) {
551          element_id('forma').totalsize.value = suma;          element_id('forma').elements['totalsize'].value = suma;
552          pbar_set(suma, media_size);          pbar_set(suma, media_size);
553          debug('total size: '+suma);          debug('total size: ' + suma);
554  }  }
555    
556  function sumiraj(e) {  function sumiraj(e) {
557          var suma = parseInt(element_id('forma').totalsize.value) || 0;          var suma = parseInt(element_id('forma').elements['totalsize'].value) || 0;
558          var len = element_id('forma').elements.length;          var len = element_id('forma').elements.length;
559          if (e) {          if (e) {
560                  var size = parseInt( element_id("fss" + e.name.substr(3)).value );                  var size = parseInt( element_id("fss" + e.name.substr(3)).value);
561                  if (e.checked) {                  if (e.checked) {
562                          suma += size;                          suma += size;
563                  } else {                  } else {
# Line 518  function sumiraj(e) { Line 579  function sumiraj(e) {
579    
580  /* progress bar */  /* progress bar */
581    
582  var _pbar_width = 0;  var _pbar_width = null;
583  var _pbar_warn = 10;    // change color in last 10%  var _pbar_warn = 10;    // change color in last 10%
584    
585  function pbar_reset() {  function pbar_reset() {
586          element_id("mask").style.left = "0px";          element_id("mask").style.left = "0px";
587          _pbar_width = element_id("mContainer").offsetWidth - 2;          _pbar_width = element_id("mContainer").offsetWidth - 2;
588          element_id("mask").style.width = _pbar_width + "px";          element_id("mask").style.width = _pbar_width + "px";
         element_id("progressIndicator").style.zIndex  = 10;  
589          element_id("mask").style.display = "block";          element_id("mask").style.display = "block";
590            element_id("progressIndicator").style.zIndex  = 10;
591          element_id("progressIndicator").innerHTML = "0";          element_id("progressIndicator").innerHTML = "0";
592  }  }
593    
594  function dec2hex(d) {  function dec2hex(d) {
595          var hch="0123456789ABCDEF";          var hch = '0123456789ABCDEF';
596          var a=d%16;          var a = d % 16;
597          var q=(d-a)/16;          var q = (d - a) / 16;
598          return hch.charAt(q)+hch.charAt(a);          return hch.charAt(q) + hch.charAt(a);
599  }  }
600    
   
601  function pbar_set(amount, max) {  function pbar_set(amount, max) {
602            debug('pbar_set('+amount+', '+max+')');
603    
604          debug('pbar_set( '+amount+' , '+max+' )');          if (_pbar_width == null) {
605                    var _mc = element_id("mContainer");
606          curWidth = parseInt(element_id("mask").offsetWidth);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.offsetWidth ? (_mc.offsetWidth - 2) : 0) || null;
607          curLeft = parseInt(element_id("mask").offsetLeft);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.clientWidth ? (_mc.clientWidth + 2) : 0) || null;
608                    if (_pbar_width == null) _pbar_width = 0;
609            }
610    
611          var pcnt = Math.floor( amount * 100 / max );          var pcnt = Math.floor(amount * 100 / max);
612          var p90 = 100 - _pbar_warn;          var p90 = 100 - _pbar_warn;
613          var pcol = pcnt - p90;          var pcol = pcnt - p90;
614          if (pcol < _pbar_warn) {          if (Math.round(pcnt) <= 100) {
615                  if (pcol < 0) pcol = 0;                  if (pcol < 0) pcol = 0;
616                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
617                  if (e && e.disabled) {                  debug('enable_button');
618                          debug('enable_button');                  e.disabled = false;
619                          var a = e.getAttributeNode('disabled') || null;                  var a = e.getAttributeNode('disabled') || null;
620                          if (a) e.removeAttributeNode(a);                  if (a) e.removeAttributeNode(a);
621                  }          } else {
         } else if (pcol > _pbar_warn) {  
622                  debug('disable button');                  debug('disable button');
623                  pcol = _pbar_warn;                  pcol = _pbar_warn;
624                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
625                  if (! e.disabled) e.disabled = true;                  if (!e.disabled) e.disabled = true;
626          }          }
627          var col_g = Math.floor( ( _pbar_warn - pcol ) * 255 / _pbar_warn );          var col_g = Math.floor((_pbar_warn - pcol) * 255 / _pbar_warn);
628          var col = '#ff' + dec2hex( col_g ) + '00';          var col = '#FF' + dec2hex(col_g) + '00';
629    
630          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);
631          element_id("gradient").style.backgroundColor = col;          element_id("gradient").style.backgroundColor = col;
632    
         var size = parseInt( _pbar_width * amount / max );  
   
         curWidth = _pbar_width - size;  
         curLeft = size ;  
   
         //debug('size: '+size+' curWidth '+curWidth+' curLeft: '+curLeft);  
   
633          element_id("progressIndicator").innerHTML = pcnt + '%';          element_id("progressIndicator").innerHTML = pcnt + '%';
634          //element_id("progressIndicator").innerHTML = amount;          //element_id("progressIndicator").innerHTML = amount;
635    
636          if (curLeft > _pbar_width) {          element_id("mask").style.clip = 'rect(' + Array(
637                  element_id("mask").style.display = "none";                  '0px',
638                  return;                  element_id("mask").offsetWidth + 'px',
639          } else {                  element_id("mask").offsetHeight + 'px',
640                  element_id("mask").style.display = "";                  Math.round(_pbar_width * amount / max) + 'px'
641          }          ).join(' ') + ')';
   
         //if(parseInt(element_id("mask").offsetWidth)>10)  
         element_id("mask").style.width = curWidth + "px";  
         element_id("mask").style.left = curLeft + "px";  
   
642  }  }
643    
644  if (!self.body) self.body = new Object();  if (!self.body) self.body = new Object();
645  self.onload = self.document.onload = self.body.onload = function() {  self.onload = self.document.onload = self.body.onload = function() {
646          pbar_reset();          //pbar_reset();
647          sumiraj();          sumiraj();
648  }  };
649    
650  //-->  // -->
651  </script>  </script>
652  <div id="fixedBox">  <div id="fixedBox">
653    
654  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>  
655    
656  <div id="mContainer">  <div id="mContainer">
657          <div id="gradient"></div>          <div id="gradient">&nbsp;</div>
658          <div id="mask"></div>          <div id="mask">&nbsp;</div>
659          <div id="progressIndicator">&nbsp;</div>          <div id="progressIndicator">0%</div>
660  </div>  </div>
   
661  <br/>  <br/>
662    
663  Note:  Note:
664  <br/>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
665  <textarea name="note" cols="10" rows="5">  
666  </textarea>  <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner" />
 <br/>  
 <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner">  
667    
668  </div>  </div>
669    <!--
670  <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;">
671  no debug output yet  no debug output yet
672  </div>  </div>
673    -->
674  EOF3  EOF3
675          $retHTML .= q{          $retHTML .= q{
676                          <input type="hidden" value="burn" name="action">                          <input type="hidden" value="burn" name="action">
# Line 656  EOF3 Line 704  EOF3
704                  }                  }
705                  my $ftype = "";                  my $ftype = "";
706    
707                    my $checkbox_key = $backup->{'hostid'}. '_' .$backup->{'backupnum'} . '_' . $backup->{'id'};
708    
709                  $retHTML .=                  $retHTML .=
710                          '<tr' . $color[$i %2 ] . '>                          '<tr' . $color[$i %2 ] . '>
711                          <td class="fview">';                          <td class="fview">';
712    
713                  # FIXME                  # FIXME
714                  $backup->{'fs_size'} = int($backup->{'size'} * 1024);                  $backup->{'fs_size'} = int($backup->{'size'} * 1024);
715    
716                  if (($backup->{'fs_size'} || 0) > 0) {                  if (($backup->{'fs_size'} || 0) > 0) {
717                          $retHTML .= '                          $retHTML .= '
718                          <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);">';  
719                  }                  }
720    
721                  $retHTML .=                  $retHTML .=
722                          '</td>' .                          '</td>' .
723                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
# Line 677  EOF3 Line 727  EOF3
727                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
728                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
729                          '<td align="right">' . $backup->{'fs_size'} .                          '<td align="right">' . $backup->{'fs_size'} .
730                          '<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>' .
731    
732                          "</tr>\n";                          "</tr>\n";
733          }          }

Legend:
Removed from v.137  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.26