/[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 254 by dpavlin, Mon Dec 12 16:07:27 2005 UTC revision 259 by dpavlin, Mon Dec 12 20:59:58 2005 UTC
# Line 420  sub getGzipSize($$) Line 420  sub getGzipSize($$)
420          );          );
421  }  }
422    
423    sub getVolumes($) {
424            my $id = shift;
425    
426            my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
427    
428            my $sth = $dbh->prepare(qq{
429                    select
430                            size
431                    from backup_parts
432                    where backup_id = ?
433                    order by part_nr asc
434            });
435    
436            $sth->execute($id);
437    
438            my $cumulative_size = 0;
439            my $volumes = 1;
440    
441            while(my ($size) = $sth->fetchrow_array) {
442                    if ($cumulative_size + $size > $max_archive_size) {
443                            $volumes++;
444                            $cumulative_size = $size;
445                    } else {
446                            $cumulative_size += $size;
447                    }
448            }
449    
450            return ($volumes,$cumulative_size);
451    }
452    
453  sub getBackupsNotBurned($) {  sub getBackupsNotBurned($) {
454    
455          my $param = shift;          my $param = shift;
# Line 468  print STDERR "## sort=". ($param->{'sort Line 498  print STDERR "## sort=". ($param->{'sort
498          while ( my $row = $sth->fetchrow_hashref() ) {          while ( my $row = $sth->fetchrow_hashref() ) {
499                  $row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) );                  $row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) );
500                  #$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );                  #$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );
                 $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024);  
501    
502                  # do some cluster calculation (approximate) and convert to kB                  my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
503                  $row->{'inc_size'} = int(($row->{'inc_size'} + 1023 ) / ( 2 * 1024 ) * 2);                  if ($row->{size} > $max_archive_size) {
504                            ($row->{volumes}, $row->{inc_size_calc}) = getVolumes($row->{id});
505                    }
506    
507                    $row->{size} = sprintf("%0.2f", $row->{size} / 1024 / 1024);
508    
509                    # do some cluster calculation (approximate)
510                    $row->{inc_size} = int(($row->{inc_size} + 1023 ) / ( 2 * 1024 ) * 2);
511                    $row->{inc_size_calc} ||= $row->{inc_size};
512                  push @ret, $row;                  push @ret, $row;
513          }          }
514                
515          return @ret;                return @ret;
516  }  }
517    
518  sub displayBackupsGrid($) {  sub displayBackupsGrid($) {
# Line 591  DIV#fixedBox #submitBurner { Line 628  DIV#fixedBox #submitBurner {
628          background-color: transparent;          background-color: transparent;
629  }  }
630    
631  #parts {  #volumes {
632          padding: 0.4em;          padding: 0.4em;
633          display: none;          display: none;
634          width: 100%;          width: 100%;
# Line 675  function checkAll(location) { Line 712  function checkAll(location) {
712    
713  function update_sum(suma, suma_disp) {  function update_sum(suma, suma_disp) {
714          if (! suma_disp) suma_disp = suma;          if (! suma_disp) suma_disp = suma;
715          element_id('forma').elements['totalsize'].value = suma_disp;          suma_disp = Math.floor(suma_disp / 1024);
716            element_id('forma').elements['totalsize_kb'].value = suma_disp;
717            element_id('forma').elements['totalsize'].value = suma;
718          pbar_set(suma, media_size);          pbar_set(suma, media_size);
719          debug('total size: ' + suma);          debug('total size: ' + suma);
720  }  }
# Line 691  function sumiraj(e) { Line 730  function sumiraj(e) {
730                          suma -= size;                          suma -= size;
731                  }                  }
732    
733                  var parts = parseInt( element_id("prt" + e.name.substr(3)).value);                  var volumes = parseInt( element_id("prt" + e.name.substr(3)).value);
734                  if (suma > max_file_size && suma == size && parts > 1) {                  if (volumes > 1) {
735                          element_id("parts").innerHTML = "This will take "+parts+" mediums!";                          if (e.checked) {
736                          element_id("parts").style.display = 'block';                                  element_id("volumes").innerHTML = "This will take "+volumes+" mediums!";
737                          update_sum(media_size, suma);                                  element_id("volumes").style.display = 'block';
738                          suma = media_size;                                  suma = size;
739                          return suma;                                  update_sum(suma);
740                  } else {                                  return suma;
741                          element_id("parts").style.display = 'none';                          } else {
742                                    suma -= size;
743                                    element_id("volumes").style.display = 'none';
744                            }
745                  }                  }
746    
747                  if (suma < 0) suma = 0;                  if (suma < 0) suma = 0;
# Line 791  self.onload = self.document.onload = sel Line 833  self.onload = self.document.onload = sel
833  </script>  </script>
834  <div id="fixedBox">  <div id="fixedBox">
835    
836  Size: <input type="text" name="totalsize" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB  <input type="hidden" name="totalsize"/>
837    Size: <input type="text" name="totalsize_kb" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB
838    
839  <div id="mContainer">  <div id="mContainer">
840          <div id="gradient">&nbsp;</div>          <div id="gradient">&nbsp;</div>
# Line 800  Size: <input type="text" name="totalsize Line 843  Size: <input type="text" name="totalsize
843  </div>  </div>
844  <br/>  <br/>
845    
846  <div id="parts">&nbsp;</div>  <div id="volumes">&nbsp;</div>
847    
848  Note:  Note:
849  <textarea name="note" cols="10" rows="5" id="note"></textarea>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
# Line 833  EOF3 Line 876  EOF3
876                  sort_header($param, 'Size/Mb', 'size', 'center') .                  sort_header($param, 'Size/Mb', 'size', 'center') .
877                  sort_header($param, 'gzip size/Kb', 'incsize', 'center') .                  sort_header($param, 'gzip size/Kb', 'incsize', 'center') .
878          qq{          qq{
879                          </tr>                          <td align="center">medias</td></tr>
880          };          };
881    
882          my @color = (' bgcolor="#e0e0e0"', '');          my @color = (' bgcolor="#e0e0e0"', '');
# Line 860  EOF3 Line 903  EOF3
903                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
904                  }                  }
905    
906                    my $img_url = $Conf{CgiImageDirURL};
907    
908                  $retHTML .=                  $retHTML .=
909                          '</td>' .                          '</td>' .
910                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .                          '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
# Line 869  EOF3 Line 914  EOF3
914                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
915                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
916                          '<td align="right">' . $backup->{'inc_size'} .                          '<td align="right">' . $backup->{'inc_size'} .
917                          '<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .                          '<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size_calc'} .'"></td>' .
918                          '<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'parts'} .'"></td>' .                          '<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'volumes'} .'"></td>' .
919                            '<td align="left">' . ( qq{<img src="$img_url/icon-cd.gif" alt="media">} x $backup->{volumes} ) . '</td>' .
920    
921                          "</tr>\n";                          "</tr>\n";
922          }          }

Legend:
Removed from v.254  
changed lines
  Added in v.259

  ViewVC Help
Powered by ViewVC 1.1.26