diff --git a/static/js/changelogDialog.js b/static/js/changelogDialog.js new file mode 100644 index 000000000..900c00393 --- /dev/null +++ b/static/js/changelogDialog.js @@ -0,0 +1,258 @@ +// vim: et:ts=4:sw=4:sts=4:ft=javascript + +'use strict'; + +pandora.ui.changelogDialog = function() { + + var height = Math.round((window.innerHeight - 48) * 0.9), + width = Math.round(window.innerWidth * 0.9), + + $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('FIXME'); + $list.reloadList(true); + } + }), + + $findSelect = Ox.Select({ + items: [ + {id: 'all', title: Ox._('Find: All')}, + {id: 'user', title: Ox._('Find: User')}, + {id: 'url', title: Ox._('Find: ID')} + ], + overlap: 'right', + type: 'image', + value: 'all' + }) + .bindEvent({ + change: function(data) { + var key = data.value, + value = $findInput.value(); + value && updateList(key, value); + $findInput.options({ + placeholder: data.title + }); + } + }), + + $findInput = Ox.Input({ + changeOnKeypress: true, + clear: true, + placeholder: Ox._('Find: All'), + 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'}), + + $list = Ox.TableList({ + columns: [ + { + id: 'id', + title: Ox._('ID'), + visible: false + }, + { + format: function(value) { + return Ox.encodeHTMLEntities(value); + }, + id: 'user', + operator: '+', + title: Ox._('User'), + visible: true, + width: 72 + }, + { + align: 'right', + format: function(value) { + return Ox.formatDate(value, "%Y-%m-%d %H:%M:%S"); + }, + id: 'created', + operator: '-', + title: Ox._('Date'), + visible: true, + width: 144 + }, + { + format: function(value, data) { + return formatURL(value, data.line); + }, + id: 'changeid', + operator: '+', + title: Ox._('ID'), + visible: true, + width: 320 + }, + { + format: function(value) { + return Ox.encodeHTMLEntities(value); + }, + id: 'text', + operator: '+', + title: Ox._('Data'), + visible: true, + width: 640 + }, + ], + columnsMovable: true, + columnsResizable: true, + columnsVisible: true, + items: pandora.api.findLogs, + keys: ['line'], + scrollbarVisible: true, + sort: [{key: 'created', operator: '-'}], + unique: 'id' + }) + .bindEvent({ + init: function(data) { + $status.html(Ox.toTitleCase( + Ox.formatCount(data.items, 'entry', 'entries') + )); + }, + 'delete': function(data) { + pandora.api.removeLogs({ids: data.ids}, function(result) { + Ox.Request.clearCache('findLogs'); + $list.reloadList(); + }); + }, + load: function() { + $reloadButton.options({disabled: false}); + }, + open: function(data) { + var value = $list.value(Ox.last(data.ids)), + $dialog = Ox.Dialog({ + buttons: [ + Ox.Button({ + id: 'close', + title: Ox._('Close') + }) + .bindEvent({ + click: function() { + $dialog.close(); + } + }) + ], + closeButton: true, + content: Ox.Element(), // FIXME + height: height - 48, + keys: {enter: 'close', escape: 'close'}, + maximizeButton: true, + removeOnClose: true, + title: formatURL(value.url, value.line), + width: width - 48 + }) + .open(); + } + } + }), + + that = Ox.Dialog({ + buttons: [ + Ox.Button({ + id: 'done', + title: Ox._('Done'), + width: 48 + }).bindEvent({ + click: function() { + that.close(); + } + }) + ], + closeButton: true, + content: Ox.SplitPanel({ + elements: [ + { + element: Ox.Bar({size: 24}) + .append($reloadButton) + .append($findElement), + size: 24 + }, + { + element: $list + } + ], + orientation: 'vertical' + }), + height: height, + maximizeButton: true, + minHeight: 256, + minWidth: 512, + padding: 0, + removeOnClose: true, + title: Ox._('Error Logs'), + width: width + }), + + $status = $('
') + .css({ + position: 'absolute', + top: '4px', + left: '128px', + right: '128px', + bottom: '4px', + paddingTop: '2px', + fontSize: '9px', + textAlign: 'center' + }) + .appendTo(that.find('.OxButtonsbar')); + + that.superClose = that.close; + that.close = function() { + Ox.Request.clearCache('FIXME'); + that.superClose(); + }; + + function formatURL(url, line) { + return Ox.encodeHTMLEntities(url.split('?')[0]) + ':' + line; + } + + function renderLog(logData) { + var $checkbox; + return Ox.Element() + .css({ + padding: '8px' + }) + .append($('
').html(logData.text));
+    }
+
+    function updateList(key, value) {
+        var query = {
+                conditions: [].concat(
+                    key != 'changeid' ? [{key: 'user', value: value, operator: '='}] : [],
+                    key != 'user' ? [{key: 'changeid', value: value, operator: '='}] : []
+                ),
+                operator: key == 'all' ? '|' : '&'
+            };
+        $list.options({
+            items: function(data, callback) {
+                return pandora.api.FIXME(Ox.extend(data, {
+                    query: query
+                }), callback);
+            }
+        });
+    }
+
+    return that;
+
+};
+
diff --git a/static/js/errorDialog.js b/static/js/errorDialog.js
index a93e54845..1a83f84d4 100644
--- a/static/js/errorDialog.js
+++ b/static/js/errorDialog.js
@@ -47,7 +47,7 @@ pandora.ui.errorDialog = function(data) {
                             .bindEvent({
                                 click: function() {
                                     that.close();
-                                    pandora.$ui.logsDialog = pandora.ui.logsDialog().open();
+                                    pandora.$ui.errorlogsDialog = pandora.ui.errorlogsDialog().open();
                                 }
                             }),
                         {}
diff --git a/static/js/logsDialog.js b/static/js/errorlogsDialog.js
similarity index 99%
rename from static/js/logsDialog.js
rename to static/js/errorlogsDialog.js
index d858d4227..519c7224f 100644
--- a/static/js/logsDialog.js
+++ b/static/js/errorlogsDialog.js
@@ -2,7 +2,7 @@
 
 'use strict';
 
-pandora.ui.logsDialog = function() {
+pandora.ui.errorlogsDialog = function() {
 
     var height = Math.round((window.innerHeight - 48) * 0.9),
         width = Math.round(window.innerWidth * 0.9),
diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js
index c2edd8857..7a463448d 100644
--- a/static/js/mainMenu.js
+++ b/static/js/mainMenu.js
@@ -206,7 +206,8 @@ pandora.ui.mainMenu = function() {
                         { id: 'events', title: Ox._('Manage Events...'), disabled: !pandora.site.capabilities.canManagePlacesAndEvents[pandora.user.level] },
                         {},
                         { id: 'users', title: Ox._('Manage Users...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] },
-                        { id: 'statistics', title: Ox._('Statistics...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] }
+                        { id: 'statistics', title: Ox._('Statistics...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] },
+                        { id: 'changelog', title: Ox._('Changelog...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] }
                     ] },
                     { id: 'helpMenu', title: Ox._('Help'), items: [
                         { id: 'help', title: Ox._('Help...'), keyboard: 'control ?' },
@@ -514,6 +515,8 @@ pandora.ui.mainMenu = function() {
                     pandora.$ui.usersDialog = pandora.ui.usersDialog().open();
                 } else if (data.id == 'statistics') {
                     pandora.$ui.statisticsDialog = pandora.ui.statisticsDialog().open();
+                } else if (data.id == 'changelog') {
+                    pandora.$ui.changelogDialog = pandora.ui.changelogDialog().open();
                 } else if (data.id == 'clearcache') {
                     Ox.Request.clearCache();
                 } else if (data.id == 'cache') {
@@ -538,7 +541,7 @@ pandora.ui.mainMenu = function() {
                     Ox.Event[pandora.localStorage('enableEventLogging') ? 'bind' : 'unbind'](pandora.logEvent);
                     that.setItemTitle('eventlogging', Ox._((pandora.localStorage('enableEventLogging') ? 'Disable' : 'Enable') + ' Event Logging'));
                 } else if (data.id == 'errorlogs') {
-                    pandora.$ui.logsDialog = pandora.ui.logsDialog().open();
+                    pandora.$ui.errorlogsDialog = pandora.ui.errorlogsDialog().open();
                 } else if (data.id == 'tests') {
                     pandora.tests();
                 }