Permalink
Browse files

Merge pull request #28 from ymettier/ym/perfwatcher_issue_28

Direct URL to a server
  • Loading branch information...
2 parents 065a739 + 8d15e8a commit 6d920baabd36e409f9bb9ff2bdbd76dacfe3d496 @ymettier ymettier committed Apr 11, 2013
Showing with 123 additions and 40 deletions.
  1. +1 −1 VERSION
  2. +11 −2 js/config.jstree.js
  3. +54 −36 js/perfwatcher.functions.js
  4. +2 −1 js/perfwatcher.js
  5. +55 −0 php/json_node_defaults.php
View
2 VERSION
@@ -1 +1 @@
-Git master branch
+1.1.20130326
View
13 js/config.jstree.js
@@ -238,11 +238,20 @@ $(function () {
for (n in path) {
hash = hash + '_' + path[n].replace('node_', '');
}
- location.hash = hash.substr(1);
+ location.hash = 'id_'+hash.substr(1);
}).bind("loaded.jstree", function (event, data) {
if (!location.hash) { return; }
var nodes = location.hash.substr(1).split('_');
- recurse_open_node(nodes);
+ if(nodes[0] == 'id') {
+ nodes.shift();
+ recurse_open_node(nodes);
+ } else if(nodes[0] == 'host') {
+ var host;
+ host = location.hash.substr(6);
+ select_node_by_name(host);
+ $('#mainSplitter').jqxSplitter('collapseAt', 0);
+ treecollapsed = true;
+ }
});
function recurse_open_node (nodes) {
View
90 js/perfwatcher.functions.js
@@ -1,16 +1,20 @@
-function select_node(nodeid) {
+function select_node_with_data(datas) {
$('#timebutton').hide();
$('#datetime').hide();
$('#timespan').hide();
$('#itemtab').remove();
$('#items').html('<div id="itemtab"></div>');
$('#itemtab').html(ich.information_tab({ }));
$('#itemtab').jqxTabs({ height: $('#mainSplitter').height() -3, theme: theme, scrollStep: 697 });
- $.getJSON('action.php?tpl=json_node_datas&id='+nodeid, function(datas) {
- var tabid = 1;
- json_item_datas = datas;
- //console.log(json_item_datas);
+ var tabid = 1;
+ json_item_datas = datas;
+ var id;
+ console.log(json_item_datas);
+ if(datas['jstree'] && datas['jstree']['id']) {
+ id = datas['jstree']['id'];
+ }
+ if(id) {
$.ajax({
async : false, type: 'POST', url: "action.php?tpl=get_hosts",
data : {
@@ -27,42 +31,56 @@ function select_node(nodeid) {
}
});
$('[tag="hostname"] b').html(datas['jstree']['title']);
- if (datas['plugins']) {
- $.each(datas['plugins'], function(plugin, plugin_instance) {
- create_plugin_tab(plugin, plugin_instance, tabid++);
- });
- }
- if (datas['datas'] && datas['datas']['tabs']) {
- $.each(datas['datas']['tabs'], function(tabref, tabcontent) {
- create_custom_tab(tabref, tabid++);
- });
- }
- $('#itemtab').jqxTabs('select', 0);
- hide_menu_for(datas['jstree']['type']);
- $('#itemtab').bind('tabclick', function (event) {
- current_tab = event.args.item;
- load_tab(event.args.item);
- });
- var panel = 0;
- var i = 0;
- $.each(json_item_datas['config']['widgets'], function (widget_name, widget_datas) {
- $(ich.widget({
- widget_id : i,
- widget : widget_name,
- widget_title : widget_datas['title'],
- })).appendTo('#infodockpanel'+panel);
- $('#widget_content'+i).load(widget_datas['content_url']);
- if (panel++ > 0) { panel = 0; }
- i++;
+ } else {
+ json_item_datas['hosts'] = [ json_item_datas['host'] ];
+ }
+ if (datas['plugins']) {
+ $.each(datas['plugins'], function(plugin, plugin_instance) {
+ create_plugin_tab(plugin, plugin_instance, tabid++);
});
- $('#infodock').jqxDocking({
- theme: theme,
- orientation: 'horizontal',
- mode: 'docked'
+ }
+ if (datas['datas'] && datas['datas']['tabs']) {
+ $.each(datas['datas']['tabs'], function(tabref, tabcontent) {
+ create_custom_tab(tabref, tabid++);
});
+ }
+ $('#itemtab').jqxTabs('select', 0);
+ if(id) {
+ hide_menu_for(datas['jstree']['type']);
+ }
+ $('#itemtab').bind('tabclick', function (event) {
+ current_tab = event.args.item;
+ load_tab(event.args.item);
+ });
+ if(json_item_datas['config'] && json_item_datas['config']['widgets']) {
+ var panel = 0;
+ var i = 0;
+ $.each(json_item_datas['config']['widgets'], function (widget_name, widget_datas) {
+ $(ich.widget({
+ widget_id : i,
+ widget : widget_name,
+ widget_title : widget_datas['title'],
+ })).appendTo('#infodockpanel'+panel);
+ $('#widget_content'+i).load(widget_datas['content_url']);
+ if (panel++ > 0) { panel = 0; }
+ i++;
+ });
+ }
+ $('#infodock').jqxDocking({
+ theme: theme,
+ orientation: 'horizontal',
+ mode: 'docked'
});
}
+function select_node_by_name(host) {
+ $.getJSON('action.php?tpl=json_node_defaults&host='+host, function(datas) { select_node_with_data(datas); } );
+}
+
+function select_node(nodeid) {
+ $.getJSON('action.php?tpl=json_node_datas&id='+nodeid, function(datas) { select_node_with_data(datas); } );
+}
+
function create_plugin_tab(plugin, plugin_instance, tabid) {
$('#itemtab').jqxTabs('addAt', tabid, plugin, '<div plugin="'+plugin+'" tabid="'+tabid+'"></div>');
}
View
3 js/perfwatcher.js
@@ -136,6 +136,7 @@ $(document).ready(function() {
case 'menu_view_toogle_tree':
if (treecollapsed) {
$('#mainSplitter').jqxSplitter('expandAt', 0);
+ treecollapsed = false;
} else {
$('#mainSplitter').jqxSplitter('collapseAt', 0);
treecollapsed = true;
@@ -151,7 +152,7 @@ $(document).ready(function() {
refresh_status();
break;
case 'menu_about_box':
- perfwatcher_about_box();
+ perfwatcher_alert_box();
break;
default:
console.log('Undefined stuff : '+ $(this).attr("id"));
View
55 php/json_node_defaults.php
@@ -0,0 +1,55 @@
+<?php # vim: set filetype=php fdm=marker sw=4 ts=4 tw=78 et :
+/**
+ *
+ * PHP version 5
+ *
+ * LICENSE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Monitoring
+ * @author Yves Mettier <ymettier@free.fr>
+ * @copyright 2013 Yves Mettier
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ * @link http://www.perfwatcher.org/
+ */
+
+header("HTTP/1.0 200 OK");
+header('Content-type: text/json; charset=utf-8');
+header("Cache-Control: no-cache, must-revalidate");
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Pragma: no-cache");
+
+if (!isset($_GET['host']) and !isset($_POST['host'])) {
+ die('Error : POST or GET id missing !!');
+}
+
+if (isset($_GET['host'])) {
+ $host = $_GET['host'];
+} elseif (isset($_POST['host'])) {
+ $host = $_POST['host'];
+} else {
+ die('Error : No valid name found !!!');
+}
+
+$plugins = load_datas($host);
+
+echo json_encode(
+ array(
+ 'host' => $host,
+ 'plugins' => $plugins,
+ 'jstree' => array('title' => $host),
+ 'datas' => array(),
+ 'config' => array(
+ 'widgets' => get_widget(array( 'type' => 'default' ) )
+ )
+ ));
+?>
+

0 comments on commit 6d920ba

Please sign in to comment.