Skip to content

Commit

Permalink
Added experimental code that renders views using the new FlotGraph
Browse files Browse the repository at this point in the history
class. The code is activated by setting $conf['flot_graph'] = true
  • Loading branch information
pcpiela committed Aug 28, 2016
1 parent e4401c3 commit cd4651d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 36 deletions.
106 changes: 76 additions & 30 deletions templates/default/view_content.tpl
Original file line number Diff line number Diff line change
@@ -1,38 +1,84 @@
{if isset($flot_graph)}
<script type="text/javascript">
$(function() {
var viewGraphs = [];
{foreach $view_items view_item}
viewGraphs.push("{$view_item.url_args}");
{/foreach}
var tz = getTimezone();
for (var i = 0; i < viewGraphs.length; i++) {
var viewGraph = viewGraphs[i];
console.log(viewGraph);
var flotGraph = new FlotGraph(viewGraph,
g_refreshInterval,
tz);
var $viewItem = $("#flot_view_item_" + i);
$viewItem.html(flotGraph.getBaseHtml());
flotGraph.initialize();
flotGraph.start();
}
});
</script>
{/if}
<div id="views-content">
<div id=view_graphs>
<script type="text/javascript">viewCommonYaxis={if $common_y_axis}true{else}false{/if};yAxisUpperLimit=null;yAxisLowerLimit=null;</script>
{if isset($number_of_view_items)}
{if $number_of_view_items == 0 }
<div class="ui-widget">
<div class="ui-state-default ui-corner-all" style="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
No graphs defined for this view. Please add some
</div>
</div>
{else}
{$i = 0}
{foreach $view_items view_item}
{$graphId = cat($GRAPH_BASE_ID "view_" $i)}
{$showEventsId = cat($SHOW_EVENTS_BASE_ID "view_" $i)}
<div class="img_view">
<button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?{$view_item.url_args}&amp;csv=1';return false;">CSV</button>
<button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?{$view_item.url_args}&amp;json=1';return false;">JSON</button>
{if $view_item['canBeDecomposed'] == 1}
<button title="Decompose graph" class="shiny-blue" onClick="javascript:location.href='?{$view_item.url_args}&amp;dg=1&amp;tab=v';return false;">Decompose</button>
{if $number_of_view_items == 0}
<div class="ui-widget">
<div class="ui-state-default ui-corner-all" style="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert"
style="float: left; margin-right: .3em;"></span>
No graphs defined for this view. Please add some
</div>
</div>
{else}
{$i = 0}
{foreach $view_items view_item}
{$graphId = cat($GRAPH_BASE_ID "view_" $i)}
{$showEventsId = cat($SHOW_EVENTS_BASE_ID "view_" $i)}
<div class="img_view">
<button title="Export to CSV"
class="cupid-green"
onClick="javascript:location.href='graph.php?{$view_item.url_args}&amp;csv=1';return false;">CSV</button>
<button title="Export to JSON"
class="cupid-green"
onClick="javascript:location.href='graph.php?{$view_item.url_args}&amp;json=1';return false;">JSON</button>
{if $view_item['canBeDecomposed'] == 1}
<button title="Decompose graph"
class="shiny-blue"
onClick="javascript:location.href='?{$view_item.url_args}&amp;dg=1&amp;tab=v';return false;">Decompose</button>
{/if}
<button title="Inspect Graph"
onClick="inspectGraph('{$view_item.url_args}'); return false;" class="shiny-blue">Inspect</button>
<input type="checkbox"
id="{$showEventsId}"
onclick="showEvents('{$graphId}', this.checked)"/>
<label title="Hide/Show Events"
class="show_event_text"
for="{$showEventsId}">Hide/Show Events</label>
<br />
{if isset($flot_graph)}
<div id="flot_view_item_{$i}"
style="height:280px;width:460px;"
class="flotgraph2 img_view"></div>
{elseif $graph_engine == "flot"}
<div id="placeholder_{$view_item.url_args}"
class="flotgraph2 img_view"></div>
<div id="placeholder_{$view_item.url_args}_legend"
class="flotlegend"></div>
{else}
<a href="graph_all_periods.php?{$view_item.url_args}">
<img id="{$graphId}"
class="noborder {$additional_host_img_css_classes}"
style="margin-top:5px;"
src="graph.php?{$view_item.url_args}" />
</a>
{/if}
</div>
{math "$i + 1" assign=i}
{/foreach}
{/if}
<button title="Inspect Graph" onClick="inspectGraph('{$view_item.url_args}'); return false;" class="shiny-blue">Inspect</button>
<input type="checkbox" id="{$showEventsId}" onclick="showEvents('{$graphId}', this.checked)"/><label title="Hide/Show Events" class="show_event_text" for="{$showEventsId}">Hide/Show Events</label>
<br />
{if $graph_engine == "flot"}
<div id="placeholder_{$view_item.url_args}" class="flotgraph2 img_view"></div>
<div id="placeholder_{$view_item.url_args}_legend" class="flotlegend"></div>
{else}
<a href="graph_all_periods.php?{$view_item.url_args}"><img id="{$graphId}" class="noborder {$additional_host_img_css_classes}" style="margin-top:5px;" src="graph.php?{$view_item.url_args}" /></a>
{/if}
</div>
{math "$i + 1" assign=i}
{/foreach}
{/if}
{/if}
</div>
</div>
11 changes: 6 additions & 5 deletions view_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
if (isset($_GET['vn']) && !is_proper_view_name($_GET['vn'])) {
?>
<div class="ui-widget">
<div class="ui-state-default ui-corner-all" styledefault="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<div class="ui-state-default ui-corner-all" styledefault="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
View names valid characters are 0-9, a-z, A-Z, -, _ and space. View has not been created.</p>
</div>
</div>
Expand All @@ -31,14 +31,14 @@

$size = isset($clustergraphsize) ? $clustergraphsize : 'default';
// set to 'default' to preserve old behavior
if ($size == 'medium')
if ($size == 'medium')
$size = 'default';

$additional_host_img_css_classes = "";
if (isset($conf['zoom_support']) && $conf['zoom_support'] === true)
$additional_host_img_css_classes = "host_${size}_zoomable";

$data->assign("additional_host_img_css_classes",
$data->assign("additional_host_img_css_classes",
$additional_host_img_css_classes);

$view_items = NULL;
Expand All @@ -61,7 +61,8 @@

$data->assign('GRAPH_BASE_ID', $GRAPH_BASE_ID);
$data->assign('SHOW_EVENTS_BASE_ID', $SHOW_EVENTS_BASE_ID);

$data->assign('graph_engine', $conf['graph_engine']);
$data->assign('flot_graph', isset($conf['flot_graph']) ? true : null);
$dwoo->output($tpl, $data);

?>
3 changes: 2 additions & 1 deletion views_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ function getViewSelectors($viewList,

$data->assign('GRAPH_BASE_ID', $GRAPH_BASE_ID);
$data->assign('SHOW_EVENTS_BASE_ID', $SHOW_EVENTS_BASE_ID);

$data->assign('graph_engine', $conf['graph_engine']);
$data->assign('flot_graph', isset($conf['flot_graph']) ? true : null);
$dwoo->output($tpl, $data);

?>

0 comments on commit cd4651d

Please sign in to comment.