aboutsummaryrefslogtreecommitdiffstats
path: root/AdminPanel
diff options
context:
space:
mode:
authorMatteo Pasotti <matteo.pasotti@gmail.com>2014-01-25 12:55:54 +0100
committerMatteo Pasotti <matteo.pasotti@gmail.com>2014-01-25 12:55:54 +0100
commit9c3601469aac8b540d30a0de0c742c85f0d9c5f2 (patch)
treea9985b0a3d1be87c736f20e327413312287285f1 /AdminPanel
parent05611faf164f13a3e110e9540ab691f9f547e551 (diff)
downloadmanatools-9c3601469aac8b540d30a0de0c742c85f0d9c5f2.tar
manatools-9c3601469aac8b540d30a0de0c742c85f0d9c5f2.tar.gz
manatools-9c3601469aac8b540d30a0de0c742c85f0d9c5f2.tar.bz2
manatools-9c3601469aac8b540d30a0de0c742c85f0d9c5f2.tar.xz
manatools-9c3601469aac8b540d30a0de0c742c85f0d9c5f2.zip
- implemented a generalized _manipulateHostDialog (was _addHostDialog)
- _addHostDialog is now just a wrapper to _manipulateHostDialog - implemented _edtHostDialog as a wrapper to _manipulateHostDialog
Diffstat (limited to 'AdminPanel')
-rw-r--r--AdminPanel/Hosts/GHosts.pm50
1 files changed, 43 insertions, 7 deletions
diff --git a/AdminPanel/Hosts/GHosts.pm b/AdminPanel/Hosts/GHosts.pm
index 09a4e69d..fcf95982 100644
--- a/AdminPanel/Hosts/GHosts.pm
+++ b/AdminPanel/Hosts/GHosts.pm
@@ -76,9 +76,22 @@ This subroutine creates the Host dialog to add host definitions
=cut
#=============================================================
-sub _addHostDialog {
+sub _manipulateHostDialog {
my $self = shift;
+ my $headerString = shift();
+ my $boolEdit = shift();
+
+ my $hostIpString = "";
+ my $hostNameString = "";
+ my $hostAliasesString = "";
+
+ if($boolEdit == 1){
+ $hostIpString = shift();
+ $hostNameString = shift();
+ $hostAliasesString = shift();
+ }
+
my $factory = yui::YUI::widgetFactory;
my $dlg = $factory->createPopupDialog();
my $layout = $factory->createVBox($dlg);
@@ -88,7 +101,7 @@ sub _addHostDialog {
my $hbox_footer = $factory->createHBox($layout);
# header
- my $labelDescription = $factory->createLabel($hbox_header,"Add the information");
+ my $labelDescription = $factory->createLabel($hbox_header,$headerString);
# content
my $firstHbox = $factory->createHBox($vbox_content);
@@ -109,6 +122,12 @@ sub _addHostDialog {
$textHostName->setWeight($yui::YD_HORIZ, 30);
$textHostAlias->setWeight($yui::YD_HORIZ, 30);
+ if($boolEdit == 1){
+ $textIPAddress->setValue($hostIpString);
+ $textHostName->setValue($hostNameString);
+ $textHostAlias->setValue($hostAliasesString);
+ }
+
# footer
my $cancelButton = $factory->createPushButton($factory->createLeft($hbox_footer),"Cancel");
my $okButton = $factory->createPushButton($factory->createRight($hbox_footer),"OK");
@@ -128,9 +147,12 @@ sub _addHostDialog {
last;
}
elsif($widget == $okButton) {
- print $textIPAddress->value();
- my $res = $self->cfgHosts->_insertHost($textIPAddress->value(),[$textHostName->value(), $textHostAlias->value()]);
- print "Insertion result: $res\n";
+ my $res = undef;
+ if($boolEdit == 0){
+ $res = $self->cfgHosts->_insertHost($textIPAddress->value(),[$textHostName->value(), $textHostAlias->value()]);
+ }else{
+ $res = $self->cfgHosts->_modifyHost($textIPAddress->value(),[$textHostName->value(), $textHostAlias->value()]);
+ }
$res = $self->cfgHosts->_writeHosts();
print "Write result: $res\n";
last;
@@ -141,6 +163,19 @@ sub _addHostDialog {
destroy $dlg;
}
+sub _addHostDialog {
+ my $self = shift();
+ return $self->_manipulateHostDialog("Add the information",0);
+}
+
+sub _edtHostDialog {
+ my $self = shift();
+ my $hostIp = shift();
+ my $hostName = shift();
+ my $hostAliases = shift();
+ return $self->_manipulateHostDialog("Modify the information",1,$hostIp,$hostName,$hostAliases);
+}
+
#=============================================================
=head2 setupTable
@@ -249,12 +284,13 @@ sub manageHostsDialog {
last;
}
elsif ($widget == $addButton) {
- # implement add host dialog
$self->_addHostDialog();
$self->setupTable();
}
elsif ($widget == $edtButton) {
- # implement modification dialog
+ my $tblItem = yui::toYTableItem($self->table->selectedItem());
+ $self->_edtHostDialog($tblItem->cell(0)->label(),$tblItem->cell(1)->label(),$tblItem->cell(2)->label());
+ $self->setupTable();
}
elsif ($widget == $remButton) {
# implement deletion dialog