dp-widgets-framework 1.0.2 → 1.0.4
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 +377 -60
- package/dist/index.js +376 -59
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
9
9
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
10
|
-
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, RefreshCw, X, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, Loader2,
|
|
10
|
+
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, RefreshCw, X, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
|
|
11
11
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
12
12
|
import { Slot } from '@radix-ui/react-slot';
|
|
13
13
|
import { debounce as debounce$1 } from 'lodash';
|
|
@@ -35970,30 +35970,35 @@ const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
|
35970
35970
|
const parsedState = JSON.parse(stateString);
|
|
35971
35971
|
if (parsedState.state) {
|
|
35972
35972
|
const chartData = parsedState.state;
|
|
35973
|
-
//
|
|
35974
|
-
|
|
35975
|
-
|
|
35976
|
-
|
|
35977
|
-
|
|
35978
|
-
|
|
35979
|
-
|
|
35980
|
-
|
|
35981
|
-
|
|
35982
|
-
|
|
35983
|
-
|
|
35984
|
-
|
|
35985
|
-
|
|
35986
|
-
|
|
35987
|
-
|
|
35988
|
-
|
|
35989
|
-
|
|
35990
|
-
|
|
35991
|
-
|
|
35992
|
-
|
|
35993
|
-
|
|
35994
|
-
|
|
35995
|
-
|
|
35996
|
-
|
|
35973
|
+
// Update chart state while preserving existing data including agent_message
|
|
35974
|
+
setChartState(prevState => {
|
|
35975
|
+
const newChartState = Object.assign({}, prevState);
|
|
35976
|
+
// Check for different chart types and map them accordingly
|
|
35977
|
+
if (chartData.bar_chart_data) {
|
|
35978
|
+
newChartState.bar_chart_data = chartData.bar_chart_data;
|
|
35979
|
+
}
|
|
35980
|
+
if (chartData.series_bar_chart_data) {
|
|
35981
|
+
newChartState.series_bar_chart_data = chartData.series_bar_chart_data;
|
|
35982
|
+
}
|
|
35983
|
+
if (chartData.series_line_chart_data) {
|
|
35984
|
+
newChartState.series_line_chart_data = chartData.series_line_chart_data;
|
|
35985
|
+
}
|
|
35986
|
+
if (chartData.pie_chart_data) {
|
|
35987
|
+
newChartState.pie_chart_data = chartData.pie_chart_data;
|
|
35988
|
+
}
|
|
35989
|
+
if (chartData.matrix_grid_data) {
|
|
35990
|
+
newChartState.matrix_grid_data = chartData.matrix_grid_data;
|
|
35991
|
+
}
|
|
35992
|
+
if (chartData.summary_data) {
|
|
35993
|
+
newChartState.summary_data = chartData.summary_data;
|
|
35994
|
+
}
|
|
35995
|
+
// Preserve agent_message if it exists
|
|
35996
|
+
if (chartData.agent_message) {
|
|
35997
|
+
newChartState.agent_message = chartData.agent_message;
|
|
35998
|
+
}
|
|
35999
|
+
console.log('Chart state updated from API response:', newChartState);
|
|
36000
|
+
return newChartState;
|
|
36001
|
+
});
|
|
35997
36002
|
}
|
|
35998
36003
|
}
|
|
35999
36004
|
}
|
|
@@ -36034,6 +36039,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36034
36039
|
const clearChat = async () => {
|
|
36035
36040
|
if (!widgetBackendUrl || !widgetId)
|
|
36036
36041
|
return;
|
|
36042
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36037
36043
|
try {
|
|
36038
36044
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36039
36045
|
method: 'POST',
|
|
@@ -36042,9 +36048,12 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36042
36048
|
},
|
|
36043
36049
|
body: JSON.stringify({
|
|
36044
36050
|
session_id: widgetId,
|
|
36045
|
-
delete_state:
|
|
36051
|
+
delete_state: true
|
|
36046
36052
|
}),
|
|
36047
36053
|
});
|
|
36054
|
+
// Clear chart state directly after clearing chat
|
|
36055
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36056
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36048
36057
|
}
|
|
36049
36058
|
catch (error) {
|
|
36050
36059
|
console.error('Failed to clear chat:', error);
|
|
@@ -36053,6 +36062,9 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36053
36062
|
const handleRefresh = async () => {
|
|
36054
36063
|
if (query) {
|
|
36055
36064
|
await clearChat();
|
|
36065
|
+
// Send trigger event to clear chart state
|
|
36066
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36067
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36056
36068
|
appendMessage(new TextMessage({
|
|
36057
36069
|
content: `${query} and render data on a bar chart`,
|
|
36058
36070
|
role: Role.User,
|
|
@@ -36060,13 +36072,13 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36060
36072
|
}
|
|
36061
36073
|
};
|
|
36062
36074
|
useEffect(() => {
|
|
36063
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36075
|
+
if (isEmpty && query && isFirstLoad && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36064
36076
|
handleRefresh();
|
|
36065
36077
|
}
|
|
36066
36078
|
}, [isEmpty, query, isFirstLoad]);
|
|
36067
36079
|
// Start timeout when chart is empty and loading
|
|
36068
36080
|
useEffect(() => {
|
|
36069
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36081
|
+
if (isEmpty && startLoadingTimeout && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36070
36082
|
startLoadingTimeout();
|
|
36071
36083
|
}
|
|
36072
36084
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36105,6 +36117,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36105
36117
|
const clearChat = async () => {
|
|
36106
36118
|
if (!widgetBackendUrl || !widgetId)
|
|
36107
36119
|
return;
|
|
36120
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36108
36121
|
try {
|
|
36109
36122
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36110
36123
|
method: 'POST',
|
|
@@ -36113,9 +36126,12 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36113
36126
|
},
|
|
36114
36127
|
body: JSON.stringify({
|
|
36115
36128
|
session_id: widgetId,
|
|
36116
|
-
delete_state:
|
|
36129
|
+
delete_state: true
|
|
36117
36130
|
}),
|
|
36118
36131
|
});
|
|
36132
|
+
// Clear chart state directly after clearing chat
|
|
36133
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36134
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36119
36135
|
}
|
|
36120
36136
|
catch (error) {
|
|
36121
36137
|
console.error('Failed to clear chat:', error);
|
|
@@ -36124,6 +36140,9 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36124
36140
|
const handleRefresh = async () => {
|
|
36125
36141
|
if (query) {
|
|
36126
36142
|
await clearChat();
|
|
36143
|
+
// Send trigger event to clear chart state
|
|
36144
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36145
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36127
36146
|
appendMessage(new TextMessage({
|
|
36128
36147
|
content: `${query} and render data on a series bar chart`,
|
|
36129
36148
|
role: Role.User,
|
|
@@ -36131,13 +36150,13 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36131
36150
|
}
|
|
36132
36151
|
};
|
|
36133
36152
|
useEffect(() => {
|
|
36134
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36153
|
+
if (isEmpty && query && isFirstLoad && !(seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.agent_message)) {
|
|
36135
36154
|
handleRefresh();
|
|
36136
36155
|
}
|
|
36137
36156
|
}, [isEmpty, query, isFirstLoad]);
|
|
36138
36157
|
// Start timeout when chart is empty and loading
|
|
36139
36158
|
useEffect(() => {
|
|
36140
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36159
|
+
if (isEmpty && startLoadingTimeout && !(seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.agent_message)) {
|
|
36141
36160
|
startLoadingTimeout();
|
|
36142
36161
|
}
|
|
36143
36162
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36170,6 +36189,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36170
36189
|
const clearChat = async () => {
|
|
36171
36190
|
if (!widgetBackendUrl || !widgetId)
|
|
36172
36191
|
return;
|
|
36192
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36173
36193
|
try {
|
|
36174
36194
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36175
36195
|
method: 'POST',
|
|
@@ -36178,9 +36198,12 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36178
36198
|
},
|
|
36179
36199
|
body: JSON.stringify({
|
|
36180
36200
|
session_id: widgetId,
|
|
36181
|
-
delete_state:
|
|
36201
|
+
delete_state: true
|
|
36182
36202
|
}),
|
|
36183
36203
|
});
|
|
36204
|
+
// Clear chart state directly after clearing chat
|
|
36205
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36206
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36184
36207
|
}
|
|
36185
36208
|
catch (error) {
|
|
36186
36209
|
console.error('Failed to clear chat:', error);
|
|
@@ -36189,6 +36212,9 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36189
36212
|
const handleRefresh = async () => {
|
|
36190
36213
|
if (query) {
|
|
36191
36214
|
await clearChat();
|
|
36215
|
+
// Send trigger event to clear chart state
|
|
36216
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36217
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36192
36218
|
appendMessage(new TextMessage({
|
|
36193
36219
|
content: `${query} and render data on a series line chart`,
|
|
36194
36220
|
role: Role.User,
|
|
@@ -36196,13 +36222,13 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36196
36222
|
}
|
|
36197
36223
|
};
|
|
36198
36224
|
useEffect(() => {
|
|
36199
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36225
|
+
if (isEmpty && query && isFirstLoad && !(seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.agent_message)) {
|
|
36200
36226
|
handleRefresh();
|
|
36201
36227
|
}
|
|
36202
36228
|
}, [isEmpty, query, isFirstLoad]);
|
|
36203
36229
|
// Start timeout when chart is empty and loading
|
|
36204
36230
|
useEffect(() => {
|
|
36205
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36231
|
+
if (isEmpty && startLoadingTimeout && !(seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.agent_message)) {
|
|
36206
36232
|
startLoadingTimeout();
|
|
36207
36233
|
}
|
|
36208
36234
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36243,6 +36269,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36243
36269
|
const clearChat = async () => {
|
|
36244
36270
|
if (!widgetBackendUrl || !widgetId)
|
|
36245
36271
|
return;
|
|
36272
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36246
36273
|
try {
|
|
36247
36274
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36248
36275
|
method: 'POST',
|
|
@@ -36251,9 +36278,12 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36251
36278
|
},
|
|
36252
36279
|
body: JSON.stringify({
|
|
36253
36280
|
session_id: widgetId,
|
|
36254
|
-
delete_state:
|
|
36281
|
+
delete_state: true
|
|
36255
36282
|
}),
|
|
36256
36283
|
});
|
|
36284
|
+
// Clear chart state directly after clearing chat
|
|
36285
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36286
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36257
36287
|
}
|
|
36258
36288
|
catch (error) {
|
|
36259
36289
|
console.error('Failed to clear chat:', error);
|
|
@@ -36262,6 +36292,9 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36262
36292
|
const handleRefresh = async () => {
|
|
36263
36293
|
if (query) {
|
|
36264
36294
|
await clearChat();
|
|
36295
|
+
// Send trigger event to clear chart state
|
|
36296
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36297
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36265
36298
|
appendMessage(new TextMessage({
|
|
36266
36299
|
content: `${query} and render data on pie chart`,
|
|
36267
36300
|
role: Role.User,
|
|
@@ -36269,13 +36302,13 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36269
36302
|
}
|
|
36270
36303
|
};
|
|
36271
36304
|
useEffect(() => {
|
|
36272
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36305
|
+
if (isEmpty && query && isFirstLoad && !(pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.agent_message)) {
|
|
36273
36306
|
handleRefresh();
|
|
36274
36307
|
}
|
|
36275
36308
|
}, [isEmpty, query, isFirstLoad]);
|
|
36276
36309
|
// Start timeout when chart is empty and loading
|
|
36277
36310
|
useEffect(() => {
|
|
36278
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36311
|
+
if (isEmpty && startLoadingTimeout && !(pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.agent_message)) {
|
|
36279
36312
|
startLoadingTimeout();
|
|
36280
36313
|
}
|
|
36281
36314
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36323,6 +36356,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36323
36356
|
const clearChat = async () => {
|
|
36324
36357
|
if (!widgetBackendUrl || !widgetId)
|
|
36325
36358
|
return;
|
|
36359
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36326
36360
|
try {
|
|
36327
36361
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36328
36362
|
method: 'POST',
|
|
@@ -36331,9 +36365,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36331
36365
|
},
|
|
36332
36366
|
body: JSON.stringify({
|
|
36333
36367
|
session_id: widgetId,
|
|
36334
|
-
delete_state:
|
|
36368
|
+
delete_state: true
|
|
36335
36369
|
}),
|
|
36336
36370
|
});
|
|
36371
|
+
// Clear chart state directly after clearing chat
|
|
36372
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36373
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36337
36374
|
}
|
|
36338
36375
|
catch (error) {
|
|
36339
36376
|
console.error('Failed to clear chat:', error);
|
|
@@ -36342,6 +36379,9 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36342
36379
|
const handleRefresh = async () => {
|
|
36343
36380
|
if (query) {
|
|
36344
36381
|
await clearChat();
|
|
36382
|
+
// Send trigger event to clear chart state
|
|
36383
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36384
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36345
36385
|
appendMessage(new TextMessage({
|
|
36346
36386
|
content: `${query} and render data on a bar chart`,
|
|
36347
36387
|
role: Role.User,
|
|
@@ -36349,13 +36389,13 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36349
36389
|
}
|
|
36350
36390
|
};
|
|
36351
36391
|
useEffect(() => {
|
|
36352
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36392
|
+
if (isEmpty && query && isFirstLoad && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36353
36393
|
handleRefresh();
|
|
36354
36394
|
}
|
|
36355
36395
|
}, [isEmpty, query, isFirstLoad]);
|
|
36356
36396
|
// Start timeout when chart is empty and loading
|
|
36357
36397
|
useEffect(() => {
|
|
36358
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36398
|
+
if (isEmpty && startLoadingTimeout && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36359
36399
|
startLoadingTimeout();
|
|
36360
36400
|
}
|
|
36361
36401
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36403,6 +36443,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36403
36443
|
const clearChat = async () => {
|
|
36404
36444
|
if (!widgetBackendUrl || !widgetId)
|
|
36405
36445
|
return;
|
|
36446
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36406
36447
|
try {
|
|
36407
36448
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36408
36449
|
method: 'POST',
|
|
@@ -36411,9 +36452,12 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36411
36452
|
},
|
|
36412
36453
|
body: JSON.stringify({
|
|
36413
36454
|
session_id: widgetId,
|
|
36414
|
-
delete_state:
|
|
36455
|
+
delete_state: true
|
|
36415
36456
|
}),
|
|
36416
36457
|
});
|
|
36458
|
+
// Clear chart state directly after clearing chat
|
|
36459
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36460
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36417
36461
|
}
|
|
36418
36462
|
catch (error) {
|
|
36419
36463
|
console.error('Failed to clear chat:', error);
|
|
@@ -36422,6 +36466,9 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36422
36466
|
const handleRefresh = async () => {
|
|
36423
36467
|
if (query) {
|
|
36424
36468
|
await clearChat();
|
|
36469
|
+
// Send trigger event to clear chart state
|
|
36470
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36471
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36425
36472
|
appendMessage(new TextMessage({
|
|
36426
36473
|
content: `${query} and render data in a data grid table`,
|
|
36427
36474
|
role: Role.User,
|
|
@@ -36429,13 +36476,13 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36429
36476
|
}
|
|
36430
36477
|
};
|
|
36431
36478
|
useEffect(() => {
|
|
36432
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36479
|
+
if (isEmpty && query && isFirstLoad && !(dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.agent_message)) {
|
|
36433
36480
|
handleRefresh();
|
|
36434
36481
|
}
|
|
36435
36482
|
}, [isEmpty, query, isFirstLoad]);
|
|
36436
36483
|
// Start timeout when chart is empty and loading
|
|
36437
36484
|
useEffect(() => {
|
|
36438
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36485
|
+
if (isEmpty && startLoadingTimeout && !(dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.agent_message)) {
|
|
36439
36486
|
startLoadingTimeout();
|
|
36440
36487
|
}
|
|
36441
36488
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36461,6 +36508,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36461
36508
|
const clearChat = async () => {
|
|
36462
36509
|
if (!widgetBackendUrl || !widgetId)
|
|
36463
36510
|
return;
|
|
36511
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
36464
36512
|
try {
|
|
36465
36513
|
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36466
36514
|
method: 'POST',
|
|
@@ -36469,9 +36517,12 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36469
36517
|
},
|
|
36470
36518
|
body: JSON.stringify({
|
|
36471
36519
|
session_id: widgetId,
|
|
36472
|
-
delete_state:
|
|
36520
|
+
delete_state: true
|
|
36473
36521
|
}),
|
|
36474
36522
|
});
|
|
36523
|
+
// Clear chart state directly after clearing chat
|
|
36524
|
+
console.log('Dispatching clearChartState event from clearChat for widgetId:', widgetId);
|
|
36525
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36475
36526
|
}
|
|
36476
36527
|
catch (error) {
|
|
36477
36528
|
console.error('Failed to clear chat:', error);
|
|
@@ -36480,6 +36531,9 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36480
36531
|
const handleRefresh = async () => {
|
|
36481
36532
|
if (query) {
|
|
36482
36533
|
await clearChat();
|
|
36534
|
+
// Send trigger event to clear chart state
|
|
36535
|
+
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36536
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
36483
36537
|
appendMessage(new TextMessage({
|
|
36484
36538
|
content: `${query} and provide a summary with statistics`,
|
|
36485
36539
|
role: Role.User,
|
|
@@ -36487,7 +36541,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36487
36541
|
}
|
|
36488
36542
|
};
|
|
36489
36543
|
useEffect(() => {
|
|
36490
|
-
if (isEmpty && query && isFirstLoad) {
|
|
36544
|
+
if (isEmpty && query && isFirstLoad && !(summaryState === null || summaryState === void 0 ? void 0 : summaryState.agent_message)) {
|
|
36491
36545
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widget_ids })));
|
|
36492
36546
|
setTimeout(() => {
|
|
36493
36547
|
handleRefresh();
|
|
@@ -36496,7 +36550,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36496
36550
|
}, [isEmpty, query, isFirstLoad]);
|
|
36497
36551
|
// Start timeout when summary is empty and loading
|
|
36498
36552
|
useEffect(() => {
|
|
36499
|
-
if (isEmpty && startLoadingTimeout) {
|
|
36553
|
+
if (isEmpty && startLoadingTimeout && !(summaryState === null || summaryState === void 0 ? void 0 : summaryState.agent_message)) {
|
|
36500
36554
|
startLoadingTimeout();
|
|
36501
36555
|
}
|
|
36502
36556
|
else if (!isEmpty && clearLoadingTimeout) {
|
|
@@ -36509,13 +36563,14 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36509
36563
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36510
36564
|
}
|
|
36511
36565
|
function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl }) {
|
|
36512
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36566
|
+
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;
|
|
36513
36567
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36514
36568
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36515
36569
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
36516
36570
|
const { threadId, setThreadId } = useCopilotContext();
|
|
36517
36571
|
const timeoutRef = useRef(null);
|
|
36518
36572
|
const [isTimeoutTriggered, setIsTimeoutTriggered] = useState(false);
|
|
36573
|
+
const [timeoutCount, setTimeoutCount] = useState(0);
|
|
36519
36574
|
useEffect(() => {
|
|
36520
36575
|
setThreadId(widget.id);
|
|
36521
36576
|
}, [widget.id, setThreadId]);
|
|
@@ -36697,16 +36752,17 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36697
36752
|
// Function to handle timeout and call loadAgentState API
|
|
36698
36753
|
const handleLoadingTimeout = useCallback(async () => {
|
|
36699
36754
|
var _a;
|
|
36700
|
-
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered)
|
|
36755
|
+
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState === null || chartState === void 0 ? void 0 : chartState.agent_message))
|
|
36701
36756
|
return;
|
|
36702
36757
|
console.log('Loading timeout triggered for widget:', widget.id);
|
|
36703
36758
|
setIsTimeoutTriggered(true);
|
|
36759
|
+
setTimeoutCount(prev => prev + 1);
|
|
36704
36760
|
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
36705
36761
|
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
36706
|
-
if (apiResponse) {
|
|
36762
|
+
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
36707
36763
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
36708
36764
|
}
|
|
36709
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName]);
|
|
36765
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName, chartState]);
|
|
36710
36766
|
// Function to start timeout
|
|
36711
36767
|
const startLoadingTimeout = useCallback(() => {
|
|
36712
36768
|
if (timeoutRef.current) {
|
|
@@ -36724,6 +36780,28 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36724
36780
|
timeoutRef.current = null;
|
|
36725
36781
|
}
|
|
36726
36782
|
}, []);
|
|
36783
|
+
// Function to clear chat and reset chart state
|
|
36784
|
+
useCallback(async (widgetId) => {
|
|
36785
|
+
if (!widgetBackendUrl)
|
|
36786
|
+
return;
|
|
36787
|
+
try {
|
|
36788
|
+
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36789
|
+
method: 'POST',
|
|
36790
|
+
headers: {
|
|
36791
|
+
'Content-Type': 'application/json',
|
|
36792
|
+
},
|
|
36793
|
+
body: JSON.stringify({
|
|
36794
|
+
session_id: widgetId,
|
|
36795
|
+
delete_state: true
|
|
36796
|
+
}),
|
|
36797
|
+
});
|
|
36798
|
+
// Reset chart state based on agent type - call getInitialState from local scope
|
|
36799
|
+
setChartState(getInitialState());
|
|
36800
|
+
}
|
|
36801
|
+
catch (error) {
|
|
36802
|
+
console.error('Failed to clear chat and state:', error);
|
|
36803
|
+
}
|
|
36804
|
+
}, [widgetBackendUrl, setChartState, agentType, widgetIds]);
|
|
36727
36805
|
// Clean up timeout on unmount
|
|
36728
36806
|
useEffect(() => {
|
|
36729
36807
|
return () => {
|
|
@@ -36732,13 +36810,26 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36732
36810
|
}
|
|
36733
36811
|
};
|
|
36734
36812
|
}, []);
|
|
36735
|
-
const { appendMessage, reset } = useCopilotChat();
|
|
36813
|
+
const { appendMessage, reset, isLoading } = useCopilotChat();
|
|
36736
36814
|
// Register the reset function with the parent component
|
|
36737
36815
|
useEffect(() => {
|
|
36816
|
+
console.log('onResetReady available:', !!onResetReady, 'reset available:', !!reset, 'widget.id:', widget.id);
|
|
36738
36817
|
if (onResetReady && reset && widget.id) {
|
|
36739
|
-
|
|
36818
|
+
console.log('Registering reset function for widget:', widget.id);
|
|
36819
|
+
// Create a wrapped reset function that also clears chart state
|
|
36820
|
+
const wrappedReset = () => {
|
|
36821
|
+
console.log('Reset called for widget:', widget.id);
|
|
36822
|
+
reset();
|
|
36823
|
+
// Clear chart state after reset
|
|
36824
|
+
console.log('Dispatching clearChartState event from reset for widgetId:', widget.id);
|
|
36825
|
+
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId: widget.id } }));
|
|
36826
|
+
};
|
|
36827
|
+
onResetReady(widget.id, wrappedReset);
|
|
36740
36828
|
}
|
|
36741
|
-
|
|
36829
|
+
else {
|
|
36830
|
+
console.log('Not registering reset - missing dependencies');
|
|
36831
|
+
}
|
|
36832
|
+
}, [reset, widget.id, onResetReady]); // Removed onResetReady from deps to avoid the error
|
|
36742
36833
|
// Listen for triggerAgent events for this widget
|
|
36743
36834
|
useEffect(() => {
|
|
36744
36835
|
const handleTriggerAgent = (event) => {
|
|
@@ -36773,14 +36864,240 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36773
36864
|
}));
|
|
36774
36865
|
}
|
|
36775
36866
|
};
|
|
36867
|
+
const handleClearChartState = (event) => {
|
|
36868
|
+
const { widgetId } = event.detail;
|
|
36869
|
+
console.log('Received clearChartState event - widgetId:', widgetId, 'current widget.id:', widget.id);
|
|
36870
|
+
if (widgetId === widget.id) {
|
|
36871
|
+
console.log('Clearing chart state for widget:', widgetId);
|
|
36872
|
+
// Reset chart state based on agent type with explicit initial state
|
|
36873
|
+
if (agentType === "Pie Chart Agent") {
|
|
36874
|
+
setChartState({
|
|
36875
|
+
pie_chart_data: {
|
|
36876
|
+
title: "",
|
|
36877
|
+
type: "pie",
|
|
36878
|
+
chart_type: "financial",
|
|
36879
|
+
data: {
|
|
36880
|
+
labels: [],
|
|
36881
|
+
values: [],
|
|
36882
|
+
percentages: [],
|
|
36883
|
+
total: 0
|
|
36884
|
+
},
|
|
36885
|
+
metadata: {
|
|
36886
|
+
categories: 0,
|
|
36887
|
+
largest_category: "",
|
|
36888
|
+
largest_value: 0,
|
|
36889
|
+
largest_percentage: 0
|
|
36890
|
+
}
|
|
36891
|
+
}
|
|
36892
|
+
});
|
|
36893
|
+
}
|
|
36894
|
+
else if (agentType === "Bar Chart Agent") {
|
|
36895
|
+
setChartState({
|
|
36896
|
+
bar_chart_data: {
|
|
36897
|
+
title: "",
|
|
36898
|
+
type: "bar",
|
|
36899
|
+
chart_type: "financial",
|
|
36900
|
+
orientation: "vertical",
|
|
36901
|
+
data: {
|
|
36902
|
+
labels: [],
|
|
36903
|
+
values: [],
|
|
36904
|
+
total: 0,
|
|
36905
|
+
average: 0
|
|
36906
|
+
},
|
|
36907
|
+
metadata: {
|
|
36908
|
+
categories: 0,
|
|
36909
|
+
highest_category: "",
|
|
36910
|
+
highest_value: 0,
|
|
36911
|
+
lowest_category: "",
|
|
36912
|
+
lowest_value: 0,
|
|
36913
|
+
range: 0
|
|
36914
|
+
}
|
|
36915
|
+
}
|
|
36916
|
+
});
|
|
36917
|
+
}
|
|
36918
|
+
else if (agentType === "Series Bar Chart Agent") {
|
|
36919
|
+
setChartState({
|
|
36920
|
+
series_bar_chart_data: {
|
|
36921
|
+
title: "",
|
|
36922
|
+
type: "series_bar",
|
|
36923
|
+
chart_type: "financial",
|
|
36924
|
+
orientation: "vertical",
|
|
36925
|
+
data: {
|
|
36926
|
+
labels: [],
|
|
36927
|
+
series: [],
|
|
36928
|
+
total: 0,
|
|
36929
|
+
average: 0
|
|
36930
|
+
},
|
|
36931
|
+
metadata: {
|
|
36932
|
+
categories: 0,
|
|
36933
|
+
series_count: 0,
|
|
36934
|
+
highest_category: "",
|
|
36935
|
+
highest_value: 0,
|
|
36936
|
+
highest_series: "",
|
|
36937
|
+
lowest_category: "",
|
|
36938
|
+
lowest_value: 0,
|
|
36939
|
+
lowest_series: "",
|
|
36940
|
+
range: 0,
|
|
36941
|
+
series_totals: {},
|
|
36942
|
+
series_averages: {}
|
|
36943
|
+
}
|
|
36944
|
+
}
|
|
36945
|
+
});
|
|
36946
|
+
}
|
|
36947
|
+
else if (agentType === "Series Line Chart Agent") {
|
|
36948
|
+
setChartState({
|
|
36949
|
+
series_bar_chart_data: {
|
|
36950
|
+
title: "",
|
|
36951
|
+
type: "series_bar",
|
|
36952
|
+
chart_type: "financial",
|
|
36953
|
+
orientation: "vertical",
|
|
36954
|
+
data: {
|
|
36955
|
+
labels: [],
|
|
36956
|
+
series: [],
|
|
36957
|
+
total: 0,
|
|
36958
|
+
average: 0
|
|
36959
|
+
},
|
|
36960
|
+
metadata: {
|
|
36961
|
+
categories: 0,
|
|
36962
|
+
series_count: 0,
|
|
36963
|
+
highest_category: "",
|
|
36964
|
+
highest_value: 0,
|
|
36965
|
+
highest_series: "",
|
|
36966
|
+
lowest_category: "",
|
|
36967
|
+
lowest_value: 0,
|
|
36968
|
+
lowest_series: "",
|
|
36969
|
+
range: 0,
|
|
36970
|
+
series_totals: {},
|
|
36971
|
+
series_averages: {}
|
|
36972
|
+
}
|
|
36973
|
+
}
|
|
36974
|
+
});
|
|
36975
|
+
}
|
|
36976
|
+
else if (agentType === "Line Chart Agent") {
|
|
36977
|
+
setChartState({
|
|
36978
|
+
bar_chart_data: {
|
|
36979
|
+
title: "",
|
|
36980
|
+
type: "line",
|
|
36981
|
+
chart_type: "financial",
|
|
36982
|
+
orientation: "horizontal",
|
|
36983
|
+
data: {
|
|
36984
|
+
labels: [],
|
|
36985
|
+
values: [],
|
|
36986
|
+
total: 0,
|
|
36987
|
+
average: 0
|
|
36988
|
+
},
|
|
36989
|
+
metadata: {
|
|
36990
|
+
categories: 0,
|
|
36991
|
+
highest_category: "",
|
|
36992
|
+
highest_value: 0,
|
|
36993
|
+
lowest_category: "",
|
|
36994
|
+
lowest_value: 0,
|
|
36995
|
+
range: 0
|
|
36996
|
+
}
|
|
36997
|
+
}
|
|
36998
|
+
});
|
|
36999
|
+
}
|
|
37000
|
+
else if (agentType === "Data Grid Agent") {
|
|
37001
|
+
setChartState({
|
|
37002
|
+
matrix_grid_data: {
|
|
37003
|
+
title: "",
|
|
37004
|
+
type: "data_grid",
|
|
37005
|
+
grid_type: "",
|
|
37006
|
+
data: {
|
|
37007
|
+
headers: [],
|
|
37008
|
+
rows: [],
|
|
37009
|
+
row_count: 0,
|
|
37010
|
+
column_count: 0
|
|
37011
|
+
},
|
|
37012
|
+
metadata: {
|
|
37013
|
+
total_rows: 0,
|
|
37014
|
+
total_columns: 0,
|
|
37015
|
+
numeric_columns: []
|
|
37016
|
+
}
|
|
37017
|
+
}
|
|
37018
|
+
});
|
|
37019
|
+
}
|
|
37020
|
+
else if (agentType === "Summary Agent") {
|
|
37021
|
+
setChartState({
|
|
37022
|
+
summary_data: {
|
|
37023
|
+
title: "",
|
|
37024
|
+
type: "summary",
|
|
37025
|
+
data: {
|
|
37026
|
+
content: "",
|
|
37027
|
+
word_count: 0,
|
|
37028
|
+
character_count: 0,
|
|
37029
|
+
character_count_no_spaces: 0,
|
|
37030
|
+
line_count: 0
|
|
37031
|
+
},
|
|
37032
|
+
metadata: {
|
|
37033
|
+
created_at: "",
|
|
37034
|
+
content_type: "text",
|
|
37035
|
+
is_multiline: false
|
|
37036
|
+
}
|
|
37037
|
+
}
|
|
37038
|
+
});
|
|
37039
|
+
}
|
|
37040
|
+
else {
|
|
37041
|
+
setChartState({ widget_ids: widgetIds });
|
|
37042
|
+
}
|
|
37043
|
+
}
|
|
37044
|
+
};
|
|
37045
|
+
console.log('Setting up event listeners for widget:', widget.id);
|
|
36776
37046
|
window.addEventListener('triggerAgent', handleTriggerAgent);
|
|
37047
|
+
window.addEventListener('clearChartState', handleClearChartState);
|
|
36777
37048
|
return () => {
|
|
36778
37049
|
window.removeEventListener('triggerAgent', handleTriggerAgent);
|
|
37050
|
+
window.removeEventListener('clearChartState', handleClearChartState);
|
|
37051
|
+
};
|
|
37052
|
+
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
37053
|
+
// Monitor chartState and add manual clear functionality
|
|
37054
|
+
useEffect(() => {
|
|
37055
|
+
// Add a global function to manually clear this widget's state
|
|
37056
|
+
const clearThisWidget = () => {
|
|
37057
|
+
console.log('Manual clear triggered for widget:', widget.id);
|
|
37058
|
+
if (agentType === "Pie Chart Agent") {
|
|
37059
|
+
setChartState({
|
|
37060
|
+
pie_chart_data: {
|
|
37061
|
+
title: "",
|
|
37062
|
+
type: "pie",
|
|
37063
|
+
chart_type: "financial",
|
|
37064
|
+
data: {
|
|
37065
|
+
labels: [],
|
|
37066
|
+
values: [],
|
|
37067
|
+
percentages: [],
|
|
37068
|
+
total: 0
|
|
37069
|
+
},
|
|
37070
|
+
metadata: {
|
|
37071
|
+
categories: 0,
|
|
37072
|
+
largest_category: "",
|
|
37073
|
+
largest_value: 0,
|
|
37074
|
+
largest_percentage: 0
|
|
37075
|
+
}
|
|
37076
|
+
}
|
|
37077
|
+
});
|
|
37078
|
+
}
|
|
37079
|
+
// Add other agent types as needed
|
|
37080
|
+
};
|
|
37081
|
+
// Make it globally accessible for testing
|
|
37082
|
+
window[`clearWidget_${widget.id}`] = clearThisWidget;
|
|
37083
|
+
return () => {
|
|
37084
|
+
delete window[`clearWidget_${widget.id}`];
|
|
36779
37085
|
};
|
|
36780
|
-
}, [widget.id,
|
|
36781
|
-
|
|
36782
|
-
|
|
36783
|
-
|
|
37086
|
+
}, [widget.id, agentType, setChartState]);
|
|
37087
|
+
console.log('agent_message==>', chartState === null || chartState === void 0 ? void 0 : chartState.agent_message);
|
|
37088
|
+
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))));
|
|
37089
|
+
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);
|
|
37090
|
+
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(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" && (
|
|
37091
|
+
// Check if data is empty based on agent type
|
|
37092
|
+
(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))) ||
|
|
37093
|
+
(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))) ||
|
|
37094
|
+
(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))) ||
|
|
37095
|
+
(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))) ||
|
|
37096
|
+
(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))) ||
|
|
37097
|
+
(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))) ||
|
|
37098
|
+
(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(CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
|
|
37099
|
+
title: ((_37 = widget.config) === null || _37 === void 0 ? void 0 : _37.copilotTitle) || widget.title,
|
|
37100
|
+
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?"
|
|
36784
37101
|
}, onSubmitMessage: () => {
|
|
36785
37102
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds })));
|
|
36786
37103
|
} })) })] }));
|
|
@@ -37117,7 +37434,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37117
37434
|
},
|
|
37118
37435
|
body: JSON.stringify({
|
|
37119
37436
|
session_id: editingWidget.id,
|
|
37120
|
-
delete_state:
|
|
37437
|
+
delete_state: true
|
|
37121
37438
|
}),
|
|
37122
37439
|
});
|
|
37123
37440
|
}
|
|
@@ -37514,8 +37831,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37514
37831
|
return (jsxRuntimeExports.jsxs("div", { className: "w-full max-w-full p-4 bg-accent/5", children: [jsxRuntimeExports.jsx(AddWidgetDialog, { isOpen: openWidgetPallete, onClose: onCloseWidgetPallete, addWidgetFn: (widgetType, config) => {
|
|
37515
37832
|
addWidget(widgetType, config);
|
|
37516
37833
|
onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
|
|
37517
|
-
}, 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(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], 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 &&
|
|
37518
|
-
jsxRuntimeExports.
|
|
37834
|
+
}, 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(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 &&
|
|
37835
|
+
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(GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), jsxRuntimeExports.jsx(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" &&
|
|
37519
37836
|
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(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))) })
|
|
37520
37837
|
// <ReactGridLayout
|
|
37521
37838
|
// className="layout"
|