Commit c2cc7749a88f41dceeb97ac4ca0e41357675cc57

Authored by Erdogan Furkan
1 parent 2cd12bf9

#10098 - Modifications including links

js/app/views/PlotComponents/PlotContextManager.js
... ... @@ -51,15 +51,71 @@ Ext.define('amdaPlotComp.PlotContextManager', {
51 51 return resPanel;
52 52 },
53 53  
54   - getInterval: function (context, panel, crtTimestamp) {
55   - resInterval = null;
  54 + getIntervalCoordInfo: function (context, panel, crtTimestamp) {
  55 + var intervalName = new Array();
  56 + var intervalId = new Array();
  57 + var intervalText = "";
56 58 Ext.each(panel.intervals, function (interval) {
57 59 if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
58   - resInterval = interval.name + ', id : ' + interval.id;
  60 + intervalName.push(interval.name);
  61 + intervalId.push(interval.id);
59 62 }
60 63 return;
61 64 });
62   - return resInterval;
  65 + if (intervalName.length > 0) {
  66 + intervalText = 'TT: ' + intervalName[0] + ', id: [' + intervalId[0];
  67 + for (i = 1; i < intervalName.length; i++) {
  68 + if (intervalName[i] == intervalName[i - 1]) {
  69 + intervalText += ', ' + intervalId[i];
  70 + }
  71 + else {
  72 + intervalText += '] | TT: ' + intervalName[i] + ', id: [' + intervalId[i];
  73 + }
  74 + }
  75 + intervalText += ']'
  76 + }
  77 + return intervalText;
  78 + },
  79 +
  80 + getAllIntervalParams(context, panel, crtTimestamp) {
  81 + var allParams = new Array();
  82 +
  83 + Ext.each(panel.intervals, function (interval) {
  84 + if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime && interval.params != "") {
  85 + allParams.push(interval.params);
  86 + }
  87 + return;
  88 +
  89 + });
  90 + return allParams;
  91 + },
  92 +
  93 + getIntervalLinks(allintervalParams) {
  94 + var links = new Array();
  95 + Ext.each(allintervalParams, function (allParams) {
  96 +
  97 + var params = allParams.split('|');
  98 +
  99 + Ext.each(params, function (param) {
  100 + if (param.toLowerCase().startsWith("http://") || param.toLowerCase().startsWith("https://")) {
  101 + links.push(param);
  102 + }
  103 + return;
  104 + });
  105 + return;
  106 + });
  107 + return links;
  108 + },
  109 +
  110 + isInterval: function (context, panel, crtTimestamp) {
  111 + isInterval = false;
  112 + Ext.each(panel.intervals, function (interval) {
  113 + if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
  114 + isInterval = true;
  115 + }
  116 + return;
  117 + });
  118 + return isInterval;
