{% extends "settings_page.html" %}

{% block header_script_files %}
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
{% endblock %}

{% block settings_pane %}
<div class="d-grid w-100 bg-mine m-0 p-0 sticky-top shadow">
    <div class="row w-100 m-0 p-3">
        <div class="col-sm-12 col-md-6 text-center text-md-start text-white ">
            <h2>Tasks</h2>
        </div>
        <div class="col-sm-12 col-md-6 text-center text-md-end">
            <button type="button" class="btn btn-info" data-bs-toggle="modal" data-bs-target="#settingsModal">Modify Settings</button>
        </div>
    </div>
</div>
<div class="d-grid w-100 m-0 p-0">
    <div class="row w-100 m-0 p-3">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th scope="col">TASK</th>
                    <th scope="col"></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <th scope="row">Update New Releases</th><td><i class="fas fa-play"></i></td>
                </tr>
                <tr>
                    <th scope="row">Update New Release Subscriptions</th><td><i class="fas fa-play"></i></td>
                </tr>
                <tr>
                    <th scope="row">Clean Database</th><td><i class="fas fa-play"></i></td>
                </tr>
                <tr>
                    <th scope="row">Restart Server</th><td><a onclick="restartServer()"><i class="fas fa-play"></i></a></td>
                </tr>
                {{ emit_tep('settings_page_tasks_task') }}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}

{% block script %}

function restartServer() {
    axios.post('{{ url_for('api.restart_server') }}')
        .then(res=>{
            console.log(res)
            stashrToast('Restarting Server', 'info')
        })
        .catch()
}

{% endblock %}