Bug correction for pagging

pull/26/head
Louis Vézina 7 years ago
parent e71aba1143
commit 47d152b457

@ -295,10 +295,6 @@ def check_update():
@route(base_url + 'system') @route(base_url + 'system')
def system(): def system():
logs = []
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
logs.append(line.rstrip())
def get_time_from_interval(interval): def get_time_from_interval(interval):
interval_clean = interval.split('[') interval_clean = interval.split('[')
interval_clean = interval_clean[1][:-1] interval_clean = interval_clean[1][:-1]
@ -385,7 +381,25 @@ def system():
elif job.trigger.__str__().startswith('cron'): elif job.trigger.__str__().startswith('cron'):
task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
return template('system', logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version) with open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')) as f:
for i, l in enumerate(f, 1):
pass
row_count = i
max_page = (row_count / 50) + 1
return template('system', base_url=base_url, task_list=task_list, row_count=row_count, max_page=max_page, bazarr_version=bazarr_version)
@route(base_url + 'logs/<page:int>')
def get_logs(page):
page_size = 50
begin = (page * page_size) - page_size
end = (page * page_size) - 1
logs_complete = []
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
logs_complete.append(line.rstrip())
logs = logs_complete[begin:end]
return template('logs', logs=logs, base_url=base_url)
@route(base_url + 'execute/<taskid>') @route(base_url + 'execute/<taskid>')
def execute_task(taskid): def execute_task(taskid):

@ -40,6 +40,8 @@
.fast.backward, .backward, .forward, .fast.forward { .fast.backward, .backward, .forward, .fast.forward {
cursor: pointer; cursor: pointer;
} }
.fast.backward, .backward, .forward, .fast.forward { pointer-events: auto; }
.fast.backward.disabled, .backward.disabled, .forward.disabled, .fast.forward.disabled { pointer-events: none; }
</style> </style>
</head> </head>
<body> <body>

@ -0,0 +1,84 @@
<html>
<head>
<!DOCTYPE html>
<script src="{{base_url}}static/jquery/jquery-latest.min.js"></script>
<script src="{{base_url}}static/semantic/semantic.min.js"></script>
<script src="{{base_url}}static/jquery/tablesort.js"></script>
<link rel="stylesheet" href="{{base_url}}static/semantic/semantic.min.css">
<style>
body {
background-color: #272727;
}
</style>
</head>
<body>
<div class="content">
<table class="ui very basic selectable table">
<thead>
<tr>
<th class="collapsing"></th>
<th>Message</th>
<th class="collapsing">Time</th>
</tr>
</thead>
<tbody>
%import time
%import datetime
%import pretty
%for log in logs:
%line = []
%line = log.split('|')
<tr class='log' data-message='{{line[2]}}' data-exception='{{line[3].replace("\\n", "<br />")}}'>
<td class="collapsing"><i class="\\
%if line[1] == 'INFO':
blue info circle \\
%elif line[1] == 'WARNING':
yellow warning circle \\
%elif line[1] == 'ERROR':
red bug \\
%end
icon"></i></td>
<td>{{line[2]}}</td>
<td title='{{line[0]}}' class="collapsing">{{pretty.date(int(time.mktime(datetime.datetime.strptime(line[0], "%d/%m/%Y %H:%M:%S").timetuple())))}}</td>
</tr>
%end
</tbody>
</table>
</div>
<div class="ui small modal">
<i class="close icon"></i>
<div class="header">
<div>Details</div>
</div>
<div class="content">
Message
<div id='message' class="ui segment">
<p></p>
</div>
Exception
<div id='exception' class="ui segment">
<p></p>
</div>
</div>
<div class="actions">
<button class="ui cancel button" >Close</button>
</div>
</div>
</body>
</html>
<script>
$('.modal')
.modal({
autofocus: false
})
;
$('.log').click(function(){
$("#message").html($(this).data("message"));
$("#exception").html($(this).data("exception"));
$('.small.modal').modal('show');
})
</script>

