Skip to content

Commit 13b26a9

Browse files
authored
Demos: replace endpoint urls (DevExpress#29263)
1 parent 5c86e48 commit 13b26a9

File tree

17 files changed

+188
-273
lines changed

17 files changed

+188
-273
lines changed

apps/demos/Demos/Charts/SignalRService/jQuery/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
88
<script src="../../../../node_modules/jquery/dist/jquery.min.js"></script>
9-
<script src="../../../../node_modules/signalr/jquery.signalR.js"></script>
10-
<script src="../signalr-hub.js"></script>
9+
<script src="../../../../node_modules/@aspnet/signalr/dist/browser/signalr.js"></script>
1110
<link rel="stylesheet" type="text/css" href="../../../../node_modules/devextreme-dist/css/dx.light.css" />
1211
<script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script>
1312
<link rel="stylesheet" type="text/css" href="styles.css" />

apps/demos/Demos/Charts/SignalRService/jQuery/index.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
$(() => {
2-
$.connection.hub.url = 'https://js.devexpress.com/Demos/Mvc/signalr';
3-
const hub = $.connection.stockTickDataHub;
2+
const hubConnection = new signalR.HubConnectionBuilder()
3+
.withUrl('https://js.devexpress.com/Demos/NetCore/stockTickDataHub', {
4+
skipNegotiation: true,
5+
transport: signalR.HttpTransportType.WebSockets,
6+
})
7+
.build();
48

59
const store = new DevExpress.data.CustomStore({
6-
load() {
7-
return hub.server.getAllData();
8-
},
9-
key: 'Date',
10+
load: () => hubConnection.invoke('getAllData'),
11+
key: 'date',
1012
});
1113

12-
hub.client.updateStockPrice = function (data) {
13-
store.push([{ type: 'insert', key: data.Date, data }]);
14-
};
14+
hubConnection.on('updateStockPrice', (data) => {
15+
store.push([{ type: 'insert', key: data.date, data }]);
16+
});
1517

16-
$.connection.hub.start({ waitForPageLoad: false }).done(() => {
18+
hubConnection.start().then(() => {
1719
$('#chart').dxChart({
1820
dataSource: store,
1921
margin: {
@@ -25,16 +27,16 @@ $(() => {
2527
title: 'Stock Price',
2628
series: [{
2729
pane: 'Price',
28-
argumentField: 'Date',
30+
argumentField: 'date',
2931
type: 'candlestick',
3032
aggregation: {
3133
enabled: true,
3234
method: 'custom',
3335
calculate(e) {
34-
const prices = e.data.map((i) => i.Price);
36+
const prices = e.data.map((i) => i.price);
3537
if (prices.length) {
3638
return {
37-
Date: new Date((e.intervalStart.valueOf() + e.intervalEnd.valueOf()) / 2),
39+
date: new Date((e.intervalStart.valueOf() + e.intervalEnd.valueOf()) / 2),
3840
open: prices[0],
3941
high: Math.max.apply(null, prices),
4042
low: Math.min.apply(null, prices),
@@ -47,9 +49,9 @@ $(() => {
4749
}, {
4850
pane: 'Volume',
4951
name: 'Volume',
50-
argumentField: 'Date',
52+
argumentField: 'date',
5153
type: 'bar',
52-
valueField: 'Volume',
54+
valueField: 'volume',
5355
color: 'red',
5456
aggregation: {
5557
enabled: true,

apps/demos/Demos/Charts/SignalRService/signalr-hub.js

Lines changed: 0 additions & 109 deletions
This file was deleted.

apps/demos/Demos/DataGrid/BatchUpdateRequest/Angular/app/app.component.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (!/localhost/.test(document.location.host)) {
1010
enableProdMode();
1111
}
1212

13-
const URL = 'https://js.devexpress.com/Demos/Mvc/api/DataGridBatchUpdateWebApi';
13+
const URL = 'https://js.devexpress.com/Demos/NetCore/api/DataGridBatchUpdateWebApi';
1414

1515
let modulePrefix = '';
1616
// @ts-ignore
@@ -40,13 +40,14 @@ export class AppComponent {
4040
e.cancel = true;
4141

4242
if (e.changes.length) {
43-
e.promise = this.processBatchRequest(`${URL}/Batch`, e.changes, e.component);
43+
const changes = this.normalizeChanges(e.changes);
44+
e.promise = this.processBatchRequest(`${URL}/Batch`, changes, e.component);
4445
}
4546
}
4647

4748
async processBatchRequest(
4849
url: string,
49-
changes: Array<DxDataGridTypes.DataChange>,
50+
changes: DxDataGridTypes.DataChange[],
5051
component: DxDataGridComponent['instance'],
5152
): Promise<void> {
5253
await lastValueFrom(
@@ -60,6 +61,29 @@ export class AppComponent {
6061
await component.refresh(true);
6162
component.cancelEditData();
6263
}
64+
65+
normalizeChanges(changes: DxDataGridTypes.DataChange[]): DxDataGridTypes.DataChange[] {
66+
return changes.map(c => {
67+
switch (c.type) {
68+
case 'insert':
69+
return {
70+
type: c.type,
71+
data: c.data,
72+
};
73+
case 'update':
74+
return {
75+
type: c.type,
76+
key: c.key,
77+
data: c.data,
78+
};
79+
case 'remove':
80+
return {
81+
type: c.type,
82+
key: c.key,
83+
};
84+
}
85+
}) as DxDataGridTypes.DataChange[];
86+
}
6387
}
6488

6589
@NgModule({

apps/demos/Demos/DataGrid/BatchUpdateRequest/React/App.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import DataGrid, { DataGridRef, Column, DataGridTypes, Editing, Pager, } from 'd
33
import { createStore } from 'devextreme-aspnet-data-nojquery';
44
import 'whatwg-fetch';
55

6-
const URL = 'https://js.devexpress.com/Demos/Mvc/api/DataGridBatchUpdateWebApi';
6+
const URL = 'https://js.devexpress.com/Demos/NetCore/api/DataGridBatchUpdateWebApi';
77

88
const ordersStore = createStore({
99
key: 'OrderID',
@@ -13,6 +13,29 @@ const ordersStore = createStore({
1313
},
1414
});
1515

16+
function normalizeChanges(changes: DataGridTypes.DataChange[]): DataGridTypes.DataChange[] {
17+
return changes.map(c => {
18+
switch (c.type) {
19+
case 'insert':
20+
return {
21+
type: c.type,
22+
data: c.data,
23+
};
24+
case 'update':
25+
return {
26+
type: c.type,
27+
key: c.key,
28+
data: c.data,
29+
};
30+
case 'remove':
31+
return {
32+
type: c.type,
33+
key: c.key,
34+
};
35+
}
36+
}) as DataGridTypes.DataChange[];
37+
}
38+
1639
async function sendBatchRequest(url: string, changes: DataGridTypes.DataChange[]) {
1740
const result = await fetch(url, {
1841
method: 'POST',
@@ -40,7 +63,8 @@ const onSaving = (e: DataGridTypes.SavingEvent) => {
4063
e.cancel = true;
4164

4265
if (e.changes.length) {
43-
e.promise = processBatchRequest(`${URL}/Batch`, e.changes, e.component);
66+
const changes = normalizeChanges(e.changes);
67+
e.promise = processBatchRequest(`${URL}/Batch`, changes, e.component);
4468
}
4569
};
4670

apps/demos/Demos/DataGrid/BatchUpdateRequest/ReactJs/App.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,36 @@ import DataGrid, { Column, Editing, Pager } from 'devextreme-react/data-grid';
33
import { createStore } from 'devextreme-aspnet-data-nojquery';
44
import 'whatwg-fetch';
55

6-
const URL = 'https://js.devexpress.com/Demos/Mvc/api/DataGridBatchUpdateWebApi';
6+
const URL = 'https://js.devexpress.com/Demos/NetCore/api/DataGridBatchUpdateWebApi';
77
const ordersStore = createStore({
88
key: 'OrderID',
99
loadUrl: `${URL}/Orders`,
1010
onBeforeSend: (method, ajaxOptions) => {
1111
ajaxOptions.xhrFields = { withCredentials: true };
1212
},
1313
});
14+
function normalizeChanges(changes) {
15+
return changes.map((c) => {
16+
switch (c.type) {
17+
case 'insert':
18+
return {
19+
type: c.type,
20+
data: c.data,
21+
};
22+
case 'update':
23+
return {
24+
type: c.type,
25+
key: c.key,
26+
data: c.data,
27+
};
28+
case 'remove':
29+
return {
30+
type: c.type,
31+
key: c.key,
32+
};
33+
}
34+
});
35+
}
1436
async function sendBatchRequest(url, changes) {
1537
const result = await fetch(url, {
1638
method: 'POST',
@@ -33,7 +55,8 @@ async function processBatchRequest(url, changes, component) {
3355
const onSaving = (e) => {
3456
e.cancel = true;
3557
if (e.changes.length) {
36-
e.promise = processBatchRequest(`${URL}/Batch`, e.changes, e.component);
58+
const changes = normalizeChanges(e.changes);
59+
e.promise = processBatchRequest(`${URL}/Batch`, changes, e.component);
3760
}
3861
};
3962
const App = () => (

apps/demos/Demos/DataGrid/BatchUpdateRequest/Vue/App.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
import { createStore } from 'devextreme-aspnet-data-nojquery';
3737
import 'whatwg-fetch';
3838
39-
const URL = 'https://js.devexpress.com/Demos/Mvc/api/DataGridBatchUpdateWebApi';
39+
const URL = 'https://js.devexpress.com/Demos/NetCore/api/DataGridBatchUpdateWebApi';
4040
4141
const ordersStore = createStore({
4242
key: 'OrderID',
@@ -50,10 +50,34 @@ const onSaving = (e: DxDataGridTypes.SavingEvent) => {
5050
e.cancel = true;
5151
5252
if (e.changes.length) {
53-
e.promise = processBatchRequest(`${URL}/Batch`, e.changes, e.component);
53+
const changes = normalizeChanges(e.changes);
54+
e.promise = processBatchRequest(`${URL}/Batch`, changes, e.component);
5455
}
5556
};
5657
58+
function normalizeChanges(changes: DxDataGridTypes.DataChange[]): DxDataGridTypes.DataChange[] {
59+
return changes.map(c => {
60+
switch (c.type) {
61+
case 'insert':
62+
return {
63+
type: c.type,
64+
data: c.data,
65+
};
66+
case 'update':
67+
return {
68+
type: c.type,
69+
key: c.key,
70+
data: c.data,
71+
};
72+
case 'remove':
73+
return {
74+
type: c.type,
75+
key: c.key,
76+
};
77+
}
78+
}) as DxDataGridTypes.DataChange[];
79+
}
80+
5781
async function processBatchRequest(
5882
url: string, changes: DxDataGridTypes.DataChange[], component: DxDataGrid['instance'],
5983
) {

0 commit comments

Comments
 (0)