error.log.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Loads the error log page
  3. *
  4. * @class MODx.page.ErrorLog
  5. * @extends MODx.Component
  6. * @param {Object} config An object of config properties
  7. * @xtype modx-page-system-event
  8. */
  9. MODx.page.ErrorLog = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. formpanel: 'modx-panel-error-log'
  13. ,buttons: [{
  14. text: _('ext_refresh')
  15. ,id: 'modx-abtn-refresh'
  16. ,cls: 'primary-button'
  17. ,handler: this.refreshLog
  18. ,scope: this
  19. ,hidden: config.record.tooLarge
  20. },{
  21. text: _('clear')
  22. ,id: 'modx-abtn-clear'
  23. ,handler: this.clear
  24. ,scope: this
  25. ,hidden: MODx.hasEraseErrorLog ? false : true
  26. },{
  27. text: _('cancel')
  28. ,id: 'modx-abtn-cancel'
  29. }]
  30. ,components: [{
  31. xtype: 'modx-panel-error-log'
  32. ,record: config.record || {}
  33. }]
  34. });
  35. MODx.page.ErrorLog.superclass.constructor.call(this,config);
  36. if (!config.record.tooLarge) {
  37. this.refreshLog();
  38. }
  39. };
  40. Ext.extend(MODx.page.ErrorLog,MODx.Component,{
  41. clear: function() {
  42. var panel = Ext.getCmp('modx-panel-error-log');
  43. panel.el.mask(_('working'));
  44. MODx.Ajax.request({
  45. url: panel.config.url
  46. ,params: {
  47. action: 'system/errorlog/clear'
  48. }
  49. ,listeners: {
  50. 'success': {fn:function(r) {
  51. this.el.unmask();
  52. if (!r.object.tooLarge && this.config.record.tooLarge) {
  53. location.href = location.href;
  54. } else {
  55. this.getForm().setValues(r.object);
  56. }
  57. },scope:panel}
  58. }
  59. });
  60. }
  61. ,refreshLog: function() {
  62. var panel = Ext.getCmp('modx-panel-error-log');
  63. panel.el.mask(_('working'));
  64. MODx.Ajax.request({
  65. url: panel.config.url
  66. ,params: {
  67. action: 'system/errorlog/get'
  68. }
  69. ,listeners: {
  70. 'success': {fn:function(r) {
  71. this.el.unmask();
  72. if (r.object.tooLarge) {
  73. location.href = location.href;
  74. } else {
  75. this.getForm().setValues(r.object);
  76. panel.setTextareaHeight();
  77. }
  78. },scope:panel}
  79. }
  80. });
  81. }
  82. });
  83. Ext.reg('modx-page-error-log',MODx.page.ErrorLog);