@ -37,6 +37,11 @@
margin-bottom: 3em; margin-bottom: 3em;
padding: 1em; padding: 1em;
} }
.fast.backward, .backward, .forward, .fast.forward {
cursor: pointer;
}
.fast.backward, .backward, .forward, .fast.forward { pointer-events: auto; }
.fast.backward.disabled, .backward.disabled, .forward.disabled, .fast.forward.disabled { pointer-events: none; }
</style> </style>
</head> </head>
<body> <body>
@ -107,61 +112,25 @@
</div> </div>
<div class="ui bottom attached tab segment" data-tab="logs"> <div class="ui bottom attached tab segment" data-tab="logs">
<div class="content"> <div class="content">
<table class="ui very basic selectable table"> <div id="logs"></div>
<thead>
<tr>
<th class="collapsing"></th>
<th>Message</th>
<th class="collapsing">Time</th>
</tr>
</thead>
<tbody>
%import time
%import datetime
%import pretty
%for log in logs:
%line = []
%line = log.split('|')
<tr class='log' data-message='{{line[2]}}' data-exception='{{line[3].replace("\\n", "<br />")}}'>
<td class="collapsing"><i class="\\
%if line[1] == 'INFO':
blue info circle \\
%elif line[1] == 'WARNING':
yellow warning circle \\
%elif line[1] == 'ERROR':
red bug \\
%end
icon"></i></td>
<td>{{line[2]}}</td>
<td title='{{line[0]}}' class="collapsing">{{pretty.date(int(time.mktime(datetime.datetime.strptime(line[0], "%d/%m/%Y %H:%M:%S").timetuple())))}}</td>
</tr>
%end
</tbody>
</table>
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="about">
Bazarr version: {{bazarr_version}}
</div>
</div>
<div class="ui small modal"> <div class="ui grid">
<i class="close icon"></i> <div class="three column row">
<div class="header"> <div class="column"></div>
<div>Details</div> <div class="center aligned column">
<i class="fast backward icon"></i>
<i class="backward icon"></i>
<span id="page"></span> / {{max_page}}
<i class="forward icon"></i>
<i class="fast forward icon"></i>
</div> </div>
<div class="content"> <div class="right floated right aligned column">Total records: {{row_count}}</div>
Message
<div id='message' class="ui segment">
<p></p>
</div> </div>
Exception
<div id='exception' class="ui segment">
<p></p>
</div> </div>
</div> </div>
<div class="actions"> </div>
<button class="ui cancel button" >Close</button> <div class="ui bottom attached tab segment" data-tab="about">
Bazarr version: {{bazarr_version}}
</div> </div>
</div> </div>
</body> </body>
@ -169,24 +138,50 @@ icon"></i></td>
<script> <script>
$('.modal')
.modal({
autofocus: false
})
;
$('.menu .item') $('.menu .item')
.tab() .tab()
; ;
$('.execute').click(function(){ function loadURL(page) {
window.location = '{{base_url}}execute/' + $(this).data("taskid"); $.ajax({
url: "{{base_url}}logs/" + page,
cache: false
}).done(function(data) {
$("#logs").html(data);
});
current_page = page;
$("#page").text(current_page);
if (current_page == 1) {
$(".backward, .fast.backward").addClass("disabled");
}
if (current_page == {{int(max_page)}}) {
$(".forward, .fast.forward").addClass("disabled");
}
if (current_page > 1 && current_page < {{int(max_page)}}) {
$(".backward, .fast.backward").removeClass("disabled");
$(".forward, .fast.forward").removeClass("disabled");
}
}
loadURL(1);
$('.backward').click(function(){
loadURL(current_page - 1);
})
$('.fast.backward').click(function(){
loadURL(1);
})
$('.forward').click(function(){
loadURL(current_page + 1);
})
$('.fast.forward').click(function(){
loadURL({{int(max_page)}});
}) })
$('.log').click(function(){ $('.execute').click(function(){
$("#message").html($(this).data("message")); window.location = '{{base_url}}execute/' + $(this).data("taskid");
$("#exception").html($(this).data("exception"));
$('.small.modal').modal('show');
}) })
$('a:not(.tabs), button:not(.cancel)').click(function(){ $('a:not(.tabs), button:not(.cancel)').click(function(){

@ -43,6 +43,8 @@
.fast.backward, .backward, .forward, .fast.forward { .fast.backward, .backward, .forward, .fast.forward {
cursor: pointer; cursor: pointer;
} }
.fast.backward, .backward, .forward, .fast.forward { pointer-events: auto; }
.fast.backward.disabled, .backward.disabled, .forward.disabled, .fast.forward.disabled { pointer-events: none; }
</style> </style>
</head> </head>
<body> <body>

Loading…
Cancel
Save