feat: Add server-side storage support for todo widget #837
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR enhances the todo widget functionality by adding support for server-side storage, allowing todo tasks to be persisted and synced across different devices and browsers.
Changes
Core Functionality
storage-type
configuration option for todo widget with two modes:browser
(default): Tasks stored in browser's localStorageserver
: Tasks stored on server in JSON filesafero
filesystem abstractionGET /api/widgets/todo/{id}
- Retrieve todo dataPUT /api/widgets/todo/{id}
- Save todo dataConfiguration
data-path
server configuration option (default:./data
)todos
data directory on startupCode Quality
Todo()
function to async for better data loadingloadFromStorage()
andsaveToStorage()
helper functionsDocumentation
docs/configuration.md
with:data-path
property in Server sectionstorage-type
property in Todo widget sectionFiles Changed
.gitignore
- Added data directorygo.mod
&go.sum
- Added afero dependencyinternal/glance/config.go
- Added DataPath fieldinternal/glance/glance.go
- Implemented data path initialization and API routesinternal/glance/static/js/todo.js
- Refactored with storage abstractioninternal/glance/templates/todo.html
- Added storage-type data attributeinternal/glance/widget-todo.go
- Implemented server-side storage logicdocs/configuration.md
- Updated documentationTesting
Breaking Changes
None. This is a backward-compatible enhancement. Existing todo widgets will continue to use browser storage by default.
Example Configuration