From 37603e411c756699854c4657233dca681eb2c27b Mon Sep 17 00:00:00 2001 From: Matteo Pasotti Date: Sun, 19 Jan 2014 01:07:59 +0100 Subject: - now able to insert host entries - cfgHosts is a instance variable --- AdminPanel/Hosts/GHosts.pm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'AdminPanel') diff --git a/AdminPanel/Hosts/GHosts.pm b/AdminPanel/Hosts/GHosts.pm index 9f82ab0c..91959297 100644 --- a/AdminPanel/Hosts/GHosts.pm +++ b/AdminPanel/Hosts/GHosts.pm @@ -49,6 +49,11 @@ has 'table' => ( init_arg => undef ); +has 'cfgHosts' => ( + is => 'rw', + init_arg => undef +); + sub start { my $self = shift; @@ -122,12 +127,38 @@ sub _addHostDialog { if ($widget == $cancelButton) { last; } + elsif($widget == $okButton) { + print $textIPAddress->value(); + my $res = $self->cfgHosts->_insertHost($textIPAddress->value(),[$textHostName->value(), $textHostAlias->value()]); + print "Insertion result: $res\n"; + $res = $self->cfgHosts->_writeHosts(); + print "Write result: $res\n"; + last; + } } } destroy $dlg; } +#============================================================= + +=head2 setupTable + +=head3 INPUT + + $self: this object + + $data: reference to the array containaing the host data to show into the table + +=head3 DESCRIPTION + +This subroutine populates a previously created YTable with the hosts data +retrieved by the Config::Hosts module + +=cut + +#============================================================= sub setupTable { my $self = shift(); my $data = shift(); @@ -182,7 +213,8 @@ sub manageHostsDialog { $leftContent->setWeight($yui::YD_HORIZ,45); $self->table($factory->createTable($leftContent,$tableHeader)); - my @hosts = AdminPanel::Hosts::hosts::_getHosts(); + $self->cfgHosts(AdminPanel::Hosts::hosts->new()); + my @hosts = $self->cfgHosts->_getHosts(); $self->setupTable(\@hosts); my $rightContent = $factory->createRight($hbox_content); -- cgit v1.2.1