neo.mjs 8.42.0 → 8.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/ServiceWorker.mjs +2 -2
- package/apps/colors/view/BarChartComponent.mjs +1 -1
- package/apps/colors/view/{TableContainer.mjs → GridContainer.mjs} +21 -22
- package/apps/colors/view/HeaderToolbar.mjs +3 -3
- package/apps/colors/view/Viewport.mjs +5 -3
- package/apps/colors/view/ViewportController.mjs +10 -10
- package/apps/covid/neo-config.json +2 -1
- package/apps/covid/view/MainContainerController.mjs +47 -39
- package/apps/covid/view/TableContainerController.mjs +20 -4
- package/apps/covid/view/country/Table.mjs +3 -3
- package/apps/portal/index.html +1 -1
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/sharedcovid/neo-config.json +1 -0
- package/apps/sharedcovid/view/MainContainerController.mjs +58 -50
- package/apps/sharedcovid/view/TableContainerController.mjs +20 -3
- package/apps/sharedcovid/view/country/Table.mjs +3 -2
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/component/coronaGallery/Viewport.mjs +4 -2
- package/examples/component/coronaGallery/neo-config.json +2 -1
- package/examples/component/coronaHelix/MainContainer.mjs +4 -2
- package/examples/component/coronaHelix/neo-config.json +2 -1
- package/examples/component/multiWindowCoronaGallery/neo-config.json +1 -0
- package/examples/component/toast/MainContainer.mjs +1 -0
- package/examples/component/toast/MainContainerController.mjs +3 -1
- package/examples/grid/animatedRowSorting/Viewport.mjs +4 -3
- package/examples/grid/cellEditing/MainContainer.mjs +6 -5
- package/examples/grid/nestedRecordFields/Viewport.mjs +1 -14
- package/examples/grid/nestedRecordFields/ViewportController.mjs +23 -0
- package/package.json +1 -1
- package/resources/scss/src/apps/colors/GridContainer.scss +68 -0
- package/resources/scss/src/grid/header/Toolbar.scss +2 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Toast.mjs +5 -4
- package/src/component/wrapper/AmChart.mjs +1 -1
- package/src/controller/Component.mjs +12 -4
- package/src/draggable/toolbar/SortZone.mjs +12 -9
- package/src/grid/Container.mjs +4 -2
- package/src/grid/column/Base.mjs +2 -1
- package/src/grid/column/Component.mjs +5 -3
- package/src/selection/Model.mjs +4 -0
- package/resources/scss/src/apps/colors/TableContainer.scss +0 -66
package/apps/ServiceWorker.mjs
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
import
|
1
|
+
import BaseGridContainer from '../../../src/grid/Container.mjs';
|
2
2
|
|
3
3
|
/**
|
4
|
-
* @class Colors.view.
|
5
|
-
* @extends Neo.
|
4
|
+
* @class Colors.view.GridContainer
|
5
|
+
* @extends Neo.grid.Container
|
6
6
|
*/
|
7
|
-
class
|
7
|
+
class GridContainer extends BaseGridContainer {
|
8
8
|
static config = {
|
9
9
|
/**
|
10
|
-
* @member {String} className='Colors.view.
|
10
|
+
* @member {String} className='Colors.view.GridContainer'
|
11
11
|
* @protected
|
12
12
|
*/
|
13
|
-
className: 'Colors.view.
|
13
|
+
className: 'Colors.view.GridContainer',
|
14
14
|
/**
|
15
15
|
* @member {Number|null} amountColumns_=null
|
16
16
|
*/
|
@@ -28,17 +28,9 @@ class TableContainer extends Container {
|
|
28
28
|
store : 'stores.colors'
|
29
29
|
},
|
30
30
|
/**
|
31
|
-
* @member {String[]} cls=['colors-
|
31
|
+
* @member {String[]} cls=['colors-grid-container']
|
32
32
|
*/
|
33
|
-
cls: ['colors-
|
34
|
-
/**
|
35
|
-
* @member {Object} columnDefaults
|
36
|
-
*/
|
37
|
-
columnDefaults: {
|
38
|
-
renderer(data) {
|
39
|
-
return {cls: ['color-' + data.value], html: ' '}
|
40
|
-
}
|
41
|
-
}
|
33
|
+
cls: ['colors-grid-container']
|
42
34
|
}
|
43
35
|
|
44
36
|
/**
|
@@ -52,12 +44,10 @@ class TableContainer extends Container {
|
|
52
44
|
let startCharCode = 'A'.charCodeAt(0),
|
53
45
|
i = 0,
|
54
46
|
columns = [{
|
55
|
-
|
56
|
-
dataField: '
|
57
|
-
dock : 'left',
|
58
|
-
minWidth : 40,
|
47
|
+
cellAlign: 'right',
|
48
|
+
dataField: 'id',
|
59
49
|
text : '#',
|
60
|
-
|
50
|
+
type : 'index',
|
61
51
|
width : 40
|
62
52
|
}],
|
63
53
|
currentChar;
|
@@ -67,6 +57,7 @@ class TableContainer extends Container {
|
|
67
57
|
|
68
58
|
columns.push({
|
69
59
|
dataField: 'column' + currentChar,
|
60
|
+
renderer : 'up.colorRenderer',
|
70
61
|
text : currentChar
|
71
62
|
})
|
72
63
|
}
|
@@ -84,6 +75,14 @@ class TableContainer extends Container {
|
|
84
75
|
afterSetAmountRows(value, oldValue) {
|
85
76
|
this.store?.clear()
|
86
77
|
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* @param {Object} data
|
81
|
+
* @returns {Object}
|
82
|
+
*/
|
83
|
+
colorRenderer({value}) {
|
84
|
+
return {cls: ['color-' + value], html: ' '}
|
85
|
+
}
|
87
86
|
}
|
88
87
|
|
89
|
-
export default Neo.setupClass(
|
88
|
+
export default Neo.setupClass(GridContainer);
|
@@ -69,10 +69,10 @@ class HeaderToolbar extends Toolbar {
|
|
69
69
|
cls : ['header-spacer'],
|
70
70
|
flex : 1
|
71
71
|
}, {
|
72
|
-
handler : '
|
72
|
+
handler : 'onDetachGridButtonClick',
|
73
73
|
iconCls : 'fas fa-table',
|
74
|
-
reference: 'detach-
|
75
|
-
text : '
|
74
|
+
reference: 'detach-grid-button',
|
75
|
+
text : 'Grid'
|
76
76
|
}, {
|
77
77
|
handler : 'onDetachPieChartButtonClick',
|
78
78
|
iconCls : 'fas fa-chart-pie',
|
@@ -2,7 +2,7 @@ import BaseViewport from '../../../src/container/Viewport.mjs';
|
|
2
2
|
import BarChartComponent from './BarChartComponent.mjs';
|
3
3
|
import HeaderToolbar from './HeaderToolbar.mjs';
|
4
4
|
import PieChartComponent from './PieChartComponent.mjs';
|
5
|
-
import
|
5
|
+
import GridContainer from './GridContainer.mjs';
|
6
6
|
import ViewportController from './ViewportController.mjs';
|
7
7
|
import ViewportStateProvider from './ViewportStateProvider.mjs';
|
8
8
|
|
@@ -36,13 +36,15 @@ class Viewport extends BaseViewport {
|
|
36
36
|
module: HeaderToolbar,
|
37
37
|
flex : 'none'
|
38
38
|
}, {
|
39
|
-
module :
|
40
|
-
reference: '
|
39
|
+
module : GridContainer,
|
40
|
+
reference: 'grid'
|
41
41
|
}, {
|
42
42
|
module : PieChartComponent,
|
43
|
+
flex : 1.3,
|
43
44
|
reference: 'pie-chart'
|
44
45
|
}, {
|
45
46
|
module : BarChartComponent,
|
47
|
+
flex : 1.3,
|
46
48
|
reference: 'bar-chart'
|
47
49
|
}],
|
48
50
|
/**
|
@@ -27,7 +27,7 @@ class ViewportController extends Controller {
|
|
27
27
|
widgetIndexMap = {
|
28
28
|
'bar-chart': 3,
|
29
29
|
'pie-chart': 2,
|
30
|
-
|
30
|
+
grid : 1
|
31
31
|
}
|
32
32
|
|
33
33
|
/**
|
@@ -188,15 +188,15 @@ class ViewportController extends Controller {
|
|
188
188
|
/**
|
189
189
|
* @param {Object} data
|
190
190
|
*/
|
191
|
-
async
|
192
|
-
await this.createBrowserWindow('
|
191
|
+
async onDetachGridButtonClick(data) {
|
192
|
+
await this.createBrowserWindow('grid')
|
193
193
|
}
|
194
194
|
|
195
195
|
/**
|
196
196
|
* @param {Object} data
|
197
197
|
*/
|
198
|
-
async
|
199
|
-
await this.createBrowserWindow('
|
198
|
+
async onDetachPieChartButtonClick(data) {
|
199
|
+
await this.createBrowserWindow('pie-chart')
|
200
200
|
}
|
201
201
|
|
202
202
|
/**
|
@@ -256,12 +256,12 @@ class ViewportController extends Controller {
|
|
256
256
|
/**
|
257
257
|
* @param {Object[]} records
|
258
258
|
*/
|
259
|
-
|
260
|
-
let
|
261
|
-
{store} =
|
259
|
+
updateGrid(records) {
|
260
|
+
let grid = this.getReference('grid'),
|
261
|
+
{store} = grid;
|
262
262
|
|
263
263
|
if (store.getCount()) {
|
264
|
-
|
264
|
+
grid.bulkUpdateRecords(records)
|
265
265
|
} else {
|
266
266
|
// Depending on the delay of the Socket Connection,
|
267
267
|
// the next data package could still contain the old settings
|
@@ -293,7 +293,7 @@ class ViewportController extends Controller {
|
|
293
293
|
if (!me.isDestroyed) {
|
294
294
|
let {data} = response;
|
295
295
|
|
296
|
-
me.
|
296
|
+
me.updateGrid(data.tableData);
|
297
297
|
me.updateCharts(data.summaryData)
|
298
298
|
}
|
299
299
|
}
|
@@ -4,5 +4,6 @@
|
|
4
4
|
"environment" : "development",
|
5
5
|
"mainPath" : "./Main.mjs",
|
6
6
|
"mainThreadAddons": ["AmCharts", "DragDrop", "MapboxGL", "Navigator", "Stylesheet"],
|
7
|
-
"themes" : ["neo-theme-dark", "neo-theme-light"]
|
7
|
+
"themes" : ["neo-theme-dark", "neo-theme-light"],
|
8
|
+
"useFallbackApi" : true
|
8
9
|
}
|
@@ -22,6 +22,14 @@ class MainContainerController extends ComponentController {
|
|
22
22
|
* @member {Number} activeMainTabIndex=0
|
23
23
|
*/
|
24
24
|
activeMainTabIndex: 0,
|
25
|
+
/**
|
26
|
+
* @member {String} apiSummaryUrl='https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/cvid_static/all.json'
|
27
|
+
*/
|
28
|
+
apiFallbackSummaryUrl: 'https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/cvid_static/all.json',
|
29
|
+
/**
|
30
|
+
* @member {String} apiUrl='https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/cvid_static_countries.json'
|
31
|
+
*/
|
32
|
+
apiFallbackUrl: 'https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/cvid_static_countries.json',
|
25
33
|
/**
|
26
34
|
* @member {String} apiSummaryUrl='https://disease.sh/v3/covid-19/all'
|
27
35
|
*/
|
@@ -77,7 +85,7 @@ class MainContainerController extends ComponentController {
|
|
77
85
|
}
|
78
86
|
|
79
87
|
item.casesPerOneMillion = item.casesPerOneMillion > item.cases ? 'N/A' : item.casesPerOneMillion || 0;
|
80
|
-
item.infected = item.casesPerOneMillion
|
88
|
+
item.infected = item.casesPerOneMillion
|
81
89
|
});
|
82
90
|
|
83
91
|
me.data = data;
|
@@ -88,23 +96,23 @@ class MainContainerController extends ComponentController {
|
|
88
96
|
me.onCountryFieldChange({
|
89
97
|
component: countryField,
|
90
98
|
value : countryField.value
|
91
|
-
})
|
99
|
+
})
|
92
100
|
}
|
93
101
|
|
94
102
|
if (['gallery', 'helix', 'table'].includes(reference)) {
|
95
103
|
if (activeTab) {
|
96
|
-
activeTab.store.data = data
|
104
|
+
activeTab.store.data = data
|
97
105
|
}
|
98
106
|
}
|
99
107
|
|
100
108
|
else if (reference === 'mapboxglmap') {
|
101
109
|
me.getReference('mapboxglmap').chartData = data;
|
102
|
-
me.mapboxglMapHasData = true
|
110
|
+
me.mapboxglMapHasData = true
|
103
111
|
}
|
104
112
|
|
105
113
|
else if (reference === 'worldmap') {
|
106
114
|
activeTab.loadData(data);
|
107
|
-
me.worldMapHasData = true
|
115
|
+
me.worldMapHasData = true
|
108
116
|
}
|
109
117
|
}
|
110
118
|
|
@@ -140,7 +148,7 @@ class MainContainerController extends ComponentController {
|
|
140
148
|
second: 'numeric'
|
141
149
|
}).format(new Date(data.updated));
|
142
150
|
|
143
|
-
container.update()
|
151
|
+
container.update()
|
144
152
|
}
|
145
153
|
|
146
154
|
/**
|
@@ -150,10 +158,10 @@ class MainContainerController extends ComponentController {
|
|
150
158
|
*/
|
151
159
|
getTabIndex(hashObject) {
|
152
160
|
if (!hashObject || !hashObject.mainview) {
|
153
|
-
return 0
|
161
|
+
return 0
|
154
162
|
}
|
155
163
|
|
156
|
-
return this.mainTabs.indexOf(hashObject.mainview)
|
164
|
+
return this.mainTabs.indexOf(hashObject.mainview)
|
157
165
|
}
|
158
166
|
|
159
167
|
/**
|
@@ -161,18 +169,19 @@ class MainContainerController extends ComponentController {
|
|
161
169
|
* @returns {Neo.component.Base}
|
162
170
|
*/
|
163
171
|
getView(tabIndex) {
|
164
|
-
return this.getReference(this.mainTabs[tabIndex])
|
172
|
+
return this.getReference(this.mainTabs[tabIndex])
|
165
173
|
}
|
166
174
|
|
167
175
|
/**
|
168
176
|
*
|
169
177
|
*/
|
170
178
|
loadData() {
|
171
|
-
let me
|
179
|
+
let me = this,
|
180
|
+
apiUrl = Neo.config.useFallbackApi ? me.apiFallbackUrl : me.apiUrl;
|
172
181
|
|
173
|
-
fetch(
|
182
|
+
fetch(apiUrl)
|
174
183
|
.then(response => response.json())
|
175
|
-
.catch(err => console.log('Can’t access ' +
|
184
|
+
.catch(err => console.log('Can’t access ' + apiUrl, err))
|
176
185
|
.then(data => me.addStoreItems(data));
|
177
186
|
}
|
178
187
|
|
@@ -180,11 +189,12 @@ class MainContainerController extends ComponentController {
|
|
180
189
|
*
|
181
190
|
*/
|
182
191
|
loadSummaryData() {
|
183
|
-
let me
|
192
|
+
let me = this,
|
193
|
+
apiSummaryUrl = Neo.config.useFallbackApi ? me.apiFallbackSummaryUrl : me.apiSummaryUrl;
|
184
194
|
|
185
|
-
fetch(
|
195
|
+
fetch(apiSummaryUrl)
|
186
196
|
.then(response => response.json())
|
187
|
-
.catch(err => console.log('Can’t access ' +
|
197
|
+
.catch(err => console.log('Can’t access ' + apiSummaryUrl, err))
|
188
198
|
.then(data => me.applySummaryData(data));
|
189
199
|
|
190
200
|
me.timeout(2000).then(() => {
|
@@ -205,7 +215,7 @@ class MainContainerController extends ComponentController {
|
|
205
215
|
country : 'all',
|
206
216
|
hash : {mainview: 'table'},
|
207
217
|
hashString: 'mainview=table'
|
208
|
-
}, null)
|
218
|
+
}, null)
|
209
219
|
}
|
210
220
|
}
|
211
221
|
|
@@ -220,7 +230,7 @@ class MainContainerController extends ComponentController {
|
|
220
230
|
me.loadData();
|
221
231
|
me.loadSummaryData();
|
222
232
|
|
223
|
-
me.component.on('mounted', me.onMainViewMounted, me)
|
233
|
+
me.component.on('mounted', me.onMainViewMounted, me)
|
224
234
|
}
|
225
235
|
|
226
236
|
/**
|
@@ -235,15 +245,15 @@ class MainContainerController extends ComponentController {
|
|
235
245
|
if (store.getCount() > 0) {
|
236
246
|
if (Neo.isRecord(value)) {
|
237
247
|
record = value;
|
238
|
-
value = value[component.displayField]
|
248
|
+
value = value[component.displayField]
|
239
249
|
} else {
|
240
|
-
record = value && store.find('country', value)?.[0]
|
250
|
+
record = value && store.find('country', value)?.[0]
|
241
251
|
}
|
242
252
|
|
243
253
|
this.setState({
|
244
254
|
country : value,
|
245
255
|
countryRecord: record || null
|
246
|
-
})
|
256
|
+
})
|
247
257
|
}
|
248
258
|
}
|
249
259
|
|
@@ -283,22 +293,22 @@ class MainContainerController extends ComponentController {
|
|
283
293
|
if (ntype === 'mapboxgl' && me.data) {
|
284
294
|
if (me.mapboxStyle) {
|
285
295
|
activeView.mapboxStyle = activeView[me.mapboxStyle];
|
286
|
-
delete me.mapboxStyle
|
296
|
+
delete me.mapboxStyle
|
287
297
|
}
|
288
298
|
|
289
299
|
if (!me.mapboxglMapHasData) {
|
290
300
|
activeView.chartData = me.data;
|
291
|
-
me.mapboxglMapHasData = true
|
301
|
+
me.mapboxglMapHasData = true
|
292
302
|
}
|
293
303
|
|
294
304
|
countryRecord = me.getStateProvider().data.countryRecord;
|
295
305
|
countryRecord && MainContainerController.selectMapboxGlCountry(activeView, countryRecord);
|
296
306
|
|
297
|
-
activeView.autoResize()
|
307
|
+
activeView.autoResize()
|
298
308
|
} else if (ntype === 'covid-world-map' && me.data) {
|
299
309
|
if (!me.worldMapHasData) {
|
300
310
|
activeView.loadData(me.data);
|
301
|
-
me.worldMapHasData = true
|
311
|
+
me.worldMapHasData = true
|
302
312
|
}
|
303
313
|
}
|
304
314
|
}
|
@@ -321,7 +331,7 @@ class MainContainerController extends ComponentController {
|
|
321
331
|
].join('')
|
322
332
|
});
|
323
333
|
|
324
|
-
table.update()
|
334
|
+
table.update()
|
325
335
|
}
|
326
336
|
|
327
337
|
/**
|
@@ -336,7 +346,7 @@ class MainContainerController extends ComponentController {
|
|
336
346
|
src : 'https://buttons.github.io/buttons.js'
|
337
347
|
});
|
338
348
|
|
339
|
-
me.getReference('tab-container').on('moveTo', me.onTabMove, me)
|
349
|
+
me.getReference('tab-container').on('moveTo', me.onTabMove, me)
|
340
350
|
}
|
341
351
|
|
342
352
|
/**
|
@@ -344,7 +354,7 @@ class MainContainerController extends ComponentController {
|
|
344
354
|
*/
|
345
355
|
onReloadDataButtonClick(data) {
|
346
356
|
this.loadData();
|
347
|
-
this.loadSummaryData()
|
357
|
+
this.loadSummaryData()
|
348
358
|
}
|
349
359
|
|
350
360
|
/**
|
@@ -357,7 +367,7 @@ class MainContainerController extends ComponentController {
|
|
357
367
|
me.component.remove(me.getReference('footer'), true);
|
358
368
|
|
359
369
|
if (activeTab.ntype === 'covid-mapboxgl-container') {
|
360
|
-
me.getReference('mapboxglmap').autoResize()
|
370
|
+
me.getReference('mapboxglmap').autoResize()
|
361
371
|
}
|
362
372
|
}
|
363
373
|
|
@@ -372,20 +382,18 @@ class MainContainerController extends ComponentController {
|
|
372
382
|
logoPath = 'https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/images/apps/covid/',
|
373
383
|
mapView = me.getReference('mapboxglmap'),
|
374
384
|
themeLight = button.text === 'Theme Light',
|
375
|
-
buttonText, cls,
|
385
|
+
buttonText, cls, iconCls, mapViewStyle, theme;
|
376
386
|
|
377
387
|
if (themeLight) {
|
378
388
|
buttonText = 'Theme Dark';
|
379
|
-
href = '../dist/development/neo-theme-light-no-css-vars.css';
|
380
389
|
iconCls = 'fa fa-moon';
|
381
390
|
mapViewStyle = mapView?.mapboxStyleLight;
|
382
|
-
theme = 'neo-theme-light'
|
391
|
+
theme = 'neo-theme-light'
|
383
392
|
} else {
|
384
393
|
buttonText = 'Theme Light';
|
385
|
-
href = '../dist/development/neo-theme-dark-no-css-vars.css';
|
386
394
|
iconCls = 'fa fa-sun';
|
387
395
|
mapViewStyle = mapView?.mapboxStyleDark;
|
388
|
-
theme = 'neo-theme-dark'
|
396
|
+
theme = 'neo-theme-dark'
|
389
397
|
}
|
390
398
|
|
391
399
|
logo.vdom.src = logoPath + (theme === 'neo-theme-dark' ? 'covid_logo_dark.jpg' : 'covid_logo_light.jpg');
|
@@ -395,7 +403,7 @@ class MainContainerController extends ComponentController {
|
|
395
403
|
|
396
404
|
component.cls.forEach(item => {
|
397
405
|
if (item.includes('neo-theme')) {
|
398
|
-
NeoArray.remove(cls, item)
|
406
|
+
NeoArray.remove(cls, item)
|
399
407
|
}
|
400
408
|
});
|
401
409
|
|
@@ -405,9 +413,9 @@ class MainContainerController extends ComponentController {
|
|
405
413
|
button.set({iconCls, text: buttonText});
|
406
414
|
|
407
415
|
if (mapView) {
|
408
|
-
mapView.mapboxStyle = mapViewStyle
|
416
|
+
mapView.mapboxStyle = mapViewStyle
|
409
417
|
} else {
|
410
|
-
me.mapboxStyle = themeLight ? 'mapboxStyleLight' : 'mapboxStyleDark'
|
418
|
+
me.mapboxStyle = themeLight ? 'mapboxStyleLight' : 'mapboxStyleDark'
|
411
419
|
}
|
412
420
|
}
|
413
421
|
|
@@ -415,14 +423,14 @@ class MainContainerController extends ComponentController {
|
|
415
423
|
* @param {Object} data
|
416
424
|
*/
|
417
425
|
onTabMove(data) {
|
418
|
-
NeoArray.move(this.mainTabs, data.fromIndex, data.toIndex)
|
426
|
+
NeoArray.move(this.mainTabs, data.fromIndex, data.toIndex)
|
419
427
|
}
|
420
428
|
|
421
429
|
/**
|
422
430
|
* @param view
|
423
431
|
* @param record
|
424
432
|
*/
|
425
|
-
static selectMapboxGlCountry(view, record) {
|
433
|
+
static selectMapboxGlCountry(view, record) {
|
426
434
|
// https://github.com/neomjs/neo/issues/490
|
427
435
|
// there are missing iso2&3 values on natural earth vector
|
428
436
|
const map = {
|
@@ -441,7 +449,7 @@ class MainContainerController extends ComponentController {
|
|
441
449
|
lng: record.countryInfo.long
|
442
450
|
});
|
443
451
|
|
444
|
-
view.zoom = 5
|
452
|
+
view.zoom = 5 // todo: we could use a different value for big countries (Russia, USA,...)
|
445
453
|
}
|
446
454
|
}
|
447
455
|
|
@@ -16,6 +16,14 @@ class TableContainerController extends ComponentController {
|
|
16
16
|
* @member {String} apiBaseUrl='https://disease.sh/'
|
17
17
|
*/
|
18
18
|
apiBaseUrl: 'https://disease.sh/',
|
19
|
+
/**
|
20
|
+
* @member {String} apiBaseUrl='https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/'
|
21
|
+
*/
|
22
|
+
apiFallbackBaseUrl: 'https://raw.githubusercontent.com/neomjs/pages/main/resources_pub/data/',
|
23
|
+
/**
|
24
|
+
* @member {String} apiHistoricalDataEndpoint='cvid_static/historical/'
|
25
|
+
*/
|
26
|
+
apiFallbackHistoricalDataEndpoint: 'cvid_static/historical/',
|
19
27
|
/**
|
20
28
|
* @member {String} apiHistoricalDataEndpoint='v3/covid-19/historical/'
|
21
29
|
*/
|
@@ -83,7 +91,7 @@ class TableContainerController extends ComponentController {
|
|
83
91
|
}
|
84
92
|
});
|
85
93
|
|
86
|
-
Object.
|
94
|
+
Object.values(map).forEach(value => {
|
87
95
|
value.active = value.cases - value.deaths - value.recovered;
|
88
96
|
dataArray.push(value);
|
89
97
|
});
|
@@ -158,8 +166,17 @@ class TableContainerController extends ComponentController {
|
|
158
166
|
* @param {String} countryName
|
159
167
|
*/
|
160
168
|
loadHistoricalData(countryName) {
|
161
|
-
let me
|
162
|
-
|
169
|
+
let me = this,
|
170
|
+
{useFallbackApi} = Neo.config,
|
171
|
+
apiPath = useFallbackApi ?
|
172
|
+
(me.apiFallbackBaseUrl + me.apiFallbackHistoricalDataEndpoint) :
|
173
|
+
(me.apiBaseUrl + me.apiHistoricalDataEndpoint);
|
174
|
+
|
175
|
+
if (useFallbackApi) {
|
176
|
+
apiPath += (countryName + '.json')
|
177
|
+
} else {
|
178
|
+
apiPath += (countryName + '?lastdays=' + me.apiHistoricalDataTimeRange)
|
179
|
+
}
|
163
180
|
|
164
181
|
fetch(apiPath)
|
165
182
|
.then(response => response.json())
|
@@ -205,7 +222,6 @@ class TableContainerController extends ComponentController {
|
|
205
222
|
me.selectedRecord = null;
|
206
223
|
}
|
207
224
|
|
208
|
-
// removed optional chaining for now, see: https://github.com/neomjs/neo/issues/467
|
209
225
|
me.loadHistoricalData(record?.countryInfo?.iso2 || 'all');
|
210
226
|
|
211
227
|
me.getReference('historical-data-label').html = 'Historical Data (' + (record?.country || 'World') + ')';
|
@@ -120,9 +120,9 @@ class Table extends Container {
|
|
120
120
|
*/
|
121
121
|
afterSetCountry(value, oldValue) {
|
122
122
|
if (oldValue !== undefined) {
|
123
|
-
let me
|
124
|
-
|
125
|
-
|
123
|
+
let me = this,
|
124
|
+
{view} = me,
|
125
|
+
{selectionModel} = view,
|
126
126
|
id;
|
127
127
|
|
128
128
|
if (view) {
|
package/apps/portal/index.html
CHANGED