From: Eric Bollengier Date: Wed, 13 Feb 2008 18:58:45 +0000 (+0000) Subject: ebl Can modify client list group for a specific client X-Git-Tag: Release-3.0.0~1873 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=720eefdfb4219def37f2cf2f8b191a20fc5cd972;p=bacula%2Fbacula ebl Can modify client list group for a specific client Disable use of Enabled flag in volume mgnt Add comment field to client_group git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6414 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bweb.pl b/gui/bweb/cgi/bweb.pl index e8e704e7ce..55a68d1148 100755 --- a/gui/bweb/cgi/bweb.pl +++ b/gui/bweb/cgi/bweb.pl @@ -113,6 +113,12 @@ if ($action eq 'begin') { # main display } elsif ($action eq 'client') { $bweb->display_clients(); +} elsif ($action eq 'client_edit') { + $bweb->client_edit(); + +} elsif ($action eq 'client_save') { + $bweb->client_save(); + } elsif ($action eq 'pool') { $bweb->display_pool(); @@ -266,7 +272,7 @@ if ($action eq 'begin') { # main display $bweb->update_slots(); } print "
"; - $bweb->move_media('no'); # enabled = no + $bweb->move_media('yes'); # pb with enabled = no for restore print "
"; } elsif ($action eq 'move_email') { diff --git a/gui/bweb/lang/en/tpl/client_list.tpl b/gui/bweb/lang/en/tpl/client_list.tpl index 7688b667bb..498db47df6 100644 --- a/gui/bweb/lang/en/tpl/client_list.tpl +++ b/gui/bweb/lang/en/tpl/client_list.tpl @@ -12,8 +12,10 @@ + + diff --git a/gui/bweb/lang/en/tpl/move_media.tpl b/gui/bweb/lang/en/tpl/move_media.tpl index 9330febe52..08abfd0e9f 100644 --- a/gui/bweb/lang/en/tpl/move_media.tpl +++ b/gui/bweb/lang/en/tpl/move_media.tpl @@ -14,11 +14,11 @@ Enabled: - User: + User: Comment: @@ -73,12 +73,12 @@ nrsTable.setup( } ); -ok=1; -for (var i=0; ok && i < document.form1.enabled.length; ++i) { - if (document.form1.enabled[i].value == '') { - document.form1.enabled[i].selected = true; - ok=0; - } -} +//ok=1; +//for (var i=0; ok && i < document.form1.enabled.length; ++i) { +// if (document.form1.enabled[i].value == '') { +// document.form1.enabled[i].selected = true; +// ok=0; +// } +//} diff --git a/gui/bweb/lang/es/tpl/client_list.tpl b/gui/bweb/lang/es/tpl/client_list.tpl index 9fbb31e6aa..52f762ff5a 100644 --- a/gui/bweb/lang/es/tpl/client_list.tpl +++ b/gui/bweb/lang/es/tpl/client_list.tpl @@ -12,8 +12,10 @@ + + diff --git a/gui/bweb/lang/es/tpl/extern.tpl b/gui/bweb/lang/es/tpl/extern.tpl new file mode 100644 index 0000000000..75b459dff1 --- /dev/null +++ b/gui/bweb/lang/es/tpl/extern.tpl @@ -0,0 +1,13 @@ +
+
+

Help ejecting media

+
+
+ +You want to: +
+
+ +
+
diff --git a/gui/bweb/lang/es/tpl/move_media.tpl b/gui/bweb/lang/es/tpl/move_media.tpl index f0171b1637..baf5fa381f 100644 --- a/gui/bweb/lang/es/tpl/move_media.tpl +++ b/gui/bweb/lang/es/tpl/move_media.tpl @@ -14,11 +14,11 @@ Activado : - Usuario: + Usuario: Comentario: @@ -73,12 +73,12 @@ nrsTable.setup( } ); -ok=1; -for (var i=0; ok && i < document.form1.enabled.length; ++i) { - if (document.form1.enabled[i].value == '') { - document.form1.enabled[i].selected = true; - ok=0; - } -} +//ok=1; +//for (var i=0; ok && i < document.form1.enabled.length; ++i) { +// if (document.form1.enabled[i].value == '') { +// document.form1.enabled[i].selected = true; +// ok=0; +// } +//} diff --git a/gui/bweb/lang/fr/tpl/client_list.tpl b/gui/bweb/lang/fr/tpl/client_list.tpl index d1d8746c27..47d8e758d9 100644 --- a/gui/bweb/lang/fr/tpl/client_list.tpl +++ b/gui/bweb/lang/fr/tpl/client_list.tpl @@ -12,8 +12,10 @@ + + diff --git a/gui/bweb/lang/fr/tpl/extern.tpl b/gui/bweb/lang/fr/tpl/extern.tpl new file mode 100644 index 0000000000..602334c98f --- /dev/null +++ b/gui/bweb/lang/fr/tpl/extern.tpl @@ -0,0 +1,13 @@ +
+
+

