root / exilog_cgi_queues.pm @ 226ad0a3c764c0606048acf7371b02765eee60d2
View | Annotate | Download (4.1 KB)
| 1 | #!/usr/bin/perl -w |
|---|---|
| 2 | # |
| 3 | # This file is part of the exilog suite. |
| 4 | # |
| 5 | # http://duncanthrax.net/exilog/ |
| 6 | # |
| 7 | # (c) Tom Kistner 2004 |
| 8 | # |
| 9 | # See LICENSE for licensing information. |
| 10 | # |
| 11 | |
| 12 | package exilog_cgi_queues; |
| 13 | use exilog_config; |
| 14 | use exilog_cgi_html; |
| 15 | use exilog_cgi_param; |
| 16 | use exilog_sql; |
| 17 | use exilog_util; |
| 18 | use strict; |
| 19 | |
| 20 | BEGIN {
|
| 21 | use Exporter; |
| 22 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
| 23 | |
| 24 | # set the version for version checking |
| 25 | $VERSION = 0.1; |
| 26 | @ISA = qw(Exporter); |
| 27 | @EXPORT = qw( |
| 28 | &queues |
| 29 | ); |
| 30 | |
| 31 | %EXPORT_TAGS = (); |
| 32 | |
| 33 | # your exported package globals go here, |
| 34 | # as well as any optionally exported functions |
| 35 | @EXPORT_OK = qw(); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | sub queues {
|
| 40 | _print_Queue_selector(); |
| 41 | my $messages = sql_select('queue',[ '*' ]);
|
| 42 | print render_queue_table($messages); |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | sub _print_Queue_selector {
|
| 47 | |
| 48 | |
| 49 | $q->div({-class=>"top_spacer"},
|
| 50 | $q->div({-align=>"left",-style=>"padding: 10px; border: 1px solid black; background: #eeeeee;"},
|
| 51 | |
| 52 | $q->table({-cellspacing=>0,-cellpadding=>4,-border=>0},
|
| 53 | $q->Tr( |
| 54 | $q->td({-align=>"left",-valign=>"top",-style=>"width: 16px;"},
|
| 55 | $q->img({-src=>"icons/server.png"})
|
| 56 | ), |
| 57 | $q->td({-align=>"left",-valign=>"top",-style=>"width: 100px;"},
|
| 58 | "Servers" |
| 59 | ), |
| 60 | $q->td({-align=>"left"},
|
| 61 | eval {
|
| 62 | my $html =""; |
| 63 | my $num = 0; |
| 64 | my $groups = {};
|
| 65 | foreach my $server (sort {$a cmp $b} keys %{ $config->{servers} }) {
|
| 66 | if (($num % 4) == 0) {
|
| 67 | $html .= '<tr>'; |
| 68 | }; |
| 69 | $html .= $q->td({-width=>"1%",-style=>"padding-right: 4px;"},
|
| 70 | $q->checkbox( { -name=>"sr",
|
| 71 | -label=>"", |
| 72 | -id=>(edt($config->{servers}->{$server},'group') ? $config->{servers}->{$server}->{group} : "-XXX"),
|
| 73 | -checked=>(ina($param->{'sr'},$server) ? 'checked' : undef),
|
| 74 | -override=>1, |
| 75 | -onDblClick=>"javascript:sr_off_except(this);", |
| 76 | -onChange=>"javascript:sr_changed();", |
| 77 | -value=>$server } ) |
| 78 | ). |
| 79 | $q->td({-width=>"1%",-style=>"padding-right: 10px;"},
|
| 80 | $server |
| 81 | ); |
| 82 | if (($num % 4) == 3) {
|
| 83 | $html .= '<td> </td></tr>'; |
| 84 | }; |
| 85 | $num++; |
| 86 | if (edt($config->{servers}->{$server},'group')) {
|
| 87 | $groups->{$config->{servers}->{$server}->{group}} = '{'.$config->{servers}->{$server}->{group}.'}';
|
| 88 | }; |
| 89 | }; |
| 90 | if (($num % 4) != 0) {
|
| 91 | $html .= '<td> </td>' x ((4-($num % 4))*2); |
| 92 | $html .= '<td> </td></tr>'; |
| 93 | }; |
| 94 | $groups->{'-all'} = 'All servers';
|
| 95 | $groups->{'-custom'} = 'Custom selection';
|
| 96 | $q->table({-border=>0,-cellpadding=>0,-cellspacing=>0,-width=>"1%"},
|
| 97 | $q->Tr( |
| 98 | $q->td({-colspan=>9,-align=>"left",-style=>"padding-bottom: 4px;"},
|
| 99 | $q->popup_menu({ -name=>"ss",
|
| 100 | -id=>"ss", |
| 101 | -style=>"width: 400px;", |
| 102 | -values=>[ sort {$a cmp $b} keys(%{$groups}) ],
|
| 103 | -labels=>$groups, |
| 104 | -onChange=>"javascript:ss_changed();", |
| 105 | -default=>(exists($param->{'ss'}) ? ($param->{'ss'} || '-all') : '-all'),
|
| 106 | -override=>1}) |
| 107 | ) |
| 108 | ), |
| 109 | $html |
| 110 | ); |
| 111 | }.($@ ? $@ : "") |
| 112 | ) |
| 113 | ) |
| 114 | ) |
| 115 | . |
| 116 | '<hr>' |
| 117 | . |
| 118 | $q->table({-cellspacing=>0,-cellpadding=>4,-border=>0,-align=>"center"},
|
| 119 | $q->Tr( |
| 120 | $q->td({-align=>"center"},
|
| 121 | $q->submit({-name=>"sm",-value=>"Start Query"})
|
| 122 | ) |
| 123 | ) |
| 124 | ) |
| 125 | |
| 126 | ) |
| 127 | ); |
| 128 | }; |
| 129 | |
| 130 | 1; |
| 131 |