Skip to content

Commit

Permalink
Merge pull request #873 from FlowFuse/392-table-column-types
Browse files Browse the repository at this point in the history
Adds in richer configuration of UI Table columns
  • Loading branch information
joepavitt authored May 22, 2024
2 parents 7db1a86 + 1e7e933 commit 557a6c9
Show file tree
Hide file tree
Showing 13 changed files with 556 additions and 34 deletions.
171 changes: 171 additions & 0 deletions docs/examples/ui-table-cell-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
[
{
"id": "78b43be39f6db8e1",
"type": "ui-table",
"z": "9cb9bb3cd8e3faee",
"group": "5c66023267e5559e",
"name": "",
"label": "text",
"order": 3,
"width": 0,
"height": 0,
"maxrows": "0",
"autocols": false,
"showSearch": false,
"selectionType": "none",
"columns": [
{
"title": "My Column",
"key": "columnA",
"type": "text",
"width": "",
"align": "start"
},
{
"title": "My Other Column",
"key": "columnB",
"type": "text",
"width": "",
"align": "start"
},
{
"title": "URL",
"key": "link",
"type": "link",
"width": "300px",
"align": "start"
},
{
"title": "Progress",
"key": "progress",
"type": "progress",
"width": "",
"align": "start"
},
{
"title": "Row",
"key": "",
"type": "row",
"width": "",
"align": "start"
},
{
"title": "Trend",
"key": "array",
"type": "sparkline-trend",
"width": "",
"align": "start"
},
{
"title": "Bar",
"key": "array",
"type": "sparkline-bar",
"width": "",
"align": "start"
},
{
"title": "Tick/Cross",
"key": "boolean",
"type": "tickcross",
"width": "",
"align": "start"
},
{
"title": "Spot",
"key": "color",
"type": "color",
"width": "",
"align": "center"
}
],
"x": 490,
"y": 60,
"wires": [
[]
]
},
{
"id": "6cdf36ffe9daf59c",
"type": "inject",
"z": "9cb9bb3cd8e3faee",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "[{\"columnA\":\"Hello\",\"columnB\":\"World\",\"link\":\"https://news.bbc.co.uk\",\"progress\":76,\"color\":\"#FF0000\",\"array\":[6,7,9,2,4],\"boolean\":true},{\"columnA\":\"Hey\",\"columnB\":\"Globe\",\"link\":\"https://flowfuse.com\",\"progress\":56,\"color\":\"#24aa69\",\"array\":[1,3,6,3,5],\"boolean\":false}]",
"payloadType": "json",
"x": 350,
"y": 60,
"wires": [
[
"78b43be39f6db8e1"
]
]
},
{
"id": "5c66023267e5559e",
"type": "ui-group",
"name": "Table Cell Types",
"page": "bbc7b44a426b2b01",
"width": "12",
"height": "1",
"order": 3,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "bbc7b44a426b2b01",
"type": "ui-page",
"name": "UI Table Example",
"ui": "c2e1aa56f50f03bd",
"path": "/table",
"icon": "table",
"layout": "grid",
"theme": "c2ff5ba1f92a0f0e",
"order": 11,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "c2e1aa56f50f03bd",
"type": "ui-base",
"name": "Dashboard",
"path": "/dashboard",
"includeClientData": true,
"acceptsClientConfig": [
"ui-control",
"ui-notification"
],
"showPathInSidebar": true,
"navigationStyle": "temporary",
"titleBarStyle": "fixed"
},
{
"id": "c2ff5ba1f92a0f0e",
"type": "ui-theme",
"name": "Default",
"colors": {
"surface": "#ffffff",
"primary": "#0094ce",
"bgPage": "#eeeeee",
"groupBg": "#ffffff",
"groupOutline": "#cccccc"
},
"sizes": {
"pagePadding": "12px",
"groupGap": "12px",
"groupBorderRadius": "4px",
"widgetGap": "12px"
}
}
]
51 changes: 50 additions & 1 deletion docs/nodes/widgets/ui-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ dynamic:
---

<script setup>
import { ref } from 'vue'

import ExampleCellTypes from '../../examples/ui-table-cell-types.json'

import FlowViewer from '../../components/FlowViewer.vue'
import AddedIn from '../../components/AddedIn.vue'

const examples = ref({
'cellTypes': ExampleCellTypes
})
</script>


# Data Table `ui-table` <AddedIn version="0.4.0" />

Renders a set of data in a tabular format. Expects an input (`msg.payload`) in the format of:
Expand Down Expand Up @@ -47,19 +57,58 @@ The table will be rendered with colums `colA`, `colB` and `colC`, unless "Column
- **Click**: The full row becomes a clickable entity, and the `ui-table` node will _output the full object_ associated to a row when clicked.
- **Checkbox**: Each row has a checkbox, and the `ui-table` node will _output an array of objects_ associated to the checked rows when a checkbox is selected.


### Configuring Columns

![Screenshot of the configuration options available for column types in Node-RED](/images/node-examples/ui-table-column-config.png "Screenshot of the configuration options available for column types in Node-RED"){data-zoomable}
_Screenshot of the configuration options available for column types in Node-RED_

If you toggle "off" the "Auto Columns" option, you will have more control to define the columns for your table. For each column, you can define the following:

