Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Direct URL to a server #28

Merged
merged 1 commit into from

1 participant

@ymettier
Owner

Hello,

Today, if I want to bookmark an URL for a server, I will bookmark something like http://myperfwatcher/#2_123_4444

I would like to be able to generate an URL containing the server hostname (for example, the server gandalf). Example :
http://myperfwatcher/search.php?hostname=gandalf or http://myperfwatcher/#gandalf
With such a URL, you could add links in extra tools (like nagios, inventory, automatic mails...)

The result whould show in the right pane, and left pane becomes useless.
Left pane could also contain a section "recent search" loaded from a cookie or from (not yet implemented) user profile in a database.

Regards,
Yves

@feraudet feraudet referenced this pull request from a commit
Cyril Feraudet Start for issue #28 cc24367
@ymettier
Owner

OK, it seems taht we both started on the same subject... :)

@ymettier ymettier merged commit 6d920ba into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 11, 2013
  1. @ymettier
This page is out of date. Refresh to see the latest.
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,5 +1,5 @@
-function select_node(nodeid) {
+function select_node_with_data(datas) {
$('#timebutton').hide();
$('#datetime').hide();
$('#timespan').hide();
@@ -7,10 +7,14 @@ function select_node(nodeid) {
$('#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' ) )
+ )
+ ));
+?>
+
Something went wrong with that request. Please try again.