dp-widgets-framework 1.0.3 → 1.0.5
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/dist/index.esm.js +383 -115
- package/dist/index.js +383 -115
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35997,30 +35997,35 @@ const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
|
35997
35997
|
const parsedState = JSON.parse(stateString);
|
|
35998
35998
|
if (parsedState.state) {
|
|
35999
35999
|
const chartData = parsedState.state;
|
|
36000
|
-
//
|
|
36001
|
-
|
|
36002
|
-
|
|
36003
|
-
|
|
36004
|
-
|
|
36005
|
-
|
|
36006
|
-
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
|
|
36013
|
-
|
|
36014
|
-
|
|
36015
|
-
|
|
36016
|
-
|
|
36017
|
-
|
|
36018
|
-
|
|
36019
|
-
|
|
36020
|
-
|
|
36021
|
-
|
|
36022
|
-
|
|
36023
|
-
|
|
36000
|
+
// Update chart state while preserving existing data including agent_message
|
|
36001
|
+
setChartState(prevState => {
|
|
36002
|
+
const newChartState = Object.assign({}, prevState);
|
|
36003
|
+
// Check for different chart types and map them accordingly
|
|
36004
|
+
if (chartData.bar_chart_data) {
|
|
36005
|
+
newChartState.bar_chart_data = chartData.bar_chart_data;
|
|
36006
|
+
}
|
|
36007
|
+
if (chartData.series_bar_chart_data) {
|
|
36008
|
+
newChartState.series_bar_chart_data = chartData.series_bar_chart_data;
|
|
36009
|
+
}
|
|
36010
|
+
if (chartData.series_line_chart_data) {
|
|
36011
|
+
newChartState.series_line_chart_data = chartData.series_line_chart_data;
|
|
36012
|
+
}
|
|
36013
|
+
if (chartData.pie_chart_data) {
|
|
36014
|
+
newChartState.pie_chart_data = chartData.pie_chart_data;
|
|
36015
|
+
}
|
|
36016
|
+
if (chartData.matrix_grid_data) {
|
|
36017
|
+
newChartState.matrix_grid_data = chartData.matrix_grid_data;
|
|
36018
|
+
}
|
|
36019
|
+
if (chartData.summary_data) {
|
|
36020
|
+
newChartState.summary_data = chartData.summary_data;
|
|
36021
|
+
}
|
|
36022
|
+
// Preserve agent_message if it exists
|
|
36023
|
+
if (chartData.agent_message) {
|
|
36024
|
+
newChartState.agent_message = chartData.agent_message;
|
|
36025
|
+
}
|
|
36026
|
+
console.log('Chart state updated from API response:', newChartState);
|
|
36027
|
+
return newChartState;
|
|
36028
|
+
});
|
|
36024
36029
|
}
|
|
36025
36030
|
}
|
|
36026
36031
|
}
|
|
@@ -36061,6 +36066,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36061
36066
|
const clearChat = async () => {
|
|
36062
36067
|
if (!widgetBackendUrl || !widgetId)
|
|
36063
36068
|
return;
|
|
36069
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36064
36070
|
try {
|
|
36065
36071
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36066
36072
|
method: 'POST',
|
|
@@ -36069,9 +36075,12 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36069
36075
|
},
|
|
36070
36076
|
body: JSON.stringify({
|
|
36071
36077
|
session_id: widgetId,
|
|
36072
|
-
delete_state:
|
|
36078
|
+
delete_state: true
|
|
36073
36079
|
}),
|
|
36074
36080
|
});
|
|
36081
|
+
// Clear chart state directly after clearing chat
|
|
36082
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36083
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36075
36084
|
}
|
|
36076
36085
|
catch (error) {
|
|
36077
36086
|
console.error('Failed to clear chat:', error);
|
|
@@ -36080,6 +36089,9 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36080
36089
|
const handleRefresh = async () => {
|
|
36081
36090
|
if (query) {
|
|
36082
36091
|
await clearChat();
|
|
36092
|
+
// Send trigger event to clear chart state
|
|
36093
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36094
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36083
36095
|
appendMessage(new TextMessage({
|
|
36084
36096
|
content: `${query} and render data on a bar chart`,
|
|
36085
36097
|
role: Role.User,
|
|
@@ -36087,13 +36099,13 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36087
36099
|
}
|
|
36088
36100
|
};
|
|
36089
36101
|
React.useEffect(() => {
|
|
36090
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36102
|
+
if (isEmpty && query && isFirstLoad && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36091
36103
|
handleRefresh();
|
|
36092
36104
|
}
|
|
36093
36105
|
}, [isEmpty, query, isFirstLoad]);
|
|
36094
36106
|
// Start timeout when chart is empty and loading
|
|
36095
36107
|
React.useEffect(() => {
|
|
36096
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36108
|
+
if (isEmpty && startLoadingTimeout && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36097
36109
|
startLoadingTimeout();
|
|
36098
36110
|
}
|
|
36099
36111
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36132,6 +36144,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36132
36144
|
const clearChat = async () => {
|
|
36133
36145
|
if (!widgetBackendUrl || !widgetId)
|
|
36134
36146
|
return;
|
|
36147
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36135
36148
|
try {
|
|
36136
36149
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36137
36150
|
method: 'POST',
|
|
@@ -36140,9 +36153,12 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36140
36153
|
},
|
|
36141
36154
|
body: JSON.stringify({
|
|
36142
36155
|
session_id: widgetId,
|
|
36143
|
-
delete_state:
|
|
36156
|
+
delete_state: true
|
|
36144
36157
|
}),
|
|
36145
36158
|
});
|
|
36159
|
+
// Clear chart state directly after clearing chat
|
|
36160
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36161
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36146
36162
|
}
|
|
36147
36163
|
catch (error) {
|
|
36148
36164
|
console.error('Failed to clear chat:', error);
|
|
@@ -36151,6 +36167,9 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36151
36167
|
const handleRefresh = async () => {
|
|
36152
36168
|
if (query) {
|
|
36153
36169
|
await clearChat();
|
|
36170
|
+
// Send trigger event to clear chart state
|
|
36171
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36172
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36154
36173
|
appendMessage(new TextMessage({
|
|
36155
36174
|
content: `${query} and render data on a series bar chart`,
|
|
36156
36175
|
role: Role.User,
|
|
@@ -36158,13 +36177,13 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36158
36177
|
}
|
|
36159
36178
|
};
|
|
36160
36179
|
React.useEffect(() => {
|
|
36161
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36180
|
+
if (isEmpty && query && isFirstLoad && !(seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.agent_message)) {
|
|
36162
36181
|
handleRefresh();
|
|
36163
36182
|
}
|
|
36164
36183
|
}, [isEmpty, query, isFirstLoad]);
|
|
36165
36184
|
// Start timeout when chart is empty and loading
|
|
36166
36185
|
React.useEffect(() => {
|
|
36167
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36186
|
+
if (isEmpty && startLoadingTimeout && !(seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.agent_message)) {
|
|
36168
36187
|
startLoadingTimeout();
|
|
36169
36188
|
}
|
|
36170
36189
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36197,6 +36216,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36197
36216
|
const clearChat = async () => {
|
|
36198
36217
|
if (!widgetBackendUrl || !widgetId)
|
|
36199
36218
|
return;
|
|
36219
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36200
36220
|
try {
|
|
36201
36221
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36202
36222
|
method: 'POST',
|
|
@@ -36205,9 +36225,12 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36205
36225
|
},
|
|
36206
36226
|
body: JSON.stringify({
|
|
36207
36227
|
session_id: widgetId,
|
|
36208
|
-
delete_state:
|
|
36228
|
+
delete_state: true
|
|
36209
36229
|
}),
|
|
36210
36230
|
});
|
|
36231
|
+
// Clear chart state directly after clearing chat
|
|
36232
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36233
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36211
36234
|
}
|
|
36212
36235
|
catch (error) {
|
|
36213
36236
|
console.error('Failed to clear chat:', error);
|
|
@@ -36216,6 +36239,9 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36216
36239
|
const handleRefresh = async () => {
|
|
36217
36240
|
if (query) {
|
|
36218
36241
|
await clearChat();
|
|
36242
|
+
// Send trigger event to clear chart state
|
|
36243
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36244
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36219
36245
|
appendMessage(new TextMessage({
|
|
36220
36246
|
content: `${query} and render data on a series line chart`,
|
|
36221
36247
|
role: Role.User,
|
|
@@ -36223,13 +36249,13 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36223
36249
|
}
|
|
36224
36250
|
};
|
|
36225
36251
|
React.useEffect(() => {
|
|
36226
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36252
|
+
if (isEmpty && query && isFirstLoad && !(seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.agent_message)) {
|
|
36227
36253
|
handleRefresh();
|
|
36228
36254
|
}
|
|
36229
36255
|
}, [isEmpty, query, isFirstLoad]);
|
|
36230
36256
|
// Start timeout when chart is empty and loading
|
|
36231
36257
|
React.useEffect(() => {
|
|
36232
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36258
|
+
if (isEmpty && startLoadingTimeout && !(seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.agent_message)) {
|
|
36233
36259
|
startLoadingTimeout();
|
|
36234
36260
|
}
|
|
36235
36261
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36270,6 +36296,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36270
36296
|
const clearChat = async () => {
|
|
36271
36297
|
if (!widgetBackendUrl || !widgetId)
|
|
36272
36298
|
return;
|
|
36299
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36273
36300
|
try {
|
|
36274
36301
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36275
36302
|
method: 'POST',
|
|
@@ -36278,9 +36305,12 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36278
36305
|
},
|
|
36279
36306
|
body: JSON.stringify({
|
|
36280
36307
|
session_id: widgetId,
|
|
36281
|
-
delete_state:
|
|
36308
|
+
delete_state: true
|
|
36282
36309
|
}),
|
|
36283
36310
|
});
|
|
36311
|
+
// Clear chart state directly after clearing chat
|
|
36312
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36313
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36284
36314
|
}
|
|
36285
36315
|
catch (error) {
|
|
36286
36316
|
console.error('Failed to clear chat:', error);
|
|
@@ -36289,6 +36319,9 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36289
36319
|
const handleRefresh = async () => {
|
|
36290
36320
|
if (query) {
|
|
36291
36321
|
await clearChat();
|
|
36322
|
+
// Send trigger event to clear chart state
|
|
36323
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36324
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36292
36325
|
appendMessage(new TextMessage({
|
|
36293
36326
|
content: `${query} and render data on pie chart`,
|
|
36294
36327
|
role: Role.User,
|
|
@@ -36296,13 +36329,13 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36296
36329
|
}
|
|
36297
36330
|
};
|
|
36298
36331
|
React.useEffect(() => {
|
|
36299
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36332
|
+
if (isEmpty && query && isFirstLoad && !(pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.agent_message)) {
|
|
36300
36333
|
handleRefresh();
|
|
36301
36334
|
}
|
|
36302
36335
|
}, [isEmpty, query, isFirstLoad]);
|
|
36303
36336
|
// Start timeout when chart is empty and loading
|
|
36304
36337
|
React.useEffect(() => {
|
|
36305
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36338
|
+
if (isEmpty && startLoadingTimeout && !(pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.agent_message)) {
|
|
36306
36339
|
startLoadingTimeout();
|
|
36307
36340
|
}
|
|
36308
36341
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36350,6 +36383,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36350
36383
|
const clearChat = async () => {
|
|
36351
36384
|
if (!widgetBackendUrl || !widgetId)
|
|
36352
36385
|
return;
|
|
36386
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36353
36387
|
try {
|
|
36354
36388
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36355
36389
|
method: 'POST',
|
|
@@ -36358,9 +36392,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36358
36392
|
},
|
|
36359
36393
|
body: JSON.stringify({
|
|
36360
36394
|
session_id: widgetId,
|
|
36361
|
-
delete_state:
|
|
36395
|
+
delete_state: true
|
|
36362
36396
|
}),
|
|
36363
36397
|
});
|
|
36398
|
+
// Clear chart state directly after clearing chat
|
|
36399
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36400
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36364
36401
|
}
|
|
36365
36402
|
catch (error) {
|
|
36366
36403
|
console.error('Failed to clear chat:', error);
|
|
@@ -36369,6 +36406,9 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36369
36406
|
const handleRefresh = async () => {
|
|
36370
36407
|
if (query) {
|
|
36371
36408
|
await clearChat();
|
|
36409
|
+
// Send trigger event to clear chart state
|
|
36410
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36411
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36372
36412
|
appendMessage(new TextMessage({
|
|
36373
36413
|
content: `${query} and render data on a bar chart`,
|
|
36374
36414
|
role: Role.User,
|
|
@@ -36376,13 +36416,13 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36376
36416
|
}
|
|
36377
36417
|
};
|
|
36378
36418
|
React.useEffect(() => {
|
|
36379
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36419
|
+
if (isEmpty && query && isFirstLoad && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36380
36420
|
handleRefresh();
|
|
36381
36421
|
}
|
|
36382
36422
|
}, [isEmpty, query, isFirstLoad]);
|
|
36383
36423
|
// Start timeout when chart is empty and loading
|
|
36384
36424
|
React.useEffect(() => {
|
|
36385
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36425
|
+
if (isEmpty && startLoadingTimeout && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36386
36426
|
startLoadingTimeout();
|
|
36387
36427
|
}
|
|
36388
36428
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36430,6 +36470,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36430
36470
|
const clearChat = async () => {
|
|
36431
36471
|
if (!widgetBackendUrl || !widgetId)
|
|
36432
36472
|
return;
|
|
36473
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36433
36474
|
try {
|
|
36434
36475
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36435
36476
|
method: 'POST',
|
|
@@ -36438,9 +36479,12 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36438
36479
|
},
|
|
36439
36480
|
body: JSON.stringify({
|
|
36440
36481
|
session_id: widgetId,
|
|
36441
|
-
delete_state:
|
|
36482
|
+
delete_state: true
|
|
36442
36483
|
}),
|
|
36443
36484
|
});
|
|
36485
|
+
// Clear chart state directly after clearing chat
|
|
36486
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36487
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36444
36488
|
}
|
|
36445
36489
|
catch (error) {
|
|
36446
36490
|
console.error('Failed to clear chat:', error);
|
|
@@ -36449,6 +36493,9 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36449
36493
|
const handleRefresh = async () => {
|
|
36450
36494
|
if (query) {
|
|
36451
36495
|
await clearChat();
|
|
36496
|
+
// Send trigger event to clear chart state
|
|
36497
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36498
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36452
36499
|
appendMessage(new TextMessage({
|
|
36453
36500
|
content: `${query} and render data in a data grid table`,
|
|
36454
36501
|
role: Role.User,
|
|
@@ -36456,13 +36503,13 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36456
36503
|
}
|
|
36457
36504
|
};
|
|
36458
36505
|
React.useEffect(() => {
|
|
36459
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36506
|
+
if (isEmpty && query && isFirstLoad && !(dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.agent_message)) {
|
|
36460
36507
|
handleRefresh();
|
|
36461
36508
|
}
|
|
36462
36509
|
}, [isEmpty, query, isFirstLoad]);
|
|
36463
36510
|
// Start timeout when chart is empty and loading
|
|
36464
36511
|
React.useEffect(() => {
|
|
36465
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36512
|
+
if (isEmpty && startLoadingTimeout && !(dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.agent_message)) {
|
|
36466
36513
|
startLoadingTimeout();
|
|
36467
36514
|
}
|
|
36468
36515
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36488,6 +36535,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36488
36535
|
const clearChat = async () => {
|
|
36489
36536
|
if (!widgetBackendUrl || !widgetId)
|
|
36490
36537
|
return;
|
|
36538
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36491
36539
|
try {
|
|
36492
36540
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36493
36541
|
method: 'POST',
|
|
@@ -36496,9 +36544,12 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36496
36544
|
},
|
|
36497
36545
|
body: JSON.stringify({
|
|
36498
36546
|
session_id: widgetId,
|
|
36499
|
-
delete_state:
|
|
36547
|
+
delete_state: true
|
|
36500
36548
|
}),
|
|
36501
36549
|
});
|
|
36550
|
+
// Clear chart state directly after clearing chat
|
|
36551
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36552
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36502
36553
|
}
|
|
36503
36554
|
catch (error) {
|
|
36504
36555
|
console.error('Failed to clear chat:', error);
|
|
@@ -36507,6 +36558,9 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36507
36558
|
const handleRefresh = async () => {
|
|
36508
36559
|
if (query) {
|
|
36509
36560
|
await clearChat();
|
|
36561
|
+
// Send trigger event to clear chart state
|
|
36562
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36563
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36510
36564
|
appendMessage(new TextMessage({
|
|
36511
36565
|
content: `${query} and provide a summary with statistics`,
|
|
36512
36566
|
role: Role.User,
|
|
@@ -36514,7 +36568,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36514
36568
|
}
|
|
36515
36569
|
};
|
|
36516
36570
|
React.useEffect(() => {
|
|
36517
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36571
|
+
if (isEmpty && query && isFirstLoad && !(summaryState === null || summaryState === void 0 ? void 0 : summaryState.agent_message)) {
|
|
36518
36572
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widget_ids })));
|
|
36519
36573
|
setTimeout(() => {
|
|
36520
36574
|
handleRefresh();
|
|
@@ -36523,7 +36577,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36523
36577
|
}, [isEmpty, query, isFirstLoad]);
|
|
36524
36578
|
// Start timeout when summary is empty and loading
|
|
36525
36579
|
React.useEffect(() => {
|
|
36526
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36580
|
+
if (isEmpty && startLoadingTimeout && !(summaryState === null || summaryState === void 0 ? void 0 : summaryState.agent_message)) {
|
|
36527
36581
|
startLoadingTimeout();
|
|
36528
36582
|
}
|
|
36529
36583
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36536,13 +36590,14 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36536
36590
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36537
36591
|
}
|
|
36538
36592
|
function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl }) {
|
|
36539
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36593
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39;
|
|
36540
36594
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36541
36595
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36542
36596
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
36543
36597
|
const { threadId, setThreadId } = reactCore.useCopilotContext();
|
|
36544
36598
|
const timeoutRef = React.useRef(null);
|
|
36545
36599
|
const [isTimeoutTriggered, setIsTimeoutTriggered] = React.useState(false);
|
|
36600
|
+
const [timeoutCount, setTimeoutCount] = React.useState(0);
|
|
36546
36601
|
React.useEffect(() => {
|
|
36547
36602
|
setThreadId(widget.id);
|
|
36548
36603
|
}, [widget.id, setThreadId]);
|
|
@@ -36724,16 +36779,17 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36724
36779
|
// Function to handle timeout and call loadAgentState API
|
|
36725
36780
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
36726
36781
|
var _a;
|
|
36727
|
-
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered)
|
|
36782
|
+
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState === null || chartState === void 0 ? void 0 : chartState.agent_message))
|
|
36728
36783
|
return;
|
|
36729
36784
|
console.log('Loading timeout triggered for widget:', widget.id);
|
|
36730
36785
|
setIsTimeoutTriggered(true);
|
|
36786
|
+
setTimeoutCount(prev => prev + 1);
|
|
36731
36787
|
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
36732
36788
|
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
36733
|
-
if (apiResponse) {
|
|
36789
|
+
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
36734
36790
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
36735
36791
|
}
|
|
36736
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName]);
|
|
36792
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName, chartState]);
|
|
36737
36793
|
// Function to start timeout
|
|
36738
36794
|
const startLoadingTimeout = React.useCallback(() => {
|
|
36739
36795
|
if (timeoutRef.current) {
|
|
@@ -36751,6 +36807,28 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36751
36807
|
timeoutRef.current = null;
|
|
36752
36808
|
}
|
|
36753
36809
|
}, []);
|
|
36810
|
+
// Function to clear chat and reset chart state
|
|
36811
|
+
React.useCallback(async (widgetId) => {
|
|
36812
|
+
if (!widgetBackendUrl)
|
|
36813
|
+
return;
|
|
36814
|
+
try {
|
|
36815
|
+
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36816
|
+
method: 'POST',
|
|
36817
|
+
headers: {
|
|
36818
|
+
'Content-Type': 'application/json',
|
|
36819
|
+
},
|
|
36820
|
+
body: JSON.stringify({
|
|
36821
|
+
session_id: widgetId,
|
|
36822
|
+
delete_state: true
|
|
36823
|
+
}),
|
|
36824
|
+
});
|
|
36825
|
+
// Reset chart state based on agent type - call getInitialState from local scope
|
|
36826
|
+
setChartState(getInitialState());
|
|
36827
|
+
}
|
|
36828
|
+
catch (error) {
|
|
36829
|
+
console.error('Failed to clear chat and state:', error);
|
|
36830
|
+
}
|
|
36831
|
+
}, [widgetBackendUrl, setChartState, agentType, widgetIds]);
|
|
36754
36832
|
// Clean up timeout on unmount
|
|
36755
36833
|
React.useEffect(() => {
|
|
36756
36834
|
return () => {
|
|
@@ -36759,13 +36837,26 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36759
36837
|
}
|
|
36760
36838
|
};
|
|
36761
36839
|
}, []);
|
|
36762
|
-
const { appendMessage, reset } = reactCore.useCopilotChat();
|
|
36840
|
+
const { appendMessage, reset, isLoading } = reactCore.useCopilotChat();
|
|
36763
36841
|
// Register the reset function with the parent component
|
|
36764
36842
|
React.useEffect(() => {
|
|
36843
|
+
console.log('onResetReady available:', !!onResetReady, 'reset available:', !!reset, 'widget.id:', widget.id);
|
|
36765
36844
|
if (onResetReady && reset && widget.id) {
|
|
36766
|
-
|
|
36845
|
+
console.log('Registering reset function for widget:', widget.id);
|
|
36846
|
+
// Create a wrapped reset function that also clears chart state
|
|
36847
|
+
const wrappedReset = () => {
|
|
36848
|
+
console.log('Reset called for widget:', widget.id);
|
|
36849
|
+
reset();
|
|
36850
|
+
// Clear chart state after reset
|
|
36851
|
+
console.log('Dispatching clearChartState event from reset for widgetId:', widget.id);
|
|
36852
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId: widget.id } }));
|
|
36853
|
+
};
|
|
36854
|
+
onResetReady(widget.id, wrappedReset);
|
|
36855
|
+
}
|
|
36856
|
+
else {
|
|
36857
|
+
console.log('Not registering reset - missing dependencies');
|
|
36767
36858
|
}
|
|
36768
|
-
}, [reset, widget.id]); // Removed onResetReady from deps to avoid the error
|
|
36859
|
+
}, [reset, widget.id, onResetReady]); // Removed onResetReady from deps to avoid the error
|
|
36769
36860
|
// Listen for triggerAgent events for this widget
|
|
36770
36861
|
React.useEffect(() => {
|
|
36771
36862
|
const handleTriggerAgent = (event) => {
|
|
@@ -36800,14 +36891,240 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36800
36891
|
}));
|
|
36801
36892
|
}
|
|
36802
36893
|
};
|
|
36894
|
+
const handleClearChartState = (event) => {
|
|
36895
|
+
const { widgetId } = event.detail;
|
|
36896
|
+
console.log('Received clearChartState event - widgetId:', widgetId, 'current widget.id:', widget.id);
|
|
36897
|
+
if (widgetId === widget.id) {
|
|
36898
|
+
console.log('Clearing chart state for widget:', widgetId);
|
|
36899
|
+
// Reset chart state based on agent type with explicit initial state
|
|
36900
|
+
if (agentType === "Pie Chart Agent") {
|
|
36901
|
+
setChartState({
|
|
36902
|
+
pie_chart_data: {
|
|
36903
|
+
title: "",
|
|
36904
|
+
type: "pie",
|
|
36905
|
+
chart_type: "financial",
|
|
36906
|
+
data: {
|
|
36907
|
+
labels: [],
|
|
36908
|
+
values: [],
|
|
36909
|
+
percentages: [],
|
|
36910
|
+
total: 0
|
|
36911
|
+
},
|
|
36912
|
+
metadata: {
|
|
36913
|
+
categories: 0,
|
|
36914
|
+
largest_category: "",
|
|
36915
|
+
largest_value: 0,
|
|
36916
|
+
largest_percentage: 0
|
|
36917
|
+
}
|
|
36918
|
+
}
|
|
36919
|
+
});
|
|
36920
|
+
}
|
|
36921
|
+
else if (agentType === "Bar Chart Agent") {
|
|
36922
|
+
setChartState({
|
|
36923
|
+
bar_chart_data: {
|
|
36924
|
+
title: "",
|
|
36925
|
+
type: "bar",
|
|
36926
|
+
chart_type: "financial",
|
|
36927
|
+
orientation: "vertical",
|
|
36928
|
+
data: {
|
|
36929
|
+
labels: [],
|
|
36930
|
+
values: [],
|
|
36931
|
+
total: 0,
|
|
36932
|
+
average: 0
|
|
36933
|
+
},
|
|
36934
|
+
metadata: {
|
|
36935
|
+
categories: 0,
|
|
36936
|
+
highest_category: "",
|
|
36937
|
+
highest_value: 0,
|
|
36938
|
+
lowest_category: "",
|
|
36939
|
+
lowest_value: 0,
|
|
36940
|
+
range: 0
|
|
36941
|
+
}
|
|
36942
|
+
}
|
|
36943
|
+
});
|
|
36944
|
+
}
|
|
36945
|
+
else if (agentType === "Series Bar Chart Agent") {
|
|
36946
|
+
setChartState({
|
|
36947
|
+
series_bar_chart_data: {
|
|
36948
|
+
title: "",
|
|
36949
|
+
type: "series_bar",
|
|
36950
|
+
chart_type: "financial",
|
|
36951
|
+
orientation: "vertical",
|
|
36952
|
+
data: {
|
|
36953
|
+
labels: [],
|
|
36954
|
+
series: [],
|
|
36955
|
+
total: 0,
|
|
36956
|
+
average: 0
|
|
36957
|
+
},
|
|
36958
|
+
metadata: {
|
|
36959
|
+
categories: 0,
|
|
36960
|
+
series_count: 0,
|
|
36961
|
+
highest_category: "",
|
|
36962
|
+
highest_value: 0,
|
|
36963
|
+
highest_series: "",
|
|
36964
|
+
lowest_category: "",
|
|
36965
|
+
lowest_value: 0,
|
|
36966
|
+
lowest_series: "",
|
|
36967
|
+
range: 0,
|
|
36968
|
+
series_totals: {},
|
|
36969
|
+
series_averages: {}
|
|
36970
|
+
}
|
|
36971
|
+
}
|
|
36972
|
+
});
|
|
36973
|
+
}
|
|
36974
|
+
else if (agentType === "Series Line Chart Agent") {
|
|
36975
|
+
setChartState({
|
|
36976
|
+
series_bar_chart_data: {
|
|
36977
|
+
title: "",
|
|
36978
|
+
type: "series_bar",
|
|
36979
|
+
chart_type: "financial",
|
|
36980
|
+
orientation: "vertical",
|
|
36981
|
+
data: {
|
|
36982
|
+
labels: [],
|
|
36983
|
+
series: [],
|
|
36984
|
+
total: 0,
|
|
36985
|
+
average: 0
|
|
36986
|
+
},
|
|
36987
|
+
metadata: {
|
|
36988
|
+
categories: 0,
|
|
36989
|
+
series_count: 0,
|
|
36990
|
+
highest_category: "",
|
|
36991
|
+
highest_value: 0,
|
|
36992
|
+
highest_series: "",
|
|
36993
|
+
lowest_category: "",
|
|
36994
|
+
lowest_value: 0,
|
|
36995
|
+
lowest_series: "",
|
|
36996
|
+
range: 0,
|
|
36997
|
+
series_totals: {},
|
|
36998
|
+
series_averages: {}
|
|
36999
|
+
}
|
|
37000
|
+
}
|
|
37001
|
+
});
|
|
37002
|
+
}
|
|
37003
|
+
else if (agentType === "Line Chart Agent") {
|
|
37004
|
+
setChartState({
|
|
37005
|
+
bar_chart_data: {
|
|
37006
|
+
title: "",
|
|
37007
|
+
type: "line",
|
|
37008
|
+
chart_type: "financial",
|
|
37009
|
+
orientation: "horizontal",
|
|
37010
|
+
data: {
|
|
37011
|
+
labels: [],
|
|
37012
|
+
values: [],
|
|
37013
|
+
total: 0,
|
|
37014
|
+
average: 0
|
|
37015
|
+
},
|
|
37016
|
+
metadata: {
|
|
37017
|
+
categories: 0,
|
|
37018
|
+
highest_category: "",
|
|
37019
|
+
highest_value: 0,
|
|
37020
|
+
lowest_category: "",
|
|
37021
|
+
lowest_value: 0,
|
|
37022
|
+
range: 0
|
|
37023
|
+
}
|
|
37024
|
+
}
|
|
37025
|
+
});
|
|
37026
|
+
}
|
|
37027
|
+
else if (agentType === "Data Grid Agent") {
|
|
37028
|
+
setChartState({
|
|
37029
|
+
matrix_grid_data: {
|
|
37030
|
+
title: "",
|
|
37031
|
+
type: "data_grid",
|
|
37032
|
+
grid_type: "",
|
|
37033
|
+
data: {
|
|
37034
|
+
headers: [],
|
|
37035
|
+
rows: [],
|
|
37036
|
+
row_count: 0,
|
|
37037
|
+
column_count: 0
|
|
37038
|
+
},
|
|
37039
|
+
metadata: {
|
|
37040
|
+
total_rows: 0,
|
|
37041
|
+
total_columns: 0,
|
|
37042
|
+
numeric_columns: []
|
|
37043
|
+
}
|
|
37044
|
+
}
|
|
37045
|
+
});
|
|
37046
|
+
}
|
|
37047
|
+
else if (agentType === "Summary Agent") {
|
|
37048
|
+
setChartState({
|
|
37049
|
+
summary_data: {
|
|
37050
|
+
title: "",
|
|
37051
|
+
type: "summary",
|
|
37052
|
+
data: {
|
|
37053
|
+
content: "",
|
|
37054
|
+
word_count: 0,
|
|
37055
|
+
character_count: 0,
|
|
37056
|
+
character_count_no_spaces: 0,
|
|
37057
|
+
line_count: 0
|
|
37058
|
+
},
|
|
37059
|
+
metadata: {
|
|
37060
|
+
created_at: "",
|
|
37061
|
+
content_type: "text",
|
|
37062
|
+
is_multiline: false
|
|
37063
|
+
}
|
|
37064
|
+
}
|
|
37065
|
+
});
|
|
37066
|
+
}
|
|
37067
|
+
else {
|
|
37068
|
+
setChartState({ widget_ids: widgetIds });
|
|
37069
|
+
}
|
|
37070
|
+
}
|
|
37071
|
+
};
|
|
37072
|
+
console.log('Setting up event listeners for widget:', widget.id);
|
|
36803
37073
|
window.addEventListener('triggerAgent', handleTriggerAgent);
|
|
37074
|
+
window.addEventListener('clearChartState', handleClearChartState);
|
|
36804
37075
|
return () => {
|
|
36805
37076
|
window.removeEventListener('triggerAgent', handleTriggerAgent);
|
|
37077
|
+
window.removeEventListener('clearChartState', handleClearChartState);
|
|
36806
37078
|
};
|
|
36807
|
-
}, [widget.id, appendMessage, agentType]);
|
|
36808
|
-
|
|
36809
|
-
|
|
36810
|
-
|
|
37079
|
+
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
37080
|
+
// Monitor chartState and add manual clear functionality
|
|
37081
|
+
React.useEffect(() => {
|
|
37082
|
+
// Add a global function to manually clear this widget's state
|
|
37083
|
+
const clearThisWidget = () => {
|
|
37084
|
+
console.log('Manual clear triggered for widget:', widget.id);
|
|
37085
|
+
if (agentType === "Pie Chart Agent") {
|
|
37086
|
+
setChartState({
|
|
37087
|
+
pie_chart_data: {
|
|
37088
|
+
title: "",
|
|
37089
|
+
type: "pie",
|
|
37090
|
+
chart_type: "financial",
|
|
37091
|
+
data: {
|
|
37092
|
+
labels: [],
|
|
37093
|
+
values: [],
|
|
37094
|
+
percentages: [],
|
|
37095
|
+
total: 0
|
|
37096
|
+
},
|
|
37097
|
+
metadata: {
|
|
37098
|
+
categories: 0,
|
|
37099
|
+
largest_category: "",
|
|
37100
|
+
largest_value: 0,
|
|
37101
|
+
largest_percentage: 0
|
|
37102
|
+
}
|
|
37103
|
+
}
|
|
37104
|
+
});
|
|
37105
|
+
}
|
|
37106
|
+
// Add other agent types as needed
|
|
37107
|
+
};
|
|
37108
|
+
// Make it globally accessible for testing
|
|
37109
|
+
window[`clearWidget_${widget.id}`] = clearThisWidget;
|
|
37110
|
+
return () => {
|
|
37111
|
+
delete window[`clearWidget_${widget.id}`];
|
|
37112
|
+
};
|
|
37113
|
+
}, [widget.id, agentType, setChartState]);
|
|
37114
|
+
console.log('agent_message==>', chartState === null || chartState === void 0 ? void 0 : chartState.agent_message);
|
|
37115
|
+
console.log('Pie Chart Agent==>', (agentType === "Pie Chart Agent" && (!((_h = (_g = (_f = chartState.pie_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h.length) || !((_l = (_k = (_j = chartState.pie_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l.length))));
|
|
37116
|
+
console.log('chartState.pie_chart_data?.data?.labels?.length==>', (_o = (_m = chartState.pie_chart_data) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.labels);
|
|
37117
|
+
return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState === null || chartState === void 0 ? void 0 : chartState.agent_message) && agentType !== "chatbot" && (
|
|
37118
|
+
// Check if data is empty based on agent type
|
|
37119
|
+
(agentType === "Bar Chart Agent" && (!((_r = (_q = (_p = chartState.bar_chart_data) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.labels) === null || _r === void 0 ? void 0 : _r.length) || !((_u = (_t = (_s = chartState.bar_chart_data) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.values) === null || _u === void 0 ? void 0 : _u.length))) ||
|
|
37120
|
+
(agentType === "Series Bar Chart Agent" && (!((_x = (_w = (_v = chartState.series_bar_chart_data) === null || _v === void 0 ? void 0 : _v.data) === null || _w === void 0 ? void 0 : _w.labels) === null || _x === void 0 ? void 0 : _x.length) || !((_0 = (_z = (_y = chartState.series_bar_chart_data) === null || _y === void 0 ? void 0 : _y.data) === null || _z === void 0 ? void 0 : _z.series) === null || _0 === void 0 ? void 0 : _0.length))) ||
|
|
37121
|
+
(agentType === "Series Line Chart Agent" && (!((_3 = (_2 = (_1 = chartState.series_bar_chart_data) === null || _1 === void 0 ? void 0 : _1.data) === null || _2 === void 0 ? void 0 : _2.labels) === null || _3 === void 0 ? void 0 : _3.length) || !((_6 = (_5 = (_4 = chartState.series_bar_chart_data) === null || _4 === void 0 ? void 0 : _4.data) === null || _5 === void 0 ? void 0 : _5.series) === null || _6 === void 0 ? void 0 : _6.length))) ||
|
|
37122
|
+
(agentType === "Pie Chart Agent" && (!((_9 = (_8 = (_7 = chartState.pie_chart_data) === null || _7 === void 0 ? void 0 : _7.data) === null || _8 === void 0 ? void 0 : _8.labels) === null || _9 === void 0 ? void 0 : _9.length) || !((_12 = (_11 = (_10 = chartState.pie_chart_data) === null || _10 === void 0 ? void 0 : _10.data) === null || _11 === void 0 ? void 0 : _11.values) === null || _12 === void 0 ? void 0 : _12.length))) ||
|
|
37123
|
+
(agentType === "Line Chart Agent" && (!((_15 = (_14 = (_13 = chartState.bar_chart_data) === null || _13 === void 0 ? void 0 : _13.data) === null || _14 === void 0 ? void 0 : _14.labels) === null || _15 === void 0 ? void 0 : _15.length) || !((_18 = (_17 = (_16 = chartState.bar_chart_data) === null || _16 === void 0 ? void 0 : _16.data) === null || _17 === void 0 ? void 0 : _17.values) === null || _18 === void 0 ? void 0 : _18.length))) ||
|
|
37124
|
+
(agentType === "Data Grid Agent" && (!((_21 = (_20 = (_19 = chartState.matrix_grid_data) === null || _19 === void 0 ? void 0 : _19.data) === null || _20 === void 0 ? void 0 : _20.headers) === null || _21 === void 0 ? void 0 : _21.length) || !((_24 = (_23 = (_22 = chartState.matrix_grid_data) === null || _22 === void 0 ? void 0 : _22.data) === null || _23 === void 0 ? void 0 : _23.rows) === null || _24 === void 0 ? void 0 : _24.length))) ||
|
|
37125
|
+
(agentType === "Summary Agent" && (!((_26 = (_25 = chartState.summary_data) === null || _25 === void 0 ? void 0 : _25.data) === null || _26 === void 0 ? void 0 : _26.content) || ((_29 = (_28 = (_27 = chartState.summary_data) === null || _27 === void 0 ? void 0 : _27.data) === null || _28 === void 0 ? void 0 : _28.content) === null || _29 === void 0 ? void 0 : _29.trim()) === ""))) ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) })) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_31 = widget.config) === null || _31 === void 0 ? void 0 : _31.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartComponent, { seriesLineChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_32 = widget.config) === null || _32 === void 0 ? void 0 : _32.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartComponent, { pieChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_33 = widget.config) === null || _33 === void 0 ? void 0 : _33.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Line Chart Agent" ? (jsxRuntimeExports.jsx(LineChartComponent, { lineChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_34 = widget.config) === null || _34 === void 0 ? void 0 : _34.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DataGridComponent, { dataGridState: chartState, styles: styles, appendMessage: appendMessage, query: (_35 = widget.config) === null || _35 === void 0 ? void 0 : _35.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Summary Agent" ? (jsxRuntimeExports.jsx(SummaryComponent, { summaryState: chartState, styles: styles, appendMessage: appendMessage, query: (_36 = widget.config) === null || _36 === void 0 ? void 0 : _36.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, widget_ids: widgetIds, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, setChartState: setChartState })) : (jsxRuntimeExports.jsx(reactUi.CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
|
|
37126
|
+
title: ((_37 = widget.config) === null || _37 === void 0 ? void 0 : _37.copilotTitle) || widget.title,
|
|
37127
|
+
initial: ((_38 = widget.config) === null || _38 === void 0 ? void 0 : _38.copilotInitialMessage) || ((_39 = widget.config) === null || _39 === void 0 ? void 0 : _39.placeholder) || "How can I help you today?"
|
|
36811
37128
|
}, onSubmitMessage: () => {
|
|
36812
37129
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds })));
|
|
36813
37130
|
} })) })] }));
|
|
@@ -37086,7 +37403,7 @@ const IconMap = {
|
|
|
37086
37403
|
'pie-chart': lucideReact.PieChart,
|
|
37087
37404
|
'chatbot': lucideReact.Bot,
|
|
37088
37405
|
};
|
|
37089
|
-
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent" }) {
|
|
37406
|
+
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId }) {
|
|
37090
37407
|
const [widgets, setWidgets] = React.useState([]);
|
|
37091
37408
|
const [availableWidgets, setAvailableWidgets] = React.useState([]);
|
|
37092
37409
|
const [isLoading, setIsLoading] = React.useState(true);
|
|
@@ -37144,7 +37461,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37144
37461
|
},
|
|
37145
37462
|
body: JSON.stringify({
|
|
37146
37463
|
session_id: editingWidget.id,
|
|
37147
|
-
delete_state:
|
|
37464
|
+
delete_state: true
|
|
37148
37465
|
}),
|
|
37149
37466
|
});
|
|
37150
37467
|
}
|
|
@@ -37207,7 +37524,13 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37207
37524
|
}
|
|
37208
37525
|
setIsLoading(true);
|
|
37209
37526
|
try {
|
|
37210
|
-
const response = await fetch(getApiUrl(`/api/pages/${pageId}`)
|
|
37527
|
+
const response = await fetch(getApiUrl(`/api/pages/${pageId}`), {
|
|
37528
|
+
method: "GET",
|
|
37529
|
+
headers: {
|
|
37530
|
+
"Content-Type": "application/json",
|
|
37531
|
+
"x-owner-id": userId || "",
|
|
37532
|
+
},
|
|
37533
|
+
});
|
|
37211
37534
|
if (!response.ok) {
|
|
37212
37535
|
throw new Error("Failed to load page data");
|
|
37213
37536
|
}
|
|
@@ -37543,62 +37866,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37543
37866
|
onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
|
|
37544
37867
|
}, defaultAgentName: defaultAgentName }), jsxRuntimeExports.jsx(EditWidgetDialog, { initialText: editInitialQuery, isOpen: showEditModal, onClose: () => setShowEditModal(false), onSubmit: handleEditSubmit }), jsxRuntimeExports.jsx("div", { className: "min-h-full", onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, onClick: () => setSelectedWidget(null), children: isLoading ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx(lucideReact.Loader2, { className: "h-8 w-8 animate-spin" }) })) : (jsxRuntimeExports.jsx(RGL, { className: "layout m-0 p-0", layouts: { lg: getLayoutFromWidgets() }, breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480 }, cols: { lg: 12, md: 8, sm: 6, xs: 2 }, rowHeight: 100, isDraggable: isEditing, isResizable: isEditing, draggableHandle: ".drag-icon", onLayoutChange: handleLayoutChange, compactType: "vertical", containerPadding: [0, 0], resizeHandles: ["sw", "nw", "se", "ne"], children: widgets.map((w) => (jsxRuntimeExports.jsxs("div", { style: { borderColor: "rgb(147 197 253 / 1)" }, className: `border border-blue-300 rounded-xl p-4 shadow-lg overflow-hidden ${isEditing ? 'pb-20' : 'pb-14'}`, children: [isEditing &&
|
|
37545
37868
|
jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end mb-4 relative", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center drag-icon cursor-grab absolute left-1/2 -translate-x-1/2", children: [jsxRuntimeExports.jsx(lucideReact.GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(lucideReact.GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(lucideReact.GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(lucideReact.Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), jsxRuntimeExports.jsx(lucideReact.Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: "w-full h-full relative", children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
|
|
37546
|
-
jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(lucideReact.MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })
|
|
37547
|
-
// <ReactGridLayout
|
|
37548
|
-
// className="layout"
|
|
37549
|
-
// layout={getLayoutFromWidgets()}
|
|
37550
|
-
// cols={12}
|
|
37551
|
-
// rowHeight={50}
|
|
37552
|
-
// onLayoutChange={handleLayoutChange}
|
|
37553
|
-
// onDragStart={() => setIsDragging(true)}
|
|
37554
|
-
// onDragStop={() => setIsDragging(false)}
|
|
37555
|
-
// isDraggable={isEditing}
|
|
37556
|
-
// isResizable={isEditing}
|
|
37557
|
-
// useCSSTransforms
|
|
37558
|
-
// compactType={null}
|
|
37559
|
-
// margin={[8, 8]}
|
|
37560
|
-
// preventCollision={true}
|
|
37561
|
-
// >
|
|
37562
|
-
// {widgets.map((widget) => (
|
|
37563
|
-
// <div
|
|
37564
|
-
// key={widget.id}
|
|
37565
|
-
// className={cn(
|
|
37566
|
-
// "bg-background rounded-lg shadow-sm border overflow-hidden transition-all",
|
|
37567
|
-
// currentSelectedWidget?.id === widget.id &&
|
|
37568
|
-
// "ring-2 ring-primary ring-offset-2"
|
|
37569
|
-
// )}
|
|
37570
|
-
// onClick={(e) => handleWidgetClick(widget, e)}
|
|
37571
|
-
// onDoubleClick={(e) => handleWidgetDoubleClick(widget, e)}
|
|
37572
|
-
// >
|
|
37573
|
-
// {widget.config?.showHeader !== false && (
|
|
37574
|
-
// <div className="p-2 border-b flex items-center justify-between">
|
|
37575
|
-
// <span className="font-medium text-sm">
|
|
37576
|
-
// {widget.title}
|
|
37577
|
-
// </span>
|
|
37578
|
-
// {isEditing && (
|
|
37579
|
-
// <Button
|
|
37580
|
-
// variant="ghost"
|
|
37581
|
-
// size="sm"
|
|
37582
|
-
// onClick={() => removeWidget(widget.id)}
|
|
37583
|
-
// >
|
|
37584
|
-
// <Trash2 className="h-4 w-4" />
|
|
37585
|
-
// </Button>
|
|
37586
|
-
// )}
|
|
37587
|
-
// </div>
|
|
37588
|
-
// )}
|
|
37589
|
-
// <div
|
|
37590
|
-
// className={cn(
|
|
37591
|
-
// "h-full",
|
|
37592
|
-
// widget.config?.showHeader !== false &&
|
|
37593
|
-
// "h-[calc(100%-40px)]"
|
|
37594
|
-
// )}
|
|
37595
|
-
// >
|
|
37596
|
-
// <WidgetRenderer widget={widget} widgetBackendUrl={widgetBackendUrl} />
|
|
37597
|
-
// </div>
|
|
37598
|
-
// </div>
|
|
37599
|
-
// ))}
|
|
37600
|
-
// </ReactGridLayout>
|
|
37601
|
-
) })] }));
|
|
37869
|
+
jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(lucideReact.MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })) })] }));
|
|
37602
37870
|
}
|
|
37603
37871
|
|
|
37604
37872
|
const Checkbox = React__namespace.forwardRef((_a, ref) => {
|