{% extends app['twig_theme'] ~ '/' ~ 'layout.twig' %}
{% import  app['twig_theme'] ~ '/macro/iptw_macro.twig' as main_macro %}

{% set title = 'Storage'|trans ~ ': ' ~ 'storages list'|trans %}


{% block footer_js %}
    
        {{ parent() }}
        {% include app.twig_theme ~ "/basic_templates/scripts-datatables.twig" %}
        {% include app.twig_theme ~ "/basic_templates/scripts-select2.twig" %}

        <script src="{{app.request_context.baseUrl}}/plugins/datatables/extensions/FixedHeader/js/dataTables.fixedHeader.js"></script>
        <link  href="{{app.request_context.baseUrl}}/plugins/datatables/extensions/FixedHeader/css/fixedHeader.dataTables.css" rel="stylesheet">

{% endblock %}
{% block footer %}

        {{ parent() }}
        <script type="text/javascript" src="./js/jquery.tmpl.min.js" defer=""></script>
        <script type="text/javascript" defer>
            {% include app.twig_theme ~ "/Storages/storages_list/storages_list.js.twig" %}
        </script>

{% endblock %}


{% block content %}
    <div id="iptv_list">
        <div class="row  filters-actions-pannel">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class=" pull-right">
                    <a href="{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/add-storage" class="btn btn-action pull-right no_context_menu" id="add_storage"><i class="fa fa-plus"></i>{{ 'Add storage'|trans }}</a>
                </div>
                <div class="pull-right">
                    <a href="{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/reset-cache" class="btn btn-action  pull-right main_ajax no_context_menu" data-id="all"><i class="fa fa-times"></i>{{ 'Clean the cache'|trans }}</a>
                </div>
                <div class="pull-right">
                    <a href="{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/refresh-cache" class="btn btn-action pull-right main_ajax no_context_menu" data-id="all"><i class="fa fa-refresh"></i>{{ 'Update the cache'|trans }}</a>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="auto-height">
                    <div class="box-name">
                        <div class="row">
                            <div class="col-xs-10 col-sm-8 col-sm-offset-2 text-center bg-warning">
                                <span class="text_black">{{ 'Clean the cache – remove all content from cache'|trans }}</span>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-10 col-sm-8 col-sm-offset-2 text-center bg-warning">
                                <span class="text_black">{{ 'Update the cache – receive new information about all content in the storage'|trans }}</span>
                            </div>
                        </div>
                    </div>
                    <div class="no-move"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="box">
                {% if attribute(app, 'dropdownAttribute') is defined %}
                    {{ main_macro.get_dropdown_attribute(app['dropdownAttribute']) }}
                {% endif %}
                <div class="box-content">
                    <div class="box-content no-padding">
                        <div class="dataTables_processing"></div>
                        <table class="table  table-hover table-datatable" id="datatable-1">
                            {% if attribute(app, 'dropdownAttribute') is defined %}
                                {{ main_macro.get_datatable_head(app['dropdownAttribute']) }}
                            {% endif %}
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/template" id="save_storage_form" >
        <form class="form-horizontal" role="form" action="{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/save-storage" id="modal_form">
            <div class="box">
                <a class="collapse-link">
                    <div class="box-header">
                        <div class="box-name">
                            <div class="row">
                                <div class="col-xs-10 col-sm-4">
                                    <span>{{ 'General information'|trans }}</span>
                                </div>
                            </div>
                        </div>
                        <div class="box-icons">
                            <i class="fa fa-chevron-up"></i>
                        </div>
                        <div class="no-move"></div>
                    </div>
                </a>
                <div class="box-content">
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Title'|trans }}<span class="icon-required">*</span></label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="hidden" title="" value="${id}" name="form[id]">
                                <input class="form-control with-error-space" type="text" title="" data-validation="required" value="${storage_name}" name="form[storage_name]" {{ "{{if storage_name}}" }}readonly="readonly"{{ "{{/if}}" }}>
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small default">
                                    {{ "{{if storage_name}}" }}
                                        {{ 'Changing the name of the storage can lead to critical consequences. To use a storage with a different name, create a new storage.'|trans }}
                                    {{ "{{else}}" }}
                                        {{ 'You can use letters, digits and symbols from the list: ! @ # $ % ^ & * ( ) _ - + : ; , .'|trans }}
                                    {{ "{{/if}}" }}
                                </span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'IP'|trans }}<span class="icon-required">*</span></label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control with-error-space" type="text" title="" data-validation="required,custom" data-validation-regexp="^(?:(?!\:\/\/).)+$" value="${storage_ip}" name="form[storage_ip]">
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'IP-address of the storage. Example : 127.0.0.1'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Apache port'|trans }}<span class="icon-required">*</span></label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control with-error-space" type="text" title="" data-validation="required,number" placeholder="88" value="${apache_port}" name="form[apache_port]">
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Number of the port, accessing to the Apache server'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Home directory'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="text" title="" value="${nfs_home_path}" name="form[nfs_home_path]">
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Home directory where the catalogues and symbol links will be created Example: /home/username/slash_folder'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Maximum of the users'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="text" title="" value="${max_online}" name="form[max_online]">
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Maximum quantity of the users, which can watching the content from the storage at the same time'|trans }}</span>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box">
                <a class="collapse-link">
                    <div class="box-header">
                        <div class="box-name">
                            <div class="row">
                                <div class="col-xs-10 col-sm-4">
                                    <span>{{ 'Additional information'|trans }}</span>
                                </div>
                            </div>
                        </div>
                        <div class="box-icons">
                            <i class="fa fa-chevron-up"></i>
                        </div>
                        <div class="no-move"></div>
                    </div>
                </a>
                <div class="box-content" id="additional_information">
                    <div class="row"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Storing content'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="form_for_simple_storage" name="form[for_simple_storage]" {{ "{{if for_simple_storage}}" }}checked="checked"{{ "{{/if}}" }}>
                                        <i class="fa fa-square-o small"></i>
                                    </label>
                                </div>
                            </div>
                            {#<span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Content storage'|trans }}</span>
                            </span>#}
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Allow TV recording'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <select class="populate placeholder own_field" name="form[dvr_type]" id="form_dvr_type">
                                    {% if app['dvrType'] %}
                                        {% for key, title in app.dvrType %}
                                            <option value="{{ key }}">{{ title }}</option>
                                        {% endfor %}
                                    {% endif %}
                                </select>
                            </div>
                            {#<span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Allow TV recording'|trans }}</span>
                            </span>#}
                        </div>
                    </div>

                    <div class="form-group" style="display:  {{ "{{if dvr_type}}" }}block{{ "{{else}}" }}none{{ "{{/if}}" }}">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Emulation'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="form_fake_tv_archive" name="form[fake_tv_archive]" {{ "{{if dvr_type}}" }}{{ "{{if fake_tv_archive}}" }}checked="checked"{{ "{{/if}}" }}{{ "{{/if}}" }}>
                                        <i class="fa fa-square-o small"></i>
                                    </label>
                                </div>
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'The emulation mode is used in case when two portals are attached to a single storage of TV archive. It is necessary to set the recording of TV archive at the first portal, and TV archive recording with the option of emulation at the second one. Thus, there will be two portals with the archive, though in fact it is recorded once.'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Stream server'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <select id="form_stream_server_type" name="form[stream_server_type]" class="populate placeholder own_fields">
                                    <option value="">&nbsp;</option>
                                    <option value="flussonic">Flussonic</option>
                                    <option value="wowza">Wowza</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" style="display:  {{ "{{if stream_server_type}}" }}block{{ "{{else}}" }}none{{ "{{/if}}" }}">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Stream server port'|trans }}<span class="icon-required">*</span></label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="text" title="" data-validation="required,number" data-validation-depends-on="form[stream_server_type]" value="${stream_server_port}" placeholder="1935" id="form_stream_server_port" name="form[stream_server_port]">
                            </div>
                        </div>
                    </div>
                    <div class="form-group" style="display:  {{ "{{if stream_server_type}}" }}block{{ "{{else}}" }}none{{ "{{/if}}" }}">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Stream server App'|trans }}<span class="icon-required">*</span></label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="text" title="" data-validation="required" data-validation-depends-on="form[stream_server_type]" value="${stream_server_app}" id="form_stream_server_app" name="form[stream_server_app]">
                            </div>
                        </div>
                    </div>
                    <hr>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Filter'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-12">
                                <input class="form-control" type="text" title="" value="${user_agent_filter}" name="form[user_agent_filter]">
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'You can filter the STBs according to their connection type (Wi-Fi, Ethernet) and to the models (250,275…). Field is case sensitive'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Access restriction'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-2">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="form_for_moderator" name="form[for_moderator]" name="form[for_moderator]" {{ "{{if for_moderator}}" }}checked="checked"{{ "{{/if}}" }}>
                                        <i class="fa fa-square-o small"></i>
                                    </label>
                                </div>
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Only moderators can watch the content from the storage'|trans }}</span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label col-sm-offset-1">{{ 'Not available for the MAG100'|trans }}</label>
                        <div class="col-xs-10 col-sm-8">
                            <div class=" col-xs-10 col-sm-2">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="form_not_for_mag100" name="form[not_for_mag100]" {{ "{{if not_for_mag100}}" }}checked="checked"{{ "{{/if}}" }}>
                                        <i class="fa fa-square-o small"></i>
                                    </label>
                                </div>
                            </div>
                            <span class="help-inline col-xs-12 col-sm-12">
                                <span class="small txt-default">{{ 'Storage is not available on the MAG100'|trans }}</span>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </script>

    <script type="text/template" id="save_storage_form_button" >
        <div class="col-xs-12">
            <button form="modal_form" type="submit" class="btn btn-success col-sm-2 pull-right" id="save_button">{{ 'Save'|trans }}</button>
            <button form="modal_form" type="reset"  class="btn btn-default col-sm-2 pull-right">{{ 'Cancel'|trans }}</button>
        </div>
    </script>
{% endblock %}