Skip to content

Commit

Permalink
Merge pull request edp963#1753 from scottsut/fix_chart_error
Browse files Browse the repository at this point in the history
Fix chart errors
  • Loading branch information
AndyFong authored May 26, 2020
2 parents 63e37ea + 535a20f commit 58f1054
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 150 deletions.
4 changes: 4 additions & 0 deletions webapp/app/assets/less/variable.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
}
}
}
.ant-calendar-picker {
width: 100% !important;
min-width: auto !important;
}
}
&.small {
:global {
Expand Down
5 changes: 2 additions & 3 deletions webapp/app/components/Control/Control.less
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;

.itemList {
flex: 2;
Expand Down Expand Up @@ -180,9 +181,7 @@

.controlForm {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
overflow-y: auto;
.controlFormAntdOverride;

.optionList {
Expand Down
17 changes: 1 addition & 16 deletions webapp/app/components/Control/Control/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { DatePicker } from 'antd'
const { WeekPicker, MonthPicker } = DatePicker
const MultiDatePicker = React.lazy(() => import('components/MultiDatePicker'))
import { DatePickerFormats } from '../constants'
import styles from '../Panel/Layouts/Layouts.less'

interface IDateProps {
control: IControlBase
Expand All @@ -38,15 +37,6 @@ const Date: FC<IDateProps> = ({ control, value, size, onChange }, ref) => {
const { Week, Month, Year, Datetime, DatetimeMinute } = DatePickerFormats
const { multiple, dateFormat } = control

const datetimePickerChange = useCallback(
(val) => {
if (!val || (Array.isArray(val) && !val.length)) {
onChange(val)
}
},
[onChange]
)

const controlled = !!onChange
if (multiple) {
value = value || ''
Expand All @@ -66,7 +56,6 @@ const Date: FC<IDateProps> = ({ control, value, size, onChange }, ref) => {
return (
<WeekPicker
ref={ref}
className={styles.controlComponent}
placeholder="请选择"
size={size}
{...(controlled && { value, onChange })}
Expand All @@ -77,7 +66,6 @@ const Date: FC<IDateProps> = ({ control, value, size, onChange }, ref) => {
return (
<MonthPicker
ref={ref}
className={styles.controlComponent}
placeholder="请选择"
format={dateFormat}
size={size}
Expand All @@ -89,15 +77,12 @@ const Date: FC<IDateProps> = ({ control, value, size, onChange }, ref) => {
return (
<DatePicker
ref={ref}
className={styles.controlComponent}
placeholder="请选择"
showTime={isDatetimePicker}
format={dateFormat}
size={size}
{...(controlled && { value })}
{...(controlled && {
onChange: isDatetimePicker ? datetimePickerChange : onChange
})}
{...(controlled && { onChange })}
{...(controlled && { onOk: onChange })}
/>
)
Expand Down
13 changes: 1 addition & 12 deletions webapp/app/components/Control/Control/DateRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IControlBase } from '../types'
import { DatePicker } from 'antd'
const { RangePicker } = DatePicker
import { DatePickerFormats } from '../constants'
import styles from '../Panel/Layouts/Layouts.less'

interface IDateRangeProps {
control: IControlBase
Expand All @@ -38,24 +37,14 @@ const DateRange: FC<IDateRangeProps> = ({ control, value, size, onChange }) => {
const { Datetime, DatetimeMinute } = DatePickerFormats
const isDatetimePicker = [Datetime, DatetimeMinute].includes(dateFormat)

const datetimePickerChange = useCallback(
(val) => {
if (!val || (Array.isArray(val) && !val.length)) {
onChange(val)
}
},
[onChange]
)

return (
<RangePicker
className={styles.controlComponent}
placeholder={placeholder}
value={value}
size={size}
showTime={isDatetimePicker}
format={dateFormat}
onChange={isDatetimePicker ? datetimePickerChange : onChange}
onChange={onChange}
onOk={onChange}
/>
)
Expand Down
4 changes: 0 additions & 4 deletions webapp/app/components/Control/Panel/Layouts/Layouts.less
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,3 @@
.antFormItemLabelSmall;
.antFormItemStyleWithoutForm;
}

.controlComponent {
width: 100% !important;
}
3 changes: 3 additions & 0 deletions webapp/app/components/SplitPane/SplitPane.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@

&-1 {
display: flex;
min-height: 0;

& > .react-resizable {
display: flex;
min-height: 0;
}
}

&-2 {
flex: 1;
display: flex;
min-height: 0;
overflow: hidden;

& > .react-resizable {
Expand Down
7 changes: 6 additions & 1 deletion webapp/app/containers/Dashboard/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const {
renderDashboardItem,
resizeDashboardItem,
resizeAllDashboardItem,
renderChartError,
openSharePanel,
drillDashboardItem,
deleteDrillHistory,
Expand Down Expand Up @@ -393,9 +394,9 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
const waitingItems = currentItems.filter((item) => !currentItemsInfo[item.id].rendered)

if (waitingItems.length) {
const { offsetHeight, scrollTop } = this.containerBody
waitingItems.forEach((item) => {
const itemTop = this.calcItemTop(item.y)
const { offsetHeight, scrollTop } = this.containerBody

if (itemTop - scrollTop < offsetHeight) {
onRenderDashboardItem(item.id)
Expand Down Expand Up @@ -865,6 +866,7 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
onLoadDashboardItemData,
onLoadBatchDataWithControlValues,
onResizeDashboardItem,
onRenderChartError,
onSetFullScreenPanelItemId,
onMonitoredSyncDataAction,
onMonitoredSearchDataAction
Expand Down Expand Up @@ -975,6 +977,7 @@ export class Grid extends React.Component<IGridProps & RouteComponentWithParams,
onShowDrillEdit={this.showDrillDashboardItemForm}
onDeleteDashboardItem={this.deleteItem}
onResizeDashboardItem={onResizeDashboardItem}
onRenderChartError={onRenderChartError}
onOpenSharePanel={onOpenSharePanel}
onDownloadCsv={this.initiateWidgetDownloadTask}
onTurnOffInteract={this.turnOffInteract}
Expand Down Expand Up @@ -1250,6 +1253,8 @@ export function mapDispatchToProps (dispatch) {
onRenderDashboardItem: (itemId: number) => dispatch(renderDashboardItem(itemId)),
onResizeDashboardItem: (itemId: number) => dispatch(resizeDashboardItem(itemId)),
onResizeAllDashboardItem: () => dispatch(resizeAllDashboardItem()),
onRenderChartError: (itemId: number, error: Error) =>
dispatch(renderChartError(itemId, error)),
onOpenSharePanel: (
id: number,
type: SharePanelType,
Expand Down
Loading

0 comments on commit 58f1054

Please sign in to comment.