@refinitiv-ui/efx-grid 6.0.90 → 6.0.92
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.d.ts +1 -1
- package/lib/column-dragging/es6/ColumnDragging.js +144 -34
- package/lib/core/dist/core.js +2446 -2625
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.js +14 -14
- package/lib/core/es6/data/DataCache.js +118 -118
- package/lib/core/es6/data/DataTable.d.ts +4 -0
- package/lib/core/es6/data/DataTable.js +219 -190
- package/lib/core/es6/data/DataView.d.ts +2 -0
- package/lib/core/es6/data/DataView.js +300 -292
- package/lib/core/es6/data/Segment.js +85 -83
- package/lib/core/es6/data/SegmentCollection.d.ts +2 -0
- package/lib/core/es6/data/SegmentCollection.js +91 -80
- package/lib/core/es6/data/WrappedView.js +41 -41
- package/lib/core/es6/grid/Core.js +635 -635
- package/lib/core/es6/grid/ILayoutGrid.js +1 -1
- package/lib/core/es6/grid/LayoutGrid.js +183 -183
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +91 -91
- package/lib/core/es6/grid/components/Cell.js +29 -29
- package/lib/core/es6/grid/components/CellFloatingPanel.js +11 -11
- package/lib/core/es6/grid/components/CellSpan.js +7 -7
- package/lib/core/es6/grid/components/CellSpans.js +36 -34
- package/lib/core/es6/grid/components/Column.js +40 -40
- package/lib/core/es6/grid/components/ElementWrapper.js +17 -17
- package/lib/core/es6/grid/components/HScrollbar.js +31 -31
- package/lib/core/es6/grid/components/Scrollbar.js +77 -77
- package/lib/core/es6/grid/components/StretchedCells.js +49 -49
- package/lib/core/es6/grid/components/VScrollbar.js +11 -11
- package/lib/core/es6/grid/components/VirtualItems.js +3 -3
- package/lib/core/es6/grid/event/EventDispatcher.js +9 -9
- package/lib/core/es6/grid/event/EventListeners.js +4 -4
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +186 -186
- package/lib/core/es6/grid/util/Conflator.js +4 -4
- package/lib/core/es6/grid/util/Reverter.js +1 -1
- package/lib/core/es6/grid/util/SectionSettings.js +20 -20
- package/lib/core/es6/grid/util/SelectionList.js +23 -23
- package/lib/core/es6/grid/util/TrackLayout.js +74 -74
- package/lib/core/es6/grid/util/Virtualizer.js +15 -15
- package/lib/core/es6/grid/util/util.js +20 -20
- package/lib/core/es6/index.d.ts +0 -2
- package/lib/core/es6/index.js +0 -3
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +193 -70
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +46 -30
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -1
- package/lib/rt-grid/es6/RowDefinition.js +74 -16
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +56 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +29 -1
- package/lib/tr-grid-util/es6/CellPainter.js +94 -93
- package/lib/tr-grid-util/es6/Conflator.js +4 -4
- package/lib/tr-grid-util/es6/CoralItems.js +6 -6
- package/lib/tr-grid-util/es6/DateTime.js +39 -39
- package/lib/tr-grid-util/es6/Deferred.js +5 -5
- package/lib/tr-grid-util/es6/Delay.js +1 -1
- package/lib/tr-grid-util/es6/Dom.js +26 -26
- package/lib/tr-grid-util/es6/DragUI.js +17 -17
- package/lib/tr-grid-util/es6/ElementObserver.js +12 -12
- package/lib/tr-grid-util/es6/ElementWrapper.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +4 -4
- package/lib/tr-grid-util/es6/ElfUtil.js +37 -37
- package/lib/tr-grid-util/es6/EventDispatcher.js +12 -12
- package/lib/tr-grid-util/es6/ExpanderIcon.js +6 -6
- package/lib/tr-grid-util/es6/ExpressionParser.js +43 -43
- package/lib/tr-grid-util/es6/Ext.js +6 -6
- package/lib/tr-grid-util/es6/FieldFormatter.js +17 -17
- package/lib/tr-grid-util/es6/FilterBuilder.js +57 -57
- package/lib/tr-grid-util/es6/FilterOperators.d.ts +12 -1
- package/lib/tr-grid-util/es6/FilterOperators.js +13 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +86 -86
- package/lib/tr-grid-util/es6/GroupDefinitions.js +90 -90
- package/lib/tr-grid-util/es6/Icon.js +4 -4
- package/lib/tr-grid-util/es6/MouseDownTrait.js +6 -6
- package/lib/tr-grid-util/es6/MultiTableManager.js +68 -68
- package/lib/tr-grid-util/es6/NumberFormatter.js +22 -22
- package/lib/tr-grid-util/es6/PercentBar.js +17 -17
- package/lib/tr-grid-util/es6/Perf.js +5 -5
- package/lib/tr-grid-util/es6/Popup.js +42 -42
- package/lib/tr-grid-util/es6/RangeBar.js +5 -5
- package/lib/tr-grid-util/es6/RequestQueue.js +5 -5
- package/lib/tr-grid-util/es6/RowPainter.js +23 -23
- package/lib/tr-grid-util/es6/SubTable.js +94 -94
- package/lib/tr-grid-util/es6/Table.js +51 -51
- package/lib/tr-grid-util/es6/TextHighlighter.js +49 -49
- package/lib/tr-grid-util/es6/TickCodes.js +2 -2
- package/lib/tr-grid-util/es6/Timer.js +2 -2
- package/lib/tr-grid-util/es6/TouchProxy.js +7 -7
- package/lib/tr-grid-util/es6/Util.js +50 -50
- package/lib/tr-grid-util/es6/formula/ADCService.js +2 -2
- package/lib/tr-grid-util/es6/formula/ADCSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/AdFinService.js +2 -2
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/Engine.js +56 -56
- package/lib/tr-grid-util/es6/formula/Formula.js +62 -62
- package/lib/tr-grid-util/es6/formula/IntervalSubscription.js +3 -3
- package/lib/tr-grid-util/es6/formula/Realtime.js +15 -15
- package/lib/tr-grid-util/es6/formula/RealtimeService.js +15 -15
- package/lib/tr-grid-util/es6/formula/TSIService.js +2 -2
- package/lib/tr-grid-util/es6/formula/TSISubscription.js +104 -104
- package/lib/tr-grid-util/es6/formula/VariableToken.js +20 -20
- package/lib/tr-grid-util/es6/formula/functions/AdFin.js +10 -10
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Info.js +2 -2
- package/lib/tr-grid-util/es6/formula/functions/Internal.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Logic.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Math.js +46 -46
- package/lib/tr-grid-util/es6/formula/functions/Statistics.js +27 -27
- package/lib/tr-grid-util/es6/formula/functions/Text.js +19 -19
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/Adc.js +36 -36
- package/lib/tr-grid-util/es6/jet/CollectionDict.js +11 -11
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +95 -95
- package/lib/tr-grid-util/es6/jet/DataSet.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockArchive.js +5 -5
- package/lib/tr-grid-util/es6/jet/MockJET.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockQuotes.js +13 -13
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +100 -100
- package/lib/tr-grid-util/es6/jet/MockRTK.js +4 -4
- package/lib/tr-grid-util/es6/jet/MockUtil.js +2 -2
- package/lib/tr-grid-util/es6/jet/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +15 -15
- package/lib/tr-grid-util/es6/locale/translation-de.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-en.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-ja.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh-hant.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation.js +1 -1
- package/lib/types/es6/ColumnDragging.d.ts +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +3 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
- package/lib/types/es6/Core/index.d.ts +0 -2
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -1
- package/lib/versions.json +4 -4
- package/package.json +1 -1
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/core/es6/grid/util/ElementFrameWork.js +0 -227
- package/lib/core/es6/grid/util/HttpRequest.d.ts +0 -53
- package/lib/core/es6/grid/util/HttpRequest.js +0 -371
- package/lib/core/es6/grid/util/PercentBar.d.ts +0 -43
- package/lib/core/es6/grid/util/PercentBar.js +0 -390
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/core/es6/grid/util/PercentBarRenderer.js +0 -316
- package/lib/core/es6/grid/util/RangeBar.d.ts +0 -25
- package/lib/core/es6/grid/util/RangeBar.js +0 -255
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +0 -53
- package/lib/types/es6/Core/grid/util/PercentBar.d.ts +0 -43
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +0 -25
@@ -6,7 +6,7 @@ import {RequestQueue} from "../RequestQueue.js";
|
|
6
6
|
/** @constructor
|
7
7
|
* @extends {EventDispatcher}
|
8
8
|
*/
|
9
|
-
|
9
|
+
let TSISubscription = function() {
|
10
10
|
this._refreshData = this._refreshData.bind(this);
|
11
11
|
|
12
12
|
// Old TSI service
|
@@ -209,18 +209,18 @@ TSISubscription.prototype.setTSISettings = function(sharedServiceUrl, taServiceU
|
|
209
209
|
* @return {*} Return the value if there is existing. Return undefined when requesting the invalid field.
|
210
210
|
*/
|
211
211
|
TSISubscription.prototype.addSymbolAndFieldToPeriod = function (symbol, field, period) {
|
212
|
-
|
212
|
+
let periodRIC = this._getPeriodRICData(period, symbol);
|
213
213
|
if(periodRIC.dataCache[field] != null) { // Already have data
|
214
214
|
return periodRIC.dataCache[field];
|
215
215
|
}
|
216
216
|
|
217
|
-
|
218
|
-
|
217
|
+
let periodMap = this._getPeriodMap(period);
|
218
|
+
let isNewSymbol = periodMap.symbol[symbol] == null;
|
219
219
|
if(isNewSymbol) {
|
220
220
|
periodMap.symbol[symbol] = true;
|
221
221
|
}
|
222
222
|
|
223
|
-
|
223
|
+
let isNewField = periodMap.field[field] == null;
|
224
224
|
if(isNewField) {
|
225
225
|
periodMap.field[field] = true;
|
226
226
|
}
|
@@ -311,7 +311,7 @@ TSISubscription.prototype._stop = function() {
|
|
311
311
|
* @private
|
312
312
|
*/
|
313
313
|
TSISubscription.prototype._refreshData = function() {
|
314
|
-
for(
|
314
|
+
for(let period in this._tsiPeriodMap) {
|
315
315
|
// Request to old TSI service
|
316
316
|
this._oldTsiDataQ.add({ period: period }); // If it has error code, it will fallback to new service automatically.
|
317
317
|
}
|
@@ -337,7 +337,7 @@ TSISubscription.prototype._getPeriodMap = function(period) {
|
|
337
337
|
* @return {Object} Object that related to period and RIC
|
338
338
|
*/
|
339
339
|
TSISubscription.prototype._getPeriodRICData = function(period, symbol) {
|
340
|
-
|
340
|
+
let tsiPeriodMap = this._getPeriodMap(period);
|
341
341
|
if(!tsiPeriodMap[symbol]) {
|
342
342
|
tsiPeriodMap[symbol] = {
|
343
343
|
view: {}, // This property will used for new TSI service
|
@@ -379,11 +379,11 @@ TSISubscription.prototype._requestMetadata = function(symbol) {
|
|
379
379
|
TSISubscription.prototype._manageMetadataQ = function() {
|
380
380
|
this._metadataTimer = 0; // Reset
|
381
381
|
|
382
|
-
|
382
|
+
let symbolMap = this._metadataMap;
|
383
383
|
this._metadataMap = {};
|
384
384
|
|
385
|
-
|
386
|
-
for(
|
385
|
+
let symbols = [];
|
386
|
+
for(let key in symbolMap) {
|
387
387
|
if(this._metadataPendingMap[key]) {
|
388
388
|
continue;
|
389
389
|
}
|
@@ -406,17 +406,17 @@ TSISubscription.prototype._manageMetadataQ = function() {
|
|
406
406
|
* @return {Promise}
|
407
407
|
*/
|
408
408
|
TSISubscription.prototype._onRequestMetadata = function(obj, q) {
|
409
|
-
|
410
|
-
|
409
|
+
let reqRics = obj.rics;
|
410
|
+
let len = reqRics.length;
|
411
411
|
if(len <= 0) {
|
412
412
|
return Promise.resolve("");
|
413
413
|
}
|
414
414
|
|
415
415
|
// Merge request
|
416
|
-
|
417
|
-
|
416
|
+
let qi = q.length;
|
417
|
+
let remaining = TSISubscription.MAX_CONCURRENT_OBJECT - len;
|
418
418
|
while(remaining > 0 && --qi >= 0) {
|
419
|
-
|
419
|
+
let qObj = q[qi];
|
420
420
|
reqRics = reqRics.concat( qObj.rics.splice(0, remaining) );
|
421
421
|
|
422
422
|
len = reqRics.length; // Update length
|
@@ -426,12 +426,12 @@ TSISubscription.prototype._onRequestMetadata = function(obj, q) {
|
|
426
426
|
}
|
427
427
|
}
|
428
428
|
|
429
|
-
|
430
|
-
|
429
|
+
let payload = { "rics": reqRics };
|
430
|
+
let pendingMap = this._metadataPendingMap;
|
431
431
|
return Util.post(this._tsiTaServiceUrl + "/GetMetadata", payload)
|
432
432
|
.then(this._extractMetadata)
|
433
433
|
.catch(function(err) {
|
434
|
-
for(
|
434
|
+
for(let i = len; --i >= 0;) {
|
435
435
|
delete pendingMap[reqRics[i]]; // Remove key from pending list due to error
|
436
436
|
}
|
437
437
|
});
|
@@ -441,22 +441,22 @@ TSISubscription.prototype._onRequestMetadata = function(obj, q) {
|
|
441
441
|
* @param {Object} serviceResponse
|
442
442
|
*/
|
443
443
|
TSISubscription.prototype._extractMetadata = function(serviceResponse) {
|
444
|
-
|
444
|
+
let instruments = serviceResponse["instruments"];
|
445
445
|
if(instruments) { // Successful request
|
446
|
-
|
447
|
-
|
448
|
-
for(
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
for(
|
454
|
-
|
455
|
-
|
456
|
-
|
446
|
+
let aryLen = Object.keys(/** @type {!Object} */(TSISubscription.INTERVAL_INDEX)).length;
|
447
|
+
let ary = new Array(aryLen); // Reused array
|
448
|
+
for(let i = instruments.length; --i >= 0;) {
|
449
|
+
let instrument = instruments[i];
|
450
|
+
|
451
|
+
let data = null;
|
452
|
+
let viewList = instrument["viewList"] || [];
|
453
|
+
for(let j = viewList.length; --j >= 0;) {
|
454
|
+
let view = viewList[j];
|
455
|
+
let intervals = view["intervals"];
|
456
|
+
let k, interval, len;
|
457
457
|
for(k = 0, len = intervals.length; k < len; k++) {
|
458
458
|
interval = intervals[k];
|
459
|
-
|
459
|
+
let idx = TSISubscription.INTERVAL_INDEX[ interval["name"] ];
|
460
460
|
if(idx != null) {
|
461
461
|
if(ary[idx] == null || TSISubscription.INTERVAL_MAIN[ interval["name"] ]) { // Main interval has more priority than other interval in same category
|
462
462
|
ary[idx] = interval;
|
@@ -464,15 +464,15 @@ TSISubscription.prototype._extractMetadata = function(serviceResponse) {
|
|
464
464
|
}
|
465
465
|
}
|
466
466
|
|
467
|
-
|
468
|
-
|
467
|
+
let viewData = null;
|
468
|
+
let columns;
|
469
469
|
for(k = 0; k < aryLen; k++) {
|
470
470
|
interval = ary[k];
|
471
471
|
ary[k] = null; // Clear array for reused
|
472
472
|
if(interval != null && viewData === null) {
|
473
473
|
columns = 0; // Reset
|
474
474
|
|
475
|
-
for(
|
475
|
+
for(let l = interval["fields"].length; --l >= 0;) { // Column mask for view + interval
|
476
476
|
columns |= TSISubscription.COLUMN_MASK_ENUM[ interval["fields"][l] ]; // undefined will be same as 0
|
477
477
|
}
|
478
478
|
|
@@ -524,14 +524,14 @@ TSISubscription.prototype._getKey = function(symbol, view, period) {
|
|
524
524
|
* @return {Object.<string, Array>}
|
525
525
|
*/
|
526
526
|
TSISubscription.prototype._buildRequestInfo = function(reqPayload, dateMap) {
|
527
|
-
|
528
|
-
|
529
|
-
|
527
|
+
let ric = reqPayload.ric;
|
528
|
+
let view = reqPayload.view;
|
529
|
+
let viewData = this._tsiMetadata[ric] && this._tsiMetadata[ric][view];
|
530
530
|
if(!viewData) {
|
531
531
|
return null;
|
532
532
|
}
|
533
533
|
|
534
|
-
|
534
|
+
let period = dateMap[reqPayload.period];
|
535
535
|
if(period == null) {
|
536
536
|
period = TSISubscription._dateCalculation(reqPayload.period).getTime();
|
537
537
|
dateMap[reqPayload.period] = period;
|
@@ -560,7 +560,7 @@ TSISubscription.prototype._requestTSIData = function(symbol, view, period) {
|
|
560
560
|
return;
|
561
561
|
}
|
562
562
|
|
563
|
-
|
563
|
+
let key = this._getKey(symbol, view, period);
|
564
564
|
if(this._tsiDataPendingMap[key] || this._tsiDataMap[key]) { // Already in list
|
565
565
|
return;
|
566
566
|
}
|
@@ -580,12 +580,12 @@ TSISubscription.prototype._requestTSIData = function(symbol, view, period) {
|
|
580
580
|
TSISubscription.prototype._manageTSIDataQ = function() {
|
581
581
|
this._tsiDataTimer = 0; // Reset
|
582
582
|
|
583
|
-
|
583
|
+
let listMap = this._tsiDataMap;
|
584
584
|
this._tsiDataMap = {};
|
585
585
|
|
586
|
-
|
587
|
-
|
588
|
-
for(
|
586
|
+
let obj;
|
587
|
+
let listArr = [];
|
588
|
+
for(let key in listMap) {
|
589
589
|
obj = listMap[key];
|
590
590
|
if(this._hasMetadata(obj.ric)) {
|
591
591
|
if(this._tsiDataPendingMap[key]) {
|
@@ -615,17 +615,17 @@ TSISubscription.prototype._manageTSIDataQ = function() {
|
|
615
615
|
* @return {!Promise}
|
616
616
|
*/
|
617
617
|
TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
618
|
-
|
619
|
-
|
618
|
+
let reqPayloads = obj.list;
|
619
|
+
let len = reqPayloads.length;
|
620
620
|
if(len <= 0) {
|
621
621
|
return Promise.resolve("");
|
622
622
|
}
|
623
623
|
|
624
624
|
// Merge request
|
625
|
-
|
626
|
-
|
625
|
+
let qi = q.length;
|
626
|
+
let remaining = TSISubscription.MAX_CONCURRENT_OBJECT - len;
|
627
627
|
while(remaining > 0 && --qi >= 0) {
|
628
|
-
|
628
|
+
let qObj = q[qi];
|
629
629
|
reqPayloads = reqPayloads.concat( qObj.list.splice(0, remaining) );
|
630
630
|
|
631
631
|
len = reqPayloads.length; // Update length
|
@@ -635,10 +635,10 @@ TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
|
635
635
|
}
|
636
636
|
}
|
637
637
|
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
for(
|
638
|
+
let dateMap = {};
|
639
|
+
let requestInfos = [];
|
640
|
+
let reqInfo;
|
641
|
+
for(let i = len; --i >= 0;) {
|
642
642
|
reqInfo = this._buildRequestInfo(reqPayloads[i], dateMap);
|
643
643
|
if(reqInfo) {
|
644
644
|
requestInfos.push( reqInfo ); // BEWARE: This is the reverse loop
|
@@ -649,14 +649,14 @@ TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
|
649
649
|
* Complete the request so that it will not stay indefinitely as "pending"
|
650
650
|
* TRGRID-2335
|
651
651
|
*/
|
652
|
-
|
652
|
+
let key = this._getKey(reqPayloads[i].ric, reqPayloads[i].view, reqPayloads[i].period);
|
653
653
|
delete this._tsiDataPendingMap[key]; // Remove from pending map
|
654
654
|
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
for(
|
655
|
+
let periodRIC = this._getPeriodRICData(reqPayloads[i].period, reqPayloads[i].ric);
|
656
|
+
let periodMap = this._getPeriodMap(reqPayloads[i].period);
|
657
|
+
let fields = periodMap.field;
|
658
|
+
let rowData = {};
|
659
|
+
for(let field in fields) {
|
660
660
|
if(!fields[field]) continue;
|
661
661
|
periodRIC.dataCache[field] = null;
|
662
662
|
rowData[reqPayloads[i].period + "♠" + field] = periodRIC.dataCache[field];
|
@@ -670,8 +670,8 @@ TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
|
670
670
|
return Promise.resolve("");
|
671
671
|
}
|
672
672
|
|
673
|
-
|
674
|
-
|
673
|
+
let self = this; // TODO: This is bad
|
674
|
+
let payload = { "messages": requestInfos.reverse() }; // Reverse array back for normal order
|
675
675
|
return Util.requestText(this._tsiTaServiceUrl + "/CalculateAllData", payload)
|
676
676
|
.then(function(serviceResponse) {
|
677
677
|
return {
|
@@ -681,8 +681,8 @@ TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
|
681
681
|
})
|
682
682
|
.then(this._extractTSIData)
|
683
683
|
.catch(function(err) { // TODO: This is bad
|
684
|
-
for(
|
685
|
-
|
684
|
+
for(let i = len; --i >= 0;) { // eslint-disable-line
|
685
|
+
let key = self._getKey(reqPayloads[i].ric, reqPayloads[i].view, reqPayloads[i].period); // eslint-disable-line
|
686
686
|
delete self._tsiDataPendingMap[key]; // Remove from pending map
|
687
687
|
}
|
688
688
|
});
|
@@ -693,8 +693,8 @@ TSISubscription.prototype._onRequestTSIData = function(obj, q) {
|
|
693
693
|
* @return {Object}
|
694
694
|
*/
|
695
695
|
TSISubscription.prototype._extractTSIData = function(res) {
|
696
|
-
|
697
|
-
|
696
|
+
let response = res.response.replace(/\[NaN(,NaN)*\]/g, "[]"); // Handler for return the invalid JSON syntax due to no data
|
697
|
+
let json;
|
698
698
|
try {
|
699
699
|
json = /** @type {Object} */(JSON.parse(response));
|
700
700
|
} catch(ex) {
|
@@ -703,10 +703,10 @@ TSISubscription.prototype._extractTSIData = function(res) {
|
|
703
703
|
}
|
704
704
|
|
705
705
|
if(json) {
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
for(
|
706
|
+
let payload = res.payload;
|
707
|
+
let len = payload.length;
|
708
|
+
let periodRIC, dataCache, view, symbol, period, rowData, field, periodMap;
|
709
|
+
for(let i = 0; i < len; i++) {
|
710
710
|
view = payload[i].view;
|
711
711
|
symbol = payload[i].ric;
|
712
712
|
period = payload[i].period;
|
@@ -715,14 +715,14 @@ TSISubscription.prototype._extractTSIData = function(res) {
|
|
715
715
|
periodRIC.view[view] = true; // Mark as already requested
|
716
716
|
dataCache = periodRIC.dataCache;
|
717
717
|
|
718
|
-
|
718
|
+
let data = json[i]["Columns"] || [];
|
719
719
|
if(data.length === 0) {
|
720
720
|
continue;
|
721
721
|
}
|
722
722
|
|
723
723
|
rowData = {};
|
724
|
-
|
725
|
-
for(
|
724
|
+
let val;
|
725
|
+
for(let j = 0, dataLen = data.length; j < dataLen; j++) {
|
726
726
|
val = data[j]["Values"][0];
|
727
727
|
if(val == null || val !== val) {
|
728
728
|
/*
|
@@ -804,23 +804,23 @@ TSISubscription.prototype._extractTSIData = function(res) {
|
|
804
804
|
* @return {Promise}
|
805
805
|
*/
|
806
806
|
TSISubscription.prototype._requestTimeSeriesData = function(obj, q) {
|
807
|
-
|
808
|
-
for(
|
809
|
-
|
807
|
+
let period = obj.period;
|
808
|
+
for(let i = q.length; --i >= 0;) {
|
809
|
+
let qObj = q[i];
|
810
810
|
if(!qObj.rics && qObj.period === period) {
|
811
811
|
q.splice(i, 1); // Remove any duplicate period that is being queued
|
812
812
|
}
|
813
813
|
}
|
814
814
|
|
815
|
-
|
816
|
-
|
817
|
-
|
815
|
+
let periodMap = this._getPeriodMap(period);
|
816
|
+
let fields = Object.keys(periodMap.field);
|
817
|
+
let symbols = obj.rics ? obj.rics : Object.keys(periodMap.symbol);
|
818
818
|
|
819
819
|
if(fields.length === 0 || symbols.length === 0) {
|
820
820
|
return null;
|
821
821
|
}
|
822
822
|
|
823
|
-
|
823
|
+
let reqDate = TSISubscription._dateCalculation(period).toJSON();
|
824
824
|
if(reqDate === null) { // Invalid date/period parameter
|
825
825
|
return null;
|
826
826
|
} else {
|
@@ -833,7 +833,7 @@ TSISubscription.prototype._requestTimeSeriesData = function(obj, q) {
|
|
833
833
|
q.unshift(obj); // Push the request back at the front of the queue
|
834
834
|
}
|
835
835
|
|
836
|
-
|
836
|
+
let payload = {
|
837
837
|
"rics": symbols.join(" "),
|
838
838
|
"factList": fields.join(","),
|
839
839
|
"date": reqDate
|
@@ -855,21 +855,21 @@ TSISubscription.prototype._requestTimeSeriesData = function(obj, q) {
|
|
855
855
|
* @param {Object} json JSON object of TSI response
|
856
856
|
*/
|
857
857
|
TSISubscription.prototype._onTSIUpdate = function(json) {
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
858
|
+
let period = json["period"];
|
859
|
+
let result = json["result"];
|
860
|
+
let periodMap = this._getPeriodMap(period);
|
861
|
+
let fields = periodMap["field"];
|
862
862
|
|
863
|
-
|
863
|
+
let header = result[0];
|
864
864
|
if(!header) {
|
865
865
|
throw("Invalid response from TSI service");
|
866
866
|
}
|
867
867
|
|
868
|
-
|
869
|
-
|
870
|
-
//
|
871
|
-
|
872
|
-
for(
|
868
|
+
let ricIdx = -1;
|
869
|
+
let returnStatusIdx = -1;
|
870
|
+
// let timestampIdx = -1;
|
871
|
+
let fieldIdxMap = {};
|
872
|
+
for(let i = header.length; --i >= 0;) {
|
873
873
|
if(header[i] === "RIC") {
|
874
874
|
ricIdx = i;
|
875
875
|
} else if(header[i] === "ReturnStatus") {
|
@@ -882,16 +882,16 @@ TSISubscription.prototype._onTSIUpdate = function(json) {
|
|
882
882
|
}
|
883
883
|
fields = Object.keys(fieldIdxMap); // Collect the fields of result
|
884
884
|
|
885
|
-
|
886
|
-
|
887
|
-
//
|
885
|
+
let rowLen = result.length;
|
886
|
+
let symbol, value, rowData, dataCache;
|
887
|
+
// let isCorrectDate;
|
888
888
|
for(i = 1; i < rowLen; i++) {
|
889
889
|
symbol = result[i][ricIdx];
|
890
890
|
|
891
891
|
if(result[i][returnStatusIdx] !== "0") { // Have an error in response, then fallback to new TS data service
|
892
892
|
// Request to new service
|
893
|
-
for(
|
894
|
-
|
893
|
+
for(let k = fields.length; --k >= 0;) {
|
894
|
+
let view = fields[k].substring(0, fields[k].lastIndexOf("."));
|
895
895
|
if(!this._hasMetadata(symbol) || (this._tsiMetadata[symbol] && this._tsiMetadata[symbol][view])) { // No metadata || Ready to make a request
|
896
896
|
this._requestTSIData(symbol, view, period);
|
897
897
|
}
|
@@ -903,7 +903,7 @@ TSISubscription.prototype._onTSIUpdate = function(json) {
|
|
903
903
|
dataCache = this._getPeriodRICData(period, symbol).dataCache;
|
904
904
|
rowData = {};
|
905
905
|
|
906
|
-
for(
|
906
|
+
for(let j = fields.length; --j >= 0;) {
|
907
907
|
// value = (isCorrectDate) ? (result[i][fieldIdxMap[fields[j]]] || null) : null; // If result is same as the requested timestamp then return the value. Otherwise return null.
|
908
908
|
value = result[i][fieldIdxMap[fields[j]]] || null; // If return empty string, it should be null
|
909
909
|
if(value !== null) {
|
@@ -939,7 +939,7 @@ TSISubscription._addDays = function(date, day) {
|
|
939
939
|
*/
|
940
940
|
TSISubscription._addMonths = function(date, month) {
|
941
941
|
// Reference: http://stackoverflow.com/questions/7937233/how-do-i-calculate-the-date-in-javascript-three-months-prior-to-today
|
942
|
-
|
942
|
+
let expectedMonth = ((date.getMonth() + month) % 12 + 12) % 12;
|
943
943
|
date.setMonth(date.getMonth() + month);
|
944
944
|
if (date.getMonth() !== expectedMonth) { // If it has an error of native date subtraction
|
945
945
|
date.setDate(0); // Backward to the last day of previous month
|
@@ -972,25 +972,25 @@ TSISubscription._addDate = function(date, num, dateUnit) {
|
|
972
972
|
* @return {Date} Date object
|
973
973
|
*/
|
974
974
|
TSISubscription._dateCalculation = function(period) {
|
975
|
-
|
975
|
+
let goBackPeriods = period.match(/\d+(D|W|M|Q|Y)/g);
|
976
976
|
if(goBackPeriods) { // Relative date pattern
|
977
|
-
|
978
|
-
for(
|
979
|
-
|
980
|
-
|
981
|
-
|
977
|
+
let now = new Date();
|
978
|
+
for(let i = goBackPeriods.length; --i >= 0;){
|
979
|
+
let p = goBackPeriods[i];
|
980
|
+
let dateUnit = p.substr(p.length - 1);
|
981
|
+
let num = -(p.substr(0, p.length - 1));
|
982
982
|
now = TSISubscription._addDate(now, num, dateUnit);
|
983
983
|
}
|
984
984
|
return now;
|
985
985
|
}
|
986
986
|
|
987
987
|
// Specified date
|
988
|
-
|
988
|
+
let temp = new Date(period);
|
989
989
|
if(temp.toJSON() === null) {
|
990
990
|
console.warn("Invalid period parameter: " + period);
|
991
991
|
return null;
|
992
992
|
}
|
993
|
-
|
993
|
+
let date = null;
|
994
994
|
if(period.match(/^\d{1,4}(-\d{2}(-\d{2})?)?$/)) { // If ISO format (YYYY-MM-DD)
|
995
995
|
date = temp;
|
996
996
|
} else { // If non ISO format
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* @param {string} str
|
4
4
|
* @param {number=} index
|
5
5
|
*/
|
6
|
-
|
6
|
+
let VariableToken = function(str, index) {
|
7
7
|
str = str.trim();
|
8
8
|
|
9
9
|
if(this._inputConverter[str]) {
|
@@ -21,8 +21,8 @@ var VariableToken = function(str, index) {
|
|
21
21
|
return;
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
let firstChar = str.charAt(0);
|
25
|
+
let lastChar = (str.length > 1) ? str.charAt(str.length - 1) : "";
|
26
26
|
if(firstChar === '"' && lastChar === '"') {
|
27
27
|
this._value = str.substring(1, str.length - 1);
|
28
28
|
this._type = "string";
|
@@ -42,19 +42,19 @@ var VariableToken = function(str, index) {
|
|
42
42
|
return;
|
43
43
|
}
|
44
44
|
|
45
|
-
|
45
|
+
let adc = str.match(/TR\.\w+\(/);
|
46
46
|
if(adc) { // ADC field with parameters
|
47
47
|
this._type = "dynamic"; // ADC field with params always a dynamic token field
|
48
48
|
return;
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
let funcs = str.match(/[\w._]+\(/g);
|
52
52
|
if(funcs && funcs.length === 1) { // There must be only one method in the given str
|
53
53
|
this._resolveFunction(str, funcs[0]); // Function has undefined value (this._value == null)
|
54
54
|
return;
|
55
55
|
}
|
56
56
|
|
57
|
-
|
57
|
+
let words = str.match(/[\w._♦]+/g);
|
58
58
|
if(words && words.length > 1) { // A group of expression without parentheses
|
59
59
|
this._resolveVariableGroup(str);
|
60
60
|
return;
|
@@ -65,7 +65,7 @@ var VariableToken = function(str, index) {
|
|
65
65
|
return;
|
66
66
|
}
|
67
67
|
|
68
|
-
|
68
|
+
let num = Number(str);
|
69
69
|
if(num === num) { // If not NaN
|
70
70
|
this._value = num;
|
71
71
|
this._type = "number";
|
@@ -187,12 +187,12 @@ VariableToken.prototype.getInputWithTokenField = function() {
|
|
187
187
|
* @return {string}
|
188
188
|
*/
|
189
189
|
VariableToken.prototype.getChildInputWithToken = function() {
|
190
|
-
|
190
|
+
let len = this._subVars ? this._subVars.length : 0;
|
191
191
|
if(len <= 0) {
|
192
192
|
return "";
|
193
193
|
}
|
194
|
-
|
195
|
-
for(
|
194
|
+
let inputs = new Array(len);
|
195
|
+
for(let i = 0; i < len; ++i) {
|
196
196
|
inputs[i] = this._subVars[i].getInputWithTokenField();
|
197
197
|
}
|
198
198
|
return inputs.join(", ");
|
@@ -233,8 +233,8 @@ VariableToken.prototype.getFunctionName = function() { return this._funcName; };
|
|
233
233
|
VariableToken.prototype.getFieldNames = function(opt_obj) {
|
234
234
|
if(this._subVars) {
|
235
235
|
if(opt_obj) {
|
236
|
-
|
237
|
-
for(
|
236
|
+
let len = this._subVars.length;
|
237
|
+
for(let i = 0; i < len; ++i) {
|
238
238
|
this._subVars[i].getFieldNames(opt_obj);
|
239
239
|
}
|
240
240
|
}
|
@@ -254,14 +254,14 @@ VariableToken.prototype.getFieldNames = function(opt_obj) {
|
|
254
254
|
* @returns {string}
|
255
255
|
*/
|
256
256
|
VariableToken.prototype._resolveVariableGroup = function(str) {
|
257
|
-
|
257
|
+
let i = this._subVars ? this._subVars.length : 0;
|
258
258
|
this._type = "group";
|
259
259
|
|
260
260
|
this._value = str.replace(/[\w._♦]+/g, function(varStr) {
|
261
261
|
if(!this._subVars) {
|
262
262
|
this._subVars = [];
|
263
263
|
}
|
264
|
-
|
264
|
+
let varToken = new VariableToken(varStr, this._subVars.length);
|
265
265
|
this._subVars.push(varToken);
|
266
266
|
return varToken.getExpression();
|
267
267
|
}.bind(this));
|
@@ -286,9 +286,9 @@ VariableToken.prototype._resolveFunction = function(str, matchedName) {
|
|
286
286
|
str = str.substr(0, str.length - 1); // Strip ")"
|
287
287
|
if(str) {
|
288
288
|
this._subVars = [];
|
289
|
-
|
290
|
-
|
291
|
-
for(
|
289
|
+
let params = str.split(",");
|
290
|
+
let len = params.length;
|
291
|
+
for(let i = 0; i < len; ++i) {
|
292
292
|
this._subVars[i] = new VariableToken(params[i], i);
|
293
293
|
}
|
294
294
|
}
|
@@ -302,9 +302,9 @@ VariableToken.prototype._resolveArray = function(str) {
|
|
302
302
|
str = str.substr(1, str.length - 1); // Strip "[" and "]"
|
303
303
|
if(str) {
|
304
304
|
this._subVars = [];
|
305
|
-
|
306
|
-
|
307
|
-
for(
|
305
|
+
let params = str.split(",");
|
306
|
+
let len = params.length;
|
307
|
+
for(let i = 0; i < len; ++i) {
|
308
308
|
this._subVars[i] = new VariableToken(params[i], i);
|
309
309
|
}
|
310
310
|
}
|
@@ -12,7 +12,7 @@ import DateTime from "../../DateTime.js";
|
|
12
12
|
* {lang=ru} AdFin data access function
|
13
13
|
* {lang=de} AdFin-Daten Zugriffsfunktion
|
14
14
|
*/
|
15
|
-
|
15
|
+
let AdFin = {};
|
16
16
|
|
17
17
|
/**
|
18
18
|
* @ignore
|
@@ -21,9 +21,9 @@ var AdFin = {};
|
|
21
21
|
* @return {boolean} true if parameter is number of seconds since 01 JAN 1970 UTC (realtime date number), false otherwise
|
22
22
|
*/
|
23
23
|
AdFin._dateIsSecondsSince1970 = function (seconds) {
|
24
|
-
|
24
|
+
let milliseconds = seconds * 1000;
|
25
25
|
if (('' + milliseconds).indexOf(".") !== -1) return false;
|
26
|
-
|
26
|
+
let jsDate = new Date(milliseconds);
|
27
27
|
if (isNaN(jsDate.getTime())) return false;
|
28
28
|
if (jsDate.getFullYear() === 1970) return false;
|
29
29
|
return true;
|
@@ -50,7 +50,7 @@ AdFin._convertDaysSince1900UTCToJJMMMYYYY = function (value) {
|
|
50
50
|
* @return {number|null} days number since 1 Jan, 1900 UTC
|
51
51
|
*/
|
52
52
|
AdFin._convertSecondsSince1970ToDaysSince1900 = function (value) {
|
53
|
-
|
53
|
+
let jsDate = new Date(value * 1000);
|
54
54
|
if (isNaN(jsDate.getTime())) return null; // invalid date
|
55
55
|
if (jsDate.getFullYear() === 1970) return null;
|
56
56
|
return DateTime.toDateNumber(jsDate); // days number since 1 Jan, 1900
|
@@ -63,7 +63,7 @@ AdFin._convertSecondsSince1970ToDaysSince1900 = function (value) {
|
|
63
63
|
* @return {string|null} string date JJMMMYYYY
|
64
64
|
*/
|
65
65
|
AdFin._convertSecondsSince1970UTCToJJMMMYYYY = function (value) {
|
66
|
-
|
66
|
+
let days = AdFin._convertSecondsSince1970ToDaysSince1900(value);
|
67
67
|
if (days == null) return null;
|
68
68
|
return AdFin._convertDaysSince1900UTCToJJMMMYYYY(days);
|
69
69
|
};
|
@@ -239,10 +239,10 @@ AdFin.Definitions = {
|
|
239
239
|
*/
|
240
240
|
AdFin._genericFunction = function (name, args) {
|
241
241
|
|
242
|
-
/** @type {Array.<{name:string, type:string}>} */
|
243
|
-
/** @type {Array.<Array.<string|number|null>>} */
|
242
|
+
/** @type {Array.<{name:string, type:string}>} */ let definitions = AdFin.Definitions[name];
|
243
|
+
/** @type {Array.<Array.<string|number|null>>} */ let parameters = [];
|
244
244
|
|
245
|
-
for (
|
245
|
+
for (let i = 0, length = args.length; i < length; ++i) {
|
246
246
|
if (args[i] != null) {
|
247
247
|
if ((definitions[i].type === "JJMMMYYYY") && (typeof (args[i]) === "number")) {
|
248
248
|
if (AdFin._dateIsSecondsSince1970(args[i])) {
|
@@ -262,7 +262,7 @@ AdFin._genericFunction = function (name, args) {
|
|
262
262
|
}
|
263
263
|
}
|
264
264
|
|
265
|
-
|
265
|
+
let adfinService = this.getIntervalService("AdFin");
|
266
266
|
if (!adfinService) {
|
267
267
|
adfinService = AdFinService.create();
|
268
268
|
if (!adfinService) {
|
@@ -272,7 +272,7 @@ AdFin._genericFunction = function (name, args) {
|
|
272
272
|
this.setIntervalService("AdFin", adfinService);
|
273
273
|
}
|
274
274
|
|
275
|
-
|
275
|
+
let res = adfinService["call"](name, parameters);
|
276
276
|
if (res === "...") {
|
277
277
|
this.setDataError("Pending - no erase"); // Data update is pending - do not erase previous value
|
278
278
|
}
|