source: trunk/web/addons/toga/index.php @ 122

Last change on this file since 122 was 122, checked in by bastiaans, 19 years ago

web/addons/toga/templates/overview.tpl:

  • Cosmetic HTML change

web/addons/toga/index.php:

  • Added Joblist filter tree text

web/addons/toga/overview.php:

  • Setup clusterimage filter

web/addons/toga/image.php:

  • Added filter handling

web/addons/toga/libtoga.php:

File size: 5.8 KB
RevLine 
[113]1<?php
2
[117]3if ( !empty( $_GET ) ) {
4        extract( $_GET );
5}
6
[113]7$my_dir = getcwd();
8
9include_once "./libtoga.php";
10
[117]11global $GANGLIA_PATH;
[113]12chdir( $GANGLIA_PATH );
13
14include_once "./class.TemplatePower.inc.php";
15chdir( $my_dir );
16
[117]17$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
18$clustername = $httpvars->getClusterName();
19$view = $httpvars->getHttpVar( "view" );
[113]20
[119]21$filter = array();
22
[117]23if( !isset($view) ) $view = "overview";
24if( !isset($sortorder) ) $sortorder = "asc";
25if( !isset($sortby) ) $sortby = "id";
[119]26if( isset($id) && ($id!='')) $filter[id]=$id;
27if( isset($state) && ($state!='')) $filter[state]=$state;
28if( isset($user) && ($user!='')) $filter[user]=$user;
29if( isset($queue) && ($queue!='')) $filter[queue]=$queue;
[117]30
31function makeHeader() {
32
33        global $tpl, $grid, $context, $initgrid;
34        global $jobrange, $jobstart, $title;
35        global $page, $gridwalk, $clustername;
36        global $parentgrid, $physical, $hostname;
[122]37        global $self, $filter, $cluster_url, $get_metric_string;
[117]38
39        if ( $context == "control" && $controlroom < 0 )
40                $header = "header-nobanner";
41        else
42                $header = "header";
43
44        # Maintain our path through the grid tree.
45        $me = $self . "@" . $grid[$self][AUTHORITY];
46
47        if ($initgrid) {
48                $gridstack = array();
49                $gridstack[] = $me;
50        } else if ($gridwalk=="fwd") {
51                # push our info on gridstack, format is "name@url>name2@url".
52                if (end($gridstack) != $me) {
53                        $gridstack[] = $me;
54                }
55        } else if ($gridwalk=="back") {
56                # pop a single grid off stack.
57                if (end($gridstack) != $me) {
58                        array_pop($gridstack);
59                }
60        }
61
62        $gridstack_str = join(">", $gridstack);
63        $gridstack_url = rawurlencode($gridstack_str);
64
65        if ($initgrid or $gridwalk) {
66                # Use cookie so we dont have to pass gridstack around within this site.
67                # Cookie values are automatically urlencoded. Expires in a day.
68                setcookie("gs", $gridstack_str, time() + 86400);
69        }
70
71        # Invariant: back pointer is second-to-last element of gridstack. Grid stack never
72        # has duplicate entries.
73        list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]);
74
75        # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell
76        # destination server that we're walking foward in the grid tree.
77        if (strstr($clustername, "http://")) {
78                $tpl->assign("refresh", "0");
79                $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");
80                echo "<h2>Redirecting, please wait...</h2>";
81                $tpl->printToScreen();
82                exit;
83        }
84
85        $tpl->assign( "refresh", $default_refresh );
86        $tpl->assign( "date", date("r") );
87        $tpl->assign( "page_title", $title );
88
89        # The page to go to when "Get Fresh Data" is pressed.
90        if (isset($page))
91                $tpl->assign("page",$page);
92        else
93                $tpl->assign("page","./");
94
95        # Templated Logo image
96        $tpl->assign("images","./templates/$template_name/images");
97
98        #
99        # Used when making graphs via graph.php. Included in most URLs
100        #
101        $sort_url=rawurlencode($sort);
102        $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";
103
104        if ($jobrange and $jobstart)
105                $get_metric_string .= "&jr=$jobrange&js=$jobstart";
106
107        # Set the Alternate view link.
108        $cluster_url=rawurlencode($clustername);
109        $node_url=rawurlencode($hostname);
110
111        # Make some information available to templates.
112        $tpl->assign("cluster_url", $cluster_url);
113        # Build the node_menu
114        $node_menu = "";
115
116        if ($parentgrid) {
117                $node_menu .= "<B>$parentgrid $meta_designator</B> ";
118                $node_menu .= "<B>&gt;</B>\n";
119        }
120
121        # Show grid.
122        $mygrid =  ($self == "unspecified") ? "" : $self;
[119]123        $node_menu .= "<B>$mygrid $meta_designator</B> ";
[117]124        $node_menu .= "<B>&gt;</B>\n";
125
126        if ($physical)
127                $node_menu .= hiddenvar("p", $physical);
128
129        if ( $clustername ) {
130                $url = rawurlencode($clustername);
[122]131                $node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> ";
132                $node_menu .= "<B>&gt;</B>\n";
[117]133                $node_menu .= hiddenvar("c", $clustername);
134        }
135
[122]136        $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";
137
[119]138        if( count( $filter ) > 0 ) {
139
140                foreach( $filter as $filtername => $filterval ) {
141
142                        $node_menu .= "<B>&gt;</B>\n";
143                        $node_menu .= "<B>'$filtername': $filterval</B> ";
144                }
145        }
146
[117]147        $tpl->assign("node_menu", $node_menu);
148
149        # Make sure that no data is cached..
150        header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    # Date in the past
151        header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
152        header ("Cache-Control: no-cache, must-revalidate");  # HTTP/1.1
153        header ("Pragma: no-cache");                          # HTTP/1.0
154}
155
156function makeFooter() {
157        global $tpl, $version, $parsetime;
158
159        $tpl->assign("webfrontend-version",$version["webfrontend"]);
160        $tpl->assign("togaweb-version", "0.1");
161        $tpl->assign("togaarch-version", "0.1");
162        $tpl->assign("togaplug-version", "0.1");
163
164        if ($version["gmetad"]) {
165                $tpl->assign("webbackend-component", "gmetad");
166                $tpl->assign("webbackend-version",$version["gmetad"]);
167        } else if ($version["gmond"]) {
168                $tpl->assign("webbackend-component", "gmond");
169                $tpl->assign("webbackend-version", $version["gmond"]);
170        }
171
172        $tpl->assign("parsetime", sprintf("%.4f", $parsetime) . "s");
173}
174
175function includeJobview() {
176        global $tpl;
177
178        $tpl->assignInclude( "main", "templates/jobview.tpl" );
179}
180
181function includeOverview() {
182        global $tpl;
183
184        $tpl->assignInclude( "main", "templates/overview.tpl" );
185}
186
187function makeJobview() {
188
189}
190
191$tpl = new TemplatePower( "templates/index.tpl" );
192
193$tpl->assignInclude( "header", "templates/header.tpl" );
194
195switch( $view ) {
196
197        case "overview":
198
199                includeOverview();
200                break;
201
202        case "jobview":
203
204                includeJobview();
205                break;
206
207        default:
208
209                includeOverview();
210                break;
211}
212
213$tpl->assignInclude( "footer", "templates/footer.tpl" );
214$tpl->prepare();
215
216$title = "Torque Report";
217makeHeader();
218
219switch( $view ) {
220
221        case "overview":
222
223                include "./overview.php";
224                makeOverview();
225                break;
226
227        case "jobview":
228
229                makeJobview();
230                break;
231
232        default:
233
234                makeOverview();
235                break;
236}
237
238makeFooter();
239
240$tpl->printToScreen();
[113]241?>
Note: See TracBrowser for help on using the repository browser.