Skip to content

Commit

Permalink
prepare for 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
guillain committed Jun 3, 2017
1 parent c158378 commit 2c1953b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions TechRequest/static/js/TechRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ var dashboardArray = function(val){
return buffer;
}

$(function() {
$('a#dashboardSub').bind('click', function() {
function dashboardUpdate(){
$.ajax({
url: "dashboard",
data: $('form').serialize(),
type: 'POST',
success: function(data) {
console.log(data);
var buffer="";
$.each(data, function(index, val){
if (val.length == 0) {
Expand All @@ -79,15 +77,22 @@ var dashboardArray = function(val){
$('#dashboardRes').html(dashboardArray(val));
}
});
if( (document.getElementById("timer").value != '0') && (document.getElementById("timer").value != '') ) {
setTimeout(dashboardUpdate, document.getElementById("timer").value * 1000);
}
},
error: function(error) {
console.log(error);
$("#result").text(error);
}
});
}
$(function() {
$('a#dashboardSub').bind('click', function() {
dashboardUpdate();
});
});

/* updateSub click */
$(function() {
$('a#updateSub').bind('click', function() {
Expand Down
5 changes: 5 additions & 0 deletions TechRequest/static/py/TechRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
def dashboard():
error = None
if request.method == 'POST':
# Set timer session value cming from the web
session['timer'] = request.form['timer'];
print 'timer: ' + session['timer']

# Get data according to the admin priv
if session['admin'] == '1':
sql = "SELECT 'admin', s.sid, s.name, 'list', DATE_FORMAT(s.birthday, '%Y-%m-%d'), "
sql += "DATE_FORMAT(s.timestamp, '%Y-%m-%d %H:%i'), s.severity, s.status "
Expand Down
2 changes: 1 addition & 1 deletion TechRequest/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<dashboard>
<div id="dashboardDiv" class="center">
<h2>Dashboard</h2>
<form action="dashboard" method="POST"><a href="#" id="dashboardSub" style="text-align:left;">Refresh</a></form>
<form action="dashboard" method="POST"><a href="#" id="dashboardSub" style="text-align:left;">Refresh</a> <input type="number" name="timer" id="timer" placeholder="Timer (s)" value="{{ session['timer'] or '0' }}" />(s)</form>
<ul id="dashboardRes" class="dashboard"></ul>
</div> <!-- /dashboardDiv -->
</dashboard>
Expand Down

0 comments on commit 2c1953b

Please sign in to comment.