From: Eric Bollengier Date: Mon, 26 Nov 2007 22:01:19 +0000 (+0000) Subject: ebl Fix mysql things X-Git-Tag: Release-3.0.0~2198 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8be46e7092bb219b9ffba7cf86738e2805b77524;p=bacula%2Fbacula ebl Fix mysql things git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5991 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bresto.pl b/gui/bweb/cgi/bresto.pl index 6f773d3f13..9071a9e768 100755 --- a/gui/bweb/cgi/bresto.pl +++ b/gui/bweb/cgi/bresto.pl @@ -739,6 +739,7 @@ SELECT JobId package main; use strict; +use POSIX qw/strftime/; use Bweb; my $conf = new Bweb::Config(config_file => $Bweb::config_file); @@ -873,19 +874,32 @@ if ($action eq 'restore') { my $u = join(" UNION ", @union); - $bvfs->dbh_do("CREATE TEMPORARY TABLE btemp AS ($u)"); + $bvfs->dbh_do("CREATE TEMPORARY TABLE btemp AS $u"); # TODO: remove FilenameId et PathId - $bvfs->dbh_do("CREATE TABLE b2$$ AS ( + + # now we have to choose the file with the max(jobid) + # for each file of btemp + if ($bvfs->dbh_is_mysql()) { + $bvfs->dbh_do("CREATE TEMPORARY TABLE btemp2 AS ( +SELECT max(JobId) as JobId, PathId, FilenameId + FROM btemp + GROUP BY PathId, FilenameId +)"); + $bvfs->dbh_do("CREATE TABLE b2$$ AS ( SELECT btemp.JobId, btemp.FileIndex, btemp.FilenameId, btemp.PathId - FROM btemp, - (SELECT max(JobId) as JobId, PathId, FilenameId - FROM btemp - GROUP BY PathId, FilenameId - ORDER BY JobId DESC) AS a - WHERE a.JobId = btemp.JobId - AND a.PathId= btemp.PathId - AND a.FilenameId = btemp.FilenameId + FROM btemp, btemp2 + WHERE btemp2.JobId = btemp.JobId + AND btemp2.PathId= btemp.PathId + AND btemp2.FilenameId = btemp.FilenameId +)"); + } else { # postgresql have distinct with more than one criteria... + $bvfs->dbh_do("CREATE TABLE b2$$ AS ( +SELECT DISTINCT ON (PathId, FilenameId) JobId, FileIndex + FROM btemp + ORDER BY PathId, FilenameId, JobId DESC )"); + } + my $bconsole = $bvfs->get_bconsole(); # TODO: pouvoir choisir le replace et le jobname my $jobid = $bconsole->run(client => $arg->{client}, @@ -918,8 +932,7 @@ if ($action eq 'list_files') { # File.FilenameId, listfiles.id, listfiles.Name, File.LStat, File.JobId print join(',', - map { "[$_->[1], $_->[0], $pathid, $_->[4], \"$_->[2]\", 10, \"2007-01-01 00:00:00\"]" } - @$files); + map { my @p=Bvfs::parse_lstat($_->[3]); "[$_->[1],$_->[0],$pathid,$_->[4],\"$_->[2]\"," . $p[7] . ",'" . strftime('%Y-%m-%d %H:%m:%S', localtime($p[11])) . "']" } @$files); print "]\n"; } elsif ($action eq 'list_dirs') { @@ -944,7 +957,7 @@ if ($action eq 'list_files') { #($pathid,$fileid,$jobid, $fid, $mtime, $size, $inchanger, $md5, $volname); my $files = $bvfs->get_all_file_versions($args->{pathid}, $args->{filenameid}, $args->{client}, $vafv); print join(',', - map { "[ $_->[3], $_->[1], $_->[0], $_->[2], '$_->[8]', $_->[6], '$_->[7]', $_->[5], $_->[4] ]" } + map { "[ $_->[3], $_->[1], $_->[0], $_->[2], '$_->[8]', $_->[6], '$_->[7]', $_->[5],'" . strftime('%Y-%m-%d %H:%m:%S', localtime($_->[4])) . "']" } @$files); print "]\n"; @@ -954,11 +967,11 @@ if ($action eq 'list_files') { my $fileid = join(',', grep { /^\d+$/ } CGI::param('fileid')); my $q=" - SELECT DISTINCT VolumeName, InChanger + SELECT DISTINCT VolumeName, Enabled, InChanger FROM File, ( -- Get all media from this job SELECT MIN(FirstIndex) AS FirstIndex, MAX(LastIndex) AS LastIndex, - VolumeName, Inchanger + VolumeName, Enabled, Inchanger FROM JobMedia JOIN Media USING (MediaId) WHERE JobId IN ($jobid) GROUP BY VolumeName, InChanger @@ -969,7 +982,7 @@ if ($action eq 'list_files') { "; my $lst = $bvfs->dbh_selectall_arrayref($q); print "["; - print join(',', map { "[ '$_->[0]', $_->[1]]" } @$lst); + print join(',', map { "['$_->[0]',$_->[1]],$_->[2]]" } @$lst); print "]\n"; } diff --git a/gui/bweb/html/bresto.js b/gui/bweb/html/bresto.js index 61869d1900..c5561eb2e0 100644 --- a/gui/bweb/html/bresto.js +++ b/gui/bweb/html/bresto.js @@ -160,7 +160,7 @@ function ext_init() id: 'name', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 }) header: 'File', dataIndex: 'name', - width: 100, + width: 200, css: 'white-space:normal;' },{ header: "Size", @@ -170,6 +170,7 @@ function ext_init() },{ header: "Date", dataIndex: 'mtime', + renderer: Ext.util.Format.dateRenderer('Y-d-m h:i:s'), width: 100 },{ dataIndex: 'pathid', @@ -188,7 +189,6 @@ function ext_init() // by default columns are sortable cm.defaultSortable = true; - // create the grid var files_grid = new Ext.grid.Grid('div-files', { ds: file_store, @@ -198,10 +198,10 @@ function ext_init() enableDragDrop: true, selModel: new Ext.grid.RowSelectionModel(), loadMask: true, + autoSizeColumns: true, enableColLock:false }); - // when we reload the view, // we clear the file version box file_store.on('beforeload', function(e) { @@ -211,7 +211,7 @@ function ext_init() // TODO: selection only when using dblclick files_grid.selModel.on('rowselect', function(e,i,r) { - Ext.brestore.filename = r.json[3]; + Ext.brestore.filename = r.json[4]; file_versions_store.load({params:init_params({action: 'list_versions', vafv: Ext.brestore.option_vafv, pathid: r.json[2], @@ -256,6 +256,7 @@ function ext_init() },{ header: "Date", dataIndex: 'mtime', + renderer: Ext.util.Format.dateRenderer('Y-d-m h:i'), width: 100 },{ dataIndex: 'pathid', @@ -282,7 +283,6 @@ function ext_init() selModel: new Ext.grid.RowSelectionModel(), loadMask: true, enableColLock:false - }); var file_selection_record = Ext.data.Record.create( @@ -348,7 +348,6 @@ function ext_init() return true; }}); - file_selection_grid.on('enddrag', function(dd,e) { alert(e) ; return true; }); @@ -376,7 +375,7 @@ function ext_init() {name: 'inchanger' }, {name: 'md5' }, {name: 'size', type: 'int' }, - {name: 'mtime'} //, type: 'date', dateFormat: 'Y-m-d h:i:s'} + {name: 'mtime', type: 'date', dateFormat: 'Y-m-d h:i:s'} ])) }); @@ -404,18 +403,22 @@ function ext_init() },{ header: "Date", dataIndex: 'mtime', + renderer: Ext.util.Format.dateRenderer('Y-d-m h:i:s'), width: 100 },{ header: "MD5", dataIndex: 'md5', width: 160 },{ + header: "pathid", dataIndex: 'pathid', hidden: true },{ + header: "filenameid", dataIndex: 'filenameid', hidden: true },{ + header: "fileid", dataIndex: 'fileid', hidden: true } @@ -593,9 +596,9 @@ function ext_init() menu: menu // assign menu by instance }, { - icon: '/bweb/remove.png', // icons can also be specified inline + icon: '/bweb/mR.png', // icons can also be specified inline cls: 'x-btn-icon', - text: 'restore', + title: 'restore', handler: function() { if (Ext.brestore.dlglaunch) { Ext.brestore.dlglaunch.show(); diff --git a/gui/bweb/html/mR.png b/gui/bweb/html/mR.png new file mode 100644 index 0000000000..39eb901007 Binary files /dev/null and b/gui/bweb/html/mR.png differ diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 1a9f591e4f..0caba34274 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -3326,7 +3326,7 @@ sub get_time_overview } my $jobt = $self->{info}->{stat_job_table} || 'Job'; my $stime1 = $self->{sql}->{"STARTTIME_P" . $type}; # get 1,2,3 - $stime1 =~ s/Job.StartTime/starttime/; + $stime1 =~ s/Job.StartTime/date/; my $stime2 = $self->{sql}->{"STARTTIME_" . $type}; # get 2007-01-03, 2007-01-23 my ($limit, $label) = $self->get_limit('since' => $arg->{since}, @@ -3358,7 +3358,6 @@ SELECT name, $stime1 AS num, JobStatus AS value, joberrors, nb_job FROM ( SELECT $stime2 AS date, - StartTime AS starttime, Client.Name AS name, MAX(severity) AS severity, COUNT(1) AS nb_job, @@ -3396,7 +3395,6 @@ SELECT name, $stime1 AS num, JobStatus AS value, joberrors, nb_job FROM ( SELECT $stime2 AS date, - StartTime AS starttime, client_group_name AS name, MAX(severity) AS severity, COUNT(1) AS nb_job, diff --git a/gui/bweb/technotes-2.3 b/gui/bweb/technotes-2.3 index 7885ccb058..6a97d30500 100644 --- a/gui/bweb/technotes-2.3 +++ b/gui/bweb/technotes-2.3 @@ -1,5 +1,7 @@ 26Nov07 -ebl fix overview to works with mysql +ebl Fix overview to works with mysql +ebl Add date support to bresto +ebl Make bresto works with mysql (no DISTINCT ON (c1,c2)) 25Nov07 ebl Use a automatic rediction when launching a new job