Skip to content
Snippets Groups Projects

Resolve "Pydantic models for UI config."

Merged Lauri Himanen requested to merge 1257-pydantic-models-for-ui-config into develop
2 files
+ 101
51
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 35
18
@@ -784,9 +784,9 @@ class Entry(UISetting):
class ModeEnum(str, Enum):
Standard = 'standard'
Scientific = 'scientific'
Separators = 'separators'
STANDARD = 'standard'
SCIENTIFIC = 'scientific'
SEPARATORS = 'separators'
class Format(UISetting):
@@ -796,15 +796,15 @@ class Format(UISetting):
class AlignEnum(str, Enum):
Left = 'left'
Right = 'right'
Center = 'center'
LEFT = 'left'
RIGHT = 'right'
CENTER = 'center'
class Column(UISetting):
'''Option for a column show in the search results.'''
label: Optional[str] = Field(description='Label shown in the header. Defaults to the quantity name.')
align: AlignEnum = Field(AlignEnum.Left, description='Alignment in the table.')
align: AlignEnum = Field(AlignEnum.LEFT, description='Alignment in the table.')
unit: Optional[str] = Field(description='''
Unit to convert to when displaying. If not given will be displayed in
using the default unit in the active unit system.
@@ -848,7 +848,7 @@ class Pagination(UISetting):
class FilterMenuActionEnum(str, Enum):
Checkbox = 'checkbox'
CHECKBOX = 'checkbox'
class FilterMenuAction(UISetting):
@@ -887,7 +887,7 @@ class Filters(OptionsBase):
class UnitSystemEnum(str, Enum):
Custom = 'Custom'
CUSTOM = 'Custom'
SI = 'SI'
AU = 'AU'
@@ -909,27 +909,41 @@ class Help(UISetting):
class Layout(UISetting):
'''Defines widget size and grid positioning for different breakpoints.'''
minH: int = Field(description='Minimum height in grid units.')
minW: int = Field(description='Minimum width in grid units.')
h: int = Field(description='Height in grid units')
w: int = Field(description='Width in grid units.')
x: int = Field(description='Horizontal grid location.')
y: int = Field(description='Vertical grid location.')
x: int = Field(description='Horizontal start location in the grid.')
y: int = Field(description='Vertical start location in the grid.')
class ScaleEnum(str, Enum):
Pow1 = 'linear'
Pow2 = '1/2'
Pow4 = '1/4'
Pow8 = '1/8'
POW1 = 'linear'
POW2 = '1/2'
POW4 = '1/4'
POW8 = '1/8'
class BreakpointEnum(str, Enum):
SM = 'sm'
MD = 'md'
LG = 'lg'
XL = 'xl'
XXL = 'xxl'
class Widget(UISetting):
'''Common configuration for all widgets.'''
type: str = Field(description='Used to identify the widget type.')
layout: Dict[str, Layout]
layout: Dict[BreakpointEnum, Layout] = Field(description='''
Defines widget size and grid positioning for different breakpoints. The
following breakpoints are supported: `sm`, `md`, `lg`, `xl` and `xxl`.
''')
class WidgetTerms(Widget):
'''Terms widget configuration.'''
type: Literal['terms'] = Field(description='Set as `terms` to get this widget type.')
quantity: str = Field(description='Targeted quantity.')
scale: ScaleEnum = Field(description='Statistics scaling.')
@@ -937,6 +951,7 @@ class WidgetTerms(Widget):
class WidgetHistogram(Widget):
'''Histogram widget configuration.'''
type: Literal['histogram'] = Field(description='Set as `histogram` to get this widget type.')
quantity: str = Field(description='Targeted quantity.')
scale: ScaleEnum = Field(description='Statistics scaling.')
@@ -955,12 +970,14 @@ class WidgetHistogram(Widget):
class WidgetPeriodicTable(Widget):
'''Periodic table widget configuration.'''
type: Literal['periodictable'] = Field(description='Set as `periodictable` to get this widget type.')
quantity: str = Field(description='Targeted quantity.')
scale: ScaleEnum = Field(description='Statistics scaling.')
class WidgetScatterPlot(Widget):
'''Scatter plot widget configuration.'''
type: Literal['scatterplot'] = Field(description='Set as `scatterplot` to get this widget type.')
x: str = Field(description='X-axis quantity.')
y: str = Field(description='Y-axis quantity.')
@@ -990,8 +1007,8 @@ class Dashboard(UISetting):
class ResourceEnum(str, Enum):
Entries = 'entries'
Materials = 'materials'
ENTRIES = 'entries'
MATERIALS = 'materials'
class App(UISetting):
Loading