package main;
use strict;
+use POSIX qw/strftime/;
use Bweb;
my $conf = new Bweb::Config(config_file => $Bweb::config_file);
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},
# 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') {
#($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";
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
";
my $lst = $bvfs->dbh_selectall_arrayref($q);
print "[";
- print join(',', map { "[ '$_->[0]', $_->[1]]" } @$lst);
+ print join(',', map { "['$_->[0]',$_->[1]],$_->[2]]" } @$lst);
print "]\n";
}
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",
},{
header: "Date",
dataIndex: 'mtime',
+ renderer: Ext.util.Format.dateRenderer('Y-d-m h:i:s'),
width: 100
},{
dataIndex: 'pathid',
// by default columns are sortable
cm.defaultSortable = true;
-
// create the grid
var files_grid = new Ext.grid.Grid('div-files', {
ds: file_store,
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) {
// 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],
},{
header: "Date",
dataIndex: 'mtime',
+ renderer: Ext.util.Format.dateRenderer('Y-d-m h:i'),
width: 100
},{
dataIndex: 'pathid',
selModel: new Ext.grid.RowSelectionModel(),
loadMask: true,
enableColLock:false
-
});
var file_selection_record = Ext.data.Record.create(
return true;
}});
-
file_selection_grid.on('enddrag', function(dd,e) {
alert(e) ; return true;
});
{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'}
]))
});
},{
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
}
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();
}
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},
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,
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,