aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatteo Pasotti <matteo.pasotti@gmail.com>2014-01-25 12:28:34 +0100
committerMatteo Pasotti <matteo.pasotti@gmail.com>2014-01-25 12:28:34 +0100
commitb6274e6f8e465f1a87526a9baef49280f58b2bed (patch)
tree1776ae05ae232f1c523f8f4a3463c0b8094bdbd5
parent69cfb584e95d150fa474b194c2e2d2dcc85d8fa8 (diff)
downloadcolin-keep-b6274e6f8e465f1a87526a9baef49280f58b2bed.tar
colin-keep-b6274e6f8e465f1a87526a9baef49280f58b2bed.tar.gz
colin-keep-b6274e6f8e465f1a87526a9baef49280f58b2bed.tar.bz2
colin-keep-b6274e6f8e465f1a87526a9baef49280f58b2bed.tar.xz
colin-keep-b6274e6f8e465f1a87526a9baef49280f58b2bed.zip
- refreshing host table after insert/delete ops
- aliases are now shown correctly (fixed string replacement issue)
-rw-r--r--AdminPanel/Hosts/GHosts.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/AdminPanel/Hosts/GHosts.pm b/AdminPanel/Hosts/GHosts.pm
index c80797a..09a4e69 100644
--- a/AdminPanel/Hosts/GHosts.pm
+++ b/AdminPanel/Hosts/GHosts.pm
@@ -161,13 +161,15 @@ retrieved by the Config::Hosts module
#=============================================================
sub setupTable {
my $self = shift();
- my $data = shift();
- foreach my $host (@$data){
+ my @hosts = $self->cfgHosts->_getHosts();
+ # clear table
+ $self->table->deleteAllItems();
+ foreach my $host (@hosts){
my $tblItem;
my $aliases = join(',',@{$host->{'hosts'}});
if(scalar(@{$host->{'hosts'}}) > 1){
- $aliases =~s/\,*$host->{'hosts'}[0]\,*//g;
+ $aliases =~s/^$host->{'hosts'}[0]\,*//g;
}elsif(scalar(@{$host->{'hosts'}}) == 1){
$aliases = "";
}
@@ -212,9 +214,9 @@ sub manageHostsDialog {
$leftContent->setWeight($yui::YD_HORIZ,45);
$self->table($factory->createTable($leftContent,$tableHeader));
+ # initialize Config::Hosts
$self->cfgHosts(AdminPanel::Hosts::hosts->new());
- my @hosts = $self->cfgHosts->_getHosts();
- $self->setupTable(\@hosts);
+ $self->setupTable();
my $rightContent = $factory->createRight($hbox_content);
$rightContent->setWeight($yui::YD_HORIZ,10);
@@ -249,6 +251,7 @@ sub manageHostsDialog {
elsif ($widget == $addButton) {
# implement add host dialog
$self->_addHostDialog();
+ $self->setupTable();
}
elsif ($widget == $edtButton) {
# implement modification dialog
@@ -259,6 +262,9 @@ sub manageHostsDialog {
my $tblItem = yui::toYTableItem($self->table->selectedItem());
# drop the host using the ip
$self->cfgHosts->_dropHost($tblItem->cell(0)->label());
+ # write changes
+ $self->cfgHosts->_writeHosts();
+ $self->setupTable();
}
}elsif ($widget == $okButton) {
# write changes