Add options to sort and resize graphs in dash. widget

This commit is contained in:
MauriceNino
2023-02-10 18:20:28 +01:00
parent bb010ff54a
commit a05e80bf26
11 changed files with 436 additions and 220 deletions

View File

@@ -53,7 +53,7 @@
"dockerode": "^3.3.2", "dockerode": "^3.3.2",
"embla-carousel-react": "^7.0.0", "embla-carousel-react": "^7.0.0",
"fily-publish-gridstack": "^0.0.13", "fily-publish-gridstack": "^0.0.13",
"framer-motion": "^6.5.1", "framer-motion": "^9.0.2",
"i18next": "^21.9.1", "i18next": "^21.9.1",
"i18next-browser-languagedetector": "^6.1.5", "i18next-browser-languagedetector": "^6.1.5",
"i18next-http-backend": "^1.4.1", "i18next-http-backend": "^1.4.1",

View File

@@ -0,0 +1,119 @@
import { Collapse, createStyles, Stack, Text } from '@mantine/core';
import { IconChevronDown, IconGripVertical } from '@tabler/icons';
import { Reorder, useDragControls } from 'framer-motion';
import { FC, ReactNode, useState } from 'react';
import { IDraggableListInputValue } from '../../../../widgets/widgets';
const useStyles = createStyles((theme) => ({
container: {
display: 'flex',
flexDirection: 'column',
borderRadius: theme.radius.md,
border: `1px solid ${
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[2]
}`,
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.white,
marginBottom: theme.spacing.xs,
gap: theme.spacing.xs,
},
row: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '12px 16px',
gap: theme.spacing.sm,
},
middle: {
flexGrow: 1,
},
symbol: {
fontSize: 16,
},
clickableIcons: {
color: theme.colorScheme === 'dark' ? theme.colors.dark[1] : theme.colors.gray[6],
cursor: 'pointer',
userSelect: 'none',
transition: 'transform .3s ease-in-out',
},
rotate: {
transform: 'rotate(180deg)',
},
collapseContent: {
padding: '12px 16px',
},
}));
type DraggableListParams = {
value: IDraggableListInputValue['defaultValue'];
onChange: (value: IDraggableListInputValue['defaultValue']) => void;
labels: Record<string, string>;
children?: Record<string, ReactNode>;
};
export const DraggableList: FC<DraggableListParams> = (props) => {
const keys = props.value.map((v) => v.key);
return (
<div>
<Reorder.Group
axis="y"
values={keys}
onReorder={(order) =>
props.onChange(order.map((key) => props.value.find((v) => v.key === key)!))
}
as="div"
>
{props.value.map((item) => (
<ListItem key={item.key} item={item} label={props.labels[item.key]}>
{props.children?.[item.key]}
</ListItem>
))}
</Reorder.Group>
</div>
);
};
const ListItem: FC<{
item: IDraggableListInputValue['defaultValue'][number];
label: string;
}> = (props) => {
const { classes, cx } = useStyles();
const controls = useDragControls();
const [showContent, setShowContent] = useState(false);
const hasContent = props.children != null && Object.keys(props.children).length !== 0;
return (
<Reorder.Item value={props.item.key} dragListener={false} dragControls={controls} as="div">
<div className={classes.container}>
<div className={classes.row}>
<IconGripVertical
className={classes.clickableIcons}
onPointerDown={(e) => controls.start(e)}
size={18}
stroke={1.5}
/>
<div className={classes.middle}>
<Text className={classes.symbol}>{props.label}</Text>
</div>
{hasContent && (
<IconChevronDown
className={cx(classes.clickableIcons, { [classes.rotate]: showContent })}
onClick={() => setShowContent(!showContent)}
size={18}
stroke={1.5}
/>
)}
</div>
{hasContent && (
<Collapse in={showContent}>
<Stack className={classes.collapseContent}>{props.children}</Stack>
</Collapse>
)}
</div>
</Reorder.Item>
);
};

View File

