{% include 'header.html' %}
<!-- Begin Page Content -->
<div class="container-fluid">

    <!-- Page Heading -->
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0" style="color: #2b5876; font-weight: bold;">Labeling</h1>
    </div>

    <!-- Content Row -->
    <div class="row">
        <div class="col-sm-12">
            <!-- Upload & Labeling Section -->
            <div class="card shadow mb-4">
                <div class="card-header py-3" style="background-color: #4e4376;">
                    <h6 class="m-0 font-weight-bold text-white">
                        <i class="fas fa-tags mr-2"></i> Labeling Data Tweet
                    </h6>
                </div>
                <div class="card-body">
                    <form method="post" action="" enctype="multipart/form-data">
                        <div class="form-group">
                            <label for="exampleFormControlFile1"><strong>Upload File</strong></label>
                            <input type="file" name="file" class="form-control-file" id="exampleFormControlFile1">
                            <small class="form-text text-muted">Upload file hasil preprocessing dengan format .csv</small>

                            {% with messages = get_flashed_messages(category_filter=["upload_gagal"]) %}
                                {% if messages %}
                                <small class="form-text text-danger">{{ messages[0] }}</small>
                                {% endif %}
                            {% endwith %}

                            {% with messages = get_flashed_messages(category_filter=["upload_berhasil"]) %}
                                {% if messages %}
                                <small class="form-text text-success">{{ messages[0] }}</small>
                                {% endif %}
                            {% endwith %}

                            {% with messages = get_flashed_messages(category_filter=["labeling_data"]) %}
                                {% if messages %}
                                <small class="form-text text-success">{{ messages[0] }}</small>
                                {% endif %}
                            {% endwith %}
                        </div>
                        <input type="submit" value="Upload Data" name="upload" class="btn btn-success mr-2">
                        <input type="submit" value="Labeling Data" name="labeling" class="btn btn-success">
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- DataTable Section -->
    <div class="card shadow mb-4">
        <div class="card-header py-3" style="background-color: #4e4376;">
            <h6 class="m-0 font-weight-bold text-white">
                <i class="fas fa-table mr-2"></i> Hasil Labeling
                <a href="{{ url_for('static', filename='files/Data Labeling.csv') }}" target="_blank"
                    class="btn btn-sm btn-warning float-right shadow-sm">
                    <i class="fas fa-download fa-sm text-white-50"></i> Download Data
                </a>
            </h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped" id="dataTable" width="100%" cellspacing="0">
                    <thead class="thead-light">
                        <tr>
                            <th>No</th>
                            <th>Username</th>
                            <th>Tweet Bersih</th>
                            <th>Translate</th>
                            <th>Hasil Labeling</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% set count = namespace(value=1) %}
                        {% for item in value %}
                        <tr>
                            <td>{{ count.value }}</td>
                            <td>{{ item[1] }}</td> <!-- Username -->
                            <td>{{ item[3] }}</td> <!-- Tweet Bersih -->
                            <td>{{ item[4] }}</td> <!-- Translate -->
                            <td>{{ item[5] }}</td> <!-- Hasil Labeling -->
                        </tr>
                        {% set count.value = count.value + 1 %}
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>
<!-- /.container-fluid -->
{% include 'footer.html' %}
