{% extends "layouts/default_ext.html" %} 
{% block title %} Case IOC {% endblock title %} 

{% block stylesheets %}
{% include 'includes/header_case.html' %}
{% endblock stylesheets %}

{% block content %}

{% include 'includes/navigation_ext.html' %}

{% include 'includes/sidenav.html' %}
<div class="main-panel">

    <div class="content">

        {% if current_user.is_authenticated %}
        {{ form.hidden_tag() }}
         <nav class="navbar navbar-header navbar-expand-lg pt-2 pb-2 bg-case-gradient nav-sticky">
                <div class="container-fluid">
                    <div class="collapse" id="search-nav">
                        <div id="tables_button"></div>
                     </div>
					<ul class="navbar-nav topbar-nav ml-md-auto align-items-center page-navigation page-navigation-style-2 page-navigation-secondary">
                        <li class="nav-item ml-2">
                            <span class="text-white text-sm mr-2" id="last_resfresh">Loading</span>
                        </li>
                        <li class="nav-item">
                            <button class="btn btn-primary btn-sm" onclick="reload_iocs();">
                                <span class="menu-title">Refresh</span>
                            </button>
                        </li>
                        <li class="nav-item">
                            <button class="btn btn-dark btn-sm" onclick="add_ioc();">
                                <span class="menu-title">Add IOC</span>
                            </button>
                        </li>
                        <li class="nav-item">
                            <div class="dropdown">
                              <button class="btn btn-sm btn-border btn-black" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                  <span class="menu-title"><i class="fas fa-ellipsis-v"></i></span>
                              </button>
                              <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                <a class="dropdown-item" href="#" onclick="fire_upload_iocs();">Upload CSV of IOCs</a>
                              </div>
                            </div>
                        </li>
					</ul>
            </div>


        </nav>

        <div class="page-inner">
            <div class="row">
                <div class="loader1 text-center ml-mr-auto" id="loading_msg">Loading...</div>
                <div class="col-md-12">
                    <div class="card" id="card_main_load" style="display:none;">
                        <div class="card-body">
                              <table class="table display wrap col-border table-striped table-hover" width="100%" cellspacing="0" id="ioc_table" >
                                <thead>
                                  <tr>
                                      <th>Value</th>
                                      <th>Type</th>
                                      <th>Description</th>
                                      <th>Tags</th>
                                      <th>Linked cases</th>
                                      <th>TLP</th>
                                  </tr>
                                </thead>
                                <tfoot>
                                  <tr>
                                      <th>Value</th>
                                      <th>Type</th>
                                      <th>Description</th>
                                      <th>Tags</th>
                                      <th>Linked cases</th>
                                      <th>TLP</th>
                                  </tr>
                                </tfoot>
                              </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    
    </div>

    {% include 'includes/footer.html' %}
</div>
<div class="modal" tabindex="-1" role="dialog" id="modal_add_ioc" data-backdrop="true">
    <div class="modal-xl modal-dialog" role="document">
        <div class="modal-content" id="modal_add_ioc_content">

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal " tabindex="-1" role="dialog" id="modal_upload_ioc" data-backdrop="true">
  <div class="modal-lg modal-dialog" role="document">
    <form method="post" action="" id="form_upload_ioc">

      <div class="modal-content">
        <div class="modal-header">
          <h5>Upload IOC list (CSV format)</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
        </div>

        <div class="modal-body">
            <div class="form-group">
                <label for="ioc_format" class="placeholder">Expected CSV File format</label>
                <textarea class="form-control col-md-12 col-sm-12 sizable-textarea" rows="2" disabled>ioc_value,ioc_type,ioc_description,ioc_tags,ioc_tlp
&lt;Value&gt;,&lt;Type&gt;,&lt;Description&gt;,&lt;TLP&gt;,Tags separated with &quot;|&quot;</textarea>
            </div>
            <div class="form-group">
                <label class="placeholder">CSV File format example</label>
                <textarea class="form-control col-md-12 col-sm-12 sizable-textarea" rows="3" disabled>ioc_value,ioc_type,ioc_description,ioc_tags,ioc_tlp
1.1.1.1,IP,Cloudfare DNS IP address,Cloudfare|DNS,green
wannacry.exe,File,Wannacry sample found,Wannacry|Malware|PE,amber</textarea>
            </div>
              <div class="form-group">
                  <label class="placeholder">Choose CSV file to import : </label>
                  <input id="input_upload_ioc" type="file" accept="text/csv">
              </div>
        </div>
        <div class='invalid-feedback' id='ioc-invalid-msg'></div>
        <div class="modal-footer">
                <button type="button" class="btn btn-outline-dark mr-auto" onclick="generate_sample_csv();">Download sample CSV</button>
                <button type="button" class="btn btn-outline-success" onclick="upload_ioc();">Upload</button>
        </div>
      </div><!-- /.modal-content -->
    </form>
  </div><!-- /.modal-dialog -->
</div>

{% endblock content %} 

{% block javascripts %}

{% include 'includes/footer_case.html' %}
<script src="/static/assets/js/iris/case.ioc.js"></script>

{% endblock javascripts %}