Skip to content

Commit

Permalink
Add functionality to add and delete row (#184)
Browse files Browse the repository at this point in the history
* Allow to add row

* Remove console

* Allow to delete row

* Fix resetting datasource payload when used ds variable

* Fix lint errors

* Fix tests

* Fix build errors

* Add tests for hooks

* Add tests for Table

* Fix exports collision

* Add tests for editors

* Fix build errors

* Add test for new row button

* Add info message for add row editor if hidden table header

* Add test for checking add and delete row

* Update CHANGELOG.md

---------

Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
asimonok and mikhail-vl authored Dec 2, 2024
1 parent 003b326 commit 0ae47de
Show file tree
Hide file tree
Showing 55 changed files with 3,227 additions and 155 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## 1.9.0 (IN PROGRESS)
## 1.9.0 (2024-12-01)

### Features / Enhancements

Expand All @@ -9,6 +9,7 @@
- Added default pagination size (#181)
- Added preformatted cell type (#180)
- Updated table cells border (#183)
- Added functionality to add and delete row (#184)

## 1.8.0 (2024-11-21)

Expand Down
203 changes: 192 additions & 11 deletions provisioning/dashboards/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 4,
"id": 2,
"links": [],
"panels": [
{
Expand Down Expand Up @@ -246,6 +246,75 @@
],
"tables": [
{
"addRow": {
"enabled": true,
"permission": {
"mode": "",
"userRole": []
},
"request": {
"datasource": "${DS}",
"payload": {
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "insert into devices values (nextval('seq_devices'), '${payload.name}', '${payload.city}', '${payload.state}', '${payload.country}')",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
}
},
"deleteRow": {
"enabled": true,
"permission": {
"mode": "",
"userRole": []
},
"request": {
"datasource": "${DS}",
"payload": {
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "DELETE FROM devices WHERE id=${payload.id}",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
}
},
"expanded": false,
"items": [
{
"aggregation": "none",
Expand Down Expand Up @@ -291,6 +360,12 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -331,7 +406,10 @@
"source": ""
},
"mode": "userRole",
"userRole": ["Editor", "Admin"]
"userRole": [
"Editor",
"Admin"
]
}
},
"enabled": true,
Expand All @@ -347,6 +425,16 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"queryOptions": {
"source": "Countries",
"value": "country"
},
"type": "select"
},
"enabled": true
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -387,7 +475,10 @@
"source": ""
},
"mode": "userRole",
"userRole": ["Editor", "Admin"]
"userRole": [
"Editor",
"Admin"
]
}
},
"enabled": true,
Expand All @@ -403,6 +494,16 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"queryOptions": {
"source": "States",
"value": "state"
},
"type": "select"
},
"enabled": true
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -443,7 +544,10 @@
"source": ""
},
"mode": "userRole",
"userRole": ["Editor", "Admin"]
"userRole": [
"Editor",
"Admin"
]
}
},
"enabled": true,
Expand All @@ -459,6 +563,16 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"queryOptions": {
"source": "Cities",
"value": "city"
},
"type": "select"
},
"enabled": true
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -494,7 +608,10 @@
"source": "Permission"
},
"mode": "query",
"userRole": ["Editor", "Admin"]
"userRole": [
"Editor",
"Admin"
]
}
},
"enabled": true,
Expand All @@ -510,6 +627,12 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": true
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -557,6 +680,12 @@
"footer": [],
"group": false,
"label": "Comments",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"objectId": "86a57480-78e4-428d-b04e-0fdaf14550cf",
"pin": "",
"sort": {
Expand Down Expand Up @@ -605,6 +734,12 @@
"footer": [],
"group": false,
"label": "Small Comments",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"objectId": "fdfb236a-45e7-4f3b-9369-8a47cdcfae42",
"pin": "",
"sort": {
Expand Down Expand Up @@ -649,6 +784,29 @@
}
},
{
"addRow": {
"enabled": false,
"permission": {
"mode": "",
"userRole": []
},
"request": {
"datasource": "",
"payload": {}
}
},
"deleteRow": {
"enabled": false,
"permission": {
"mode": "",
"userRole": []
},
"request": {
"datasource": "",
"payload": {}
}
},
"expanded": false,
"items": [
{
"aggregation": "none",
Expand Down Expand Up @@ -694,6 +852,12 @@
"footer": [],
"group": true,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -745,6 +909,12 @@
"footer": [],
"group": true,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -796,6 +966,12 @@
"footer": [],
"group": true,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -847,6 +1023,12 @@
"footer": [],
"group": false,
"label": "",
"newRowEdit": {
"editor": {
"type": "string"
},
"enabled": false
},
"pin": "",
"sort": {
"descFirst": false,
Expand Down Expand Up @@ -999,7 +1181,9 @@
"config": {},
"name": "edit",
"type": "boolean",
"values": ["true"]
"values": [
"true"
]
}
],
"meta": {},
Expand Down Expand Up @@ -1031,27 +1215,24 @@
"type": "volkovlabs-table-panel"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 40,
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Timescale",
"value": "timescale"
},
"hide": 0,
"includeAll": false,
"label": "DS",
"multi": false,
"name": "DS",
"options": [],
"query": "grafana-postgresql-datasource",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
Expand All @@ -1064,6 +1245,6 @@
"timezone": "browser",
"title": "Devices",
"uid": "edxke3hyi04cgc",
"version": 6,
"version": 5,
"weekStart": ""
}
Loading

0 comments on commit 0ae47de

Please sign in to comment.