From e6019f4dcbd514119f783755c090475fdf70599c Mon Sep 17 00:00:00 2001 From: jollytoad Date: Wed, 9 Nov 2005 09:05:58 +0000 Subject: [PATCH] Partial navigation support for slony. --- browser.php | 6 ++-- classes/Misc.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++-- database.php | 18 ++---------- plugin_slony.php | 54 +++++++++++++++++++++------------- 4 files changed, 112 insertions(+), 42 deletions(-) diff --git a/browser.php b/browser.php index b5ff3de7..4578d449 100644 --- a/browser.php +++ b/browser.php @@ -5,7 +5,7 @@ * if you click on a database it shows a list of database objects in that * database. * - * $Id: browser.php,v 1.50 2005/09/07 08:11:15 chriskl Exp $ + * $Id: browser.php,v 1.51 2005/11/09 09:05:58 jollytoad Exp $ */ // Include application functions @@ -54,7 +54,7 @@ WebFXTreeAbstractNode.prototype.target = 'detail'; WebFXTreeAbstractNode.prototype._ondblclick = function(){} // Show tree XML on double click - for debugging purposes only -/* + // UNCOMMENT THIS FOR DEBUGGING (SHOWS THE SOURCE XML) WebFXTreeAbstractNode.prototype._ondblclick = function(e){ var el = e.target || e.srcElement; @@ -63,7 +63,7 @@ WebFXTreeAbstractNode.prototype._ondblclick = function(e){ window.open(this.src, this.target || "_self"); return false; }; -*/ + var tree = new WebFXLoadTree("", "servers.php?action=tree", "servers.php"); tree.write(); diff --git a/classes/Misc.php b/classes/Misc.php index 974683d0..0b8f6392 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.111 2005/10/10 21:33:19 xzilla Exp $ + * $Id: Misc.php,v 1.112 2005/11/09 09:05:58 jollytoad Exp $ */ class Misc { @@ -438,7 +438,7 @@ * @param $section The name of the tab bar. */ function getNavTabs($section) { - global $data, $lang, $conf; + global $data, $lang, $conf, $slony; $hide_advanced = ($conf['show_advanced'] === false); @@ -573,6 +573,13 @@ 'hide' => ($hide_advanced || !$data->hasCasts()), 'help' => 'pg.cast', ), + 'slony' => array ( + 'title' => 'Slony', + 'url' => 'plugin_slony.php', + 'urlvars' => array('subject' => 'database', 'action' => 'clusters_properties'), + 'hide' => !isset($slony), + 'help' => '', + ), 'export' => array ( 'title' => $lang['strexport'], 'url' => 'database.php', @@ -793,6 +800,40 @@ ), ); + case 'slony_cluster': + return array ( + 'properties' => array ( + 'title' => $lang['strproperties'], + 'url' => 'plugin_slony.php', + 'urlvars' => array( + 'subject' => 'slony_cluster', + 'action' => 'cluster_properties', + 'slony_cluster' => field('slony_cluster') + ), + 'help' => '', + ), + 'nodes' => array ( + 'title' => $lang['strnodes'], + 'url' => 'plugin_slony.php', + 'urlvars' => array( + 'subject' => 'slony_cluster', + 'action' => 'nodes_properties', + 'slony_cluster' => field('slony_cluster') + ), + 'help' => '', + ), + 'sets' => array ( + 'title' => $lang['strrepsets'], + 'url' => 'plugin_slony.php', + 'urlvars' => array( + 'subject' => 'slony_cluster', + 'action' => 'sets_properties', + 'slony_cluster' => field('slony_cluster') + ), + 'help' => '', + ), + ); + default: return array(); } @@ -972,6 +1013,17 @@ } if ($subject == 'schema') $done = true; + if (isset($_REQUEST['slony_cluster']) && !$done) { + $vars .= 'slony_cluster='.urlencode($_REQUEST['slony_cluster']).'&'; + $trail['slony_cluster'] = array( + 'title' => 'Slony Cluster', + 'text' => $_REQUEST['slony_cluster'], + 'url' => "redirect.php?subject=slony_cluster&{$vars}", + 'help' => 'sl.cluster' + ); + } + if ($subject == 'slony_cluster') $done = true; + if (isset($_REQUEST['table']) && !$done) { $vars .= "subject=table&table=".urlencode($_REQUEST['table']); $trail['table'] = array( @@ -1003,6 +1055,25 @@ 'help' => 'pg.function' ); break; + case 'slony_node': + $vars .= 'no_id='.urlencode($_REQUEST['no_id']).'&no_name='.urlencode($_REQUEST['no_name']); + $trail[$subject] = array( + 'title' => 'Slony Node', + 'text' => $_REQUEST['no_name'], + 'url' => "redirect.php?{$vars}", + 'help' => 'sl.'.$subject + ); + break; + case 'slony_set': + $vars .= "{$subject}_id=".urlencode($_REQUEST[$subject]).'&'; + $vars .= "subject={$subject}&{$subject}=".urlencode($_REQUEST[$subject]); + $trail[$subject] = array( + 'title' => $lang['str'.$subject], + 'text' => $_REQUEST[$subject], + 'url' => "redirect.php?{$vars}", + 'help' => 'sl.'.$subject + ); + break; default: if (isset($_REQUEST[$subject])) { $trail[$_REQUEST[$subject]] = array( @@ -1535,6 +1606,7 @@ $info['username'] = $_SESSION['sharedUsername']; $info['password'] = $_SESSION['sharedPassword']; $_reload_browser = true; + $this->setServerInfo(null, $info, $server_id); } return $info; diff --git a/database.php b/database.php index 4be0dbf9..c1b45d5c 100755 --- a/database.php +++ b/database.php @@ -3,7 +3,7 @@ /** * Manage schemas within a database * - * $Id: database.php,v 1.77 2005/10/18 04:00:19 chriskl Exp $ + * $Id: database.php,v 1.78 2005/11/09 09:05:58 jollytoad Exp $ */ // Include application functions @@ -540,21 +540,7 @@ $reqvars = $misc->getRequestVars('database'); - if ($data->hasSchemas()) - $tabs = $misc->getNavTabs('database'); - else - $tabs = array_merge($misc->getNavTabs('schema'), $misc->getNavTabs('database')); - - // Show slony node if enabled on this database - if (isset($slony)) { - $tabs['slony'] = array ( - 'title' => 'Slony', - 'url' => 'plugin_slony.php', - 'urlvars' => array('action' => 'clusters_properties'), - 'hide' => false, - 'help' => '' - ); - } + $tabs = $misc->getNavTabs('database'); $items = $misc->adjustTabsForTree($tabs); diff --git a/plugin_slony.php b/plugin_slony.php index ae7794fb..31e7c112 100755 --- a/plugin_slony.php +++ b/plugin_slony.php @@ -3,11 +3,11 @@ /** * Slony database tab plugin * - * $Id: plugin_slony.php,v 1.5 2005/10/18 04:00:19 chriskl Exp $ + * $Id: plugin_slony.php,v 1.6 2005/11/09 09:05:58 jollytoad Exp $ */ // Avoid database connections whenever possible - switch ($_REQUEST['action']) { + switch (isset($_REQUEST['action']) ? $_REQUEST['action'] : '') { case 'clusters_top': case 'nodes_top': case 'sets_top': @@ -21,6 +21,11 @@ $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; $PHP_SELF = $_SERVER['PHP_SELF']; + + // Include 'slony_cluster' in $misc->href if present + if (isset($_REQUEST['slony_cluster'])) { + $misc->href .= '&slony_cluster=' . urlencode($_REQUEST['slony_cluster']); + } /** * Generate the somewhat complex Slony tree @@ -30,9 +35,11 @@ global $misc, $data, $lang, $PHP_SELF, $slony; $reqvars = $misc->getRequestVars('database'); + if (isset($slony)) + $reqvars['slony_cluster'] = $slony->slony_cluster; // Determine what actual tree we are building - switch ($subject) { + switch ($subject) { case 'clusters': // Clusters @@ -53,9 +60,7 @@ 'icon' => field('icon', 'folder'), 'action' => url(field('url'), $reqvars, - array( - 'action' => 'cluster_properties' - ) + array('action' => 'cluster_properties') ), 'branch' => url(field('url'), $reqvars, @@ -83,7 +88,9 @@ 'action' => url(field('url'), $reqvars, field('urlvars', array()), - array('action' => 'nodes_properties') + array( + 'action' => 'nodes_properties' + ) ), 'branch' => url(field('url'), $reqvars, @@ -131,8 +138,11 @@ 'action' => url('plugin_slony.php', $reqvars, array( + 'subject' => 'slony_node', 'action' => 'node_properties', - 'no_id' => field('no_id') + 'no_id' => field('no_id'), + 'no_name' => field('no_comment'), + 'slony_cluster' => $slony->slony_cluster ) ), 'branch' => url('plugin_slony.php', @@ -408,6 +418,7 @@ global $lang; $misc->printTrail('database'); + $misc->printTabs('database','slony'); $misc->printMsg($msg); $clusters = $slony->getClusters(); @@ -430,12 +441,12 @@ 'properties' => array( 'title' => $lang['strproperties'], 'url' => "plugin_slony.php?{$misc->href}&action=cluster_properties&", - 'vars' => array() + 'vars' => array('slony_cluster' => 'cluster') ), 'drop' => array( 'title' => $lang['strdrop'], 'url' => "plugin_slony.php?{$misc->href}&action=confirm_drop_cluster&", - 'vars' => array() + 'vars' => array('slony_cluster' => 'cluster') ) ); @@ -456,7 +467,7 @@ global $lang; $misc->printTrail('slony_cluster'); - $misc->printTitle($lang['strproperties']); + $misc->printTabs('slony_cluster', 'properties'); $misc->printMsg($msg); // Fetch the cluster information @@ -573,7 +584,8 @@ global $PHP_SELF, $slony, $misc; global $lang; - $misc->printTrail('slony_nodes'); + $misc->printTrail('slony_cluster'); + $misc->printTabs('slony_cluster', 'nodes'); $misc->printMsg($msg); $nodes = $slony->getNodes(); @@ -595,13 +607,13 @@ $actions = array ( 'properties' => array( 'title' => $lang['strproperties'], - 'url' => "plugin_slony.php?{$misc->href}&action=node_properties&", - 'vars' => array('no_id' => 'no_id') + 'url' => "plugin_slony.php?{$misc->href}&action=node_properties&subject=slony_node&", + 'vars' => array('no_id' => 'no_id', 'no_name' => 'no_comment') ), 'drop' => array( 'title' => $lang['strdrop'], - 'url' => "plugin_slony.php?{$misc->href}&action=confirm_drop_node&", - 'vars' => array('no_id' => 'no_id') + 'url' => "plugin_slony.php?{$misc->href}&action=confirm_drop_node&subject=slony_node&", + 'vars' => array('no_id' => 'no_id', 'no_name' => 'no_comment') ) ); @@ -1075,7 +1087,8 @@ global $PHP_SELF, $slony, $misc; global $lang; - $misc->printTrail('database'); + $misc->printTrail('slony_cluster'); + $misc->printTabs('slony_cluster', 'sets'); $misc->printMsg($msg); $sets = $slony->getReplicationSets(); @@ -2229,14 +2242,13 @@ case 'subscription_properties': doSubscription(); break; - case 'clusters_properties': - doClusters(); - break; case 'cluster_properties': doCluster(); break; + case 'clusters_properties': default: - // Shouldn't happen + doClusters(); + break; } $misc->printFooter(); -- 2.39.5