]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bweb/lib/Bweb.pm
ebl Doesn't display running job more in job hist
[bacula/bacula] / gui / bweb / lib / Bweb.pm
index 85d34144311a52daec3b204ed7e7c4d25cb96015..5b14313b5ef450d93e8b6068963f0773e82812c4 100644 (file)
@@ -1137,7 +1137,7 @@ sub dbh_selectrow_hashref
 # display Mb/Gb/Kb
 sub human_size
 {
-    my @unit = qw(b Kb Mb Gb Tb);
+    my @unit = qw(B KB MB GB TB);
     my $val = shift || 0;
     my $i=0;
     my $format = '%i %s';
@@ -1259,7 +1259,7 @@ sub display_clients
     my ($self) = @_;
 
     my $where='';
-    my $arg = $self->get_form("client", "qre_client", "jclient_groups");
+    my $arg = $self->get_form("client", "qre_client", "jclient_groups", "qnotingroup");
 
     if ($arg->{qre_client}) {
        $where = "WHERE Name $self->{sql}->{MATCH} $arg->{qre_client} ";
@@ -1269,6 +1269,14 @@ sub display_clients
        $where = "JOIN client_group_member ON (Client.ClientId = client_group_member.clientid) 
                   JOIN client_group USING (client_group_id)
                   WHERE client_group_name IN ($arg->{jclient_groups})";
+    } elsif ($arg->{qnotingroup}) {
+       $where =   "
+  WHERE NOT EXISTS
+   (SELECT 1 FROM client_group_member
+     WHERE Client.ClientId = client_group_member.ClientId
+   )
+";
+   
     }
 
     my $query = "
@@ -1377,6 +1385,7 @@ sub get_form
                 maxvoljobs  => 0,
                 maxvolbytes => 0,
                 maxvolfiles => 0,
+                pathid => 1,
                 );
 
     my %opt_ss =(              # string with space
@@ -2005,7 +2014,7 @@ SELECT  Job.JobId       AS jobid,
           LEFT JOIN FileSet  ON (Job.FileSetId = FileSet.FileSetId)
           $cgq
  WHERE Client.ClientId=Job.ClientId
-   AND Job.JobStatus != 'R'
+   AND Job.JobStatus NOT IN ('R', 'C')
  $where
  $limit
 ";
@@ -2087,19 +2096,24 @@ SELECT client_group_name AS client_group_name,
        COALESCE(jobok.jobbytes,0)  + COALESCE(joberr.jobbytes,0)  AS jobbytes,
        COALESCE(jobok.joberrors,0) + COALESCE(joberr.joberrors,0) AS joberrors,
        COALESCE(jobok.nbjobs,0)  AS nbjobok,
-       COALESCE(joberr.nbjobs,0) AS nbjoberr
+       COALESCE(joberr.nbjobs,0) AS nbjoberr,
+       COALESCE(jobok.duration, '0:0:0') AS duration
 
-FROM (
+FROM client_group LEFT JOIN (
     SELECT client_group_name AS client_group_name, COUNT(1) AS nbjobs, 
            SUM(JobFiles) AS jobfiles, SUM(JobBytes) AS jobbytes, 
-           SUM(JobErrors) AS joberrors
+           SUM(JobErrors) AS joberrors,
+           SUM($self->{sql}->{SEC_TO_TIME}(  $self->{sql}->{UNIX_TIMESTAMP}(EndTime)  
+                              - $self->{sql}->{UNIX_TIMESTAMP}(StartTime)))
+                        AS duration
+
     FROM Job JOIN client_group_member ON (Job.ClientId = client_group_member.ClientId)
              JOIN client_group USING (client_group_id)
     
     WHERE JobStatus = 'T'
     $where
     $limit
-) AS jobok LEFT JOIN
+) AS jobok USING (client_group_name) LEFT JOIN
 
 (
     SELECT client_group_name AS client_group_name, COUNT(1) AS nbjobs, 
@@ -3337,36 +3351,37 @@ sub label_barcodes
     }
 
     my $slots = '';
+    my $slots_sql = '';
     my $t = 300 ;
     if ($arg->{slots}) {
        $slots = join(",", @{ $arg->{slots} });
+       $slots_sql = " AND Slot IN ($slots) ";
        $t += 60*scalar( @{ $arg->{slots} }) ;
     }
 
-    my $b = new Bconsole(pref => $self->{info}, timeout => $t,log_stdout => 1);
-    print "<h1>This command can take long time, be patient...</h1>";
-    print "<pre>" ;
-    $b->label_barcodes(storage => $storage,
-                      drive => $arg->{drive},
-                      pool  => 'Scratch',
-                      slots => $slots) ;
-    $b->close();
-    print "</pre>";
-
     $self->dbh_do("
   UPDATE Media 
        SET LocationId =   (SELECT LocationId 
                              FROM Location 
                             WHERE Location = '$arg->{ach}'),
 
-           RecyclePoolId = PoolId
-
-     WHERE Media.PoolId = (SELECT PoolId 
+           RecyclePoolId = (SELECT PoolId 
                              FROM Pool
                             WHERE Name = 'Scratch')
-       AND (LocationId = 0 OR LocationId IS NULL)
+
+     WHERE (LocationId = 0 OR LocationId IS NULL)
+       $slots_sql
 ");
 
+    my $b = new Bconsole(pref => $self->{info}, timeout => $t,log_stdout => 1);
+    print "<h1>This command can take long time, be patient...</h1>";
+    print "<pre>" ;
+    $b->label_barcodes(storage => $storage,
+                      drive => $arg->{drive},
+                      pool  => 'Scratch',
+                      slots => $slots) ;
+    $b->close();
+    print "</pre>";
 }
 
 sub purge