<!--
 Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

{% extends 'base.html' %}

{% block content %}
<h1>Add New Service [ACL-IPV4]</h1>
<form method="POST" action="{{ url_for('service.add_configure_ACL_IPV4') }}">
    <fieldset>
        <div class="row mb-3">
            {{ form_acl.hidden_tag() }}
        </div> 
        <h4>Generic ACL Parameters</h4>
        {% if form_acl.acl_params is not none %}
        <div class="row mb-3">
            {{ form_acl.name.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.name.errors %}
                {{ form_acl.name(class="form-control is-invalid", placeholder="Mandatory") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.name.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.name(class="form-control", placeholder="Mandatory") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.type.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.type.errors %}
                {{ form_acl.type(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.type.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.type(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.sequence_id.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.sequence_id.errors %}
                {{ form_acl.sequence_id(class="form-control is-invalid", placeholder="Mandatory") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.sequence_id.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.sequence_id(class="form-control", placeholder="Mandatory") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.forwarding_action.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.forwarding_action.errors %}
                {{ form_acl.forwarding_action(class="form-control is-invalid", placeholder="Mandatory") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.forwarding_action.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.forwarding_action(class="form-control", placeholder="Mandatory") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.log_action.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.log_action.errors %}
                {{ form_acl.log_action(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.log_action.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.log_action(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.traffic_flow.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.traffic_flow.errors %}
                {{ form_acl.traffic_flow(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.traffic_flow.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.traffic_flow(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.interface.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.interface.errors %}
                {{ form_acl.interface(class="form-control is-invalid", placeholder="Mandatory") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.interface.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.interface(class="form-control", placeholder="Mandatory") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.subinterface.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.subinterface.errors %}
                {{ form_acl.subinterface(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.subinterface.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.subinterface(class="form-control") }}
                {% endif %}
            </div>
        </div>
        </br>
        <h4>Specific ACL_IPV4 Parameters</h4>
        <div class="row mb-3">
            {{ form_acl.source_address.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.source_address.errors %}
                {{ form_acl.source_address(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.source_address.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.source_address(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.destination_address.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.destination_address.errors %}
                {{ form_acl.destination_address(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.destination_address.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.destination_address(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.protocol.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.protocol.errors %}
                {{ form_acl.protocol(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.protocol.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.protocol(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.hop_limit.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.hop_limit.errors %}
                {{ form_acl.hop_limit(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.hop_limit.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.hop_limit(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.dscp.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.dscp.errors %}
                {{ form_acl.dscp(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.dscp.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.dscp(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.source_port.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.source_port.errors %}
                {{ form_acl.source_port(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.source_port.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.source_port(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.destination_port.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.destination_port.errors %}
                {{ form_acl.destination_port(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.destination_port.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.destination_port(class="form-control") }}
                {% endif %}
            </div>
        </div>
        <div class="row mb-3">
            {{ form_acl.tcp_flags.label(class="col-sm-2 col-form-label") }}
            <div class="col-sm-10">
                {% if form_acl.tcp_flags.errors %}
                {{ form_acl.tcp_flags(class="form-control is-invalid") }}
                <div class="invalid-feedback">
                    {% for error in form_acl.tcp_flags.errors %}
                    <span>{{ error }}</span>
                    {% endfor %}
                </div>
                {% else %}
                {{ form_acl.tcp_flags(class="form-control") }}
                {% endif %}
            </div>
        </div>
        {% endif %}
        <button type="submit" class="btn btn-primary">
            <i class="bi bi-plus-circle-fill"></i>
            {{ submit_text }}
        </button>
        <button type="button" class="btn btn-block btn-secondary" onclick="javascript: history.back()">
            <i class="bi bi-box-arrow-in-left"></i>
            Cancel
        </button>
    </fieldset>
    </form>
    {% endblock %}