@@ -3,24 +3,25 @@ import {
Button, Button,
Group, Group,
MultiSelect, MultiSelect,
NumberInput,
Select,
Slider,
Stack, Stack,
Switch, Switch,
TextInput,
Text, Text,
NumberInput, TextInput,
Slider,
Select,
} from '@mantine/core'; } from '@mantine/core';
import { ContextModalProps } from '@mantine/modals'; import { ContextModalProps } from '@mantine/modals';
import { IconAlertTriangle } from '@tabler/icons'; import { IconAlertTriangle } from '@tabler/icons';
import { Trans, useTranslation } from 'next-i18next'; import { Trans, useTranslation } from 'next-i18next';
import { useState } from 'react'; import { FC, useState } from 'react';
import Widgets from '../../../../widgets';
import type { IWidgetOptionValue } from '../../../../widgets/widgets';
import { useConfigContext } from '../../../../config/provider'; import { useConfigContext } from '../../../../config/provider';
import { useConfigStore } from '../../../../config/store'; import { useConfigStore } from '../../../../config/store';
import { IWidget } from '../../../../widgets/widgets';
import { useColorTheme } from '../../../../tools/color'; import { useColorTheme } from '../../../../tools/color';
import Widgets from '../../../../widgets';
import type { IDraggableListInputValue, IWidgetOptionValue } from '../../../../widgets/widgets';
import { IWidget } from '../../../../widgets/widgets';
import { DraggableList } from './DraggableList';
export type WidgetEditModalInnerProps = { export type WidgetEditModalInnerProps = {
widgetId: string; widgetId: string;
@@ -93,7 +94,17 @@ export const WidgetsEditModal = ({
</Alert> </Alert>
); );
} }
return WidgetOptionTypeSwitch(option, index, t, key, value, handleChange);
return (
<WidgetOptionTypeSwitch
key={`${key}.${index}`}
option={option}
widgetId={innerProps.widgetId}
propName={key}
value={value}
handleChange={handleChange}
/>
);
})} })}
<Group position="right"> <Group position="right">
<Button onClick={() => context.closeModal(id)} variant="light"> <Button onClick={() => context.closeModal(id)} variant="light">
@@ -108,20 +119,20 @@ export const WidgetsEditModal = ({
// Widget switch // Widget switch
// Widget options are computed based on their type. // Widget options are computed based on their type.
// here you can define new types for options (along with editing the widgets.d.ts file) // here you can define new types for options (along with editing the widgets.d.ts file)
function WidgetOptionTypeSwitch( const WidgetOptionTypeSwitch: FC<{
option: IWidgetOptionValue, option: IWidgetOptionValue;
index: number, widgetId: string;
t: any, propName: string;
key: string, value: any;
value: string | number | boolean | string[], handleChange: (key: string, value: IntegrationOptionsValueType) => void;
handleChange: (key: string, value: IntegrationOptionsValueType) => void }> = ({ option, widgetId, propName: key, value, handleChange }) => {
) { const { t } = useTranslation([`modules/${widgetId}`, 'common']);
const { primaryColor, secondaryColor } = useColorTheme(); const { primaryColor } = useColorTheme();
switch (option.type) { switch (option.type) {
case 'switch': case 'switch':
return ( return (
<Switch <Switch
key={`${option.type}-${index}`}
label={t(`descriptor.settings.${key}.label`)} label={t(`descriptor.settings.${key}.label`)}
checked={value as boolean} checked={value as boolean}
onChange={(ev) => handleChange(key, ev.currentTarget.checked)} onChange={(ev) => handleChange(key, ev.currentTarget.checked)}
@@ -131,7 +142,6 @@ function WidgetOptionTypeSwitch(
return ( return (
<TextInput <TextInput
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`}
label={t(`descriptor.settings.${key}.label`)} label={t(`descriptor.settings.${key}.label`)}
value={value as string} value={value as string}
onChange={(ev) => handleChange(key, ev.currentTarget.value)} onChange={(ev) => handleChange(key, ev.currentTarget.value)}
@@ -141,7 +151,6 @@ function WidgetOptionTypeSwitch(
return ( return (
<MultiSelect <MultiSelect
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`}
data={option.data} data={option.data}
label={t(`descriptor.settings.${key}.label`)} label={t(`descriptor.settings.${key}.label`)}
value={value as string[]} value={value as string[]}
@@ -153,7 +162,6 @@ function WidgetOptionTypeSwitch(
return ( return (
<Select <Select
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`}
defaultValue={option.defaultValue} defaultValue={option.defaultValue}
data={option.data} data={option.data}
label={t(`descriptor.settings.${key}.label`)} label={t(`descriptor.settings.${key}.label`)}
@@ -165,7 +173,6 @@ function WidgetOptionTypeSwitch(
return ( return (
<NumberInput <NumberInput
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`}
label={t(`descriptor.settings.${key}.label`)} label={t(`descriptor.settings.${key}.label`)}
value={value as number} value={value as number}
onChange={(v) => handleChange(key, v!)} onChange={(v) => handleChange(key, v!)}
@@ -176,7 +183,6 @@ function WidgetOptionTypeSwitch(
<Stack spacing="xs"> <Stack spacing="xs">
<Slider <Slider
color={primaryColor} color={primaryColor}
key={`${option.type}-${index}`}
label={value} label={value}
value={value as number} value={value as number}
min={option.min} min={option.min}
@@ -186,7 +192,57 @@ function WidgetOptionTypeSwitch(
/> />
</Stack> </Stack>
); );
case 'draggable-list':
// eslint-disable-next-line no-case-declarations
const typedVal = value as IDraggableListInputValue['defaultValue'];
return (
<Stack spacing="xs">
<Text>{t(`descriptor.settings.${key}.label`)}</Text>
<DraggableList
value={typedVal}
onChange={(v) => handleChange(key, v)}
labels={Object.fromEntries(
Object.entries(option.items).map(([graphName]) => [
graphName,
t(`descriptor.settings.${graphName}.label`),
])
)}
>
{Object.fromEntries(
Object.entries(option.items).map(([graphName, graph]) => [
graphName,
Object.entries(graph).map(([subKey, setting], i) => (
<WidgetOptionTypeSwitch
key={`${graphName}.${subKey}.${i}`}
option={setting as IWidgetOptionValue}
widgetId={widgetId}
propName={`${graphName}.${subKey}`}
value={typedVal.find((v) => v.key === graphName)?.subValues?.[subKey]}
handleChange={(_, newVal) =>
handleChange(
key,
typedVal.map((oldVal) =>
oldVal.key === graphName
? {
...oldVal,
subValues: {
...oldVal.subValues,
[subKey]: newVal,
},
}
: oldVal
)
)
}
/>
)),
])
)}
</DraggableList>
</Stack>
);
default: default:
return null; return null;
} }
} };

View File

@@ -83,6 +83,7 @@ export const WidgetsMenu = ({ integration, widget }: WidgetsMenuProps) => {
inner: { inner: {
position: 'sticky', position: 'sticky',
top: 30, top: 30,
maxHeight: '100%',
}, },
}, },
}); });

View File

@@ -228,33 +228,37 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
...previous.apps.filter((x) => !isAppAffectedFilter(x)), ...previous.apps.filter((x) => !isAppAffectedFilter(x)),
...previous.apps ...previous.apps
.filter((x) => isAppAffectedFilter(x)) .filter((x) => isAppAffectedFilter(x))
.map((app): AppType => ({ .map(
...app, (app): AppType => ({
area: { ...app,
...app.area, area: {
type: 'wrapper', ...app.area,
properties: { type: 'wrapper',
...app.area.properties, properties: {
id: mainWrapperId, ...app.area.properties,
id: mainWrapperId,
},
}, },
}, })
})), ),
], ],
widgets: [ widgets: [
...previous.widgets.filter((widget) => !isWidgetAffectedFilter(widget)), ...previous.widgets.filter((widget) => !isWidgetAffectedFilter(widget)),
...previous.widgets ...previous.widgets
.filter((widget) => isWidgetAffectedFilter(widget)) .filter((widget) => isWidgetAffectedFilter(widget))
.map((widget): IWidget<string, any> => ({ .map(
...widget, (widget): IWidget<string, any> => ({
area: { ...widget,
...widget.area, area: {
type: 'wrapper', ...widget.area,
properties: { type: 'wrapper',
...widget.area.properties, properties: {
id: mainWrapperId, ...widget.area.properties,
id: mainWrapperId,
},
}, },
}, })
})), ),
], ],
categories: previous.categories.filter((x) => x.id !== category.id), categories: previous.categories.filter((x) => x.id !== category.id),
wrappers: previous.wrappers.filter((x) => x.position !== currentItem.position), wrappers: previous.wrappers.filter((x) => x.position !== currentItem.position),

View File

@@ -24,7 +24,7 @@ export const DashDotCompactNetwork = ({ info }: DashDotCompactNetworkProps) => {
const downSpeed = bytes.toPerSecondString(info?.network?.speedDown); const downSpeed = bytes.toPerSecondString(info?.network?.speedDown);
return ( return (
<Group noWrap align="start" position="apart" w="100%" maw="251px"> <Group noWrap align="start" position="apart" w="100%">
<Text weight={500}>{t('card.graphs.network.label')}</Text> <Text weight={500}>{t('card.graphs.network.label')}</Text>
<Stack align="end" spacing={0}> <Stack align="end" spacing={0}>
<Group spacing={0}> <Group spacing={0}>

View File

@@ -25,7 +25,7 @@ export const DashDotCompactStorage = ({ info }: DashDotCompactStorageProps) => {
}); });
return ( return (
<Group noWrap align="start" position="apart" w="100%" maw="251px"> <Group noWrap align="start" position="apart" w="100%">
<Text weight={500}>{t('card.graphs.storage.label')}</Text> <Text weight={500}>{t('card.graphs.storage.label')}</Text>
<Stack align="end" spacing={0}> <Stack align="end" spacing={0}>
<Text color="dimmed" size="xs"> <Text color="dimmed" size="xs">

View File

@@ -1,63 +1,71 @@
import { createStyles, Stack, Title, useMantineTheme } from '@mantine/core'; import { createStyles, Title, useMantineTheme } from '@mantine/core';
import { DashDotGraph as GraphType } from './types'; import { DashDotCompactNetwork, DashDotInfo } from './DashDotCompactNetwork';
import { DashDotCompactStorage } from './DashDotCompactStorage';
interface DashDotGraphProps { interface DashDotGraphProps {
graph: GraphType; graph: string;
graphHeight: number;
isCompact: boolean; isCompact: boolean;
multiView: boolean;
dashDotUrl: string; dashDotUrl: string;
usePercentages: boolean; usePercentages: boolean;
info: DashDotInfo;
} }
export const DashDotGraph = ({ export const DashDotGraph = ({
graph, graph,
graphHeight,
isCompact, isCompact,
multiView,
dashDotUrl, dashDotUrl,
usePercentages, usePercentages,
info,
}: DashDotGraphProps) => { }: DashDotGraphProps) => {
const { classes } = useStyles(); const { classes } = useStyles();
return (
<Stack return graph === 'storage' && isCompact ? (
className={classes.graphStack} <DashDotCompactStorage info={info} />
w="100%" ) : graph === 'network' && isCompact ? (
maw="251px" <DashDotCompactNetwork info={info} />
style={{ ) : (
width: isCompact ? (graph.twoSpan ? '100%' : 'calc(50% - 10px)') : undefined, <div className={classes.graphContainer}>
}}
>
<Title className={classes.graphTitle} order={4}> <Title className={classes.graphTitle} order={4}>
{graph.name} {graph}
</Title> </Title>
<iframe <iframe
className={classes.iframe} className={classes.iframe}
key={graph.name} key={graph}
title={graph.name} title={graph}
src={useIframeSrc(dashDotUrl, graph, isCompact, usePercentages)} src={useIframeSrc(dashDotUrl, graph, multiView, usePercentages)}
style={{
height: `${graphHeight}px`,
}}
/> />
</Stack> </div>
); );
}; };
const useIframeSrc = ( const useIframeSrc = (
dashDotUrl: string, dashDotUrl: string,
graph: GraphType, graph: string,
isCompact: boolean, multiView: boolean,
usePercentages: boolean usePercentages: boolean
) => { ) => {
const { colorScheme, colors, radius } = useMantineTheme(); const { colorScheme, colors, radius } = useMantineTheme();
const surface = (colorScheme === 'dark' ? colors.dark[7] : colors.gray[0]).substring(1); // removes # from hex value const surface = (colorScheme === 'dark' ? colors.dark[7] : colors.gray[0]).substring(1); // removes # from hex value
const graphId = graph.id === 'memory' ? 'ram' : graph.id;
return ( return (
`${dashDotUrl}` + `${dashDotUrl}` +
'?singleGraphMode=true' + '?singleGraphMode=true' + // obsolete in newer versions
`&graph=${graphId}` + `&graph=${graph}` +
`&theme=${colorScheme}` + `&theme=${colorScheme}` +
`&surface=${surface}` + `&surface=${surface}` +
`&gap=${isCompact ? 10 : 5}` + '&gap=5' +
`&innerRadius=${radius.lg}` + `&innerRadius=${radius.lg}` +
`&multiView=${graph.isMultiView}` + `&multiView=${multiView}` +
`&showPercentage=${usePercentages ? 'true' : 'false'}` `&showPercentage=${usePercentages.toString()}` +
'&textOffset=16' +
'&textSize=12'
); );
}; };
@@ -65,7 +73,7 @@ export const useStyles = createStyles((theme, _params, getRef) => ({
iframe: { iframe: {
flex: '1 0 auto', flex: '1 0 auto',
maxWidth: '100%', maxWidth: '100%',
height: '140px', width: '100%',
borderRadius: theme.radius.lg, borderRadius: theme.radius.lg,
border: 'none', border: 'none',
colorScheme: 'light', // fixes white borders around iframe colorScheme: 'light', // fixes white borders around iframe
@@ -74,13 +82,14 @@ export const useStyles = createStyles((theme, _params, getRef) => ({
ref: getRef('graphTitle'), ref: getRef('graphTitle'),
position: 'absolute', position: 'absolute',
right: 0, right: 0,
bottom: 0,
opacity: 0, opacity: 0,
transition: 'opacity .1s ease-in-out', transition: 'opacity .1s ease-in-out',
pointerEvents: 'none', pointerEvents: 'none',
marginTop: 10, marginBottom: 12,
marginRight: 25, marginRight: 12,
}, },
graphStack: { graphContainer: {
position: 'relative', position: 'relative',
[`&:hover .${getRef('graphTitle')}`]: { [`&:hover .${getRef('graphTitle')}`]: {
opacity: 0.5, opacity: 0.5,

View File

@@ -1,4 +1,4 @@
import { Center, createStyles, Group, Stack, Text, Title } from '@mantine/core'; import { Center, createStyles, Grid, Stack, Text, Title } from '@mantine/core';
import { IconUnlink } from '@tabler/icons'; import { IconUnlink } from '@tabler/icons';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import axios from 'axios'; import axios from 'axios';
@@ -6,45 +6,126 @@ import { useTranslation } from 'next-i18next';
import { useConfigContext } from '../../config/provider'; import { useConfigContext } from '../../config/provider';
import { defineWidget } from '../helper'; import { defineWidget } from '../helper';
import { IWidget } from '../widgets'; import { IWidget } from '../widgets';
import { DashDotCompactNetwork, DashDotInfo } from './DashDotCompactNetwork'; import { DashDotInfo } from './DashDotCompactNetwork';
import { DashDotCompactStorage } from './DashDotCompactStorage';
import { DashDotGraph } from './DashDotGraph'; import { DashDotGraph } from './DashDotGraph';
const definition = defineWidget({ const definition = defineWidget({
id: 'dashdot', id: 'dashdot',
icon: 'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/dashdot.png', icon: 'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/dashdot.png',
options: { options: {
cpuMultiView: { url: {
type: 'switch', type: 'text',
defaultValue: false, defaultValue: '',
},
storageMultiView: {
type: 'switch',
defaultValue: false,
},
useCompactView: {
type: 'switch',
defaultValue: true,
}, },
usePercentages: { usePercentages: {
type: 'switch', type: 'switch',
defaultValue: false, defaultValue: false,
}, },
graphs: { columns: {
type: 'multi-select', type: 'number',
defaultValue: ['cpu', 'memory'], defaultValue: 2,
data: [
// ['cpu', 'memory', 'storage', 'network', 'gpu'], into { label, value }
{ label: 'CPU', value: 'cpu' },
{ label: 'Memory', value: 'memory' },
{ label: 'Storage', value: 'storage' },
{ label: 'Network', value: 'network' },
{ label: 'GPU', value: 'gpu' },
],
}, },
url: { graphHeight: {
type: 'text', type: 'number',
defaultValue: '', defaultValue: 115,
},
graphsOrder: {
type: 'draggable-list',
defaultValue: [
{
key: 'storage',
subValues: {
enabled: true,
compactView: true,
span: 2,
multiView: false,
},
},
{
key: 'network',
subValues: {
enabled: true,
compactView: true,
span: 2,
},
},
{
key: 'cpu',
subValues: {
enabled: true,
multiView: false,
span: 1,
},
},
{
key: 'ram',
subValues: {
enabled: true,
span: 1,
},
},
{
key: 'gpu',
subValues: {
enabled: false,
span: 1,
},
},
],
items: {
cpu: {
enabled: {
type: 'switch',
},
span: {
type: 'number',
},
multiView: {
type: 'switch',
},
},
storage: {
enabled: {
type: 'switch',
},
span: {
type: 'number',
},
compactView: {
type: 'switch',
},
multiView: {
type: 'switch',
},
},
ram: {
enabled: {
type: 'switch',
},
span: {
type: 'number',
},
},
network: {
enabled: {
type: 'switch',
},
span: {
type: 'number',
},
compactView: {
type: 'switch',
},
},
gpu: {
enabled: {
type: 'switch',
},
span: {
type: 'number',
},
},
},
}, },
}, },
gridstack: { gridstack: {
@@ -83,60 +164,41 @@ function DashDotTile({ widget }: DashDotTileProps) {
<IconUnlink size={40} strokeWidth={1.2} /> <IconUnlink size={40} strokeWidth={1.2} />
<Title order={5}>{t('card.errors.protocolDowngrade.title')}</Title> <Title order={5}>{t('card.errors.protocolDowngrade.title')}</Title>
<Text align="center" size="sm"> <Text align="center" size="sm">
{t('card.errors.protocolDowngrade.text')} {t('card.errors.protocolDowngrade.text')}
</Text> </Text>
</Stack> </Stack>
</Center> </Center>
); );
} }
const graphs = widget?.properties.graphs.map((graph) => ({ const { graphsOrder, usePercentages, columns, graphHeight } = widget.properties;
id: graph,
name: t(`card.graphs.${graph}.title`),
twoSpan: ['network', 'gpu'].includes(graph),
isMultiView:
(graph === 'cpu' && widget.properties.cpuMultiView) ||
(graph === 'storage' && widget.properties.storageMultiView),
}));
const isCompact = widget?.properties.useCompactView ?? false;
const isCompactStorageVisible = graphs?.some((g) => g.id === 'storage' && isCompact);
const isCompactNetworkVisible = graphs?.some((g) => g.id === 'network' && isCompact);
const usePercentages = widget?.properties.usePercentages ?? false;
const displayedGraphs = graphs?.filter(
(g) => !isCompact || !['network', 'storage'].includes(g.id)
);
return ( return (
<> <Stack spacing="xs">
<Title order={3} mb="xs"> <Title order={3}>{t('card.title')}</Title>
{t('card.title')}
</Title>
{!info && <p>{t('card.errors.noInformation')}</p>} {!info && <p>{t('card.errors.noInformation')}</p>}
{info && ( {info && (
<div className={classes.graphsContainer}> <div className={classes.graphsContainer}>
<Group position="apart" w="100%"> <Grid grow gutter="sm" w="100%" columns={columns}>
{isCompactStorageVisible && <DashDotCompactStorage info={info} />} {graphsOrder
{isCompactNetworkVisible && <DashDotCompactNetwork info={info} />} .filter((g) => g.subValues.enabled)
</Group> .map((g) => (
<Group position="center" w="100%" className={classes.graphsWrapper}> <Grid.Col span={Math.min(columns, g.subValues.span)}>
{displayedGraphs?.map((graph) => ( <DashDotGraph
<DashDotGraph dashDotUrl={dashDotUrl}
key={graph.id} info={info}
graph={graph} graph={g.key as any}
dashDotUrl={dashDotUrl} graphHeight={graphHeight}
isCompact={isCompact} isCompact={g.subValues.compactView ?? false}
usePercentages={usePercentages} multiView={g.subValues.multiView ?? false}
/> usePercentages={usePercentages}
))} />
</Group> </Grid.Col>
))}
</Grid>
</div> </div>
)} )}
</> </Stack>
); );
} }
@@ -171,12 +233,6 @@ export const useDashDotTileStyles = createStyles(() => ({
rowGap: 10, rowGap: 10,
columnGap: 10, columnGap: 10,
}, },
graphsWrapper: {
'& > *:nth-child(odd):last-child': {
width: '100% !important',
maxWidth: '100% !important',
},
},
})); }));
export default definition; export default definition;

View File

@@ -3,7 +3,7 @@ import React from 'react';
import { AreaType } from '../types/area'; import { AreaType } from '../types/area';
import { ShapeType } from '../types/shape'; import { ShapeType } from '../types/shape';
// Type of widgets which are safed to config // Type of widgets which are saved to config
export type IWidget<TKey extends string, TDefinition extends IWidgetDefinition> = { export type IWidget<TKey extends string, TDefinition extends IWidgetDefinition> = {
id: TKey; id: TKey;
properties: { properties: {
@@ -18,15 +18,7 @@ export type IWidget<TKey extends string, TDefinition extends IWidgetDefinition>
// Makes the type less specific // Makes the type less specific
// For example when the type true is used as input the result is boolean // For example when the type true is used as input the result is boolean
// By not using this type the definition would always be { property: true } // By not using this type the definition would always be { property: true }
type MakeLessSpecific<TInput extends IWidgetOptionValue['defaultValue']> = TInput extends boolean type MakeLessSpecific<T> = T extends boolean ? boolean : T;
? boolean
: TInput extends number
? number
: TInput extends string[]
? string[]
: TInput extends string
? string
: never;
// Types of options that can be specified for the widget edit modal // Types of options that can be specified for the widget edit modal
export type IWidgetOptionValue = export type IWidgetOptionValue =
@@ -35,7 +27,8 @@ export type IWidgetOptionValue =
| ITextInputOptionValue | ITextInputOptionValue
| ISliderInputOptionValue | ISliderInputOptionValue
| ISelectOptionValue | ISelectOptionValue
| INumberInputOptionValue; | INumberInputOptionValue
| IDraggableListInputValue;
// Interface for data type // Interface for data type
interface DataType { interface DataType {
@@ -84,6 +77,18 @@ export type ISliderInputOptionValue = {
step: number; step: number;
}; };
export type IDraggableListInputValue = {
type: 'draggable-list';
defaultValue: {
key: string;
subValues?: Record<string, any>;
}[];
items: Record<
string,
Record<string, Omit<Exclude<IWidgetOptionValue, IDraggableListInputValue>, 'defaultValue'>>
>;
};
// is used to type the widget definitions which will be used to display all widgets // is used to type the widget definitions which will be used to display all widgets
export type IWidgetDefinition<TKey extends string = string> = { export type IWidgetDefinition<TKey extends string = string> = {
id: TKey; id: TKey;

View File

@@ -1274,7 +1274,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@motionone/animation@npm:^10.12.0": "@motionone/animation@npm:^10.15.1":
version: 10.15.1 version: 10.15.1
resolution: "@motionone/animation@npm:10.15.1" resolution: "@motionone/animation@npm:10.15.1"
dependencies: dependencies:
@@ -1286,17 +1286,17 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@motionone/dom@npm:10.12.0": "@motionone/dom@npm:^10.15.3":
version: 10.12.0 version: 10.15.5
resolution: "@motionone/dom@npm:10.12.0" resolution: "@motionone/dom@npm:10.15.5"
dependencies: dependencies:
"@motionone/animation": ^10.12.0 "@motionone/animation": ^10.15.1
"@motionone/generators": ^10.12.0 "@motionone/generators": ^10.15.1
"@motionone/types": ^10.12.0 "@motionone/types": ^10.15.1
"@motionone/utils": ^10.12.0 "@motionone/utils": ^10.15.1
hey-listen: ^1.0.8 hey-listen: ^1.0.8
tslib: ^2.3.1 tslib: ^2.3.1
checksum: 123356f28e44362c4f081aae3df22e576f46bfcb07e01257b2ac64a115668448f29b8de67e4b6e692c5407cffb78ffe7cf9fa1bc064007482bab5dd23a69d380 checksum: 2453fe3df6a2b4b339d075bcd598bda1eee1926ba0ad881edfd154362b0992c91f31c08d83c469c7e8cb8bf8ebc0ed5530972673cf5c74d99e46e3772cf5f1cb
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1310,7 +1310,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@motionone/generators@npm:^10.12.0": "@motionone/generators@npm:^10.15.1":
version: 10.15.1 version: 10.15.1
resolution: "@motionone/generators@npm:10.15.1" resolution: "@motionone/generators@npm:10.15.1"
dependencies: dependencies:
@@ -1321,14 +1321,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@motionone/types@npm:^10.12.0, @motionone/types@npm:^10.15.1": "@motionone/types@npm:^10.15.1":
version: 10.15.1 version: 10.15.1
resolution: "@motionone/types@npm:10.15.1" resolution: "@motionone/types@npm:10.15.1"
checksum: 98091f7dca257508d94d1080678c433da39a814e8e58aaa742212bf6c2a5b5e2120a6251a06e3ea522219ce6d1b6eb6aa2cab224b803fe52789033d8398ef0aa checksum: 98091f7dca257508d94d1080678c433da39a814e8e58aaa742212bf6c2a5b5e2120a6251a06e3ea522219ce6d1b6eb6aa2cab224b803fe52789033d8398ef0aa
languageName: node languageName: node
linkType: hard linkType: hard
"@motionone/utils@npm:^10.12.0, @motionone/utils@npm:^10.15.1": "@motionone/utils@npm:^10.15.1":
version: 10.15.1 version: 10.15.1
resolution: "@motionone/utils@npm:10.15.1" resolution: "@motionone/utils@npm:10.15.1"
dependencies: dependencies:
@@ -4786,33 +4786,21 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"framer-motion@npm:^6.5.1": "framer-motion@npm:^9.0.2":
version: 6.5.1 version: 9.0.2
resolution: "framer-motion@npm:6.5.1" resolution: "framer-motion@npm:9.0.2"
dependencies: dependencies:
"@emotion/is-prop-valid": ^0.8.2 "@emotion/is-prop-valid": ^0.8.2
"@motionone/dom": 10.12.0 "@motionone/dom": ^10.15.3
framesync: 6.0.1
hey-listen: ^1.0.8 hey-listen: ^1.0.8
popmotion: 11.0.3 tslib: ^2.4.0
style-value-types: 5.0.0
tslib: ^2.1.0
peerDependencies: peerDependencies:
react: ">=16.8 || ^17.0.0 || ^18.0.0" react: ^18.0.0
react-dom: ">=16.8 || ^17.0.0 || ^18.0.0" react-dom: ^18.0.0
dependenciesMeta: dependenciesMeta:
"@emotion/is-prop-valid": "@emotion/is-prop-valid":
optional: true optional: true
checksum: 737959063137b4ccafe01e0ac0c9e5a9531bf3f729f62c34ca7a5d7955e6664f70affd22b044f7db51df41acb21d120a4f71a860e17a80c4db766ad66f2153a1 checksum: 5694d3a49acb9f753f0eed4a946c2b33efc237e0863b882cc4bed9a6022447ce2c9024134b5e9fd7b6f73602d9af046fa633c0f7235e8cbb24702b403299b55e
languageName: node
linkType: hard
"framesync@npm:6.0.1":
version: 6.0.1
resolution: "framesync@npm:6.0.1"
dependencies:
tslib: ^2.1.0
checksum: a23ebe8f7e20a32c0b99c2f8175b6f07af3ec6316aad52a2316316a6d011d717af8d2175dcc2827031c59fabb30232ed3e19a720a373caba7f070e1eae436325
languageName: node languageName: node
linkType: hard linkType: hard
@@ -5397,7 +5385,7 @@ __metadata:
eslint-plugin-testing-library: ^5.5.1 eslint-plugin-testing-library: ^5.5.1
eslint-plugin-unused-imports: ^2.0.0 eslint-plugin-unused-imports: ^2.0.0
fily-publish-gridstack: ^0.0.13 fily-publish-gridstack: ^0.0.13
framer-motion: ^6.5.1 framer-motion: ^9.0.2
i18next: ^21.9.1 i18next: ^21.9.1
i18next-browser-languagedetector: ^6.1.5 i18next-browser-languagedetector: ^6.1.5
i18next-http-backend: ^1.4.1 i18next-http-backend: ^1.4.1
@@ -7684,18 +7672,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"popmotion@npm:11.0.3":
version: 11.0.3
resolution: "popmotion@npm:11.0.3"
dependencies:
framesync: 6.0.1
hey-listen: ^1.0.8
style-value-types: 5.0.0
tslib: ^2.1.0
checksum: 9fe7d03b4ec0e85bfb9dadc23b745147bfe42e16f466ba06e6327197d0e38b72015afc2f918a8051dedc3680310417f346ffdc463be6518e2e92e98f48e30268
languageName: node
linkType: hard
"postcss@npm:8.4.14": "postcss@npm:8.4.14":
version: 8.4.14 version: 8.4.14
resolution: "postcss@npm:8.4.14" resolution: "postcss@npm:8.4.14"
@@ -8799,16 +8775,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"style-value-types@npm:5.0.0":
version: 5.0.0
resolution: "style-value-types@npm:5.0.0"
dependencies:
hey-listen: ^1.0.8
tslib: ^2.1.0
checksum: 16d198302cd102edf9dba94e7752a2364c93b1eaa5cc7c32b42b28eef4af4ccb5149a3f16bc2a256adc02616a2404f4612bd15f3081c1e8ca06132cae78be6c0
languageName: node
linkType: hard
"styled-jsx@npm:5.1.1": "styled-jsx@npm:5.1.1":
version: 5.1.1 version: 5.1.1
resolution: "styled-jsx@npm:5.1.1" resolution: "styled-jsx@npm:5.1.1"
@@ -9073,7 +9039,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tslib@npm:^2.0.0, tslib@npm:^2.1.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0": "tslib@npm:^2.0.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0":
version: 2.5.0 version: 2.5.0
resolution: "tslib@npm:2.5.0" resolution: "tslib@npm:2.5.0"
checksum: ae3ed5f9ce29932d049908ebfdf21b3a003a85653a9a140d614da6b767a93ef94f460e52c3d787f0e4f383546981713f165037dc2274df212ea9f8a4541004e1 checksum: ae3ed5f9ce29932d049908ebfdf21b3a003a85653a9a140d614da6b767a93ef94f460e52c3d787f0e4f383546981713f165037dc2274df212ea9f8a4541004e1