<%inherit file="//layout/base.html" /> <%namespace name="lib" file="//lib.html" import="*" /> <%! import os import logging logger = logging.getLogger('splunk.appserver.templates.view') successfullyRenderedPanels = {} %>
${_('Loading...')}
${next.body()}
<%def name="title()"> ${VIEW['label']} - ${APP['label']|h} - Splunk ${cherrypy.config.get('version_label')} (${cherrypy.config.get('build_number')}) <%def name="head()"> % if VIEW.get("refresh"): % endif <%def name="body_element_open()"> <% bodyCSSClasses = [ 'splTemplate-' + os.path.split(self.filename)[-1].split('.')[0], 'splView-' + VIEW['id'] ] if VIEW['objectMode'] == 'SimpleForm': bodyCSSClasses.append('splFormSearch') bodyCSSClasses = ' '.join(bodyCSSClasses) %> <%def name="css()"> <%coreCSSFiles = ["/static/css/view.css", "/static/css/skins/default/default.css", '/static/css/print.css'] %> <%lib:stylesheet_tags files="${coreCSSFiles}" compile="False" /> <%lib:stylesheet_tags files="${cssFiles}" compile="False" /> <%def name="custom_css()"> <%lib:stylesheet_tags files="${customCssFiles}" compile="False" /> <%lib:stylesheet_tags files="${printCssFiles}" compile="False" media="print"/> <%def name="js()"> <% coreJsFiles = [ # external packages "/static/js/contrib/lowpro_for_jquery.js", "/static/js/contrib/json2.js", "/static/js/contrib/swfobject.js", "/static/js/contrib/firebug.js", "/static/js/contrib/jquery-ui-1.6.custom.min.js", "/static/js/contrib/jquery.ui.tablesorter.js", "/static/js/contrib/jquery.uitablefilter.js", "/static/js/contrib/jquery.bgiframe.min.js", "/static/js/contrib/jquery.cookie.js", "/static/js/contrib/jquery.form.js", # TEMPORARY - we're still looking for something better than strftime "/static/js/contrib/strftime.js", # splunk packages "/static/js/logger.js", "/static/js/error.js", "/static/js/session.js", "/static/js/job.js", "/static/js/messenger.js", "/static/js/search_context.js", "/static/js/jobber.js", "/static/js/menu_builder.js", "/static/js/admin.js", "/static/js/time_range.js", "/static/js/module_loader.js", "/static/js/ja_bridge.js", "/static/js/legend.js", "/static/js/jquery.sparkline.js", "/static/js/popup.js", "/static/js/layout_engine.js", "/static/js/print.js", "/static/js/page_status.js", "/static/js/dev.js", "/static/js/window.js", "/static/js/field_summary.js", "/static/js/viewmaster.js", "/static/js/textarea_resize.js", # Check for the CSRF token "/static/js/splunk.jquery.csrf_protection.js", # Check for the X-Splunk-Messages-Available flag and instruct the Messenger to update itself "/static/js/splunk.jquery.check_messages.js", # init.js was moved into the js_initialization() call so that it could always be after all files, including the files that might have been added to js() by sub-templates. ] %> ## start: core js <%lib:script_tags files="${coreJsFiles}" compile="False" /> ## dynamic view dependency js <%lib:script_tags files="${jsFiles}" compile="False" /> <% params = {} paramConfig = { 'sticky': {}, 'persistable': {} } # process every module for panelName in modules: for module in modules[panelName]: # generate module configuration dict params[module.get('id')] = module.get('params', dict()) # output persistence data, if available if module['stickyParams']: paramConfig['sticky'][module['id']] = module['stickyParams'] if module['persistableParams']: paramConfig['persistable'][module['id']] = module['persistableParams'] %> ## required params js % if toBeResurrected: <%doc> tempting to use simplejson to dump this out into Splunk.ModuleLoader. however this makes us vulnerable to injection attacks through permalink, because firefox will close this block at the first , and then you can run arbitrary javascript on the client. HTML escaping seems the lowest-cost and highest-stability defense here, although it's definitely odd and open for discussion. % endif ## buffered inline js <%lib:get_script_blocks /> <%def name="js_initialization()"> <%lib:script_tags files="${['/static/js/init.js']}" /> <%def name="buildModule(module)"><% attributesToEmit = {"id":1,"parentmodule":1,"autoRun":1} %> ## 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])) : % endfor
<%call expr="buildModule(modules[panelName][i])">
% else : % for module in modules[panelName] : <%call expr="buildModule(module)"> % endfor % endif ## 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)">
% endif <%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. <%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])">
% endfor
## 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(); % endif % endfor