<%! from splunk.appserver.mrsparkle.lib import times %> <% # # generate a JSON literal of all of the time ranges that have been specified # in time.conf # timeRanges = times.getTimeRanges(namespace=APP['id']) menuItems = [] ''' Although times.conf has a submenu hierarchy, the values come out as a flat list. The hierarchy is then built here. In that list among the regular top-level items, there will be a) stubs for the submenus themselves, within the regular items, marked with is_sub_menu = True and label=foo. b) the children of those submenus , marked with sub_menu = foo. We will not append those children into the main menuItems array, but rather keep them in a dict by sub_menu name. Then in a second pass we will attach the children appropriately. ''' subMenuContents = {} for t in timeRanges: if 'is_sub_menu' in t: item = { "is_sub_menu" : True, "label" : _(t['label']), "rawLabel" : t['label'], "order": t['order'] } menuItems.append(item) continue item = { "label" : _(t['label']), "rawLabel": t['label'], "attrs" : {}, "style": "timeRangePreset", "order": t['order'] } # if defined, add in earliest/latest identifiers # the resurrection logic depends on the absence/presence of start and end keys # TODO: convert start/end to earliest/latest for k in ('earliest_time', 'latest_time'): if t[k]: item['attrs'][k] = t[k] subMenuName = t.get('sub_menu', False) if (subMenuName) : #subMenuName = _(subMenuName) if (subMenuName not in subMenuContents) : subMenuContents[subMenuName] = [] subMenuContents[subMenuName].append(item) else : menuItems.append(item) ''' Now we go through and attach the children for each of the sub_menus, which we've been keeping off to the side in the subMenuContents dict until now. ''' for i in range(len(menuItems)): if "is_sub_menu" in menuItems[i]: subMenuLabel = menuItems[i]["rawLabel"] # If this isnt true it'll have been caught by the runtime check in times.py # we check here only to prevent the exception. if subMenuLabel in subMenuContents: menuItems[i]["items"] = subMenuContents[subMenuLabel] # This was just a marker for us to do this rearranging. # Now that we are done we delete the marker. del menuItems[i]["is_sub_menu"] jsonOutput = jsonify(menuItems) %> <%page args="module"/> <%namespace name="lib" file="//lib.html" import="*"/> <%call expr="lib.add_script_block()"> Splunk.Module.loadParams.${module['id']}.timeRangeJson = ${jsonOutput}; % if 'label' in module: ${_(module.get('label', ' '))|h} % endif ${_('Dropdown')}

## ${_('Custom Time Range')}

#### ${_('Range Type')}

${_('Date')} ${_('Relative')} ${_('Real-time')} ${_('Advanced search language')}

#### ${_('Earliest time')}

${_('Specific Date')} ${_('Earliest Date')}

#### ${_('Latest time')}

${_('Specific Date')} ${_('Now')}
${_('Earliest time')} ${_('Earliest time unit selection')}
${_('Snap to')}

##### ${_('Search language equivalent')}

##### ${_('Effective range')}

${_('Time window')} ${_('Time window unit selection')}

##### ${_('Search language equivalent')}

a
${_('Earliest')}

##### ${_('Effective Earliest')}

${_('Latest')}

##### ${_('Effective Latest')}