Commit dca17cf37d444c0a49801e017c6174d905aff775

Authored by Benjamin Renard
1 parent de9b2578

New implementation for interactive plot session

desktop.php
... ... @@ -109,10 +109,10 @@
109 109  
110 110 //create mask class (LoadMask for elements has been deprecated, use Ext.dom.Element.mask & Ext.dom.Element.unmask)
111 111 var AMDAMask = new Ext.Class({
112   - show : function(tabId)
  112 + show : function(interactivePlot)
113 113 {
114 114 var msg = 'Processing...Please wait';
115   - if (tabId)
  115 + if (interactivePlot)
116 116 msg += ' <br/> <p align="center"><input id="killopBtn" type="button" value="Kill process" /></p>';
117 117  
118 118 var mask = Ext.getBody().mask(msg);
... ... @@ -125,9 +125,10 @@
125 125  
126 126 if (maskMsg)
127 127 maskMsg.style.zIndex = '99999';
128   - if (tabId)
  128 + if (interactivePlot)
129 129 {
130   - var killBtn = Ext.get('killopBtn');
  130 + //ToDo - BRE
  131 + /* var killBtn = Ext.get('killopBtn');
131 132 var multiPlotWin = myDesktopApp.desktop.getWindow(amdaDesktop.InteractivePlotMgr.id);
132 133 // multiPlotWin was closed - single plot mode
133 134 if (!multiPlotWin) {
... ... @@ -160,7 +161,7 @@
160 161 },this);
161 162  
162 163 },
163   - this);
  164 + this);*/
164 165  
165 166 }
166 167 },
... ...
js/app/controllers/NewPlotModule.js
... ... @@ -14,7 +14,8 @@ Ext.define(&#39;amdaDesktop.NewPlotModule&#39;, {
14 14 requires: [
15 15 'amdaUI.NewPlotUI',
16 16 'amdaPlotObj.PlotRequestObject',
17   - 'amdaModel.NewPlotNode'
  17 + 'amdaModel.NewPlotNode',
  18 + 'amdaUI.NewPlotTabResultUI'
18 19 ],
19 20  
20 21 contentId : 'newPlotUI',
... ... @@ -36,6 +37,8 @@ Ext.define(&#39;amdaDesktop.NewPlotModule&#39;, {
36 37 uiType : 'newPanelPlot',
37 38 helpTitle : 'Help on Plot Module',
38 39  
  40 + plotResultWindowsManager : new Ext.AbstractManager(),
  41 +
39 42 /**
40 43 * @override
41 44 */
... ... @@ -57,5 +60,85 @@ Ext.define(&#39;amdaDesktop.NewPlotModule&#39;, {
57 60 getState : function() {
58 61 // return Ext.state.Manager.get(this.id + '_form');
59 62 return Ext.state.Manager.get('timeinterval');
60   - }
  63 + },
  64 +
  65 + computeResultWindowSize : function(panelResult)
  66 + {
  67 + var size = panelResult.getImageSize();
  68 + size.width += 30;
  69 + size.height += 95;
  70 +
  71 + return size;
  72 + },
  73 +
  74 + startInteractiveSession : function(session) {
  75 + var me = this;
  76 + Ext.each(session.result, function (tabResult) {
  77 + var winResultId = tabResult.id+"-win";
  78 +
  79 + var winResult = me.getWindowResult(winResultId);
  80 +
  81 + var plotTabConfig = {
  82 + folder : session.folder,
  83 + plotFile : tabResult.plot,
  84 + context : tabResult.context
  85 + };
  86 +
  87 + if (winResult == null) {
  88 + //create new result win
  89 + var panelResult = new amdaUI.NewPlotTabResultUI(plotTabConfig);
  90 +
  91 + var size = me.computeResultWindowSize(panelResult);
  92 +
  93 + var win = myDesktopApp.getDesktop().createWindow({
  94 + id : tabResult.id+"-win",
  95 + title : tabResult.id,
  96 + width : size.width,
  97 + height: size.height,
  98 + layout: 'fit',
  99 + items : [
  100 + panelResult
  101 + ],
  102 + listeners: {
  103 + scope: me,
  104 + beforeclose: function(win,opt) {
  105 + me.plotResultWindowsManager.unregister(win);
  106 + }
  107 + },
  108 + getPanelResult: function() {
  109 + return panelResult;
  110 + }
  111 + });
  112 + win.show();
  113 + me.plotResultWindowsManager.register(win);
  114 + }
  115 + else
  116 + {
  117 + //update result
  118 + winResult.getPanelResult().updatePlotImage(plotTabConfig);
  119 + //update window size
  120 + var size = me.computeResultWindowSize(winResult.getPanelResult());
  121 + winResult.setSize(size.width, size.height);
  122 +
  123 + winResult.toFront();
  124 + }
  125 + });
  126 + },
  127 +
  128 + closeInteractiveSession : function() {
  129 + var me = this;
  130 + this.plotResultWindowsManager.each(function (key, value, length) {
  131 + value.close();
  132 + me.plotResultWindowsManager.unregister(value);
  133 + });
  134 + },
  135 +
  136 + updateInteractiveSession : function() {
  137 +
  138 + },
  139 +
  140 + getWindowResult: function(winResultId){
  141 + if (!this.plotResultWindowsManager.get(winResultId)) return null;
  142 + return this.plotResultWindowsManager.get(winResultId);
  143 + }
61 144 });
62 145 \ No newline at end of file
... ...
js/app/models/ExecutableNode.js
... ... @@ -52,10 +52,10 @@ Ext.define(&#39;amdaModel.ExecutableNode&#39;, {
52 52 */
53 53 realExecute : function() {
54 54  
55   - var tabId = this.get('nodeType') == 'request' ? this.get('object').get('tabId') : null;
  55 + var isInteractivePlot = (this.get('nodeType') == 'request') && (this.get('object').get('file-output') == 'INTERACTIVE');
56 56  
57 57 if (!loadMask.isMasked())
58   - loadMask.show(tabId);
  58 + loadMask.show(isInteractivePlot);
59 59  
60 60 AmdaAction.execute({nodeType : this.get('nodeType')}, this.get('object').getJsonValues(true), function(res,e){
61 61  
... ... @@ -74,8 +74,16 @@ Ext.define(&#39;amdaModel.ExecutableNode&#39;, {
74 74 return;
75 75 }
76 76  
77   - var newobj = this.createJobObject(res);
78   - var newNode = Ext.create(this.get('jobNode'),
  77 + if (isInteractivePlot)
  78 + {
  79 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
  80 + module.startInteractiveSession(res);
  81 + });
  82 + }
  83 + else
  84 + {
  85 + var newobj = this.createJobObject(res);
  86 + var newNode = Ext.create(this.get('jobNode'),
79 87 {
80 88 info : res.info,
81 89 jobType : this.get('nodeType'),
... ... @@ -89,45 +97,25 @@ Ext.define(&#39;amdaModel.ExecutableNode&#39;, {
89 97 leaf : true,
90 98 object : newobj});
91 99  
  100 + newNode.get('object').on('execute', function() {
  101 + // Then call the node creation method
  102 + this.execute(arguments);
  103 + }, newNode);
92 104  
93   - newNode.get('object').on('execute', function() {
94   - // Then call the node creation method
95   - this.execute(arguments);
96   - }, newNode);
97   -
98   - // new Tab
99   - switch (res.status)
100   - {
101   - case amdaModel.BkgJobNode.STATUS_LIST.DONE :
102   - //New tab, non-interactive session
103   - var isInteractive = false;
104   - var isNewTab = true;
105   - if (newobj.get('format') && newobj.get('format') == 'PNG')
106   - {
107   - isInteractive = true;
108   - //TODO each new plot create new BkgJobNode => delete old!!!
109   - // plot window (1-5)
110   - // newNode.set('tabId', this.get('object').get('tabId'));
111   -
112   - // if it is plot for TimeTable
113   - if (res.tableName) {
114   - newobj.set('intervalN', res.intervalN);
115   - newobj.set('totalN', res.totalN);
116   - newobj.set('ttName', res.tableName);
117   - }
118   - }
119   -
120   - if (!isInteractive)
121   - newNode.createJobNode(true);
122   - newNode.editNode(isNewTab, isInteractive);
123   - break;
124   - case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
125   - newNode.createJobNode(false);
126   - break;
127   - default:
128   - newNode.createJobNode(true);
  105 + switch (res.status)
  106 + {
  107 + case amdaModel.BkgJobNode.STATUS_LIST.DONE :
  108 + newNode.createJobNode(true);
  109 + newNode.editNode(isNewTab, isInteractive);
  110 + break;
  111 + case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
  112 + newNode.createJobNode(false);
  113 + break;
  114 + default:
  115 + newNode.createJobNode(true);
  116 + }
129 117 }
130   - }, this );
  118 + }, this );
131 119 },
132 120  
133 121 createJobObject: function(res) {
... ...
js/app/views/NewPlotTabResultUI.js 0 โ†’ 100644
... ... @@ -0,0 +1,119 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : NewPlotTabResultUI.js
  4 + * @class amdaUI.NewPlotTabResultUI
  5 + * @extends Ext. panel.Panel
  6 + * @brief Plot Tab Result UI definition (View)
  7 + * @author
  8 + * @version $Id: NewPlotTabResultUI.js benjamin $
  9 + ********************************************************************************
  10 + * FT Id : Date : Name - Description
  11 + *******************************************************************************
  12 + *
  13 + */
  14 +
  15 +Ext.define('amdaUI.NewPlotTabResultUI', {
  16 + extend: 'Ext.panel.Panel',
  17 +
  18 + alias: 'widget.newPlotTabResult',
  19 +
  20 + requires: [
  21 + 'amdaUI.InteractiveIntervalPlugin'
  22 + ],
  23 +
  24 + isPortrait : false,
  25 + pageWidth : 0,
  26 + pageHeight : 0,
  27 +
  28 + constructor: function(config) {
  29 + this.addEvents({'pagesize':true});
  30 +
  31 + this.init(config);
  32 + this.callParent(arguments);
  33 + },
  34 +
  35 + getImageSize : function() {
  36 + var size = {
  37 + width : this.pageWidth * this.sliderPage.getValue()/100.,
  38 + height : this.pageHeight * this.sliderPage.getValue()/100.
  39 + }
  40 + return size;
  41 + },
  42 +
  43 + getImageUrl: function(resultFolder, plotFile) {
  44 + return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
  45 + },
  46 +
  47 + createPlotImage: function(resultFolder, plotFile, context) {
  48 + var size = this.getImageSize();
  49 + this.panelImage = Ext.create('Ext.Img', {
  50 + src : this.getImageUrl(resultFolder, plotFile),
  51 + width : size.width,
  52 + height : size.height,
  53 + refreshMe : function(){
  54 + var el;
  55 + if(el = this.el){
  56 + el.dom.src = this.src + '?dc=' + new Date().getTime();
  57 + }
  58 + },
  59 + listeners : {
  60 + render : function(){
  61 + this.refreshMe();
  62 + }
  63 + }
  64 + });
  65 +
  66 + return this.panelImage;
  67 + },
  68 +
  69 + updatePlotImage: function(configResult) {
  70 + this.isPortrait = configResult.context.page.portrait;
  71 + this.pageWidth = configResult.context.page.width;
  72 + this.pageHeight = configResult.context.page.height;
  73 +
  74 + this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
  75 +
  76 + var size = this.getImageSize();
  77 + this.panelImage.setSize(size.width, size.height);
  78 +
  79 + this.panelImage.refreshMe();
  80 + },
  81 +
  82 + init: function(configResult){
  83 + this.isPortrait = configResult.context.page.portrait;
  84 + this.pageWidth = configResult.context.page.width;
  85 + this.pageHeight = configResult.context.page.height;
  86 +
  87 + this.sliderPage = new Ext.slider.Single({
  88 + width: 130,
  89 + value: 75,
  90 + increment: 5,
  91 + minValue: 50,
  92 + maxValue: 100,
  93 + fieldLabel : 'Resize',
  94 + labelWidth : 40,
  95 + listeners: {
  96 + scope : this,
  97 + changecomplete: function(s, v)
  98 + {
  99 + //ToDo - this.resetMire();
  100 + var size = this.getImageSize();
  101 + this.panelImage.width = size.width;
  102 + this.panelImage.height = size.height;
  103 + this.panelImage.doComponentLayout();
  104 + this.fireEvent('pagesize',this,v);
  105 + }
  106 + }
  107 + });
  108 +
  109 + var newPlotResultTabPanelConfig = {
  110 + preventHeader : true,
  111 + autoScroll: true,
  112 + items: [
  113 + this.createPlotImage(configResult.folder, configResult.plotFile, configResult.context)
  114 + ]
  115 + };
  116 +
  117 + Ext.apply(this , newPlotResultTabPanelConfig);
  118 + }
  119 +});
0 120 \ No newline at end of file
... ...
js/app/views/NewPlotUI.js
... ... @@ -62,6 +62,10 @@ Ext.define(&#39;amdaUI.NewPlotUI&#39;, {
62 62 * @return false
63 63 */
64 64 fclose : function() {
  65 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
  66 + module.closeInteractiveSession();
  67 + });
  68 +
65 69 return false;
66 70 },
67 71  
... ...