Skip to content

Commit

Permalink
(improvement)(chat-sdk) optimize tip and card title (#1652)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhliu committed Sep 11, 2024
1 parent fb96ce5 commit 91982a9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React, { ReactNode, useState } from 'react';

type Props = {
queryId?: number;
question: string;
queryMode?: string;
executeLoading: boolean;
entitySwitchLoading: boolean;
Expand All @@ -24,6 +25,7 @@ type Props = {

const ExecuteItem: React.FC<Props> = ({
queryId,
question,
queryMode,
executeLoading,
entitySwitchLoading,
Expand Down Expand Up @@ -124,6 +126,7 @@ const ExecuteItem: React.FC<Props> = ({
isSimpleMode={isSimpleMode}
forceShowTable={showMsgContentTable}
queryId={queryId}
question={question}
data={data}
chartIndex={chartIndex}
triggerResize={triggerResize}
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/chat-sdk/src/components/ChatItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ const ChatItem: React.FC<Props> = ({
<ExecuteItem
isSimpleMode={isSimpleMode}
queryId={parseInfo?.queryId}
question={msg}
queryMode={parseInfo?.queryMode}
executeLoading={executeLoading}
entitySwitchLoading={entitySwitchLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { useState } from 'react';

type Props = {
data: MsgDataType;
question: string;
loading: boolean;
onApplyAuth?: (model: string) => void;
};

const MetricCard: React.FC<Props> = ({ data, loading, onApplyAuth }) => {
const MetricCard: React.FC<Props> = ({ data, question, loading, onApplyAuth }) => {
const { queryMode, queryColumns, queryResults, entityInfo, aggregateInfo } = data;

const { metricInfos } = aggregateInfo || {};
Expand All @@ -39,11 +40,7 @@ const MetricCard: React.FC<Props> = ({ data, loading, onApplyAuth }) => {
return (
<div className={matricCardClass}>
<div className={`${prefixCls}-top-bar`}>
{indicatorColumn?.name ? (
<div className={`${prefixCls}-indicator-name`}>{indicatorColumn?.name}</div>
) : (
<div style={{ height: 10 }} />
)}
<div className={`${prefixCls}-indicator-name`}>{question}</div>
</div>
<Spin spinning={loading}>
<div className={`${prefixCls}-indicator`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Text: React.FC<Props> = ({ columns, referenceColumn, dataSource }) => {

const initData = () => {
let textValue = dataSource[0][columns[0].nameEn];
setText(textValue === undefined ? '暂无数据,如有疑问请联系管理员' : textValue);
setText(textValue === undefined ? '暂无数据' : textValue);
if (referenceColumn) {
const referenceDataValue = dataSource[0][referenceColumn.nameEn];
setReferenceData(referenceDataValue || []);
Expand Down
5 changes: 4 additions & 1 deletion webapp/packages/chat-sdk/src/components/ChatMsg/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isMobile } from '../../utils/utils';

type Props = {
queryId?: number;
question: string;
data: MsgDataType;
chartIndex: number;
triggerResize?: boolean;
Expand All @@ -25,6 +26,7 @@ type Props = {

const ChatMsg: React.FC<Props> = ({
queryId,
question,
data,
chartIndex,
triggerResize,
Expand Down Expand Up @@ -176,6 +178,7 @@ const ChatMsg: React.FC<Props> = ({
return (
<MetricCard
data={{ ...data, queryColumns: columns, queryResults: dataSource }}
question={question}
loading={loading}
/>
);
Expand Down Expand Up @@ -342,7 +345,7 @@ const ChatMsg: React.FC<Props> = ({
return (
<div className={chartMsgClass} style={style}>
{dataSource?.length === 0 ? (
<div>暂无数据,如有疑问请联系管理员</div>
<div>暂无数据</div>
) : (
<div>
{getMsgContent()}
Expand Down

0 comments on commit 91982a9

Please sign in to comment.