{#
    (C) 2020 - ntop.org

    This is the template for the manage configurations page.
#}

<div class="row">
    <div class="col-md-12">
        <div class="card card-shadow">
            <div class="card-body">
                <div class="radio-list">
                    {% for key, config in pairsByField(manage_configurations.configuration_items, 'order', asc) do %}
                        <div class="form-check">
                            <input class="form-check-input" {{ (config.key == manage_configurations.selected_item and 'checked' or '') }}
                                type="radio" name="configuration" id="{{key}}-radio"
                                value="{{config.key}}">
                            <label class="form-check-label" for="{{key}}-radio">
                                {{config.label}}
                            </label>
                        </div>
                        {% if key == 'all' then %} <hr> {% end %}
                    {% end %}
                </div>
            </div>
            <div class="card-footer">
                <button id="btn-import" data-toggle="modal" data-target="#import-modal" type="submit" value="import" class="btn btn-primary">
                    <i class='fas fa-file-import'></i>
                    <span>{{ i18n("import") }}</span>
                </button>
                <a id="btn-export" download="{{ manage_configurations.selected_item }}_config.json" class="btn btn-primary" href="{{ ntop.getHttpPrefix() }}/lua/rest/v1/export/{{ manage_configurations.selected_item }}/config.lua?download=1">
                    <i class='fas fa-file-export'></i>
                    <span>{{ i18n("export") }}</span>
                </a>
                <button id="btn-factory-reset" data-target='#reset-modal' data-toggle="modal" class="btn btn-danger">
                    <i class="fas fa-undo-alt"></i> {{ i18n("factory_reset")}}
                </button>
            </div>
        </div>
    </div>
</div>

{*
    template_utils.gen("pages/modals/scripts_config/import_modal.html", {
        dialog={
            id      = "import-modal",
            title   = i18n("manage_configurations.import_modal.title", {import_element = manage_configurations.configuration_items[manage_configurations.selected_item].label}),
            label   = "",
            message = i18n("host_pools.config_import_message"),
            cancel  = i18n("cancel"),
            apply   = i18n("apply"),
        }
      })
*}

{*
    template_utils.gen("modal_confirm_dialog.html", {
        dialog={
            id = "reset-modal",
            message = i18n('manage_configurations.factory_reset.body', {
                reset_element = manage_configurations.configuration_items[manage_configurations.selected_item].label
            }),
            title = i18n("manage_configurations.factory_reset.title", {
                reset_element = manage_configurations.configuration_items[manage_configurations.selected_item].label
            }),
            confirm = i18n("factory_reset"),
            custom_alert_class = 'alert alert-danger',
            confirm_button = 'btn-danger'
        }
    })
*}

<script type="text/javascript">

    const importCSRF = "{{ ntop.getRandomCSRFValue() }}";

    i18n.import = "{{ i18n('import') }}";
    i18n.export = "{{ i18n('export') }}";
    i18n.invalid_file = "{{ i18n('invalid_file') }}"

    i18n.success = "{{ i18n('success') }}";
    i18n.failure = "{{ i18n('failure') }}";

    i18n.manage_configurations = { messagges: {}};

    i18n.manage_configurations.messagges.reset_success = "{{ i18n('manage_configurations.messages.reset_success') }}";
    i18n.manage_configurations.messagges.reset_all_success = "{* i18n('manage_configurations.messages.reset_all_success', {product=info.product})  *}";
    i18n.manage_configurations.messagges.import_success = "{{ i18n('manage_configurations.messages.import_success') }}";

</script>
<script type="text/javascript" src="{{ ntop.getHttpPrefix() }}/js/pages/manage-configurations.js"></script>