modx.panel.error.log.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. MODx.panel.ErrorLog = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. url: MODx.config.connector_url
  5. ,id: 'modx-panel-error-log'
  6. ,cls: 'container'
  7. ,baseParams: {
  8. action: 'system/errorlog/clear'
  9. }
  10. // ,layout: 'form' // unnecessary and creates a wrong box shadow
  11. ,items: [{
  12. html: _('error_log')
  13. ,id: 'modx-error-log-header'
  14. ,xtype: 'modx-header'
  15. },{
  16. layout: 'form'
  17. ,hideLabels: true
  18. ,autoHeight: true
  19. ,border: true
  20. ,items: [{
  21. html: '<p>'+_('error_log_desc')+'</p>'
  22. ,xtype: 'modx-description'
  23. },{
  24. xtype: 'panel'
  25. ,border: false
  26. ,cls:'main-wrapper'
  27. ,layout: 'form'
  28. ,labelAlign: 'top'
  29. ,items: [{
  30. xtype: 'textarea'
  31. ,name: 'log'
  32. ,hideLabel: true
  33. ,id: 'modx-error-log-content'
  34. ,grow: true
  35. ,anchor: '100%'
  36. ,hidden: config.record.tooLarge ? true : false
  37. ,style: 'white-space:pre;overflow: auto;'
  38. },{
  39. html: '<p>'+_('error_log_too_large',{
  40. name: config.record.name
  41. })+'</p>'
  42. ,border: false
  43. ,hidden: config.record.tooLarge ? false : true
  44. },{
  45. xtype: 'button'
  46. ,text: _('error_log_download',{size: config.record.size})
  47. ,cls: 'primary-button'
  48. ,style: 'margin-top: 15px;'
  49. ,hidden: config.record.tooLarge ? false : true
  50. ,handler: this.download
  51. ,scope: this
  52. }]
  53. }]
  54. }]
  55. });
  56. MODx.panel.ErrorLog.superclass.constructor.call(this,config);
  57. this.setup();
  58. };
  59. Ext.extend(MODx.panel.ErrorLog,MODx.FormPanel,{
  60. initialized: false
  61. ,setup: function() {
  62. if (this.initialized) { this.clearDirty(); return true; }
  63. this.getForm().setValues(this.config.record);
  64. this.clearDirty();
  65. MODx.fireEvent('ready');
  66. this.initialized = true;
  67. return true;
  68. }
  69. ,download: function() {
  70. location.href = this.config.url+'?action=system/errorlog/download&HTTP_MODAUTH='+MODx.siteId;
  71. }
  72. /**
  73. * Set the textarea height to make use of the maximum "space" the client viewport allows
  74. */
  75. ,setTextareaHeight: function() {
  76. var elem = Ext.getCmp('modx-error-log-content');
  77. // Client viewport visible height
  78. var clientHeight = document.documentElement.clientHeight || window.innerHeight || document.body.clientHeight
  79. // Our textarea "top" position
  80. ,elemTop = elem.el.getTop()
  81. // The followings are to prevent scrolling if possible (slice is to remove "px" from the values, since we want integers)
  82. ,wrapperPadding = this.el.select('.main-wrapper').first().getStyle('padding-bottom').slice(0, -2)
  83. ,containerMargin = this.el.getStyle('margin-bottom').slice(0, -2);
  84. // Now set our max available height for our textarea
  85. elem.el.setHeight(clientHeight - elemTop - wrapperPadding - containerMargin);
  86. }
  87. });
  88. Ext.reg('modx-panel-error-log',MODx.panel.ErrorLog);