63 119 },
64 120  
65 121  
... ...
js/app/views/PlotComponents/PlotIntervalRefPlug.js 0 โ†’ 100644
... ... @@ -0,0 +1,141 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : PlotIntervalRefPlug.js
  4 + * @plugin amdaPlotComp.PlotIntervalRefPlug
  5 + * @extends Ext.util.Observable
  6 + * @ptype plotIntervalRefPlugin
  7 + * @brief Shows references for Interval
  8 + * @author Furkan
  9 + * @version $Id: PlotIntervalRefPlug.js
  10 + ********************************************************************************
  11 + * FT Id : Date : Name - Description
  12 + *******************************************************************************
  13 + * :
  14 + */
  15 +
  16 +
  17 +Ext.define('amdaPlotComp.PlotIntervalRefPlug', {
  18 + extend: 'Ext.util.Observable',
  19 + alias: 'plugin.plotIntervalRefPlugin',
  20 +
  21 + id: 'plot-intervalref-plug',
  22 + win: null,
  23 + form: null,
  24 + interactiveId: '',
  25 + actionDone: '',
  26 + durationDone: 0,
  27 +
  28 + constructor: function (config) {
  29 + Ext.apply(this, config);
  30 + this.callParent(arguments);
  31 + },
  32 +
  33 + onDestroy: function () {
  34 + this.win = null;
  35 + },
  36 +
  37 + init: function (cmp) {
  38 + this.hostCmp = cmp;
  39 + },
  40 +
  41 + /**
  42 + * creation of the window
  43 + */
  44 + show: function (interactiveId, links, xPos, yPos) {
  45 + if (!this.win) {
  46 + this.win = new Ext.Window({
  47 + id: 'plot-intervalref-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID
  48 + width: 265,
  49 + x: 0, y: 0,
  50 + baseCls: 'x-panel',
  51 + title: 'Catalogue references',
  52 + layout: 'fit',
  53 + constrain: true,
  54 + collapsible: true,
  55 + resizable: false,
  56 + ghost: false,
  57 + renderTo: this.hostCmp.ownerCt.body,
  58 + items: this.getFormConfig(links),
  59 + listeners: {
  60 + scope: this,
  61 + beforeclose: function () {
  62 + this.hostCmp.panelImage.stopZoom();
  63 + Ext.PluginManager.unregister(this);
  64 + }
  65 + },
  66 + getConstrainVector: function (constrainTo) {
  67 + var me = this;
  68 + if (me.constrain || me.constrainHeader) {
  69 + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
  70 + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
  71 + }
  72 + }
  73 + });
  74 +
  75 + this.win.on('destroy', this.onDestroy, this);
  76 +
  77 + Ext.PluginManager.register(this);
  78 + }
  79 +
  80 + this.interactiveId = interactiveId;
  81 + this.win.show();
  82 + this.win.setPosition(xPos, yPos - 250);
  83 + },
  84 +
  85 + close: function () {
  86 + if (this.win == null)
  87 + return;
  88 + this.win.close();
  89 + },
  90 + /**
  91 + * Main form
  92 + */
  93 + getFormConfig: function (links) {
  94 + this.form = new Ext.form.FormPanel({
  95 + frame: true,
  96 + width: 265,
  97 + height: 80,
  98 + layout: {
  99 + type: 'vbox',
  100 + pack: 'start',
  101 + align: 'stretch'
  102 + },
  103 + fieldDefaults: {
  104 + labelWidth: 60
  105 + },
  106 + items: [
  107 + {
  108 + xtype: 'fieldcontainer',
  109 + layout: 'hbox',
  110 + fieldLabel: 'Select the reference from the list',
  111 + labelAlign: 'top',
  112 + bodyStyle: { background: '#dfe8f6' },
  113 + border: false,
  114 + items: [
  115 + {
  116 + xtype: 'combo',
  117 + name: 'referencelink',
  118 + store: links,
  119 + editable: false,
  120 + width: 250,
  121 + value: 'References',
  122 + triggerAction: 'all'
  123 + }
  124 + ],
  125 + }],
  126 + buttons: [
  127 +
  128 + {
  129 + text: 'Open in new tab',
  130 + scope: this,
  131 + handler: function () {
  132 + var referencelink = this.form.getForm().findField('referencelink');
  133 + window.open(referencelink.getValue(), "_blank");
  134 + }
  135 + }
  136 + ]
  137 +
  138 + });
  139 + return this.form;
  140 + }
  141 +});
... ...
js/app/views/PlotTabResultUI.js
... ... @@ -16,6 +16,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
16 16 requires: [
17 17 'amdaPlotComp.PlotZoomPlug',
18 18 'amdaPlotComp.PlotExtendShiftPlug',
  19 + 'amdaPlotComp.PlotIntervalRefPlug',
19 20 'amdaPlotComp.PlotContextManager',
20 21 'amdaPlotComp.PlotResultImage'
21 22 ],
... ... @@ -258,12 +259,8 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
258 259 case 'timeAxis':
259 260 var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
260 261 var crtTime = new Date(crtTimestamp * 1000);
261   - var interval = amdaPlotComp.PlotContextManager.getInterval(me.crtContext, panel, crtTimestamp);
  262 + intervalText = amdaPlotComp.PlotContextManager.getIntervalCoordInfo(me.crtContext, panel, crtTimestamp);
