<%!
    title = 'Splunk Admin Server Control'
    from splunk.appserver.mrsparkle.lib.util import build_breadcrumbs_string
    import splunk
    from splunk.appserver.mrsparkle.lib import util, i18n
%>
<%namespace name="lib" file="//lib.html" import="*"/>
<%inherit file="//layout/admin.html" />
<%def name="title()">${_('Data inputs')} - ${parent.title()}</%def>

<%
    evt_local_source = '/' + '/'.join(['servicesNS', '-', APP['id'], 'data', 'inputs', 'win-event-log-collections', 'localhost'])
    evt_local_uri  = make_url(['manager', APP['id'], 'data', 'inputs', 'win-event-log-collections', 'localhost'], _qs=dict(action='edit', uri=evt_local_source))
    evt_remote_uri = make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='evt_logs_remote', input_mode=1))
    breadcrumbs = build_breadcrumbs_string( [ (_('Manager'), '/manager'), (_('Data inputs'), make_url(['manager', namespace, 'datainputstats'], translate=False)) ])
    newInputMap = {
        'data/inputs/win-event-log-collections/localhost': 'evt_logs_local',
        'data/inputs/win-event-log-collections': 'evt_logs_remote',
        'data/inputs/monitor': 'file_monitor',
        'data/inputs/win-perfmon': 'perfmon_local',
        'data/inputs/win-wmi-collections': 'perfmon_remote',
        'data/inputs/tcp/raw': 'tcp',
        'data/inputs/udp': 'udp',
        'data/inputs/http': 'http',
        'data/inputs/registry': 'regmon',
        'data/inputs/ad': 'admon',
        'data/inputs/WinHostMon': 'hostmon',
        'data/inputs/WinNetMon': 'netmon',
        'data/inputs/WinPrintMon': 'printmon',
        'data/inputs/script': 'scripts',
        'deployment/server/setup/data/inputs/remote_monitor': 'file_monitor',
        'deployment/server/setup/data/inputs/tcp/remote_raw': 'tcp',
        'deployment/server/setup/data/inputs/remote_script': 'scripts'
    }
    isCloud = util.isCloud()
%>

<style>
    .col-1 {
        width: 70%;
    }
</style>