Help ejecting media

+
+
+ +You want to: +
+
+ +
+
diff --git a/gui/bweb/lang/fr/tpl/move_media.tpl b/gui/bweb/lang/fr/tpl/move_media.tpl index ffe2a64b6c..48c91dc742 100644 --- a/gui/bweb/lang/fr/tpl/move_media.tpl +++ b/gui/bweb/lang/fr/tpl/move_media.tpl @@ -14,11 +14,11 @@ En ligne : - Utilisateur : + Utilisateur : Commentaire : @@ -73,12 +73,12 @@ nrsTable.setup( } ); -ok=1; -for (var i=0; ok && i < document.form1.enabled.length; ++i) { - if (document.form1.enabled[i].value == '') { - document.form1.enabled[i].selected = true; - ok=0; - } -} +//ok=1; +//for (var i=0; ok && i < document.form1.enabled.length; ++i) { +// if (document.form1.enabled[i].value == '') { +// document.form1.enabled[i].selected = true; +// ok=0; +// } +//} diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index d0d994c4f3..fe6f774062 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -93,6 +93,16 @@ sub debug } } +sub fdebug +{ + my ($self, $what) = @_; + + my $old = $self->{debug}; + $self->{debug}=1; + $self->debug($what); + $self->{debug} = $old; +} + =head1 FUNCTION error - display an error to the user @@ -1548,6 +1558,26 @@ sub display_end $self->display($self->{info}, "end.tpl"); } +sub client_edit +{ + my ($self) = @_; + my $arg = $self->get_form("qclient"); + my $f1 = $self->get_client_group_filter(); + my $f2 = $self->get_client_filter(); + + my $query = " +SELECT client_group_name, here + FROM client_group $f1 + LEFT JOIN (SELECT 1 AS here, client_group_id + FROM Client JOIN client_group_member USING (ClientId) $f2 + WHERE Name = $arg->{qclient}) AS temp USING (client_group_id) +"; + + my $all = $self->dbh_selectall_hashref($query, 'client_group_name'); + + $self->display({ client_group => [ values %$all ], %$arg }, "client_edit.tpl"); +} + sub display_clients { my ($self) = @_; @@ -1845,7 +1875,7 @@ SELECT Client.Name as clientname } my $query = " -SELECT client_group_name AS name +SELECT client_group_name AS name, comment AS comment FROM client_group $filter "; my $grps = $self->dbh_selectall_hashref($query, 'name'); @@ -1855,7 +1885,7 @@ SELECT client_group_name AS name if ($what{db_usernames}) { my $query = " -SELECT username +SELECT username, comment FROM bweb_user "; my $users = $self->dbh_selectall_hashref($query, 'username'); @@ -1865,7 +1895,7 @@ SELECT username if ($what{db_roles}) { my $query = " -SELECT rolename +SELECT rolename, comment FROM bweb_role "; my $r = $self->dbh_selectall_hashref($query, 'rolename'); @@ -2795,6 +2825,48 @@ sub update_location ########################################################### +sub client_save +{ + my ($self) = @_; + my $arg = $self->get_form(qw/jclient_groups qclient/); + + unless ($arg->{qclient}) { + return $self->error("Can't get client name"); + } + + $self->can_do('r_group_mgnt'); + + my $f1 = $self->get_client_filter(); + my $f2 = $self->get_client_group_filter(); + + $self->{dbh}->begin_work(); + + my $query = " +DELETE FROM client_group_member + WHERE ClientId IN + (SELECT ClientId + FROM Client $f1 + WHERE Client.Name = $arg->{qclient}) +"; + $self->dbh_do($query); + + if ($arg->{jclient_groups}) { + $query = " + INSERT INTO client_group_member (client_group_id, ClientId) + (SELECT client_group_id, (SELECT ClientId + FROM Client $f1 + WHERE Name = $arg->{qclient}) + FROM client_group $f2 WHERE client_group_name IN ($arg->{jclient_groups}) + ) +"; + $self->dbh_do($query); + } + + $self->{dbh}->commit() or $self->error($self->{dbh}->errstr); + + $self->display_clients(); +} + sub groups_edit { my ($self) = @_; @@ -2815,7 +2887,7 @@ sub groups_edit my $query = " SELECT Name AS name - FROM Client JOIN client_group_member using (clientid) + FROM Client JOIN client_group_member using (ClientId) JOIN client_group using (client_group_id) WHERE client_group_name = $grp->{qclient_group} "; @@ -2834,12 +2906,12 @@ sub groups_save my ($self) = @_; $self->can_do('r_group_mgnt'); - my $arg = $self->get_form(qw/qclient_group jclients qnewgroup/); + my $arg = $self->get_form(qw/qclient_group jclients qnewgroup qcomment/); if (!$arg->{qclient_group} and $arg->{qnewgroup}) { my $query = " -INSERT INTO client_group (client_group_name) -VALUES ($arg->{qnewgroup}) +INSERT INTO client_group (client_group_name, comment) +VALUES ($arg->{qnewgroup}, $arg->{qcomment}) "; $self->dbh_do($query); $arg->{qclient_group} = $arg->{qnewgroup}; @@ -2862,8 +2934,8 @@ DELETE FROM client_group_member if ($arg->{jclients}) { $query = " - INSERT INTO client_group_member (clientid, client_group_id) - (SELECT Clientid, + INSERT INTO client_group_member (ClientId, client_group_id) + (SELECT ClientId, (SELECT client_group_id FROM client_group WHERE client_group_name = $arg->{qclient_group}) @@ -2875,7 +2947,7 @@ DELETE FROM client_group_member if ($arg->{qclient_group} ne $arg->{qnewgroup}) { $query = " UPDATE client_group - SET client_group_name = $arg->{qnewgroup} + SET client_group_name = $arg->{qnewgroup}, comment = $arg->{qcomment} WHERE client_group_name = $arg->{qclient_group} "; @@ -3534,7 +3606,7 @@ SELECT sum(Job.JobFiles) AS nb_files, client_group.client_group_name AS clientname FROM Job JOIN Client USING (ClientId) - JOIN client_group_member ON (Client.ClientId = client_group_member.clientid) + JOIN client_group_member ON (Client.ClientId = client_group_member.ClientId) JOIN client_group USING (client_group_id) WHERE client_group.client_group_name = $carg->{qclient_group} diff --git a/gui/bweb/script/Form.pm.patch b/gui/bweb/script/Form.pm.patch new file mode 100644 index 0000000000..ccb9af1e66 --- /dev/null +++ b/gui/bweb/script/Form.pm.patch @@ -0,0 +1,30 @@ +--- Form-original.pm 2005-12-07 09:32:27.000000000 -0500 ++++ Form.pm 2007-05-08 13:26:16.000000000 -0400 +@@ -18,5 +18,4 @@ + textarea => "TextInput", + +- button => "IgnoreInput", + "reset" => "IgnoreInput", + +@@ -25,4 +24,5 @@ + option => "ListInput", + ++ button => "SubmitInput", + submit => "SubmitInput", + image => "ImageInput", +@@ -118,5 +118,5 @@ + eval { + # optimization +- $p->report_tags(qw(form input textarea select optgroup option keygen label)); ++ $p->report_tags(qw(form input textarea select optgroup option keygen label button)); + }; + +@@ -184,4 +184,8 @@ + $f->push_input($type, $attr); + } ++ elsif ($tag eq "button") { ++ my $type = delete $attr->{type} || "submit"; ++ $f->push_input($type, $attr); ++ } + elsif ($tag eq "textarea") { + $attr->{textarea_value} = $attr->{value} diff --git a/gui/bweb/script/bweb-mysql.sql b/gui/bweb/script/bweb-mysql.sql index 36bfe48b6a..430b011f93 100644 --- a/gui/bweb/script/bweb-mysql.sql +++ b/gui/bweb/script/bweb-mysql.sql @@ -56,7 +56,7 @@ CREATE TABLE bweb_role ( roleid serial not null, rolename text not null, --- comment text default '', + comment text default '', primary key (roleid) ); CREATE UNIQUE INDEX bweb_role_idx on bweb_role (rolename(255)); @@ -108,6 +108,7 @@ CREATE TABLE client_group ( client_group_id serial not null, client_group_name text not null, + comment text default '', primary key (client_group_id) ); @@ -116,7 +117,7 @@ CREATE UNIQUE INDEX client_group_idx on client_group (client_group_name(255)); CREATE TABLE client_group_member ( client_group_id integer not null, - clientid integer not null, + ClientId integer not null, primary key (client_group_id, clientid) ); diff --git a/gui/bweb/script/bweb-postgresql.sql b/gui/bweb/script/bweb-postgresql.sql index db725562f3..0fed9269d2 100644 --- a/gui/bweb/script/bweb-postgresql.sql +++ b/gui/bweb/script/bweb-postgresql.sql @@ -78,7 +78,7 @@ CREATE TABLE bweb_role ( roleid serial not null, rolename text not null, --- comment text default '', + comment text default '', primary key (roleid) ); CREATE UNIQUE INDEX bweb_role_idx on bweb_role (rolename); @@ -131,6 +131,7 @@ CREATE TABLE client_group ( client_group_id serial not null, client_group_name text not null, + comment text default '', primary key (client_group_id) ); diff --git a/gui/bweb/script/upgrade-2.2_3.0_mysql.sql b/gui/bweb/script/upgrade-2.2_3.0_mysql.sql index 96af27d4b6..8af542387b 100644 --- a/gui/bweb/script/upgrade-2.2_3.0_mysql.sql +++ b/gui/bweb/script/upgrade-2.2_3.0_mysql.sql @@ -2,6 +2,9 @@ -- Upgrade from 2.2 -- -------------------------------------------------- +ALTER TABLE client_group ADD COLUMN comment text; +ALTER TABLE client_group_member RENAME COLUMN clientid TO ClientId; + CREATE TABLE bweb_user ( userid serial not null, @@ -18,7 +21,7 @@ CREATE TABLE bweb_role ( roleid serial not null, rolename text not null, --- comment text default '', + comment text default '', primary key (roleid) ); CREATE UNIQUE INDEX bweb_role_idx on bweb_role (rolename(255)); diff --git a/gui/bweb/script/upgrade-2.2_3.0_postgresql.sql b/gui/bweb/script/upgrade-2.2_3.0_postgresql.sql index 47ae2b31b6..a41b315771 100644 --- a/gui/bweb/script/upgrade-2.2_3.0_postgresql.sql +++ b/gui/bweb/script/upgrade-2.2_3.0_postgresql.sql @@ -22,6 +22,9 @@ initcond = '' ); BEGIN; + +ALTER TABLE client_group ADD COLUMN comment text; + CREATE TABLE bweb_user ( userid serial not null, @@ -38,7 +41,7 @@ CREATE TABLE bweb_role ( roleid serial not null, rolename text not null, --- comment text default '', + comment text default '', primary key (roleid) ); CREATE UNIQUE INDEX bweb_role_idx on bweb_role (rolename); diff --git a/gui/bweb/technotes-2.3 b/gui/bweb/technotes-2.3 index 9b6dc1be95..776dde86be 100644 --- a/gui/bweb/technotes-2.3 +++ b/gui/bweb/technotes-2.3 @@ -1,3 +1,8 @@ +13Feb08 +ebl Can modify client list group for a specific client +ebl Disable use of Enabled flag in volume mgnt +ebl Add comment field to client_group + 09Jan08 ebl Adapt btime for bacula 2.2.7 diff --git a/gui/bweb/tpl/client_list.tpl b/gui/bweb/tpl/client_list.tpl index a452f4b164..85b400f331 100644 --- a/gui/bweb/tpl/client_list.tpl +++ b/gui/bweb/tpl/client_list.tpl @@ -15,6 +15,7 @@ + diff --git a/gui/bweb/tpl/extern.tpl b/gui/bweb/tpl/extern.tpl new file mode 100644 index 0000000000..07126c5d38 --- /dev/null +++ b/gui/bweb/tpl/extern.tpl @@ -0,0 +1,13 @@ +
+
+

__Help ejecting media__

+
+
+ +__You want to:__ +
+
+ +
+
diff --git a/gui/bweb/tpl/move_media.tpl b/gui/bweb/tpl/move_media.tpl index ece6034542..2a05209c25 100644 --- a/gui/bweb/tpl/move_media.tpl +++ b/gui/bweb/tpl/move_media.tpl @@ -14,11 +14,11 @@ __Enabled:__ - __User:__ + __User:__ __Comment:__ @@ -73,12 +73,12 @@ nrsTable.setup( } ); -ok=1; -for (var i=0; ok && i < document.form1.enabled.length; ++i) { - if (document.form1.enabled[i].value == '') { - document.form1.enabled[i].selected = true; - ok=0; - } -} +//ok=1; +//for (var i=0; ok && i < document.form1.enabled.length; ++i) { +// if (document.form1.enabled[i].value == '') { +// document.form1.enabled[i].selected = true; +// ok=0; +// } +//}