Add admin settings for interval and table cleanup.

Interval is used as the default in the editRuleflow page.
table cleanup works as a setting, but doesn't do anything yet.
This commit is contained in:
Colin Kuskie 2009-02-09 13:36:52 -08:00 committed by Patrick Donelan
parent aa6367d459
commit 266dca5af6
3 changed files with 102 additions and 1 deletions

View file

@ -110,7 +110,7 @@ sub www_editRuleflow {
);
$f->integer(
name => 'pauseInterval',
value => $session->form->get('pauseInterval') || 300,
value => $session->form->get('pauseInterval') || $session->setting->get('passiveAnalyticsInterval') || 300,
label => $i18n->get('pause interval'),
hoverHelp => $i18n->get('pause interval help'),
);
@ -131,6 +131,7 @@ sub www_editRuleflow {
}
$steps .= '<tr><td>&nbsp;</td><td>Other</td></tbody></table><div style="clear: both;"></div>';
my $ac = WebGUI::AdminConsole->new($session,'passiveAnalytics');
$ac->addSubmenuItem($session->url->page('op=passiveAnalytics;func=settings'), $i18n->get('Passive Analytics Settings'));
return $ac->render($error.$f->print.$addmenu.$steps, 'Passive Analytics');
}
@ -251,4 +252,64 @@ sub www_promoteRule {
return www_editRuleflow($session);
}
#-------------------------------------------------------------------
=head2 www_settings ( session )
Configure Passive Analytics settings.
=cut
sub www_settings {
my $session = shift;
my $error = shift;
return $session->privilege->insufficient() unless canView($session);
if ($error) {
$error = qq|<div class="error">$error</div>\n|;
}
my $i18n = WebGUI::International->new($session, "PassiveAnalytics");
my $f = WebGUI::HTMLForm->new($session);
$f->hidden(
name=>'op',
value=>'passiveAnalytics'
);
$f->hidden(
name=>'func',
value=>'settingsSave'
);
$f->integer(
name => 'pauseInterval',
value => $session->form->get('pauseInterval') || $session->setting->get('passiveAnalyticsInterval') || 300,
label => $i18n->get('default pause interval'),
hoverHelp => $i18n->get('default pause interval help'),
);
$f->yesNo(
name => 'deleteDelta',
value => $session->form->get('deleteDelta') || $session->setting->get('passiveAnalyticsDeleteDelta') || 0,
label => $i18n->get('Delete Delta Table?'),
hoverHelp => $i18n->get('Delete Delta Table? help'),
);
$f->submit();
my $ac = WebGUI::AdminConsole->new($session,'passiveAnalytics');
$ac->addSubmenuItem($session->url->page('op=passiveAnalytics;func=editRuleflow'), $i18n->get('Passive Analytics'));
return $ac->render($error.$f->print, 'Passive Analytics Settings');
}
#-------------------------------------------------------------------
=head2 www_settingsSave ( session )
Save Passive Analytics settings.
=cut
sub www_settingsSave {
my $session = shift;
return $session->privilege->insufficient() unless canView($session);
my $form = $session->form;
$session->setting->set('passiveAnalyticsInterval', $form->process('pauseInterval', 'integer'));
$session->setting->set('passiveAnalyticsDeleteDelta', $form->process('deleteDelta', 'yesNo' ));
return www_settings($session);
}
1;

View file

@ -20,6 +20,16 @@ our $I18N = {
lastUpdated => 0,
},
'default pause interval' => {
message => q|Default Pause Threshold|,
lastUpdated => 0,
},
'default pause interval help' => {
message => q|Set the default pause interval displayed the user sees in the Passive Analytics screen.|,
lastUpdated => 0,
},
'other' => {
message => q|Other|,
lastUpdated => 0,
@ -65,6 +75,12 @@ home\?func=match, or<br />
context => q||
},
'Passive Analytics Settings' => {
message => q|Passive Analytics Settings|,
lastUpdated => 0,
context => q||
},
'Edit Rule' => {
message => q|Edit Rule|,
lastUpdated => 0,
@ -95,6 +111,18 @@ home\?func=match, or<br />
context => q|Button label to begin analyzing the logs.|
},
'Delete Delta Table?' => {
message => q|Delete Delta Table?|,
lastUpdated => 0,
context => q|Button label to begin analyzing the logs.|
},
'Delete Delta Table? help' => {
message => q|Should the delta table be cleaned up after the Passive Analytics analyzer is done?|,
lastUpdated => 0,
context => q|Button label to begin analyzing the logs.|
},
};
1;

View file

@ -35,6 +35,7 @@ installPassiveAnalyticsRule($session);
installPassiveAnalyticsConfig($session);
installWorkflow($session);
#addAdminGroup($session);
addPassiveAnalyticsSettings($session);
finish($session);
@ -93,6 +94,17 @@ sub installPassiveAnalyticsRule {
print "DONE!\n";
}
#----------------------------------------------------------------------------
# Add the PassiveAnalytics Rule table
sub addPassiveAnalyticsSettings {
my $session = shift;
print "\tInstall Passive Analytics settings... ";
# and here's our code
$session->setting->add('passiveAnalyticsInterval', 300);
$session->setting->add('passiveAnalyticsDeleteDelta', 0);
print "DONE!\n";
}
#----------------------------------------------------------------------------
# Add the Passive Analytics config file entry
# for the adminConsole and the content handler