public static function render($name, $graphs, $selects = array(), $currentValues = array()) { // Necessary to do unshift-with-a-key $selects = array_reverse($selects, true); $selects['time'] = Dashboard::getTimes(); $selects = array_reverse($selects, true); // Default $currentValues['time'] = '1h'; foreach ($selects as $name => $select) { if (!empty($_GET[$name])) { $currentValues[$name] = $_GET[$name]; } else { if (!isset($currentValues[$name])) { $currentValues[$name] = null; } } } ?> <!DOCTYPE html> <html> <head> <title><?php echo $name; ?> </title> <link rel="stylesheet" type="text/css" href="css/screen.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script src="js/dashboard.js"></script> </head> <body id="deploy" class="dashboard"> <div id="status"></div> <form id="controls" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php foreach ($selects as $name => $select) { echo "<select name=\"{$name}\">"; foreach ($select as $key => $value) { echo "<option value=\"{$key}\""; if ($key == $currentValues[$name]) { echo "selected"; } echo ">{$value}</option>"; } echo "</select>"; } ?> </form> <?php foreach ($graphs as $section => $items) { echo "<div class=\"graphgroup\">"; echo "<h1>" . htmlentities($section) . " (" . Dashboard::displayTime($currentValues['time']) . ")</h1>\n"; foreach ($items as $item) { $item->setTime($currentValues['time']); echo $item->getDashboardHTML(); } echo "</div>"; } ?> </body> </html> <?php }
<?php require_once 'Dashboard.php'; $times = isset($times) ? $times : Dashboard::getTimes(); if (!isset($time)) { $time = !empty($_GET['time']) ? $_GET['time'] : '1h'; } if (!isset($hide_deploys)) { $hide_deploys = !empty($_GET['hide_deploys']) ? $_GET['hide_deploys'] : false; } $show_deploys = !$hide_deploys; if (isset($graphs)) { if (Dashboard::hasGraphitePie($graphs)) { $page_js_imports = array_merge(isset($page_js_imports) ? $page_js_imports : array(), array("/assets/js/flot/jquery.flot.js", "/assets/js/flot/jquery.flot.pie.js", "/assets/js/flot.js", "/assets/js/graphite_percentage.js")); } if (Dashboard::hasGraphitePercentage($graphs)) { $page_js_imports = array_merge(isset($page_js_imports) ? $page_js_imports : array(), array("/assets/js/d3-2.9.1.min.js", "/assets/js/graphite_percentage.js", "/assets/js/graphite_bar_percentage.js")); } $has_graphite_with_html_legend = false; foreach ((array) $graphs as $section) { foreach ((array) $section as $graph) { if (isset($graph['type']) && $graph['type'] == 'graphite' && isset($graph['show_html_legend']) && $graph['show_html_legend'] == true) { $has_graphite_with_html_legend = true; } } } if ($has_graphite_with_html_legend) { $page_js_imports = array_merge(isset($page_js_imports) ? $page_js_imports : array(), array("/assets/js/zeroclipboard-0.7/ZeroClipboard.js", "/assets/js/copyurl.js")); $page_css_imports = array_merge(isset($page_css_imports) ? $page_css_imports : array(), array("/assets/css/copyurl.css")); } }
<?php require_once 'phplib/Dashboard.php'; $times = Dashboard::getTimes(); $time = !empty($_GET['time']) ? $_GET['time'] : "1h"; ?> <!DOCTYPE html> <html> <head> <title>Example PgBouncer Dashboard</title> <link rel="stylesheet" type="text/css" href="assets/css/screen.css"> <script src="assets/js/jquery-1.6.2.min.js"></script> <script src="assets/js/dashboard.js"></script> </head> <body id="postgresql" class="dashboard"> <div id="status"></div> <?php $tabs = Dashboard::$DB_TABS; $tab_url = Dashboard::getTabUrl(__FILE__); include 'phplib/template_tabs.php'; ?> <form id="controls" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php echo Controls::buildTimeControl($time, $times); ?>