Changed history display method
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -26,13 +26,13 @@ def index():
|
|||||||
@app.route('/status')
|
@app.route('/status')
|
||||||
@requires_auth
|
@requires_auth
|
||||||
def somehtml():
|
def somehtml():
|
||||||
history = []
|
#history = []
|
||||||
with open('history.json', 'r') as json_data:
|
#with open('history.json', 'r') as json_data:
|
||||||
history = json.load(json_data)
|
# history = json.load(json_data)
|
||||||
history = history[-15:]
|
#history = history[-15:]
|
||||||
for event in history:
|
#for event in history:
|
||||||
event['time'] = epochFormat(event['time'])
|
# event['time'] = epochFormat(event['time'])
|
||||||
return render_template('status.html', events = history[::-1])
|
return render_template('status.html')
|
||||||
|
|
||||||
@app.route('/users')
|
@app.route('/users')
|
||||||
@requires_auth
|
@requires_auth
|
||||||
@@ -42,7 +42,12 @@ def users():
|
|||||||
@app.route('/history')
|
@app.route('/history')
|
||||||
@requires_auth
|
@requires_auth
|
||||||
def history():
|
def history():
|
||||||
return 'You have reached history'
|
return render_template('history.html')
|
||||||
|
|
||||||
|
@app.route('/gethistory')
|
||||||
|
@requires_auth
|
||||||
|
def getHistory():
|
||||||
|
return send_from_directory('.', 'history.json')
|
||||||
|
|
||||||
@app.route('/getcardinfo/<cardID>')
|
@app.route('/getcardinfo/<cardID>')
|
||||||
@requires_auth
|
@requires_auth
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
$('.search-bar').change(function() {
|
||||||
|
alert('text changed');
|
||||||
|
});
|
||||||
+29
-3
@@ -1,3 +1,5 @@
|
|||||||
|
var eventHistory = []
|
||||||
|
|
||||||
function overlay_in() {
|
function overlay_in() {
|
||||||
$('.shadow').css({'display' : 'block'});
|
$('.shadow').css({'display' : 'block'});
|
||||||
$('.overlay').css({'display' : 'block'});
|
$('.overlay').css({'display' : 'block'});
|
||||||
@@ -29,8 +31,27 @@ function save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.event').click(function() {
|
jQuery.ajaxSetup({ cache: false });
|
||||||
var cardID = $(this).attr('card-id')
|
$.getJSON('http://127.0.0.1:5000/gethistory', function(data) {
|
||||||
|
eventHistory = data;
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var dateString = (new Date(data[i].time*1000)).toLocaleString();
|
||||||
|
var newElement = '<div class="event" card-id="' + data[i].cardID + '">\
|
||||||
|
<div class="time">' + dateString + '</div>\
|
||||||
|
<div class="name">';
|
||||||
|
if (data[i].name == "")
|
||||||
|
newElement += '<span class="unknown_card">' + data[i].cardID + '</span>';
|
||||||
|
else
|
||||||
|
newElement += data[i].name;
|
||||||
|
newElement += '</div>\
|
||||||
|
</div>';
|
||||||
|
var toInsert = $(newElement);
|
||||||
|
$('.search-bar').after(toInsert);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.recent').on('click', '.event', function() {
|
||||||
|
var cardID = $(this).attr('card-id');
|
||||||
$('.card-id').text(cardID);
|
$('.card-id').text(cardID);
|
||||||
$.getJSON('http://127.0.0.1:5000/getcardinfo/' + cardID, function(data) {
|
$.getJSON('http://127.0.0.1:5000/getcardinfo/' + cardID, function(data) {
|
||||||
$('#name').val(data.name);
|
$('#name').val(data.name);
|
||||||
@@ -49,5 +70,10 @@ $(document).ready(function() {
|
|||||||
$('#tools').prop('checked', false);
|
$('#tools').prop('checked', false);
|
||||||
});
|
});
|
||||||
overlay_in();
|
overlay_in();
|
||||||
})
|
});
|
||||||
|
$('.search-bar').on('keyup', function() {
|
||||||
|
if (eventHistory[1].name.match($('.search-bar').val())) {
|
||||||
|
alert('match');
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
+4
-1
@@ -10,6 +10,7 @@ html {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 30%;
|
width: 30%;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.event {
|
.event {
|
||||||
@@ -26,12 +27,14 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.history-header {
|
.history-header {
|
||||||
|
display: inline-block;
|
||||||
background-color: #013A3A;
|
background-color: #013A3A;
|
||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
margin: 0 -10pt 12pt 10pt;
|
margin: 0 0 8pt 0;
|
||||||
padding: 10pt 0 10pt 0;
|
padding: 10pt 0 10pt 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 16pt;
|
font-size: 16pt;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>History</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="static/style.css">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
||||||
|
<script
|
||||||
|
src="http://code.jquery.com/jquery-3.1.1.js"
|
||||||
|
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script type="text/javascript" src="static/history_script.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input type="text" name="search" class="search-bar">
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+3
-13
@@ -13,19 +13,9 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="recent">
|
<div class="recent">
|
||||||
<div class="history-header">History</div>
|
<div class="history-header">History</div><br>
|
||||||
{% for event in events %}
|
<input type="text" name="search-bar" class="search-bar" placeholder="Search">
|
||||||
<div class="event" card-id="{{event.cardID}}">
|
|
||||||
<div class="time">{{event.time}}</div>
|
|
||||||
<div class="name">
|
|
||||||
{% if event.name == "" %}
|
|
||||||
<span class="unknown_card">{{event.cardID}}</span>
|
|
||||||
{% else %}
|
|
||||||
{{event.name}}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="everything-else">
|
<div class="everything-else">
|
||||||
<h1>Card access manager</h1>
|
<h1>Card access manager</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user