package.containers.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. * The packages list main container
  3. *
  4. * @class MODx.panel.Packages
  5. * @extends MODx.Panel
  6. * @param {Object} config An object of options.
  7. * @xtype modx-panel-packages
  8. */
  9. MODx.panel.Packages = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. layout:'card'
  13. ,border:false
  14. ,layoutConfig:{ deferredRender: true }
  15. ,defaults:{
  16. autoHeight: true
  17. ,autoWidth: true
  18. ,border: false
  19. }
  20. ,activeItem: 0
  21. ,items:[{
  22. xtype:'modx-package-grid'
  23. ,id:'modx-package-grid'
  24. ,bodyCssClass: 'grid-with-buttons'
  25. },{
  26. xtype: 'modx-package-beforeinstall'
  27. ,id:'modx-package-beforeinstall'
  28. },{
  29. xtype: 'modx-package-details'
  30. ,id:'modx-package-details'
  31. ,bodyCssClass: 'modx-template-detail'
  32. }]
  33. ,buttons: [{
  34. text: _('cancel')
  35. ,id:'package-list-reset'
  36. ,hidden: true
  37. ,handler: function(btn, e){
  38. var bc = Ext.getCmp('packages-breadcrumbs');
  39. var last = bc.data.trail[bc.data.trail.length - 2];
  40. if (last != undefined && last.rec != undefined) {
  41. bc.data.trail.pop();
  42. bc.data.trail.pop();
  43. bc.data.trail.shift();
  44. bc.updateDetail(bc.data);
  45. var grid = Ext.getCmp('modx-package-grid');
  46. grid.install(last.rec);
  47. return;
  48. }
  49. Ext.getCmp('modx-panel-packages').activate();
  50. }
  51. ,scope: this
  52. },{
  53. text: _('continue')
  54. ,id:'package-install-btn'
  55. ,cls:'primary-button'
  56. ,hidden: true
  57. ,handler: this.install
  58. ,disabled: false
  59. ,scope: this
  60. ,autoWidth: true
  61. ,autoHeight: true
  62. },{
  63. text: _('setup_options')
  64. ,id:'package-show-setupoptions-btn'
  65. ,cls:'primary-button'
  66. ,hidden: true
  67. ,handler: this.onSetupOptions
  68. ,scope: this
  69. ,autoWidth: true
  70. ,autoHeight: true
  71. }]
  72. });
  73. MODx.panel.Packages.superclass.constructor.call(this,config);
  74. };
  75. Ext.extend(MODx.panel.Packages,MODx.Panel,{
  76. activate: function() {
  77. Ext.getCmp('card-container').getLayout().setActiveItem(this.id);
  78. Ext.getCmp('modx-package-grid').activate();
  79. Ext.each(this.buttons, function(btn){ Ext.getCmp(btn.id).hide(); });
  80. }
  81. /**
  82. *
  83. * @param va ExtJS instance of the button that was clicked
  84. * @param event The Ext.EventObjectImpl from clicking the button
  85. * @param options Object containing the setup options if available, or undefined.
  86. * @returns {boolean}
  87. */
  88. ,install: function(va, event, options){
  89. options = options || {};
  90. var r;
  91. var g = Ext.getCmp('modx-package-grid');
  92. if (!g) return false;
  93. // Set the signature from the button config (set in MODx.panel.PackageBeforeInstall.updatePanel)
  94. if (va.signature != undefined && va.signature != '') {
  95. r = {signature: va.signature};
  96. } else {
  97. r = g.menu.record.data ? g.menu.record.data : g.menu.record;
  98. }
  99. // Load up the installation console
  100. var topic = '/workspace/package/install/'+r.signature+'/';
  101. g.loadConsole(Ext.getBody(),topic);
  102. // Grab the params to send to the install processor
  103. var params = {
  104. action: 'workspace/packages/install'
  105. ,signature: r.signature
  106. ,register: 'mgr'
  107. ,topic: topic
  108. };
  109. // Include the setup options that were provided from MODx.window.SetupOptions.install
  110. Ext.apply(params, options);
  111. // Trigger the actual installation
  112. MODx.Ajax.request({
  113. url: MODx.config.connector_url
  114. ,params: params
  115. ,listeners: {
  116. 'success': {fn:function() {
  117. var bc = Ext.getCmp('packages-breadcrumbs');
  118. var trail= bc.data.trail;
  119. trail.pop();
  120. if (trail.length > 1) {
  121. last = trail[trail.length - 1];
  122. if (last != undefined && last.rec != undefined) {
  123. bc.data.trail.pop();
  124. bc.data.trail.shift();
  125. bc.updateDetail(bc.data);
  126. var grid = Ext.getCmp('modx-package-grid');
  127. grid.install(last.rec);
  128. return;
  129. }
  130. }
  131. this.activate();
  132. Ext.getCmp('modx-package-grid').refresh();
  133. },scope:this}
  134. ,'failure': {fn:function() {
  135. this.activate();
  136. },scope:this}
  137. }
  138. });
  139. return true;
  140. }
  141. ,onSetupOptions: function(btn){
  142. if(this.win == undefined){
  143. this.win = new MODx.window.SetupOptions({
  144. id: 'modx-window-setupoptions'
  145. ,signature: btn.signature || ''
  146. });
  147. } else {
  148. this.win.signature = btn.signature || '';
  149. this.win.title = _('setup_options');
  150. }
  151. this.win.show(btn);
  152. var opts = Ext.getCmp('modx-package-beforeinstall').getOptions();
  153. this.win.fetch(opts);
  154. }
  155. });
  156. Ext.reg('modx-panel-packages',MODx.panel.Packages);
  157. /**
  158. * The package browser container
  159. *
  160. * @class MODx.panel.PackagesBrowser
  161. * @extends MODx.Panel
  162. * @param {Object} config An object of options.
  163. * @xtype modx-panel-packages-browser
  164. */
  165. MODx.panel.PackagesBrowser = function(config) {
  166. config = config || {};
  167. Ext.applyIf(config,{
  168. layout: 'column'
  169. ,border: false
  170. ,items:[{
  171. xtype: 'modx-package-browser-tree'
  172. ,id: 'modx-package-browser-tree'
  173. ,width: 250
  174. },{
  175. layout:'card'
  176. ,columnWidth: 1
  177. ,defaults:{ border: false }
  178. ,border:false
  179. ,id:'package-browser-card-container'
  180. ,layoutConfig:{ deferredRender:true }
  181. ,items:[{
  182. xtype:'modx-package-browser-home'
  183. ,id:'modx-package-browser-home'
  184. },{
  185. xtype: 'modx-package-browser-repositories'
  186. ,id: 'modx-package-browser-repositories'
  187. },{
  188. xtype:'modx-package-browser-grid'
  189. ,id:'modx-package-browser-grid'
  190. ,bodyCssClass: 'grid-with-buttons'
  191. },{
  192. xtype: 'modx-package-browser-details'
  193. ,id: 'modx-package-browser-details'
  194. ,bodyCssClass: 'modx-template-detail'
  195. },{
  196. xtype: 'modx-package-browser-view'
  197. ,id: 'modx-package-browser-view'
  198. ,bodyCssClass: 'modx-template-detail'
  199. }]
  200. }]
  201. });
  202. MODx.panel.PackagesBrowser.superclass.constructor.call(this,config);
  203. };
  204. Ext.extend(MODx.panel.PackagesBrowser,MODx.Panel,{
  205. activate: function(){
  206. Ext.getCmp('modx-layout').hideLeftbar(true, false);
  207. Ext.getCmp('card-container').getLayout().setActiveItem(this.id);
  208. Ext.getCmp('modx-package-browser-home').activate();
  209. this.updateBreadcrumbs(_('provider_home_msg'));
  210. }
  211. ,updateBreadcrumbs: function(msg, highlight){
  212. var bd = { text: msg };
  213. if(highlight){ bd.className = 'highlight'; }
  214. bd.trail = [{ text : _('package_browser') }];
  215. Ext.getCmp('packages-breadcrumbs').updateDetail(bd);
  216. }
  217. ,showWait: function(){
  218. if (!this.wait) {
  219. this.wait = new MODx.PackageBrowserWaitWindow();
  220. }
  221. this.wait.show();
  222. }
  223. ,hideWait: function() {
  224. if (this.wait) {
  225. this.wait.destroy();
  226. delete this.wait;
  227. }
  228. }
  229. });
  230. Ext.reg('modx-panel-packages-browser',MODx.panel.PackagesBrowser);