From: Eric Bollengier Date: Thu, 15 Nov 2007 22:50:24 +0000 (+0000) Subject: ebl Update bresto.html, add some code to get a jobid, fileindex from X-Git-Tag: Release-3.0.0~2245 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d64c6e6419c3b69efb53febc595f6e626648ae64;p=bacula%2Fbacula ebl Update bresto.html, add some code to get a jobid, fileindex from user selection. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5935 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bresto.pl b/gui/bweb/cgi/bresto.pl index 1acba67901..eee5613999 100755 --- a/gui/bweb/cgi/bresto.pl +++ b/gui/bweb/cgi/bresto.pl @@ -834,7 +834,8 @@ my $q=" SELECT DISTINCT VolumeName, InChanger FROM File, ( -- Get all media from this job - SELECT MAX(FirstIndex), MIN(LastIndex), VolumeName, Inchanger + SELECT MAX(FirstIndex) AS FirstIndex, MIN(LastIndex) AS LastIndex, + VolumeName, Inchanger FROM JobMedia JOIN Media USING (MediaId) WHERE JobId IN ($jobid) GROUP BY VolumeName, InChanger @@ -843,8 +844,94 @@ my $q=" AND File.FileIndex >= allmedia.FirstIndex AND File.FileIndex <= allmedia.LastIndex; "; + my $lst = $bvfs->dbh_selectall_arrayref($q); + print "["; + print join(',', map { "[ '$_->[0]', $_->[1]]" } @$lst); + print "]\n"; + +} elsif ($action eq 'list_storage') { # TODO: use .storage hier + my $q="SELECT Name FROM Storage"; + my $lst = $bvfs->dbh_selectall_arrayref($q); + print "["; + print join(',', map { "[ '$_->[0]' ]" } @$lst); + print "]\n"; +} elsif ($action eq 'restore') { + my $fileid = join(',', grep { /^\d+$/ } CGI::param('fileid')); + my @dirid = grep { /^\d+$/ } CGI::param('dirid'); + my $inclause = join(',', @jobid); + + my @union; + + if ($fileid) { + push @union, "(SELECT JobId, FileIndex FROM File WHERE FileId IN ($fileid))"; + } + + foreach my $dirid (@dirid) { + push @union, " + (SELECT File.JobId, File.FileIndex, File.FilenameId, File.PathId + FROM Path JOIN File USING (PathId) + WHERE Path.Path LIKE + (SELECT ". $bvfs->dbh_strcat('Path',"'\%'") ." FROM Path + WHERE PathId = $dirid + ) + AND File.JobId IN ($inclause))"; + } + + my $u = join(" UNION ", @union); + + $bvfs->dbh_do("CREATE TEMP TABLE btemp (JobId integer, FileIndex integer, FilenameId integer, PathId integer)"); + $bvfs->dbh_do("INSERT INTO btemp $u"); + # TODO: remove FilenameId et PathId + $bvfs->dbh_do("CREATE TABLE b2$$ (JobId integer, FileIndex integer, FilenameId integer, PathId integer)"); + $bvfs->dbh_do("INSERT INTO b2$$ ( +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 +)"); + + print "b2$$"; } +__END__ + +CREATE VIEW files AS + SELECT path || name,pathid,filenameid,fileid,jobid + FROM File JOIN FileName USING (FilenameId) JOIN Path USING (PathId); + + + +CREATE temp TABLE bresto (JobId integer, FileIndex integer, FilenameId integer, PathId integer); +INSERT INTO bresto +(SELECT JobId, FileIndex, FilenameId, PathId FROM File WHERE FileId IN (5716)) +UNION +(SELECT File.JobId, File.FileIndex, FilenameId, PathId + FROM Path JOIN File USING (PathId) + WHERE Path.Path LIKE + (SELECT Path || '%' FROM Path WHERE PathId = 1) + AND File.JobId IN (1)); + +CREATE TABLE bresto2 (JobId integer, FileIndex integer, FilenameId integer, PathId integer); + +INSERT INTO bresto2 ( SELECT bresto.JobId, bresto.FileIndex, bresto.FilenameId, bresto.PathId + FROM bresto, + (SELECT max(JobId) as JobId, PathId, FilenameId + FROM bresto + GROUP BY PathId, FilenameId + ORDER BY JobId DESC) AS a + WHERE a.JobId = bresto.JobId and a.PathId=bresto.PathId and a.FilenameId = bresto.FilenameId); + +DROP TABLE bresto; + +# attention, je sais pas si on peut se fier au jobid pour selection la meilleur version... + +# dirid = 844 +# fileid = 5716 diff --git a/gui/bweb/html/bresto.js b/gui/bweb/html/bresto.js index 559850076c..b4c2701a34 100644 --- a/gui/bweb/html/bresto.js +++ b/gui/bweb/html/bresto.js @@ -54,7 +54,7 @@ Ext.brestore.root_path=''; // user location Ext.brestore.option_vosb = false; Ext.brestore.option_vafv = false; - +Ext.brestore.dlglaunch; function get_node_path(node) { @@ -605,7 +605,11 @@ function ext_init() cls: 'x-btn-icon', text: 'restore', handler: function() { - var dialog = new Ext.LayoutDialog("div-resto-dlg", { + if (Ext.brestore.dlglaunch) { + Ext.brestore.dlglaunch.show(); + return 0; + } + Ext.brestore.dlglaunch = new Ext.LayoutDialog("div-resto-dlg", { // modal:true, width:600, height:400, @@ -629,6 +633,7 @@ function ext_init() // alwaysShowTabs: true } }); + var dialog = Ext.brestore.dlglaunch; dialog.addKeyListener(27, dialog.hide, dialog); dialog.addButton('Submit', dialog.hide, dialog); dialog.addButton('Close', dialog.hide, dialog); @@ -638,6 +643,32 @@ function ext_init() labelWidth: 80 }); + var storage_store = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: '/cgi-bin/bweb/bresto.pl', + method: 'GET', + params:{action:'list_storage'} + }), + + reader: new Ext.data.ArrayReader({ + }, Ext.data.Record.create([ + {name: 'name' } + ])) + }); + + var resto_store = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: '/cgi-bin/bweb/bresto.pl', + method: 'GET', + params:{action:'list_resto'} + }), + + reader: new Ext.data.ArrayReader({ + }, Ext.data.Record.create([ + {name: 'name' } + ])) + }); + fs.fieldset( {legend:'Restore job'}, new Ext.form.ComboBox({ @@ -659,7 +690,7 @@ function ext_init() new Ext.form.ComboBox({ fieldLabel: 'job', hiddenName:'job', - store: client_store, + store: resto_store, displayField:'name', typeAhead: true, mode: 'local', @@ -668,39 +699,40 @@ function ext_init() selectOnFocus:true, width:190 }) -// , -// new Ext.form.TextField({ -// fieldLabel: 'Where', -// name: 'where', -// width:190 -// }), -// -// new Ext.form.ComboBox({ -// fieldLabel: 'client', -// hiddenName:'client', -// store: client_store, -// displayField:'name', -// typeAhead: true, -// mode: 'local', -// triggerAction: 'all', -// emptyText:'Select a client...', -// selectOnFocus:true, -// width:190 -// }), -// new Ext.form.ComboBox({ -// fieldLabel: 'storage', -// hiddenName:'storage', -// store: client_store, -// displayField:'name', -// typeAhead: true, -// mode: 'local', -// triggerAction: 'all', -// emptyText:'Select a storage...', -// selectOnFocus:true, -// width:190 -// }) - ); + , + new Ext.form.TextField({ + fieldLabel: 'Where', + name: 'where', + width:190 + }), + new Ext.form.ComboBox({ + fieldLabel: 'client', + hiddenName:'client', + store: client_store, + displayField:'name', + typeAhead: true, + mode: 'local', + triggerAction: 'all', + emptyText:'Select a client...', + selectOnFocus:true, + width:190 + }), + new Ext.form.ComboBox({ + fieldLabel: 'storage', + hiddenName:'storage', + store: storage_store, + displayField:'name', + typeAhead: true, + mode: 'local', + triggerAction: 'all', + emptyText:'Select a storage...', + selectOnFocus:true, + width:190 + }) + ); + storage_store.load({params:{action: 'list_storage'}}); + resto_store.load({params:{action: 'list_resto'}}); fs.render('div-resto-form'); // var f = new Ext.form.BasicForm('div-resto-form', {url: '/bweb/test', method: 'GET',