262 263 xText = crtTime.toJSON();
263   -
264   - if (interval != null) {
265   - intervalText = interval;
266   - }
267 264 break;
268 265 case 'y-left':
269 266 yLeftText = me.getAxisValue(axis, panel.plotArea.y + panel.plotArea.height, panel.plotArea.y, sourceYPos);
... ... @@ -288,7 +285,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
288 285 if (yRightText != '')
289 286 text += (', Y Right : ' + yRightText);
290 287 if (intervalText != '')
291   - text += (', TT : ' + intervalText);
  288 + text += (', ' + intervalText);
292 289 }
293 290 else
294 291 me.panelImage.resetCursor();
... ... @@ -305,6 +302,10 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
305 302 var sourceXPos = me.toPixelOnSourceImage(imageX);
306 303 var sourceYPos = me.toPixelOnSourceImage(imageY);
307 304 var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos);
  305 + var timeAxisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panel, 'timeAxis');
  306 + if (timeAxisContext == null)
  307 + return;
  308 + var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(timeAxisContext, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
308 309  
309 310 if (panel != null) {
310 311 if (panel.plotArea.hasSpectro) {
... ... @@ -312,10 +313,7 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
312 313 {
313 314 text: 'Instant cut at this position',
314 315 handler: function () {
315   - var timeAxisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panel, 'timeAxis');
316   - if (timeAxisContext == null)
317   - return;
318   - var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(timeAxisContext, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
  316 +
319 317 var crtTime = new Date(crtTimestamp * 1000);
320 318 crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset());
321 319 me.callInteractivePlot({ 'action': 'instant', 'interactiveId': this.interactiveId, 'panelId': panel.id, 'time': crtTime });
... ... @@ -327,6 +325,8 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
327 325 }
328 326 if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos))
329 327 me.createZoomItemsForPanel(panel.id);
  328 +
  329 +
330 330 }
331 331  
332 332 if (me.contextualMenu.items.getCount() > 0)
... ... @@ -371,6 +371,32 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
371 371 }
372 372 ]);
373 373  
  374 + if (amdaPlotComp.PlotContextManager.isInterval(me.crtContext, panel, crtTimestamp)) {
  375 + var allintervalParams = amdaPlotComp.PlotContextManager.getAllIntervalParams(me.crtContext, panel, crtTimestamp);
  376 + if (allintervalParams.length > 0) {
  377 +
  378 + var links = amdaPlotComp.PlotContextManager.getIntervalLinks(allintervalParams);
  379 + if (links.length > 0) {
  380 + me.contextualMenu.add('-');
  381 + me.contextualMenu.add([
  382 + {
  383 +
  384 + text: 'Open references',
  385 + handler: function () {
  386 + if (links.length == 1) {
  387 + window.open(links, "_blank");
  388 + }
  389 + else {
  390 + var intervalRefPlugin = this.getPlugin('plot-intervalref-plugin-id');
  391 + intervalRefPlugin.show(me.interactiveId, links, sourceXPos, sourceYPos);
  392 + }
  393 + },
  394 + scope: me
  395 + }]);
  396 + }
  397 + }
  398 + }
  399 +
374 400 me.contextualMenu.showAt(absoluteX, absoluteY);
375 401 }
376 402 });
... ... @@ -717,6 +743,10 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
717 743 {
718 744 ptype: 'plotExtendShiftPlugin',
719 745 pluginId: 'plot-extendshift-plugin-id'
  746 + },
  747 + {
  748 + ptype: 'plotIntervalRefPlugin',
  749 + pluginId: 'plot-intervalref-plugin-id'
720 750 }],
721 751 listeners: {
722 752 scope: this,
... ... @@ -727,6 +757,9 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
727 757 var exttendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
728 758 if (exttendShiftPlugin)
729 759 exttendShiftPlugin.close();
  760 + var intervalRefPlugin = this.getPlugin('plot-intervalref-plugin-id');
  761 + if (intervalRefPlugin)
  762 + intervalRefPlugin.close();
730 763 }
731 764 }
732 765 };
... ...