- **Key**: The key in the object to use for the column data.
- **Label**: The text to display in the column header.
- **Width**: The width of the column, can be in `px`, `%`, or any other valid CSS sizing.
- **Align:** The alignment of the text in the column. Can be `Left`, `Center`, or `Right`. Note that some columns do look odd with "Center" alignment as the header does also contain space for the sorting icon.
- **Type**: Defines the cell's type and controls how your data will be rendered for this column.

### Cell Types <AddedIn version="1.10.0" />

![An example of a ui-table displaying various of the cell types available](/images/node-examples/ui-table-cell-types.png "An example of a ui-table displaying various of the cell types available"){data-zoomable}
_An example of a ui-table displaying various of the cell types available_

- **Text**: Renders the cell as plain text.
- **HTML**: Will respect new line breaks (e.g. `\n`) and basic HTML tags.
- **Link**: Renders the cell as a hyperlink. The `Link` field should contain the URL to link to.
- **Color**: Renders the cell as a colored box. The `Color` field should contain a valid CSS color.
- **Tick/Cross**: Renders the cell as a tick or cross. The `Value` field should contain a boolean (`true`/`false`) value.
- **Progress**: Renders the cell as a progress bar. The `Value` field should contain a number between 0 and 100.
- **Sparkline - Trend**: Renders the cell as a small line chart without axes. The `Value` field should contain an array of numbers to be plotted.
- **Sparkline - Bar**: Renders the cell as a small bar chart without axes. The `Value` field should contain an array of numbers to be plotted.
- **Row Number**: Renders the row number into the cell.

#### Example

<FlowViewer :flow="examples['cellTypes']" height="200px"/>

## Dynamic Properties

<DynamicPropsTable/>

## Examples
## Table Configuration

### Search & Filter

The `ui-table` node can be configured to include a search bar above the table. This will allow users to search and filter across all columns, and automatically search across all columns when you type.

#### Example

![Example of a Data Table with Search & Filter](/images/node-examples/ui-table-search.png "Example of a Data Table with Search & Filter"){data-zoomable}
*Example of a Data Table with Search & Filter" enabled.*

### Interaction

Example that show how a table will appear with different selection types chosen.

#### Default - No Selection Events

![Example of a Data Table](/images/node-examples/ui-table.png "Example of a Data Table"){data-zoomable}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions nodes/widgets/locales/en-US/ui_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script type="text/html" data-help-name="ui-table">
<p>
Display and manage complex datasets with ease using the ui-table widget.
</p>
<h3>Input</h3>
<p>
The ui-table widget requires an array of data to be sent via <code>msg.payload</code>.
The table will then render a row for each object within the array, and, by default, a
column for each property in the objects.
</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>Max Rows <span class="property-type">num</span></dt>
<dd>
Defines the maximum number of data-rows to render in the table.
Excess rows will be available through pagination control.
</dd>
<dt>Selection <span class="property-type">none | click | checkbox</span></dt>
<dd>
Defines any interaction available on the table. This will emit events
with the respective selections taking place.
</dd>
<dt>Show Search <span class="property-type">boolean</span></dt>
<dd>Will display a search bar above the table, allowing for text-based filtering of the data.</dd>
<dt>Auto Columns <span class="property-type">boolean</span></dt>
<dd>
If true, the table will automatically display all data provided.
If false, then you have much more control over the rendering of each column.
</dd>
<dt>Columns <span class="property-type">array</span></dt>
<dd>A list of the columns to render in the table. Only an available option if "Auto Columns" is set to "false"</dd>
</dl>
<h3>Cell Types</h3>
<p>The following details the available cell types that can be used in your tables</p>
<dl class="message-properties">
<dt>Text <span class="property-type">any</span></dt>
<dd>Will render the raw value provided, without any modification or formatting</dd>
<dt>HTML <span class="property-type">string</span></dt>
<dd>Respects new line breaks (e.g. <code>\n</code>) and basic HTML tags.</dd>
<dt>Link <span class="property-type">url</span></dt>
<dd>Renders the cell as a hyperlink. The "Link" value provided should be a valid URL.</dd>
<dt>Color <span class="property-type">color</span></dt>
<dd>Renders the cell as a colored box. The "Color" field should contain a valid CSS color.</dd>
<dt>Tick/Cross <span class="property-type">boolean</span></dt>
<dd>Renders the cell as a tick or cross. The "Value" field should contain a boolean value.</dd>
<dt>Progress <span class="property-type">number</span></dt>
<dd>Renders the cell as a progress bar. The `Value` field should contain a number between 0 and 100.</dd>
<dt>Sparkline - Trend <span class="property-type">array</span></dt>
<dd>Renders the cell as a small line chart without axes. The value should be an array of numbers to be plotted.</dd>
<dt>Sparkline - Bar <span class="property-type">array</span></dt>
<dd>Renders the cell as a small bar chart without axes. The value should be an array of numbers to be plotted.</dd>
<dt>Row Number <span class="property-type">number</span></dt>
<dd>Requires no "key" to be provided as this will just render the row number (1 -> n).</dd>
</dl>
</script>
6 changes: 6 additions & 0 deletions nodes/widgets/locales/en-US/ui_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"autoCalculateColumns": "Auto Calculate Columns",
"key": "Key",
"label": "Label",
"type": "Type",
"width": "Width",
"align": "Align",
"alignLeft": "Left",
"alignCenter": "Center",
"alignRight": "Right",
"column": "column",
"selection": "Interaction",
"search": "Search",
Expand Down
Loading

0 comments on commit 557a6c9

Please sign in to comment.