import { Alert, Button, Card, Checkbox, Dialog, FormContainer, FormItem, Input, Notification, Select, Table, Tabs, toast, } from '@/components/ui' import TBody from '@/components/ui/Table/TBody' import THead from '@/components/ui/Table/THead' import Td from '@/components/ui/Table/Td' import Th from '@/components/ui/Table/Th' import Tr from '@/components/ui/Table/Tr' import TabContent from '@/components/ui/Tabs/TabContent' import TabList from '@/components/ui/Tabs/TabList' import TabNav from '@/components/ui/Tabs/TabNav' import { getRoles, getUsers } from '@/services/identity.service' import { deleteChartJsonItem, getChartByCode, putChartJsonItem, putCharts, } from '@/services/chart.service' import { LanguageInfo } from '@/proxy/config/models' import { getDataSources } from '@/proxy/data-source' import { themeOptions, tooltipFormatListOptions } from '@/shared/options' import { SelectBoxOption } from '@/shared/types' import { useStoreState } from '@/store' import { useLocalization } from '@/utils/hooks/useLocalization' import setNull from '@/utils/setNull' import { Field, FieldArray, FieldProps, Form, Formik, FormikProps, getIn } from 'formik' import { useEffect, useState } from 'react' import { Helmet } from 'react-helmet' import { FaEdit, FaMinus, FaFileMedical, FaPlus, FaTrash } from 'react-icons/fa' import { Link, useParams } from 'react-router-dom' import { object, string } from 'yup' import { chartAnnotationTypeListOptions, chartArgumentAxisHoverModeListOptions, chartArgumentAxisIntervalListOptions, chartArgumentAxisLabelDisplayModeListOptions, chartArgumentAxisLabelOverlappingBehaviorListOptions, chartArgumentAxisPositionListOptions, chartArgumentAxisTypeListOptions, chartBreakStyleLineListOptions, chartEasingListOptions, chartLegendOrientationListOptions, chartLegendPositionListOptions, chartPaletteExtensionModeOptions, chartPaletteOptions, chartSeriesDashStyleOptions, chartSeriesSelectionModeOptions, chartSeriesTypeOptions, chartTitleHorizantalAlignmentListOptions, chartTitleTextOverFlowListOptions, chartTitleVerticalAlignmentListOptions, chartTitleWordWrapListOptions, chartTooltipLocationListOptions, chartWordWrapListOptions, chartZoomAndPanAxisOptions, chartZoomAndPanKeyOptions, } from './options' import { ChartDialogType, ChartOperation } from './types' import { IdentityRoleDto, IdentityUserDto } from '@/proxy/admin/models' import { MenuDto } from '@/proxy/menus/models' import { DataSourceTypeEnum } from '@/proxy/form/models' import { BreakDto, ChartAnnotationDto, ChartEditDto, ChartPanesDto, ChartSeriesDto, ChartValueAxisDto, } from '@/proxy/charts/models' import { Container } from '@/components/shared' const chartPanesValidationSchema = object().shape({ name: string().required(), }) const chartSeriesValidationSchema = object().shape({ name: string().required(), }) const chartAxisValidationSchema = object().shape({ name: string().required(), title: string().required(), }) const chartAnnotationsValidationSchema = object().shape({ name: string().required(), }) const fieldFeedback = (form: FormikProps, name: string) => { const error = getIn(form.errors, name) const touch = getIn(form.touched, name) return { errorMessage: error || '', invalid: typeof touch === 'undefined' ? false : error && touch, } } const chartValidationSchema = object().shape({ cultureName: string().required(), chartCode: string().required(), }) interface DatabaseOperation { isOpen: ChartDialogType id: string operation: ChartOperation index: number panesValues?: ChartPanesDto seriesValues?: ChartSeriesDto annotationsValues?: ChartAnnotationDto axisValues?: ChartValueAxisDto } const defaultDatabaseOperation: DatabaseOperation = { isOpen: '', id: '', operation: 'select', index: -1, } interface ConfirmDelete { isOpen: boolean id: string index: number fieldName: ChartDialogType } const defaultConfirmDelete: ConfirmDelete = { isOpen: false, id: '', index: -1, fieldName: 'pane', } function ChartEdit() { const { chartCode } = useParams() const { translate } = useLocalization() const [dataSourceList, setDataSourceList] = useState([]) const languages: LanguageInfo[] | undefined = useStoreState( (state) => state.abpConfig.config?.localization.languages, ) const permissions: Record | undefined = useStoreState( (state) => state.abpConfig.config?.auth.grantedPolicies, ) const [chartValues, setChartValues] = useState() const [langOptions, setLangOptions] = useState([]) const [roleList, setRoleList] = useState([]) const [userList, setUserList] = useState([]) const [permissionOptions, setPermissionOptions] = useState([]) const [confirmDelete, setConfirmDelete] = useState(defaultConfirmDelete) const [databaseOperationsModalData, setDatabaseOperationsModalData] = useState(defaultDatabaseOperation) const valueAxisList = () => { return chartValues?.valueAxisDto.map((key: ChartValueAxisDto) => ({ value: key.name, label: key.name, })) } const valuePaneList = () => { return chartValues?.panesDto.map((key: ChartPanesDto) => ({ value: key.name, label: key.name, })) } const SeriesList = () => { return chartValues?.seriesDto.map((key: ChartSeriesDto) => ({ value: key.name, label: key.name, })) } useEffect(() => { if (languages) { setLangOptions( languages.map((lang) => ({ value: lang.cultureName, label: lang.displayName, })), ) } }, [languages]) useEffect(() => { if (permissions) { setPermissionOptions( Object.keys(permissions).map((key) => { return { value: key, label: key, } }), ) } }, [permissions]) const getRoleList = async () => { const response = await getRoles() if (response.data?.items) { setRoleList( response.data.items.map((role: IdentityRoleDto) => ({ value: role.id, label: role.name, })), ) } } const getUserList = async () => { const response = await getUsers() if (response.data?.items) { setUserList( response.data.items.map((user: IdentityUserDto) => ({ value: user.id, label: user.name, })), ) } } const getChartValues = async () => { if (!chartCode) return const res = await getChartByCode(chartCode) setNull(res.data) setChartValues(res.data) } const getDataSourceList = async () => { const response = await getDataSources() if (response.data?.items) { setDataSourceList( response.data.items.map((a) => ({ value: a.code, label: a.code, })), ) } } useEffect(() => { getChartValues() getRoleList() getUserList() getDataSourceList() }, [chartCode]) return chartValues && roleList && userList && permissionOptions ? ( { setSubmitting(true) await putCharts({ ...values }) toast.push( {'Chart Bilgileri Kaydedildi.'} , { placement: 'top-end', }, ) setSubmitting(false) }} > {({ touched, errors, resetForm, isSubmitting, values }) => (

🔙 {chartCode}

{chartValues.isTenant && ( Bu bir MULTI TENANT form'dur, veri kaybı olmaması için, sorgularda TENANTID parametresini kullanmayı unutmayınız. )}
Details Database Common Permissions Series Axis Panes Animations Crosshair Export Legend Zoom & Pan Annotations {({ field, form }: FieldProps) => ( option.value === values.roleId)} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.dataSourceCode, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} General Adaptive Layout Settings Title Settings Tooltip Settings Margin Settings Size Settings ScrollBar Settings {({ field, form }: FieldProps) => ( option.value === values.commonDto.palette, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.titleDto.verticalAlignment, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.titleDto.textOverflow, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.tooltipDto.format, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.tooltipDto.border.dashStyle, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.permissionDto.c, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.permissionDto.u, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.commonSeriesSettingsDto.type, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.commonSeriesSettingsDto.axis, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.commonSeriesSettingsDto.dashStyle, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} Value Axis Argument Axis Options Common Axis Settings {chartValues.valueAxisDto.map((row, index) => ( ))}
Value Type Position Type Name Title Visible
{row.valueType} {row.position} {row.type} {row.name} {row.title} {row.visible}
{({ field, form }: FieldProps) => ( option.value === values.argumentAxisDto.argumentType, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.argumentAxisDto.aggregationInterval, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.argumentAxisDto.label.overlappingBehavior, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )}
{chartValues.panesDto.map((row, index) => ( ))}
Name Background Color Height
{row.name} {row.backgroundColor} {row.height}
{({ field, form }: FieldProps) => ( option.value === values.crosshairDto.dashStyle, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.crosshairDto.horizontalLine.dashStyle, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.legendDto.orientation, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.legendDto.border.dashStyle, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )}
{({ field, form }: FieldProps) => ( option.value === values.zoomAndPanDto.valueAxis, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.commonAnnotationSettingsDto.type, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.commonAnnotationSettingsDto.wordWrap, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.type, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.pane)} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.selectionMode, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.valueType, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.position, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} Grid Break Style Breaks
{({ field, form }: FieldProps) => ( option.value === values.type, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => ( option.value === values.wordWrap, )} onChange={(option) => form.setFieldValue(field.name, option?.value)} /> )} {({ field, form }: FieldProps) => (