Skip to content

Commit

Permalink
Add Jquery lib nos templates #22
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed Nov 26, 2020
1 parent 82e6337 commit abdede6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
8 changes: 8 additions & 0 deletions tasktracking/tasks/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ a:hover {
float: left;
}

.fas.fa-pause {
color: #be630d;
cursor: pointer;
margin: 5px;
font-size: 20px;
float: left;
}

.fas.fa-stop {
color: #db1e47;
cursor: pointer;
Expand Down
14 changes: 13 additions & 1 deletion tasktracking/tasks/static/js/crom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ var tempo = 1000;
var cron;


function start() {
function start(tarefa_pk) {
cron = setInterval(() => { timer(); }, tempo);
console.log('Execução da Tarefa ' + tarefa_pk + ' cadastrada!');

$.ajax({ // initialize an AJAX request
url: 'http://localhost:8000/cadastrar_execucao', // set the url of the request (= localhost:8000/hr/ajax/load-cities/)
data: {
'tarefa_pk': tarefa_pk // add the country id to the GET parameters
},
success: function (data) {
console.log('Ajax: Execução da Tarefa ' + tarefa_pk + ' cadastrada!');
}
});

}
function pause() {
clearInterval(cron);
Expand Down
2 changes: 2 additions & 0 deletions tasktracking/tasks/static/js/jquery-3.5.1.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tasktracking/tasks/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
<p>Copyright &copy; 2020 - by Turma de Pweb 2020.6</br></p>
</footer>
</div>

<script src="{% static 'js/jquery-3.5.1.min.js' %}"></script>
{% block myscripts %}{% endblock myscripts %}
</body>
</html>
13 changes: 9 additions & 4 deletions tasktracking/tasks/templates/tasks/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load static %}

{% block titulo %}
<title>PWeb 2020.6 - Index</title>
Expand All @@ -24,24 +25,28 @@
<ul class="task-list">
{% for tarefa in lista_tarefas %}
<li class="task-item">
<span><i class="fas fa-play"></i></span>
<span><i class="fas fa-stop"></i></span>
<span><i class="fas fa-play" onclick="start('{{ tarefa.pk }}')"></i></span>
<span><i class="fas fa-pause" onclick="pause()"></i></span>
<span><i class="fas fa-stop" onclick="stop()"></i></span>
<span>&nbsp;</span>
<a href="{% url 'detalhar_tarefa' tarefa.pk %}"
<span>{{ tarefa }}</span>
</a>
<span>00:00:00</span>
<div id="counter" class="d-inline">00:00:00</div>
<div class="tag_text">
{% for tag in tarefa.tag_set.all %}
{{ tag }}<span>&nbsp;</span>
{% endfor %}
</div>
<input />
<span>00:00:00</span>
<span><i class="fas fa-trash"></i></span>
<span><i class="fas fa-edit"></i></span>
</li>
{% endfor %}
</ul>
</div>
{% endblock%}

{% block myscripts %}
<script src="{% static 'js/crom.js' %}"></script>
{% endblock myscripts %}

0 comments on commit abdede6

Please sign in to comment.