%inherit file="//layout/base.html" />
<%namespace name="lib" file="//lib.html" import="*" />
<%!
import os
import logging
logger = logging.getLogger('splunk.appserver.templates.view')
successfullyRenderedPanels = {}
%>
\
% if "templatePath" in module :
<% logger.debug('rendering module %s' % module['templatePath']) %>\
<%include file="${module['templatePath']}" args="module=module"/>\
% endif
%def>
## generates the markup for all modules within the given panel. Currently used by all view templates.
<%def name="buildPanelContents(modules, panelName)"><%
successfullyRenderedPanels[panelName] = 1
# TODO - Remove this once the params stanza is implemented everywhere
for module in modules[panelName]:
if module.has_key('params'):
for param in module['params']:
if not module.has_key(param):
module[param] = module['params'][param]
%>\
% if (panelName=="splSearchControls-inline") :
% for i in range(len(modules[panelName])) :
<%call expr="buildModule(modules[panelName][i])">%call> |
% endfor
% else :
% for module in modules[panelName] :
<%call expr="buildModule(module)">%call>
% endfor
% endif
%def>
## much simpler rendering used by the top masthead modules. Currently used by all view templates.
<%def name="buildSimplePanelContainer(modules, panelName)">
% if (panelName in modules) :
<%call expr="buildPanelContents(modules, panelName)">%call>
% endif
%def>
<%doc>
This is used by the row x column layouts in dashboard.html and in builder.html
for the given row number, it will generate the internal html and overall
layout for the layoutPanels in that row.
The complexity here is considerable. The full picture is as follows:
this template builds a row of N * layoutPanels (N<4 currently)
each of the N layoutPanels. can contain
-- M * "ungrouped" modules
-- P * "groups", each of which can contain several modules.
eg: dashboard.html uses the full range available here. See comments in that file.
builder.html has no use for the "grouped" modules so it only has the "ungrouped" ones.
%doc>
<%def name="getFloatLayoutRow(modules, row)">
<%
rowMatrix = []
basePanelName = 'panel_row' + str(row) + '_col'
col = 1
ungrouped = []
if (modules.get(basePanelName + str(col))) :
while (modules.get(basePanelName + str(col))) :
panelName = basePanelName + str(col)
successfullyRenderedPanels[panelName] = 1
rowMatrix.append([panelName])
col = col + 1
## rowMatrix is now filled with ONLY the ungrouped modules from each panel.
## start second pass, to get the grouped modules.
col = 1
for col in range(1,4) :
# maybe this panel has no grouped modules. Skip it.
if (not modules.get(basePanelName + str(col) + "_grp1")) :
pass
else :
group = 1
baseGroupName = basePanelName + str(col) + "_grp"
while (modules.get(baseGroupName + str(group))) :
panelName = baseGroupName + str(group)
rowMatrix[col-1].append(panelName)
successfullyRenderedPanels[panelName] = 1
group = group + 1
rowClasses = ["layoutRow", "equalHeightRow", "splClearfix", basePanelName]
if (row==1) :
rowClasses.append("firstRow")
if (len(rowMatrix) == 1) :
rowClasses.append("oneColRow")
elif (len(rowMatrix) == 2) :
rowClasses.append("twoColRow")
elif (len(rowMatrix) == 3) :
rowClasses.append("threeColRow")
%>
% for i in range(len(rowMatrix)) :
<%
cellClasses = ["layoutCell"]
if (i==0) :
cellClasses.append("firstCell")
if (i==len(rowMatrix)-1) :
cellClasses.append("lastCell")
%>
<%call expr="next.getDashboardPanel(modules, rowMatrix[i])">%call>
% endfor
%def>
## we check that all the layoutPanels we had ended up with a home. If not we tell the user.
% for panelName in modules :
% if (panelName not in successfullyRenderedPanels) :
<%call expr="lib.add_script_block()">
this.messenger = Splunk.Messenger.System.getInstance();
this.messenger.send("error", "splunk", sprintf(_("found an invalid value for layoutPanel - '%s'."), "${panelName}"));
// a misconfigured hierarchy can often derail the module loading, so the 'Loading' string can get stuck there.
$("#loading").hide();
%call>
% endif
% endfor