Skip to content

Commit 49fc62b

Browse files
committed
fix: widget bugs and ai agent
1 parent da975d7 commit 49fc62b

File tree

3 files changed

+35
-56
lines changed

3 files changed

+35
-56
lines changed

Diff for: services/webui/src/components/widgets/KeyValue/index.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const getTable = (
104104

105105
export default function KeyValueWidget({ kpis }: KPIProps) {
106106
const [items, setItems] = useState<any[]>([])
107+
const [showError, setShowError] = useState(false)
107108

108109
const RunQuery = (query_id: string) => {
109110
let url = ''
@@ -162,6 +163,7 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
162163
})
163164
}).catch((err)=>{
164165
console.log("err",err)
166+
setShowError(true)
165167
})
166168
})
167169

@@ -173,12 +175,16 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
173175

174176
useEffect(() => {
175177
if (kpis.length > 0) {
178+
setShowError(false)
176179
handleKPIs()
177180
}
178181
}, [kpis])
182+
const GetItems = () => {
183+
return items
184+
}
179185
return (
180186
<>
181-
{items.length == 0 || items.length != kpis.length ? (
187+
{(items.length == 0 || items.length != kpis.length || showError) ? (
182188
<>
183189
<Alert header="Error" type="error">
184190
Error fetching fata
@@ -187,9 +193,11 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
187193
) : (
188194
<>
189195
<KeyValuePairs
190-
columns={kpis.length >4 ? 4 : kpis.length}
196+
columns={kpis.length > 4 ? 4 : kpis.length}
191197
minColumnWidth={250}
192-
items={items}
198+
// @ts-ignore
199+
200+
items={GetItems()}
193201
/>
194202
</>
195203
)}

Diff for: services/webui/src/components/widgets/WidgetLayout/index.tsx

+15-52
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,11 @@ export default function WidgetLayout({
235235
?.info
236236
}
237237
onChange={(e: any) => {
238-
setWidgetProps({
239-
...widgetProps,
240-
kpis: [
241-
...(widgetProps?.kpis ||
242-
[]),
243-
{
244-
info: e.detail
245-
.value,
246-
count_kpi: '',
247-
list_kpi: '',
248-
},
249-
],
250-
})
238+
HandleKPIPropChange(
239+
index,
240+
e.detail.value,
241+
'info'
242+
)
251243
}}
252244
/>
253245
<Input
@@ -257,23 +249,11 @@ export default function WidgetLayout({
257249
?.count_kpi
258250
}
259251
onChange={(e: any) => {
260-
setWidgetProps({
261-
...widgetProps,
262-
kpis: [
263-
...(widgetProps?.kpis ||
264-
[]),
265-
{
266-
info: widgetProps
267-
?.kpis?.[
268-
index
269-
]?.info,
270-
count_kpi:
271-
e.detail
272-
.value,
273-
list_kpi: '',
274-
},
275-
],
276-
})
252+
HandleKPIPropChange(
253+
index,
254+
e.detail.value,
255+
'count_kpi'
256+
)
277257
}}
278258
/>
279259
<Input
@@ -283,28 +263,11 @@ export default function WidgetLayout({
283263
?.list_kpi
284264
}
285265
onChange={(e: any) => {
286-
setWidgetProps({
287-
...widgetProps,
288-
kpis: [
289-
...(widgetProps?.kpis ||
290-
[]),
291-
{
292-
info: widgetProps
293-
?.kpis?.[
294-
index
295-
]?.info,
296-
count_kpi:
297-
widgetProps
298-
?.kpis?.[
299-
index
300-
]
301-
?.count_kpi,
302-
list_kpi:
303-
e.detail
304-
.value,
305-
},
306-
],
307-
})
266+
HandleKPIPropChange(
267+
index,
268+
e.detail.value,
269+
'list_kpi'
270+
)
308271
}}
309272
/>
310273
</>

Diff for: services/webui/src/pages/AI/chat/AIChat.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,17 @@ function AIChat({ setOpen }: any) {
344344
user_clarification_response:answer
345345

346346
}
347+
// @ts-ignore
348+
const token = JSON.parse(localStorage.getItem('openg_auth')).token
349+
350+
const config = {
351+
headers: {
352+
Authorization: `Bearer ${token}`,
353+
},
354+
}
347355

348356
axios
349-
.post(`/main/core/api/v4/chatbot/generate-query`, body)
357+
.post(`/main/core/api/v4/chatbot/generate-query`,body,config)
350358
.then((res) => {
351359
if (res?.data) {
352360
const output = res?.data

0 commit comments

Comments
 (0)