print "]\n";
exit 0;
-} elsif ($action eq 'list_job') { # list jobs for a client [[jobid,endtime,'desc'],..]
+} elsif ($action eq 'list_job') {
+ # list jobs for a client [[jobid,endtime,'desc'],..]
+
print CGI::header('application/x-javascript');
my $filter = $bvfs->get_client_filter();
exit 0;
}
-# get jobid param and apply user filter
-my @jobid = $bvfs->get_jobids(grep { /^\d+(,\d+)*$/ } CGI::param('jobid'));
-# get jobid from date arg
-if (!scalar(@jobid) and $args->{qdate} and $args->{client}) {
- @jobid = $bvfs->set_job_ids_for_date($args->{client}, $args->{qdate});
-}
-$bvfs->set_curjobids(@jobid);
-print STDERR "limit=$args->{limit}:$args->{offset} date=$args->{qdate} currentjobids = ", join(",", @jobid), "\n";
-$bvfs->set_limits($args->{offset}, $args->{limit});
-
-if (!scalar(@jobid)) {
- exit 0;
-}
-
-if (CGI::param('init')) { # used when choosing a job
- $bvfs->update_brestore_table(@jobid);
-}
-
-my $pathid = CGI::param('node') || '';
-my $path = CGI::param('path');
-
-if ($pathid =~ /^(\d+)$/) {
- $pathid = $1;
-} elsif ($path) {
- $pathid = $bvfs->get_pathid($path);
-} else {
- $pathid = $bvfs->get_root();
-}
-$bvfs->ch_dir($pathid);
-
-# permit to use a regex filter
-if ($args->{qpattern}) {
- $bvfs->set_pattern($args->{qpattern});
-}
-
-if ($action eq 'restore') {
-
- # TODO: pouvoir choisir le replace et le jobname
- my $arg = $bvfs->get_form(qw/client storage regexwhere where/);
-
- if (!$arg->{client}) {
- print "ERROR: missing client\n";
- exit 1;
- }
+sub fill_table_for_restore
+{
+ my (@jobid) = @_;
my $fileid = join(',', grep { /^\d+$/ } CGI::param('fileid'));
my @dirid = grep { /^\d+$/ } CGI::param('dirid');
)");
}
+ return "b2$$";
+}
+
+sub get_media_list
+{
+ my ($jobid, $fileid) = @_;
+ my $q="
+ SELECT DISTINCT VolumeName, Enabled, InChanger
+ FROM File,
+ ( -- Get all media from this job
+ SELECT MIN(FirstIndex) AS FirstIndex, MAX(LastIndex) AS LastIndex,
+ VolumeName, Enabled, Inchanger
+ FROM JobMedia JOIN Media USING (MediaId)
+ WHERE JobId IN ($jobid)
+ GROUP BY VolumeName,Enabled,InChanger
+ ) AS allmedia
+ WHERE File.FileId IN ($fileid)
+ AND File.FileIndex >= allmedia.FirstIndex
+ AND File.FileIndex <= allmedia.LastIndex
+";
+ my $lst = $bvfs->dbh_selectall_arrayref($q);
+ return $lst;
+}
+
+# get jobid param and apply user filter
+my @jobid = $bvfs->get_jobids(grep { /^\d+(,\d+)*$/ } CGI::param('jobid'));
+
+# get jobid from date arg
+if (!scalar(@jobid) and $args->{qdate} and $args->{client}) {
+ @jobid = $bvfs->set_job_ids_for_date($args->{client}, $args->{qdate});
+}
+
+$bvfs->set_curjobids(@jobid);
+$bvfs->set_limits($args->{offset}, $args->{limit});
+
+if (!scalar(@jobid)) {
+ exit 0;
+}
+
+if (CGI::param('init')) { # used when choosing a job
+ $bvfs->update_brestore_table(@jobid);
+}
+
+my $pathid = CGI::param('node') || '';
+my $path = CGI::param('path');
+
+if ($pathid =~ /^(\d+)$/) {
+ $pathid = $1;
+} elsif ($path) {
+ $pathid = $bvfs->get_pathid($path);
+} else {
+ $pathid = $bvfs->get_root();
+}
+$bvfs->ch_dir($pathid);
+
+# permit to use a regex filter
+if ($args->{qpattern}) {
+ $bvfs->set_pattern($args->{qpattern});
+}
+
+if ($action eq 'restore') {
+
+ # TODO: pouvoir choisir le replace et le jobname
+ my $arg = $bvfs->get_form(qw/client storage regexwhere where/);
+
+ if (!$arg->{client}) {
+ print "ERROR: missing client\n";
+ exit 1;
+ }
+
+ my $table = fill_table_for_restore(@jobid);
+ if (!$table) {
+ exit 1;
+ }
+
my $bconsole = $bvfs->get_bconsole();
# TODO: pouvoir choisir le replace et le jobname
my $jobid = $bconsole->run(client => $arg->{client},
where => $arg->{where},
regexwhere=> $arg->{regexwhere},
restore => 1,
- file => "?b2$$");
+ file => "?$table");
- $bvfs->dbh_do("DROP TABLE b2$$");
+ $bvfs->dbh_do("DROP TABLE $table");
if (!$jobid) {
print CGI::header('text/html');
print "]\n";
} elsif ($action eq 'get_media') {
+ my ($jobid, $fileid, $table);
- my $jobid = join(',', @jobid);
- my $fileid = join(',', grep { /^\d+(,\d+)*$/ } CGI::param('fileid'));
+ # in this mode, we compute the result to get all needed media
+ if (CGI::param('force')) {
+ $table = fill_table_for_restore(@jobid);
+ if (!$table) {
+ exit 1;
+ }
- my $q="
- SELECT DISTINCT VolumeName, Enabled, InChanger
- FROM File,
- ( -- Get all media from this job
- SELECT MIN(FirstIndex) AS FirstIndex, MAX(LastIndex) AS LastIndex,
- VolumeName, Enabled, Inchanger
- FROM JobMedia JOIN Media USING (MediaId)
- WHERE JobId IN ($jobid)
- GROUP BY VolumeName,Enabled,InChanger
- ) AS allmedia
- WHERE File.FileId IN ($fileid)
- AND File.FileIndex >= allmedia.FirstIndex
- AND File.FileIndex <= allmedia.LastIndex
-";
- my $lst = $bvfs->dbh_selectall_arrayref($q);
+ $jobid = "SELECT DISTINCT JobId FROM $table";
+ $fileid = "SELECT FileId FROM $table";
+
+ } else {
+ $jobid = join(',', @jobid);
+ $fileid = join(',', grep { /^\d+(,\d+)*$/ } CGI::param('fileid'));
+ }
+
+ my $lst = get_media_list($jobid, $fileid);
print "[";
print join(',', map { "['$_->[0]',$_->[1],$_->[2]]" } @$lst);
print "]\n";
+ if ($table) {
+ $bvfs->dbh_do("DROP TABLE $table");
+ }
+
}
__END__
Ext.brestore.use_filerelocation=false;
Ext.brestore.limit = 2000;
Ext.brestore.offset = 0;
+Ext.brestore.force_reload = 0;
+
function get_node_path(node)
{
var temp='';
ddGroup : 'TreeDD',
copy:false,
notifyDrop : function(dd, e, data){
+ console.info("DropTarget");
var r;
if (data.selections) {
if (data.grid.id == 'div-files') {
return true;
}});
+ function force_reload_media_store() {
+ Ext.brestore.force_reload = 1;
+ reload_media_store();
+ Ext.brestore.force_reload = 0;
+ }
+
function reload_media_store() {
var items = file_selection_store.data.items;
var tab_fileid=new Array();
+ var tab_dirid=new Array();
var tab_jobid=new Array();
var enable_compute=false;
for(var i=0;i<items.length;i++) {
if (items[i].data['fileid']) {
- tab_fileid.push(items[i].data['fileid']);
+ tab_fileid.push(items[i].data['fileid']);
} else {
- enable_compute=true;
+ tab_dirid.push(items[i].data['pathid']);
+ enable_compute=true;
}
tab_jobid.push(items[i].data['jobid']);
}
var res = tab_fileid.join(",");
var res2 = tab_jobid.join(",");
-
+ var res3 = tab_dirid.join(",");
+
Ext.brestore.media_store.baseParams = init_params({
action: 'get_media',
jobid: res2,
- fileid: res
+ fileid: res,
+ dirid: res3,
+ force: Ext.brestore.force_reload
});
Ext.brestore.media_store.load();
if (enable_compute) {
header: "Volume",
id: 'volumename',
dataIndex: 'volumename',
- width: 140
+ width: 200
}
]);
colModel: media_cm,
enableDragDrop: false,
loadMask: true,
- width: 200,
- autoHeight: true,
+ width: 400,
+ height: 180,
frame: true
});
xtype : 'fieldset',
title : 'Media needed',
autoHeight : true,
- defaults : {width: 210},
+ defaults : {width: 280},
bodyStyle : 'padding:5px 5px 0',
items :[ media_grid,
{xtype: 'button', id: 'reload_media',
text: 'Compute with directories',
tooltip: 'Can take long time...',
- handler:reload_media_store}]
+ handler:force_reload_media_store}]
}],
}, {
xtype : 'panel',