{% extends "layouts/default.html" %}

{% block title %} Manage Modules {% endblock title %}

{% block stylesheets %}
<link rel="stylesheet" href="/static/assets/css/suggestags.css">
<link rel="stylesheet" href="/static/assets/css/dataTables.group.min.css">
{% endblock stylesheets %}

{% block content %}

{% if current_user.is_authenticated %}
<div class="page-inner">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <div class="row">
                        <div class="col">
                            <div class="card-title">Modules management</div>
                            {{ form.hidden_tag() }}
                        </div>
                        <div class="col">
                            <button type="button" class="btn btn-sm btn-dark float-right ml-2" onclick="refresh_modules();">
                                Refresh
                            </button>
                            <button class="btn btn-sm btn-dark float-right ml-2" onclick="add_module();">Add module</button>
                        </div>
                    </div>
                </div>
                <div class="card-body">

                    <div class="table-responsive" id="module_table_wrapper">
                        <div class="selectgroup">
                            <span id="table_buttons"></span>
                        </div>
                        <table class="table display table table-striped table-hover" width="100%"
                            cellspacing="0" id="modules_table">
                            <thead>
                                <tr>
                                    <th>#ID</th>
                                    <th>Module name</th>
                                    <th>Has pipeline</th>
                                    <th>Module version</th>
                                    <th>Interface version</th>
                                    <th>Date added</th>
                                    <th>Added by</th>
                                    <th>Active</th>
                                </tr>
                            </thead>
                            <tfoot>
                                <tr>
                                    <th>#ID</th>
                                    <th>Module name</th>
                                    <th>Has pipeline</th>
                                    <th>Module version</th>
                                    <th>Interface version</th>
                                    <th>Date added</th>
                                    <th>Added by</th>
                                    <th>Active</th>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <div class="row">
                        <div class="col">
                            <div class="card-title">Registered hooks</div>
                        </div>
                        <div class="col">
                            <button type="button" class="btn btn-sm btn-icon btn-round btn-outline-black float-right" onclick="refresh_modules_hooks();">
                                <i class="fas fa-sync rotate"></i>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="card-body">

                    <div class="table-responsive" id="hooks_table_wrapper">
                        <div class="selectgroup">
                            <span id="table_buttons"></span>
                        </div>
                        <table class="table display table table-striped table-hover" width="100%"
                            cellspacing="0" id="hooks_table">
                            <thead>
                                <tr>
                                    <th>#ID</th>
                                    <th>Registrant module</th>
                                    <th>Hook name</th>
                                    <th>Hook description</th>
                                    <th>Automatic trigger</th>
                                    <th>Active</th>
                                </tr>
                            </thead>
                            <tfoot>
                                <tr>
                                    <th>#ID</th>
                                    <th>Registrant module</th>
                                    <th>Hook name</th>
                                    <th>Hook description</th>
                                    <th>Automatic trigger</th>
                                    <th>Active</th>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal" tabindex="-1" role="dialog" id="modal_add_module" data-backdrop="true">
        <div class="modal-xl modal-dialog modal-dialog-scrollable" role="document">
            <div class="modal-content" id="modal_add_module_content">

            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <div class="modal bg-shadow-gradient" tabindex="-1" role="dialog" id="modal_update_param" data-backdrop="true">
        <div class="modal-xl modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
            <div class="modal-content shadow-lg p-3 mb-5 rounded" id="modal_update_param_content">

            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
</div>
    {% endif %}

    {% endblock content %}

    {% block javascripts %}
    <script src="/static/assets/js/plugin/ace/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/assets/js/plugin/ace/src-noconflict/ext-language_tools.js" type="text/javascript"
        charset="utf-8"></script>
    <script src="/static/assets/js/plugin/datatables/dataTables.group.min.js"></script>
    <script src="/static/assets/js/iris/manage.modules.js"></script>
    {% endblock javascripts %}