<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <label>Name:</label>
        <input value="{{spider.name}}" />
    </div>
    <div>
        <label>Triggers:</label>
        <table>
            {% for trigger in spider.triggers %}
                <tr>
                    <td>{{trigger.cron_pattern}}</td>
                </tr>
            {% end %}
        </table>
        <div><a href="/projects/{{spider.project.name}}/spiders/{{spider.name}}/triggers">Create Trigger</a>
        <a href="/spiders">Back</a></div>
    </div>
    {% if webhook %}
        <div>
            <label>Webhook:</label>
            <div><pre>{{ webhook.payload_url }}</pre></div>
        </div>
    {% end %}
    <div>
        <label>Jobs:</label>
        <table border="1">
            <tr>
                <th>JobID</th>
                <th>Start At</th>
                <th>Duration</th>
                <th>Log</th>
                <th>Status</th>
            </tr>
            {% for job in jobs %}
                <tr>
                    <td>{{job.id}}</td>
                    <td>{{job.start_time}}</td>
                    <td>{{job.complete_time-job.start_time}}</td>
                    <td><a href="/logs/{{job.project_name}}/{{job.spider_name}}/{{job.id}}.log">Log</a></td>
                    {% if job.status == 2 %}
                        <td style="background-color:green; color:#fff">SUCCESS</td>
                    {% else %}
                        <td style="background-color:red; color:#fff">FAIL</td>
                    {% end %}
                </tr>
            {% end %}
        </table>
    </div>
</body>
</html>