Merge branch 'master' of git+ssh://github.com/adefaria/clearscm
[clearscm.git] / clearadm / viewdetails.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: viewdetails.cgi,v $
6
7 View Details
8
9 =head1 VERSION
10
11 =over
12
13 =item Author
14
15 Andrew DeFaria <Andrew@ClearSCM.com>
16
17 =item Revision
18
19 $Revision: 1.11 $
20
21 =item Created:
22
23 Mon Oct 25 11:10:47 PDT 2008
24
25 =item Modified:
26
27 $Date: 2011/01/14 16:51:58 $
28
29 =back
30
31 =head1 SYNOPSIS
32
33  Usage viewdetails.cgi: [-u|sage] [-r|egion <region>] -vi|ew <viewname>
34                         [-ve|rbose] [-d|ebug]
35
36  Where:
37    -u|sage:           Displays usage
38    -r|egion <region>: Region to use when looking for the view
39    -vi|ew<viewname>:  Name of view to display details for
40
41    -ve|rbose:         Be verbose
42    -d|ebug:           Output debug messages
43
44 =head2 DESCRIPTION
45
46 This script display the details for the given view
47
48 =cut
49
50 use strict;
51 use warnings;
52
53 use FindBin;
54 use Getopt::Long;
55 use CGI qw(:standard :cgi-lib *table start_Tr end_Tr);
56 use CGI::Carp 'fatalsToBrowser';
57
58 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
59
60 use Clearadm;
61 use ClearadmWeb;
62 use Clearcase;
63 use Clearcase::View;
64 use Clearcase::Views;
65 use Display;
66 use Utils;
67
68 my %opts = Vars;
69
70 my $subtitle = 'View Details';
71
72 $opts{region} ||= $Clearcase::CC->region;
73
74 my $VERSION  = '$Revision: 1.12 $';
75   ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
76
77 sub DisplayTable ($) {
78   my ($view) = @_;
79
80   my $permissions     = setField $view->owner_mode
81                       . setField $view->group_mode
82                       . setField $view->other_mode;
83   my $active          = ($view->active) ? 'YES' : 'NO';
84   my $gpath           = $view->gpath;
85
86   $gpath = font {-class => 'unknown'}, '&lt;no-gpath&gt;'
87     if $gpath eq '<no-gpath>';
88
89   display start_table {
90     -cellspacing    => 1,
91     -class          => 'main',
92   };
93
94   my $clearadm = Clearadm->new;
95
96   my %clearadmview = $clearadm->GetView($view->tag, $view->region);
97
98   display start_Tr;
99     display th {class => 'label'},              'Tag:';
100     display td {class => 'data', colspan => 3}, setField $view->tag;
101     display th {class => 'label'},              'Server:';
102     display td {class => 'data'}, a {
103       href => 'systemdetails.cgi?system=' . $view->shost
104     }, $view->shost;
105     display th {class => 'label'},               'Region:';
106     display td {class => 'data'},                 $view->region;
107   display end_Tr;
108
109   display start_Tr;
110     display th {class => 'label'},              'Properties:';
111     display td {class => 'data', colspan => 3}, $view->properties;
112     display th {class => 'label'},              'Text Mode:';
113     display td {class => 'data'},               $view->text_mode;
114     display th {class => 'label'},              'Permission:';
115     display td {class => 'data'},               $permissions;
116   display end_Tr;
117
118   display start_Tr;
119     display th {class => 'label'},              'Owner:';
120     display td {class => 'data', colspan => 3}, $view->owner;
121     display th {class => 'label'},              'Active:';
122     display td {class => 'data', colspan => 3}, $active;
123   display end_Tr;
124
125   display start_Tr;
126     display th {class => 'label'},              'Created by:';
127     display td {class => 'data', colspan => 3}, $view->created_by;
128     display th {class => 'label'},              'on:';
129     display td {class => 'data', colspan => 3}, $view->created_date;
130   display end_Tr;
131
132   display start_Tr;
133     display th {class => 'label'},              'CS Updated by:';
134     display td {class => 'data', colspan => 3}, $view->cs_updated_by;
135     display th {class => 'label'},              'on:';
136     display td {class => 'data', colspan => 3}, $view->cs_updated_date;
137   display end_Tr;
138
139   display start_Tr;
140     display th {class => 'label'},              'Global Path:';
141     display td {class => 'data', colspan => 7}, $gpath;
142   display end_Tr;
143
144   display start_Tr;
145     display th {class => 'label'},              'Access Path:';
146     display td {class => 'data', colspan => 7}, $view->access_path;
147   display end_Tr;
148
149   display start_Tr;
150     display th {class => 'label'},              'UUID:';
151     display td {class => 'data', colspan => 7}, $view->uuid;
152   display end_Tr;
153
154   display start_Tr;
155     display th {class => 'labelCentered', colspan => 10}, 'View Storage Pools';
156   display end_Tr;
157
158   my $image = $clearadmview{dbsmall}
159     ? "data:image/png;base64,$clearadmview{dbsmall}"
160     : "plotstorage.cgi?type=view&storage=db&tiny=1&tag=" . $view->tag;
161
162   display start_Tr;
163     display th {class => 'label'},                                'Database:';
164     display td {class => 'data', colspan => 3, align => 'center'}, a {href =>
165        "plot.cgi?type=view&storage=db&scaling=Day&points=7&region=" . $view->region . '&tag=' . $view->tag
166     }, img {
167       src    => $image,
168       border => 0,
169     };
170
171     $image = $clearadmview{privatesmall}
172       ? "data:image/png;base64,$clearadmview{privatesmall}"
173       : "plotstorage.cgi?type=view&storage=private&tiny=1&tag=" . $view->tag;
174
175     display th {class => 'label'},                                'Private:';
176     display td {class => 'data', colspan => 5, align => 'center'}, a {href =>
177        "plot.cgi?type=view&storage=private&scaling=Day&points=7&region=" . $view->region . '&tag=' . $view->tag
178     }, img {
179       src    => $image,
180       border => 0,
181     };
182   display end_Tr;
183
184   $image = $clearadmview{adminsmall}
185     ? "data:image/png;base64,$clearadmview{adminsmall}"
186     : "plotstorage.cgi?type=view&storage=admin&tiny=1&tag=" . $view->tag;
187
188   display start_Tr;
189     display th {class => 'label'},                                'Admin:';
190     display td {class => 'data', colspan => 3, align => 'center'}, a {href =>
191        "plot.cgi?type=view&storage=admin&scaling=Day&points=7&region=" . $view->region . '&tag=' . $view->tag
192     }, img {
193       src    => $image,
194       border => 0,
195     };
196
197     $image = $clearadmview{totalsmall}
198       ? "data:image/png;base64,$clearadmview{totalsmall}"
199       : "plotstorage.cgi?type=view&storage=total&tiny=1&tag=" . $view->tag;
200
201     display th {class => 'label'},                                'Total Space:';
202     display td {class => 'data', colspan => 5, align => 'center'}, a {href =>
203        "plot.cgi?type=view&storage=total&scaling=Day&points=7&region=" . $view->region . '&tag=' . $view->tag
204     }, img {
205       src    => $image,
206       border => 0,
207     };
208   display end_Tr;
209
210   display end_table;
211   
212   return
213 } # DisplayTable
214
215 sub DisplayRegion() {
216   display start_form (action => 'viewdetails.cgi');
217
218   display 'Region ';
219
220   display popup_menu (
221     -name     => 'region',
222     -values   => [$Clearcase::CC->regions],
223     -default  => $Clearcase::CC->region,
224     -onchange => 'submit();',
225   );
226
227   display submit (
228     -value => 'Go',
229   );
230
231   display end_form;
232   
233   return
234 } # DisplayRegion
235
236 sub DisplayViews($) {
237   my ($region) = @_;
238
239   my $views = Clearcase::Views->new ($region);
240   my @views = $views->views;
241
242   unless (@views) {
243     push @views, 'No Views';
244   } # unless
245
246   display start_form(action => 'viewdetails.cgi');
247
248   display 'Region ';
249
250   display popup_menu (
251     -name     => 'region',
252     -values   => [$Clearcase::CC->regions],
253     -default  => $region,
254     -onchange => 'submit();',
255   );
256
257   display b ' View: ';
258
259   display popup_menu (
260      -name     => 'view',
261      -values   => \@views,
262      -onchange => 'submit();',
263   );
264
265   display submit(
266     -value     => 'Go',
267   );
268
269   display end_form;
270   
271   return;
272 } # DisplayViews
273
274 # Main
275 GetOptions(
276   \%opts,
277   'usage'        => sub { Usage },
278   'verbose'      => sub { set_verbose },
279   'debug'        => sub { set_debug },
280   'view=s',
281   'region=s',
282 ) or Usage "Invalid parameter";
283
284 # Announce ourselves
285 verbose "$FindBin::Script v$VERSION";
286
287 heading $subtitle;
288
289 display h1 {
290   -class => 'center',
291 }, $subtitle;
292
293 unless ($opts{tag}) {
294   unless ($opts{region}) {
295     DisplayRegion;
296   } else {
297     DisplayViews $opts{region};
298   } # unless
299
300   exit;
301 } # unless
302
303 DisplayTable(Clearcase::View->new($opts{tag}, $opts{region}));
304
305 footing;
306
307 =pod
308
309 =head1 CONFIGURATION AND ENVIRONMENT
310
311 DEBUG: If set then $debug is set to this level.
312
313 VERBOSE: If set then $verbose is set to this level.
314
315 TRACE: If set then $trace is set to this level.
316
317 =head1 DEPENDENCIES
318
319 =head2 Perl Modules
320
321 L<CGI>
322
323 L<CGI::Carp|CGI::Carp>
324
325 L<FindBin>
326
327 L<Getopt::Long|Getopt::Long>
328
329 =head2 ClearSCM Perl Modules
330
331 =begin man 
332
333  Clearadm
334  ClearadmWeb
335  Clearcase
336  Clearcase::View
337  Clearcase::Views
338  Display
339  Utils
340
341 =end man
342
343 =begin html
344
345 <blockquote>
346 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
347 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
348 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a><br>
349 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/View.pm">Clearcase::View</a><br>
350 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/Views.pm">Clearcase::Views</a><br>
351 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
352 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
353 </blockquote>
354
355 =end html
356
357 =head1 BUGS AND LIMITATIONS
358
359 There are no known bugs in this script
360
361 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
362
363 =head1 LICENSE AND COPYRIGHT
364
365 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
366
367 =cut