SysUpdate.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.SysUpdate', {
  3. extend : 'Ext.app.Controller',
  4. requires : [ 'erp.util.BaseUtil' ],
  5. views : [ 'ma.SysUpdate' ],
  6. init : function() {
  7. var me = this;
  8. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  9. this.control({
  10. 'button[id=check]' : {//一键升级
  11. click : function(btn) {
  12. var grid = Ext.getCmp('update-grid');
  13. grid.store.each(function(item){
  14. if(!item.get('installed')) {
  15. me.install(item, grid.store.indexOf(item));
  16. }
  17. });
  18. }
  19. },
  20. 'button[id=close]' : {
  21. click : function() {
  22. me.BaseUtil.getActiveTab().close();
  23. }
  24. },
  25. 'gridpanel[id=update-grid]' : {
  26. afterrender : function(grid) {
  27. me.getPatchInfo(grid);
  28. grid.install = function(idx) {
  29. me.install(grid.store.getAt(idx));
  30. };
  31. grid.uninstall = function(idx) {
  32. me.uninstall(grid.store.getAt(idx));
  33. };
  34. }
  35. }
  36. });
  37. },
  38. getPatchInfo: function(grid, idx) {
  39. Ext.Ajax.request({
  40. url: basePath + 'ma/patch/getInfo.action',
  41. method: 'GET',
  42. callback: function(opt, s, r) {
  43. var rs = Ext.decode(r.responseText);
  44. if(rs.success) {
  45. var u = rs.usoft, p = Ext.Array.pluck(rs.local, 'name');
  46. if(u != null && u.length > 0) {
  47. Ext.each(u, function(){
  48. if(Ext.Array.contains(p, this.name)) {
  49. this.installed = true;
  50. } else {
  51. this.installed = false;
  52. }
  53. });
  54. grid.store.loadData(u);
  55. } else {
  56. grid.store.loadData(rs.local);
  57. }
  58. } else {
  59. if(rs.exceptionInfo) {
  60. showError(rs.exceptionInfo);
  61. }
  62. }
  63. }
  64. });
  65. },
  66. install: function(record) {
  67. Ext.Ajax.request({
  68. url: basePath + 'ma/patch/install.action',
  69. params: {
  70. pname: record.get('name'),
  71. files: record.get('files')
  72. },
  73. timeout: 50000,
  74. callback: function(opt, s, r) {
  75. var rs = Ext.decode(r.responseText);
  76. if(rs.success) {
  77. record.set('installed', true);
  78. showMessage('提示', '补丁包' + record.get('name') + '已成功安装,请立即重启服务器生效!');
  79. }
  80. }
  81. });
  82. },
  83. uninstall: function(record) {
  84. Ext.Ajax.request({
  85. url: basePath + 'ma/patch/uninstall.action',
  86. params: {
  87. pname: record.get('name')
  88. },
  89. timeout: 50000,
  90. callback: function(opt, s, r) {
  91. var rs = Ext.decode(r.responseText);
  92. if(rs.success) {
  93. record.set('installed', false);
  94. showMessage('提示', '补丁包' + record.get('name') + '已成功卸载,服务器现在重启,请勿执行任何操作!');
  95. }
  96. }
  97. });
  98. }
  99. });