list_jobs.html 10.1 KB
Newer Older
1
{% extends 'base.html' %}
2 3 4 5 6
{% load static %}

{% block style %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
7
<link rel="stylesheet" href="{% static 'css/atom-one-dark.css' %}">
8 9 10 11 12 13 14 15
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
<link rel="stylesheet" href="{% static 'css/font-awesome.min.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
{% endblock %}

{% block title %}
<title>Job</title>
{% endblock %}
16 17

{% block content %}
18
{% csrf_token %}
19 20 21
<div class="loading">
    <div class="loading-content"><i class="fa fa-refresh fa-spin"></i></div>
</div>
22 23 24 25 26
<div class="container-fluid container-max">
    <!-- START: Table pending -->
    <div class="table-item">
        <div class="table-header">
            <div class="table-title">Pending</div>
27 28 29
            {% if user.is_authenticated %}
                <a href="{% url 'new_job' %}" class="table-button btn btn-primary">New Job</a>
            {% endif %}
30 31 32 33 34
        </div>
        <div class="table-wrap">
            <table data-table="pending" class="table table-sm table-custom">
                <thead class="thead-inverse">
                <th>Job</th>
35
                <th>Spider</th>
36 37 38 39 40
                <th>Created date</th>
                <th>Status</th>
                <th style="width: 250px">Actions</th>
                </thead>
                <tbody>
41
                <!-- Line 1 -->
42
                {% for i in jobs.pending %}
43 44
                <tr id="{{ i.pk }}">
                    <td data-col="job">{{ i.name }}</td>
45
                    <td data-col="spider">{{ i.spider }}</td>
46
                    <td data-col="created-date">{{ i.create_time|date:"d.m.Y" }} {{ i.create_time|time:"H:i" }}</td>
47 48
                    <td data-col="status" class="text-success">{{ i.status }}</td>
                    <td data-col="action">
49
                        {% if user.is_authenticated %}
50 51 52 53 54 55
                        <button class="btn btn-sm btn-primary" data-loading="loading" data-action="run"
                                data-loading-text="Running..." data-text="Run">Run
                        </button>
                        <button class="btn btn-sm btn-danger" data-action="delete" data-loading-text="Deleting..."
                                data-text="Delete">Delete
                        </button>
56
                        <a class="btn btn-sm btn-secondary" href="{% url 'edit_job' i.id %}" >
57
                            <i class="fa fa-cog" aria-hidden="true"></i>
58
                        </a>
59
                        {% endif %}
60 61
                    </td>
                </tr>
62 63 64 65
                {% endfor %}
                </tbody>
            </table>
        </div>
66
    </div>
67 68 69 70 71 72 73 74 75 76
    <!-- END: Table pending -->
    <!-- START: Table Running -->
    <div class="table-item">
        <div class="table-header">
            <div class="table-title">Running</div>
        </div>
        <div class="table-wrap">
            <table data-table="running" class="table table-sm table-custom">
                <thead class="thead-inverse">
                <th>Job</th>
77
                <th>Spider</th>
78 79 80
                <th>Created date</th>
                <th>Start date</th>
                <th>Status</th>
81
                <th>Log</th>
82 83 84 85 86
                <th style="width: 250px">Actions</th>
                </thead>
                <tbody>
                <!-- Line 1 -->
                {% for i in jobs.running %}
87 88
                <tr id="{{ i.pk }}">
                    <td data-col="job">{{ i.name }}</td>
89
                    <td data-col="spider">{{ i.spider }}</td>
90 91
                    <td data-col="created-date">{{ i.create_time|date:"d.m.Y" }} {{ i.create_time|time:"H:i" }}</td>
                    <td data-col="start-date">{{ i.start_time|date:"d.m.Y" }} {{ i.start_time|time:"H:i"}}</td>
92 93
                    <td data-col="status" class="text-success">{{ i.status }}</td>
                    <td data-col="log">
94
                        <a class="btn btn-sm btn-secondary" href="?action=log&id={{ i.pk }}">Get log</a>
95 96
                    </td>
                    <td data-col="action">
97
                        {% if user.is_authenticated %}
98 99 100 101 102 103
                        <button class="btn btn-sm btn-primary" data-action="cancel" data-loading-text="Cancelling..."
                                data-text="Cancel">Cancel
                        </button>
                        <button class="btn btn-sm btn-danger" data-action="delete" data-loading-text="Deleting..."
                                data-text="Delete">Delete
                        </button>
104
                        {% endif %}
105 106
                    </td>
                </tr>
107 108 109 110
                {% endfor %}
                </tbody>
            </table>
        </div>
111
    </div>
112 113 114 115 116
    <!-- END: Table Running -->
    <!-- START: Table Finished -->
    <div class="table-item">
        <div class="table-header">
            <div class="table-title">Finished</div>
117

118 119 120 121 122
        </div>
        <div class="table-wrap">
            <table data-table="finished" class="table table-sm table-custom">
                <thead class="thead-inverse">
                <th>Job</th>
123
                <th>Spider</th>
124 125
                <th>Created date</th>
                <th>Started date</th>
126
                <th>Finished date</th>
127 128 129 130 131 132 133
                <th>Status</th>
                <th>Log</th>
                <th style="width: 250px">Actions</th>
                </thead>
                <tbody>
                <!-- Line 1 -->
                {% for i in jobs.finished %}
134 135
                <tr id="{{ i.pk }}">
                    <td data-col="job">{{ i.name }}</td>
136
                    <td data-col="spider">{{ i.spider }}</td>
137 138
                    <td data-col="created-date">{{ i.create_time|date:"d.m.Y" }} {{ i.create_time|time:"H:i" }}</td>
                    <td data-col="start-date">{{ i.start_time|date:"d.m.Y" }} {{ i.start_time|time:"H:i"}}</td>
139
                    <td data-col="finished-date">{{ i.end_time|date:"d.m.Y" }} {{ i.end_time|time:"H:i" }}</td>
140 141
                    <td data-col="status" class="text-success">{{ i.status }}</td>
                    <td data-col="log">
142
                        <a class="btn btn-sm btn-secondary" href="?action=log&id={{ i.pk }}">Get log</a>
143 144
                    </td>
                    <td data-col="action">
145
                        {% if user.is_authenticated %}
146 147 148 149 150 151
                        <button class="btn btn-sm btn-primary" data-action="restart" data-loading-text="Restarting..."
                                data-text="Restart">Restart
                        </button>
                        <button class="btn btn-sm btn-danger" data-action="delete" data-loading-text="Deleting..."
                                data-text="Delete">Delete
                        </button>
152
                        {% endif %}
153 154
                    </td>
                </tr>
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    <!-- END: Table finished -->
    <!-- START: Table deleted -->
    <div class="table-item">
        <div class="table-header">
            <div class="table-title">Deleted</div>
        </div>
        <div class="table-wrap">
            <table data-table="deleted" class="table table-sm table-custom">
                <thead class="thead-inverse">
                <th>Job</th>
170
                <th>Spider</th>
171 172 173 174 175 176 177 178 179 180
                <th>Created date</th>
                <th>Started date</th>
                <th style="width: 200px;">Finished date</th>
                <th>Status</th>
                <th>Log</th>
                <th style="width: 250px">Actions</th>
                </thead>
                <tbody>
                <!-- Line 1 -->
                {% for i in jobs.deleted %}
181 182
                <tr id="{{ i.pk }}">
                    <td data-col="job">{{ i.name }}</td>
183
                    <td data-col="spider">{{ i.spider }}</td>
184 185
                    <td data-col="created-date">{{ i.create_time|date:"d.m.Y" }} {{ i.create_time|time:"H:i" }}</td>
                    <td data-col="start-date">{{ i.start_time|date:"d.m.Y" }} {{ i.start_time|time:"H:i"}}</td>
186
                    <td data-col="finished-date">{{ i.end_time|date:"d.m.Y" }} {{ i.end_time|time:"H:i" }}</td>
187 188
                    <td data-col="status" class="text-success">{{ i.status }}</td>
                    <td data-col="log">
189
                        <a class="btn btn-sm btn-secondary" href="?action=log&id={{ i.pk }}">Get log</a>
190 191
                    </td>
                    <td data-col="action">
192
                        {% if user.is_authenticated %}
193 194 195
                        <button class="btn btn-sm btn-success" data-action='activate' data-loading-text="Activating..."
                                data-text="Activate">Activate
                        </button>
196
                        {% endif %}
197 198
                    </td>
                </tr>
199 200 201 202 203 204
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    <!-- END: Table deleted -->
205 206
    <div class="modal" id="log-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle"
         aria-hidden="true">
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
207
        <div class="modal-dialog" role="document">
208
            <div class="modal-content">
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
209 210
                <div class="modal-body">
                    <button type="button" class="close modal-close" data-dismiss="modal" aria-label="Close">
211 212
                        <span aria-hidden="true">&times;</span>
                    </button>
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
213 214 215
                    <pre><code class="js">

</code></pre>
216 217 218 219
                </div>
            </div>
        </div>
    </div>
220 221
</div>
{% endblock %}
222

223
{% block script %}
224 225 226
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"
        integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
        crossorigin="anonymous"></script>
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
227
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
228
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.2/axios.min.js"></script>
Vasyl Bodnaruk's avatar
Vasyl Bodnaruk committed
229
<script src="{% static 'js/highlight.pack.js' %}"></script>
230 231
<script src="{% static 'js/dateformat.js' %}"></script>
<script src="{% static 'js/tables.js' %}"></script>
232
{% endblock %}