Blame view
sources/settings/js/log.js
1.87 KB
|
03e52840d
|
1 2 |
/** * Copyright (c) 2012, Robin Appelman <icewind1991@gmail.com> |
|
31b7f2792
|
3 |
* Copyright (c) 2013, Morris Jobke <morris.jobke@gmail.com> |
|
03e52840d
|
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OC.Log={
reload:function(count){
if(!count){
count=OC.Log.loaded;
}
OC.Log.loaded=0;
$('#log tbody').empty();
OC.Log.getMore(count);
},
levels:['Debug','Info','Warning','Error','Fatal'],
loaded:3,//are initially loaded
getMore:function(count){
|
|
31b7f2792
|
20 |
count = count || 10; |
|
03e52840d
|
21 |
$.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){
|
|
31b7f2792
|
22 |
if(result.status === 'success'){
|
|
03e52840d
|
23 |
OC.Log.addEntries(result.data); |
|
03e52840d
|
24 |
if(!result.remain){
|
|
31b7f2792
|
25 |
$('#moreLog').hide();
|
|
03e52840d
|
26 |
} |
|
31b7f2792
|
27 |
$('#lessLog').show();
|
|
03e52840d
|
28 29 30 |
} }); }, |
|
31b7f2792
|
31 32 33 34 35 36 37 38 39 40 41 |
showLess:function(count){
count = count || 10;
//calculate remaining items - at least 3
OC.Log.loaded = Math.max(3,OC.Log.loaded-count);
$('#moreLog').show();
// remove all non-remaining items
$('#log tr').slice(OC.Log.loaded).remove();
if(OC.Log.loaded <= 3) {
$('#lessLog').hide();
}
},
|
|
03e52840d
|
42 43 44 45 46 47 48 |
addEntries:function(entries){
for(var i=0;i<entries.length;i++){
var entry=entries[i];
var row=$('<tr/>');
var levelTd=$('<td/>');
levelTd.text(OC.Log.levels[entry.level]);
row.append(levelTd);
|
|
31b7f2792
|
49 |
|
|
03e52840d
|
50 51 52 |
var appTd=$('<td/>');
appTd.text(entry.app);
row.append(appTd);
|
|
31b7f2792
|
53 |
|
|
03e52840d
|
54 55 56 |
var messageTd=$('<td/>');
messageTd.text(entry.message);
row.append(messageTd);
|
|
31b7f2792
|
57 |
|
|
03e52840d
|
58 |
var timeTd=$('<td/>');
|
|
6d9380f96
|
59 |
timeTd.addClass('date');
|
|
03e52840d
|
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
if(isNaN(entry.time)){
timeTd.text(entry.time);
} else {
timeTd.text(formatDate(entry.time*1000));
}
row.append(timeTd);
$('#log').append(row);
}
OC.Log.loaded += entries.length;
}
}
$(document).ready(function(){
$('#moreLog').click(function(){
OC.Log.getMore();
})
|
|
31b7f2792
|
76 77 78 |
$('#lessLog').click(function(){
OC.Log.showLess();
})
|
|
03e52840d
|
79 |
}); |