diff options
Diffstat (limited to 'ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/MonitorGUI/View.pm')
-rw-r--r-- | ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/MonitorGUI/View.pm | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/MonitorGUI/View.pm b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/MonitorGUI/View.pm new file mode 100644 index 0000000..bab462f --- /dev/null +++ b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/MonitorGUI/View.pm | |||
@@ -0,0 +1,214 @@ | |||
1 | package MonitorGUI::View; | ||
2 | |||
3 | use strict; | ||
4 | |||
5 | my @server_list; | ||
6 | my $max_port; | ||
7 | my $regions; | ||
8 | |||
9 | sub screen_header { | ||
10 | return << "HEADER"; | ||
11 | <HTML> | ||
12 | <HEAD> | ||
13 | <STYLE TYPE="text/css"> | ||
14 | <!-- | ||
15 | a:link {font-size: 12pt; text-decoration:none; color:#0000ff ;} | ||
16 | a:visited {font-size: 12pt; text-decoration:none; color:#ff0000 ;} | ||
17 | a:active {font-size: 12pt; text-decoration:none; color:#00ff00 ;} | ||
18 | a:hover {font-size: 12pt; text-decoration:underline; color:#ff00ff ;} | ||
19 | td {font-size: 12pt;border:0;} | ||
20 | th {background-color:#000000; font-size: 12pt;border:0; color:#FFFFFF; } | ||
21 | tr {background-color:#FFFFFF; } | ||
22 | b {font-size: 12pt;} | ||
23 | //table {background-color:#000000; } | ||
24 | --> | ||
25 | </STYLE> | ||
26 | <META http-equiv="content-type" content="text/html;charset=UTF-8" /> | ||
27 | <META name="refresh" content="300" /> | ||
28 | <TITLE>Region Monitor GUI, 3Di</TITLE> | ||
29 | </HEAD> | ||
30 | <BODY> | ||
31 | HEADER | ||
32 | } | ||
33 | |||
34 | sub screen_footer { | ||
35 | return << "FOOTER"; | ||
36 | </BODY> | ||
37 | </HTML> | ||
38 | FOOTER | ||
39 | } | ||
40 | |||
41 | sub html { | ||
42 | my $grid_info = shift; | ||
43 | my $regions_list = $grid_info->{"sim-profiles"}; | ||
44 | $regions = undef; | ||
45 | foreach(@$regions_list) { | ||
46 | my $ip = $_->{sim_ip} || "UNKNOWN"; | ||
47 | my $port = $_->{sim_port} || "UNKNOWN"; | ||
48 | $regions->{$ip}->{$port} = $_; | ||
49 | if (!$regions->{max_port} || $regions->{max_port} < $port) { | ||
50 | $regions->{max_port} = $port; | ||
51 | } | ||
52 | } | ||
53 | @server_list = keys %$regions; | ||
54 | $max_port = $regions->{max_port}; | ||
55 | my $html = ""; | ||
56 | foreach my $machine (@server_list) { | ||
57 | next if ($machine eq "max_port"); | ||
58 | $html .= &_machine_view($machine, $regions->{$machine}); | ||
59 | } | ||
60 | return $html; | ||
61 | } | ||
62 | |||
63 | sub _machine_view { | ||
64 | my ($ip, $info) = @_; | ||
65 | my $region_html = ""; | ||
66 | foreach my $region (keys %$info) { | ||
67 | $region_html .= &_region_html($info->{$region}); | ||
68 | } | ||
69 | my $html =<< "MACHINE_HTML"; | ||
70 | <h3>$ip</h3> | ||
71 | $region_html | ||
72 | <hr size=0 noshade /> | ||
73 | MACHINE_HTML | ||
74 | } | ||
75 | |||
76 | sub _region_html { | ||
77 | my $region_info = shift; | ||
78 | my $name = $region_info->{name} || "UNKNOWN"; | ||
79 | my $x = $region_info->{x} || -1; | ||
80 | my $y = $region_info->{y} || -1; | ||
81 | my $ip = $region_info->{sim_ip} || "UNKNOWN"; | ||
82 | my $port = $region_info->{sim_port} || "UNKNOWN"; | ||
83 | my $get_scene_presence_filter = $region_info->{get_scene_presence_filter}; | ||
84 | my $get_scene_presence = $region_info->{get_scene_presence}; | ||
85 | my $get_avatar_filter = $region_info->{get_avatar_filter}; | ||
86 | my $get_avatar = $region_info->{get_avatar}; | ||
87 | my $avatar_names = $region_info->{avatar_names}; | ||
88 | my $action_forms = &_action_forms($region_info); | ||
89 | my $html = <<"REGION_HTML"; | ||
90 | <strong>$name</strong><br/> | ||
91 | $ip:$port | X: $x Y: $y<br/> | ||
92 | <table border="0"> | ||
93 | <tr> | ||
94 | <td>get_avatar</td> | ||
95 | <td>$get_avatar</td> | ||
96 | <td></td> | ||
97 | </tr> | ||
98 | <tr> | ||
99 | <td>get_avatar_filter</td> | ||
100 | <td>$get_avatar_filter</td> | ||
101 | <td>$avatar_names</td> | ||
102 | </tr> | ||
103 | <tr> | ||
104 | <td>get_scene_presence</td> | ||
105 | <td>$get_scene_presence</td> | ||
106 | <td></td> | ||
107 | </tr> | ||
108 | <tr> | ||
109 | <td>get_scene_presence_filter</td> | ||
110 | <td>$get_scene_presence_filter</td> | ||
111 | <td></td> | ||
112 | </tr> | ||
113 | </table> | ||
114 | $action_forms | ||
115 | REGION_HTML | ||
116 | return $html; | ||
117 | } | ||
118 | |||
119 | sub _action_forms { | ||
120 | my $region_info = shift; | ||
121 | my $ip = $region_info->{sim_ip}; | ||
122 | my $port = $region_info->{sim_port}; | ||
123 | my $default_input_port = $max_port + 1; | ||
124 | my $move_to_options = ""; | ||
125 | my $split_to_options = ""; | ||
126 | my $merge_ip_options = ""; | ||
127 | foreach(@server_list) { | ||
128 | next if ($_ eq "max_port"); | ||
129 | $merge_ip_options .= "<option value=\"$_\">$_\n"; | ||
130 | $split_to_options .= "<option value=\"$_\">$_\n"; | ||
131 | #next if ($_ eq $ip); | ||
132 | $move_to_options .= "<option value=\"$_\">$_\n"; | ||
133 | } | ||
134 | my $merge_port_options = ""; | ||
135 | my $merge_disabled = "disabled"; | ||
136 | |||
137 | foreach(keys %{$regions->{$ip}}) { | ||
138 | next if ($_ eq $port); | ||
139 | $merge_disabled = ""; | ||
140 | } | ||
141 | # for(9000..$max_port) { # TODO : | ||
142 | # next if ($_ eq $port); | ||
143 | # $merge_port_options .= "<option value=\"$_\">$_\n"; | ||
144 | # } | ||
145 | my %port = (); | ||
146 | foreach my $ip (keys %$regions) { | ||
147 | next if ($ip eq "max_port"); | ||
148 | print STDERR "--" . $ip . "\n"; | ||
149 | foreach my $region_port (keys %{$regions->{$ip}}) { | ||
150 | print STDERR "---" . $region_port . "\n"; | ||
151 | $port{$region_port} = 1; | ||
152 | } | ||
153 | } | ||
154 | foreach (keys %port) { | ||
155 | $merge_port_options .= "<option value=\"$_\">$_\n"; | ||
156 | $merge_disabled = ""; | ||
157 | } | ||
158 | return << "ACTION_FORMS"; | ||
159 | <table> | ||
160 | <tr> | ||
161 | <form method="POST"> | ||
162 | <td> | ||
163 | <input type="hidden" name="A" value="move" /> | ||
164 | <input type="hidden" name="from_ip" value="$ip" /> | ||
165 | <input type="hidden" name="from_port" value="$port" /> | ||
166 | <input type="submit" value="Move to" /> | ||
167 | <select name="to_ip"> | ||
168 | $move_to_options | ||
169 | </select>: | ||
170 | <input type="text" name="to_port" size="5" value="$default_input_port"/> | ||
171 | </td> | ||
172 | </form> | ||
173 | |||
174 | <td> | ||
175 | | | ||
176 | </td> | ||
177 | |||
178 | <form method="POST"> | ||
179 | <td> | ||
180 | <input type="hidden" name="A" value="split" /> | ||
181 | <input type="hidden" name="from_ip" value="$ip" /> | ||
182 | <input type="hidden" name="from_port" value="$port" /> | ||
183 | <input type="submit" value="Split to" /> | ||
184 | <select name="to_ip"> | ||
185 | $split_to_options | ||
186 | </select>: | ||
187 | <input type="text" name="to_port" size="5" value="$default_input_port"/> | ||
188 | </td> | ||
189 | </form> | ||
190 | |||
191 | <td> | ||
192 | | | ||
193 | </td> | ||
194 | |||
195 | <form method="POST"> | ||
196 | <td> | ||
197 | <input type="hidden" name="A" value="merge" /> | ||
198 | <input type="hidden" name="from_ip" value="$ip" /> | ||
199 | <input type="hidden" name="master_port" value="$port" /> | ||
200 | <input type="submit" value="Merge" $merge_disabled /> | ||
201 | <select name="slave_ip" $merge_disabled> | ||
202 | $merge_ip_options | ||
203 | </select> | ||
204 | <select name="slave_port" $merge_disabled> | ||
205 | $merge_port_options | ||
206 | </select> | ||
207 | </td> | ||
208 | </form> | ||
209 | </tr> | ||
210 | </table> | ||
211 | ACTION_FORMS | ||
212 | } | ||
213 | |||
214 | 1; | ||