<div class="dataInputsWrapper">
    <h1>${_('Local inputs')}</h1>
    <div class="dataInputsDesc">
        % if isForwardReceiveAccessible:
            % if util.isLite():
                ${_('Set up data inputs from files and directories, network ports, and scripted inputs. To configure Splunk Light to receive data from a Splunk Forwarder, go to <a href="%(url)s">Data Receiving</a>.') %  dict([('url',make_url(['manager', namespace, 'forwardreceive']))])}
            % else:
                ${_('Set up data inputs from files and directories, network ports, and scripted inputs. If you want to set up forwarding and receiving between two Splunk instances, go to <a href="%(url)s">Forwarding and receiving</a>.') %  dict([('url',make_url(['manager', namespace, 'forwardreceive']))])}
            % endif
        % else:
            ${_('Set up data inputs from files and directories, network ports, and scripted inputs.')}
        % endif
    </div>
    <!--<p class="splClearfix">
    	<a href="${make_url(['manager', APP['id'], 'adddata'], _qs=dict(breadcrumbs=breadcrumbs))}" class="splButton-primary">
    		<span>${_('Add data')}</span>
    	</a>
    </p>

    <br> -->
    <div class="listWrapper">
        <table class="splTable splTable-list" id="dataInputs">
            % if indexData:
                <tr>
                    <th class="col-1">${_('Type')}</th>
                    <th class="col-2">${_('Inputs')}</th>
                    <th class="col-3">${_('Actions')}</th>
                </tr>
                % if winData:
                    % if canView['win-event-log']:
                        <tr>
                            <td class="col-1 input_name"><a href="${evt_local_uri}">${_('Local event log collection')}</a></td>
                            <td class="col-2">-</td>
                            <td class="col-3"><a href="${evt_local_uri}">${_('Edit')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Collect event logs from this machine.')}</td>
                        </tr>
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', APP['id'], 'data', 'inputs', 'win-event-log-collections'])}">${_('Remote event log collections')}</a></td>
                            <td class="col-2">${indexData.get('win-event-log','0')}</td>
                            <td class="col-3"><a href="${evt_remote_uri}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Collect event logs from remote hosts. Note: this uses WMI and requires a domain account.')}</td>
                        </tr>
                    % endif
                % endif

                % if not isCloud and canView['monitor']:
                    <tr>
                        <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'monitor'])}">${_('Files &amp; directories')}</a></td>
                        <td class="col-2">${indexData.get('monitor','0')}</td>
                        <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='file_monitor', input_mode=1))}">${_('Add new')}</a></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="input_description">${_('Index a local file or monitor an entire directory. ')}</td>
                    </tr>
                % endif

                % if winData:
                    % if canView['win-perfmon']:
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'win-perfmon'])}">${_('Local performance monitoring')}</a></td>
                            <td class="col-2">${indexData.get('win-perfmon','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='perfmon_local', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Collect performance data from local machine. ')}</td>
                        </tr>
                    % endif
                    % if canView['win-wmi']:
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'win-wmi-collections'])}">${_('Remote performance monitoring')}</a></td>
                            <td class="col-2">${indexData.get('win-wmi','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='perfmon_remote', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Collect performance and event information from remote hosts. Requires domain credentials. ')}</td>
                        </tr>
                    % endif
                % endif

                % if canView['http']:
                    <tr>
                        <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'http-eventcollector'])}">${_('HTTP Event Collector')}</a></td>
                        <td class="col-2">${indexData.get('http','0')}</td>
                        <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='http', input_mode=1))}">${_('Add new')}</a></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="input_description">${_('Receive data over HTTP or HTTPS.')}</td>
                    </tr>
                % endif

                % if not isCloud:
                    % if canView['tcp']:
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'tcp', 'raw'])}">${_('TCP')}</a></td>
                            <td class="col-2">${indexData.get('tcp','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='tcp', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Listen on a TCP port for incoming data, e.g. syslog.')}</td>
                        </tr>
                    % endif

                    % if canView['udp']:
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'udp'])}">${_('UDP')}</a></td>
                            <td class="col-2">${indexData.get('udp','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='udp', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Listen on a UDP port for incoming data, e.g. syslog. ')}</td>
                        </tr>
                    % endif
                % endif

                % if winData:
                    % if canView['win-regmon']:
                        <tr>
                            <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'registry'])}">${_('Registry monitoring')}</a></td>
                            <td class="col-2">${indexData.get('win-regmon','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='regmon', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Have Splunk index the local Windows Registry, and monitor it for changes. ')}</td>
                        </tr>
                    % endif
                    % if canView['win-admon']:
                        <tr>
                            <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'ad'])}">${_('Active Directory monitoring')}</a></td>
                            <td class="col-2">${indexData.get('win-admon','0')}</td>
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='admon', input_mode=1))}">${_('Add new')}</a></td>
                        </tr>
                        <tr>
                            <td colspan="3" class="input_description">${_('Index and monitor Active Directory. ')}</td>
                        </tr>
                    % endif
                % endif

                % if not isCloud and canView['scripts']:
                    <tr>
                        <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'script'])}">${_('Scripts')}</a></td>
                        <td class="col-2">${indexData.get('scripts','0')}</td>
                        <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type='scripts', input_mode=1))}">${_('Add new')}</a></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="input_description">${_('Run custom scripts to collect or generate more data. ')}</td>
                    </tr>
                % endif

                % for input in modInputs:
                    <tr>
                        <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', input['name']])}">${_(input['title'])}</a></td>
                        <td class="col-2">${input['count']}</td>
                        % if input['add_as_mod_input']:
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type=input['type'], input_mode=1, modinput=1))}">${_('Add new')}</a></td>
                        % else:
                            <td class="col-3"><a href="${make_url(['manager', APP['id'], 'adddata', 'selectsource'], _qs=dict(input_type=input['type'], input_mode=1))}">${_('Add new')}</a></td>
                        % endif
                    </tr>
                    <tr>
                        <td colspan="3" class="input_description">${_(input['description'])}</td>
                    </tr>
                % endfor
            % else:
                <tr>
                    <td colspan="3">${_('Indexes data not returned')}</td>
                </tr>
            % endif

        </table>
    </div>


    <h1>${_('Forwarded inputs')}</h1>
    <br>
    <div class="listWrapper">
        <table class="splTable splTable-list" id="dataInputs">
            % if indexData:
            <tr>
                <th class="col-1">${_('Type')}</th>
                <th class="col-2">${_('Inputs')}</th>
                <th class="col-3">${_('Actions')}</th>
            </tr>

            % if canView['fwdEventLogs']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'remote_eventlogs'])}">${_('Windows Event Logs')}</a></td>
                    <td class="col-2">${indexData.get('fwdEventLogs','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='evt_logs_local'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Collect event logs from forwarders.')}</td>
                </tr>
            % endif

            <!--
            <tr>
                <td class="col-1 input_name"><a href="${make_url(['manager', APP['id'], 'data', 'inputs', 'win-event-log-collections'])}">${_('Remote event log collections')}</a></td>
                <td class="col-2">${indexData.get('elCount','0')}</td>
                <td class="col-3"><a href="${evt_remote_uri}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td colspan="3" class="input_description">${_('Collect event logs from remote hosts. Note: this uses WMI and requires a domain account.')}</td>
            </tr> -->

            % if canView['fwdMonitor']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'remote_monitor'])}">${_('Files &amp; Directories')}</a></td>
                    <td class="col-2">${indexData.get('fwdMonitor','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='file_monitor'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Monitor files or directories on forwarders.')}</td>
                </tr>
            % endif

            % if canView['fwdPerfMon']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'remote_perfmon'])}">${_('Windows Performance Monitoring')}</a></td>
                    <td class="col-2">${indexData.get('fwdPerfMon','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='perfmon_local'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Collect performance data from forwarders.')}</td>
                </tr>
            % endif

            <!--
            <tr>
                <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'win-wmi-collections'])}">${_('Remote performance monitoring')}</a></td>
                <td class="col-2">${indexData.get('wmiCount','0')}</td>
                <td class="col-3"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'win-wmi-collections', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td colspan="3" class="input_description">${_('Collect performance and event information from remote hosts. Requires domain credentials. ')}</td>
            </tr>   -->

            % if canView['fwdTcp']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'tcp', 'remote_raw'])}">${_('TCP')}</a></td>
                    <td class="col-2">${indexData.get('fwdTcp','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='tcp'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Configure a forwarder to listen on a TCP port for incoming data.')}</td>
                </tr>
            % endif

            % if canView['fwdUdp']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'remote_udp'])}">${_('UDP')}</a></td>
                    <td class="col-2">${indexData.get('fwdUdp','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='udp'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Configure a forwarder to listen on a UDP port for incoming data.')}</td>
                </tr>
            % endif

            <!--<tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'registry'])}">${_('Registry monitoring')}</a></td>
                <td class="col-2">${indexData.get('regCount','0')}</td>
                <td class="col-3"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'registry', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td colspan="3" class="input_description">${_('Have Splunk index the local Windows Registry, and monitor it for changes. ')}</td>
            </tr>

            <tr>
                <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'ad'])}">${_('Active Directory monitoring')}</a></td>
                <td class="col-2">${indexData.get('adCount','0')}</td>
                <td class="col-3"><a href="${make_url(['manager', namespace, 'data', 'inputs', 'ad', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td colspan="3" class="input_description">${_('Index and monitor Active Directory. ')}</td>
            </tr>
            -->

            % if canView['fwdScripts']:
                <tr>
                    <td class="col-1 input_name"><a href="${make_url(['manager', namespace, 'deployment', 'server', 'setup', 'data', 'inputs', 'remote_script'])}">${_('Scripts')}</a></td>
                    <td class="col-2">${indexData.get('fwdScripts','0')}</td>
                    <td class="col-3"><a href="${make_url(['manager', namespace, 'adddata', 'selectforwarders'], _qs=dict(input_type='scripts'))}">${_('Add new')}</a></td>
                </tr>
                <tr>
                    <td colspan="3" class="input_description">${_('Collect data from scripts installed on forwarders.')}</td>
                </tr>
            % endif

            % else:
            <tr>
                <td colspan="3">${_('Indexes data not returned')}</td>
            </tr>
            % endif

        </table>
    </div>

</div>
