examples: add media-stats-ui plugin

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7c9ccac175440d278fd129dbd53f04d66a6a6964
This commit is contained in:
raf 2026-03-11 17:09:56 +03:00
commit 119f6d2e06
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 466 additions and 0 deletions

View file

@ -0,0 +1,132 @@
{
"id": "stats",
"title": "Library Statistics",
"route": "/plugins/media-stats-ui/stats",
"icon": "chart-bar",
"layout": {
"type": "tabs",
"default_tab": 0,
"tabs": [
{
"label": "Overview",
"content": {
"type": "container",
"gap": 24,
"children": [
{
"type": "heading",
"level": 2,
"content": "Library Statistics"
},
{
"type": "text",
"content": "Live summary of your media library. Refreshes every 30 seconds.",
"variant": "secondary"
},
{
"type": "card",
"title": "Summary",
"content": [
{
"type": "description_list",
"data": "stats",
"horizontal": true
}
]
},
{
"type": "chart",
"chart_type": "bar",
"data": "type-breakdown",
"title": "Files by Type",
"x_axis_label": "Media Type",
"y_axis_label": "Count",
"height": 280
}
]
}
},
{
"label": "Recent Files",
"content": {
"type": "container",
"gap": 16,
"children": [
{
"type": "heading",
"level": 2,
"content": "Recently Added"
},
{
"type": "data_table",
"data": "recent",
"sortable": true,
"filterable": true,
"page_size": 10,
"columns": [
{
"key": "title",
"header": "Title"
},
{
"key": "media_type",
"header": "Type"
},
{
"key": "file_size",
"header": "Size",
"data_type": "file_size"
},
{
"key": "created_at",
"header": "Added",
"data_type": "date_time"
}
]
}
]
}
},
{
"label": "Media Grid",
"content": {
"type": "container",
"gap": 16,
"children": [
{
"type": "heading",
"level": 2,
"content": "Browse Media"
},
{
"type": "media_grid",
"data": "recent",
"columns": 4,
"gap": 12
}
]
}
}
]
},
"data_sources": {
"stats": {
"type": "endpoint",
"path": "/api/v1/statistics",
"poll_interval": 30
},
"recent": {
"type": "endpoint",
"path": "/api/v1/media"
},
"type-breakdown": {
"type": "static",
"value": [
{ "type": "Audio", "count": 0 },
{ "type": "Video", "count": 0 },
{ "type": "Image", "count": 0 },
{ "type": "Document", "count": 0 }
]
}
}
}

View file

@ -0,0 +1,126 @@
{
"id": "tag-manager",
"title": "Tag Manager",
"route": "/plugins/media-stats-ui/tag-manager",
"icon": "tag",
"layout": {
"type": "tabs",
"default_tab": 0,
"tabs": [
{
"label": "All Tags",
"content": {
"type": "container",
"gap": 16,
"children": [
{
"type": "heading",
"level": 2,
"content": "Manage Tags"
},
{
"type": "conditional",
"condition": {
"op": "eq",
"left": { "function": "len", "args": ["tags"] },
"right": 0
},
"then": {
"type": "text",
"content": "No tags yet. Use the 'Create Tag' tab to add one.",
"variant": "secondary"
},
"else": {
"type": "data_table",
"data": "tags",
"sortable": true,
"filterable": true,
"page_size": 20,
"columns": [
{ "key": "name", "header": "Tag Name" },
{ "key": "color", "header": "Color" },
{ "key": "item_count", "header": "Items", "data_type": "number" }
]
}
}
]
}
},
{
"label": "Create Tag",
"content": {
"type": "container",
"gap": 24,
"children": [
{
"type": "heading",
"level": 2,
"content": "Create New Tag"
},
{
"type": "text",
"content": "Tags are used to organise media items. Choose a name and an optional colour.",
"variant": "secondary"
},
{
"type": "form",
"submit_label": "Create Tag",
"submit_action": "create-tag",
"cancel_label": "Reset",
"fields": [
{
"id": "name",
"label": "Tag Name",
"type": { "type": "text", "max_length": 64 },
"required": true,
"placeholder": "e.g. favourite, to-watch, archived",
"help_text": "Must be unique. Alphanumeric characters, spaces, and hyphens.",
"validation": [
{ "type": "min_length", "value": 1 },
{ "type": "max_length", "value": 64 },
{ "type": "pattern", "regex": "^[a-zA-Z0-9 \\-]+$" }
]
},
{
"id": "color",
"label": "Colour",
"type": {
"type": "select",
"options": [
{ "value": "#ef4444", "label": "Red" },
{ "value": "#f97316", "label": "Orange" },
{ "value": "#eab308", "label": "Yellow" },
{ "value": "#22c55e", "label": "Green" },
{ "value": "#3b82f6", "label": "Blue" },
{ "value": "#8b5cf6", "label": "Purple" },
{ "value": "#ec4899", "label": "Pink" },
{ "value": "#6b7280", "label": "Grey" }
]
},
"required": false,
"default_value": "#3b82f6",
"help_text": "Optional accent colour shown beside the tag."
}
]
}
]
}
}
]
},
"data_sources": {
"tags": {
"type": "endpoint",
"path": "/api/v1/tags",
"poll_interval": 0
}
},
"actions": {
"create-tag": {
"method": "POST",
"path": "/api/v1/tags",
"success_message": "Tag created successfully!",
"error_message": "Failed to create tag: the name may already be in use."
}
}
}