2011-11-01 16:08:09 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-15 20:23:57 +00:00
|
|
|
pandora.ui.errorlogsDialog = function() {
|
2013-07-19 07:38:21 +00:00
|
|
|
|
2011-11-01 16:08:09 +00:00
|
|
|
var height = Math.round((window.innerHeight - 48) * 0.9),
|
|
|
|
width = Math.round(window.innerWidth * 0.9),
|
2013-07-19 07:38:21 +00:00
|
|
|
|
|
|
|
$reloadButton = Ox.Button({
|
|
|
|
disabled: true,
|
|
|
|
title: 'redo',
|
|
|
|
tooltip: Ox._('Reload'),
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$reloadButton.options({disabled: true});
|
|
|
|
Ox.Request.clearCache('findLogs');
|
|
|
|
$list.reloadList(true);
|
|
|
|
}
|
|
|
|
}),
|
2011-11-01 16:08:09 +00:00
|
|
|
|
|
|
|
$findSelect = Ox.Select({
|
|
|
|
items: [
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'all', title: Ox._('Find: All')},
|
|
|
|
{id: 'user', title: Ox._('Find: User')},
|
|
|
|
{id: 'url', title: Ox._('Find: URL')},
|
|
|
|
{id: 'text', title: Ox._('Find: Text')}
|
2011-11-01 16:08:09 +00:00
|
|
|
],
|
|
|
|
overlap: 'right',
|
2011-12-22 18:30:03 +00:00
|
|
|
type: 'image',
|
|
|
|
value: 'all'
|
2011-11-01 16:08:09 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2011-12-21 15:34:28 +00:00
|
|
|
var key = data.value,
|
2011-11-01 16:08:09 +00:00
|
|
|
value = $findInput.value();
|
|
|
|
value && updateList(key, value);
|
|
|
|
$findInput.options({
|
2011-12-21 15:34:28 +00:00
|
|
|
placeholder: data.title
|
2011-11-01 16:08:09 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
changeOnKeypress: true,
|
|
|
|
clear: true,
|
2013-05-10 14:54:30 +00:00
|
|
|
placeholder: Ox._('Find: All'),
|
2011-11-01 16:08:09 +00:00
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
var key = $findSelect.value(),
|
|
|
|
value = data.value;
|
|
|
|
updateList(key, value);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findElement = Ox.FormElementGroup({
|
|
|
|
elements: [
|
|
|
|
$findSelect,
|
|
|
|
$findInput
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px'}),
|
|
|
|
|
2012-06-27 07:41:39 +00:00
|
|
|
$list = Ox.TableList({
|
2011-11-01 16:08:09 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
id: 'id',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('ID'),
|
2012-05-26 15:46:24 +00:00
|
|
|
visible: false
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-02-22 10:14:07 +00:00
|
|
|
format: function(value) {
|
|
|
|
return Ox.encodeHTMLEntities(value);
|
|
|
|
},
|
2011-11-02 17:58:16 +00:00
|
|
|
id: 'user',
|
2012-02-22 10:14:07 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('User'),
|
2011-11-01 16:08:09 +00:00
|
|
|
visible: true,
|
2011-11-02 17:58:16 +00:00
|
|
|
width: 72
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
{
|
2011-11-02 17:58:16 +00:00
|
|
|
align: 'right',
|
2011-11-01 16:08:09 +00:00
|
|
|
format: function(value) {
|
2012-03-21 21:52:51 +00:00
|
|
|
return Ox.formatDate(value, "%Y-%m-%d %H:%M:%S");
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
2012-02-22 10:14:07 +00:00
|
|
|
id: 'created',
|
2011-11-01 16:08:09 +00:00
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Date'),
|
2011-11-01 16:08:09 +00:00
|
|
|
visible: true,
|
2011-11-02 17:58:16 +00:00
|
|
|
width: 144
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-02-23 17:46:02 +00:00
|
|
|
format: function(value, data) {
|
2011-11-03 01:52:15 +00:00
|
|
|
return formatURL(value, data.line);
|
2011-11-02 17:58:16 +00:00
|
|
|
},
|
2012-02-22 10:14:07 +00:00
|
|
|
id: 'url',
|
2011-11-02 17:58:16 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('URL'),
|
2011-11-02 17:58:16 +00:00
|
|
|
visible: true,
|
|
|
|
width: 320
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-02-22 10:14:07 +00:00
|
|
|
format: function(value) {
|
|
|
|
return Ox.encodeHTMLEntities(value);
|
|
|
|
},
|
2011-11-01 16:08:09 +00:00
|
|
|
id: 'text',
|
2012-02-22 10:14:07 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Text'),
|
2011-11-02 17:58:16 +00:00
|
|
|
visible: true,
|
|
|
|
width: 640
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
],
|
2011-11-02 17:58:16 +00:00
|
|
|
columnsMovable: true,
|
|
|
|
columnsResizable: true,
|
2011-11-01 16:08:09 +00:00
|
|
|
columnsVisible: true,
|
|
|
|
items: pandora.api.findLogs,
|
2011-11-02 17:58:16 +00:00
|
|
|
keys: ['line'],
|
2011-11-01 16:08:09 +00:00
|
|
|
scrollbarVisible: true,
|
2012-06-27 22:24:02 +00:00
|
|
|
sort: [{key: 'created', operator: '-'}],
|
|
|
|
unique: 'id'
|
2011-11-01 16:08:09 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
2013-07-19 07:38:21 +00:00
|
|
|
$status.html(Ox.toTitleCase(
|
|
|
|
Ox.formatCount(data.items, 'entry', 'entries')
|
|
|
|
));
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
'delete': function(data) {
|
|
|
|
pandora.api.removeLogs({ids: data.ids}, function(result) {
|
2011-11-01 16:13:26 +00:00
|
|
|
Ox.Request.clearCache('findLogs');
|
2012-03-18 17:52:59 +00:00
|
|
|
$list.reloadList();
|
2011-11-01 16:08:09 +00:00
|
|
|
});
|
2011-11-03 01:52:15 +00:00
|
|
|
},
|
2013-07-19 07:38:21 +00:00
|
|
|
load: function() {
|
|
|
|
$reloadButton.options({disabled: false});
|
|
|
|
},
|
2011-11-03 01:52:15 +00:00
|
|
|
open: function(data) {
|
|
|
|
var value = $list.value(Ox.last(data.ids)),
|
|
|
|
$dialog;
|
|
|
|
if (/^Traceback/.test(value.text)) {
|
|
|
|
$dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
id: 'close',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Close')
|
2011-11-03 01:52:15 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
2013-07-19 09:34:01 +00:00
|
|
|
content: $('<code>').append(
|
|
|
|
$('<pre>')
|
|
|
|
.addClass('OxSelectable')
|
|
|
|
.css({margin: '16px'})
|
|
|
|
.text(value.text)
|
|
|
|
),
|
2011-11-03 01:52:15 +00:00
|
|
|
height: height - 48,
|
|
|
|
keys: {enter: 'close', escape: 'close'},
|
|
|
|
maximizeButton: true,
|
2012-03-18 17:52:59 +00:00
|
|
|
removeOnClose: true,
|
2011-11-03 01:52:15 +00:00
|
|
|
title: formatURL(value.url, value.line),
|
|
|
|
width: width - 48
|
|
|
|
})
|
|
|
|
.open();
|
|
|
|
}
|
2011-11-01 16:08:09 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
id: 'done',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Done'),
|
2011-11-01 16:08:09 +00:00
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
|
|
|
content: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
2011-11-02 17:58:16 +00:00
|
|
|
element: Ox.Bar({size: 24})
|
2013-07-19 07:38:21 +00:00
|
|
|
.append($reloadButton)
|
|
|
|
.append($findElement),
|
2011-11-02 17:58:16 +00:00
|
|
|
size: 24
|
2011-11-01 16:08:09 +00:00
|
|
|
},
|
|
|
|
{
|
2011-11-02 17:58:16 +00:00
|
|
|
element: $list
|
2011-11-01 16:08:09 +00:00
|
|
|
}
|
|
|
|
],
|
2011-11-02 17:58:16 +00:00
|
|
|
orientation: 'vertical'
|
2011-11-01 16:08:09 +00:00
|
|
|
}),
|
|
|
|
height: height,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
padding: 0,
|
2012-03-18 17:52:59 +00:00
|
|
|
removeOnClose: true,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Error Logs'),
|
2011-11-01 16:08:09 +00:00
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
|
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '4px',
|
2011-11-03 12:58:22 +00:00
|
|
|
left: '128px',
|
|
|
|
right: '128px',
|
2011-11-01 16:08:09 +00:00
|
|
|
bottom: '4px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
2012-05-26 15:46:24 +00:00
|
|
|
textAlign: 'center'
|
2011-11-01 16:08:09 +00:00
|
|
|
})
|
2012-05-22 13:15:16 +00:00
|
|
|
.appendTo(that.find('.OxButtonsbar'));
|
2011-11-01 16:08:09 +00:00
|
|
|
|
2012-03-19 15:57:36 +00:00
|
|
|
that.superClose = that.close;
|
|
|
|
that.close = function() {
|
|
|
|
Ox.Request.clearCache('findLogs');
|
|
|
|
that.superClose();
|
|
|
|
};
|
|
|
|
|
2011-11-03 01:52:15 +00:00
|
|
|
function formatURL(url, line) {
|
2012-02-22 10:14:07 +00:00
|
|
|
return Ox.encodeHTMLEntities(url.split('?')[0]) + ':' + line;
|
2011-11-03 01:52:15 +00:00
|
|
|
}
|
2011-11-01 16:08:09 +00:00
|
|
|
|
|
|
|
function renderLog(logData) {
|
|
|
|
var $checkbox;
|
|
|
|
return Ox.Element()
|
|
|
|
.css({
|
|
|
|
padding: '8px'
|
|
|
|
})
|
|
|
|
.append($('<pre>').html(logData.text));
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateList(key, value) {
|
|
|
|
var query = {
|
2012-05-24 08:22:56 +00:00
|
|
|
conditions: [].concat(
|
2011-11-01 16:08:09 +00:00
|
|
|
key != 'url' ? [{key: 'user', value: value, operator: '='}] : [],
|
|
|
|
key != 'user' ? [{key: 'url', value: value, operator: '='}] : []
|
|
|
|
),
|
|
|
|
operator: key == 'all' ? '|' : '&'
|
|
|
|
};
|
|
|
|
$list.options({
|
|
|
|
items: function(data, callback) {
|
|
|
|
return pandora.api.findLogs(Ox.extend(data, {
|
|
|
|
query: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|
|
|
|
|