-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
WebAPI: Support persisting WebUI client data #23088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3a522f9
to
f6b6945
Compare
@glassez I would especially like to get your opinion on this, as I know you've thought about this functionality in the past. Would this API be sufficient or does it need additional/different functionality? |
Let's not look into the implementation details for now, but rather discuss general issues. First of all, it is worth recalling that I would expect to see some abstract storage of user data, rather than limiting its scope to preferences/settings. It's more a matter of terminology but it also determines the logic of its interface, which I suggest below. As for its interface, I would provide three entrypoints:
I believe that the above should cover the needs of saving client settings and states (and maybe allow something else in the future). Note that if clients (i.e. client software) embed some identifier in the key names, this will allow them to avoid conflicts when accessing the same qBittorrent instance from different clients. |
I don't personally foresee this being used for anything other than settings. In some cases one may consider a setting to be user data (e.g. a file path to save torrents to). Was there a specific example of user data that you had in mind?
This is effectively the interface included in this PR, with the exception that Does
Now I'm really curious what you see these endpoints being used for. As I said, I see it being used to store WebUI-specific preferences, all of which would be global. Of course these endpoints would accept any generic key, so clients could implement the per-client identifiers you're describing, but it's hard for me to imagine without a concrete example use case. |
To begin with, even the client settings are just data for the server. (And, by the way, they should be stored in the appropriate place.)
Well, it could make sense.
If it wasn't clear from the previous comment, then by "user data" I mean the single piece of data referenced by its key/name.
They are intended to be used to store any data that makes sense for the client application to store between launches, i.e. client-specific settings, the states (sizes, positions, etc.) of various widgets, the history of data entered in some controls, etc.
After all, there may (and do) exist different alternative clients. So, if someone were to use several different clients at the same time (alternately), then they might have conflicts of some data having commonly used keys (well, for example, |
827eb1c
to
bc47962
Compare
I've updated the code and the PR description to reflect these changes.
I still expect some of this data to be unique per-client, such as sizes and positions, since the WebUI can be opened on many different devices with different screen sizes and resolutions. I think we agree on the broader points though. |
I wrote about this in the last paragraph of the previous comment. Or do you mean something else? |
@Piccirello
You should never return all the stored data but only explicitly requested by client. |
As for |
@Chocobo1 |
Will this also be used by the GUI? Since some of the settings in the WebUI are also present in the GUI client. |
When I say client I mean each web browser that access the WebUI. If I'm using two different computers, or a computer and a mobile device, I don't necessarily want them to have the same window sizes. This is very different than the GUI where you want to persist all of these settings because the GUI is only ever accessed from a single device.
Ah I did miss that. I generally agree that's useful though I also think it would be useful to fetch all data, that way it can be cached in the client (like we do with preferences today).
The current approach is easier as it means that values can be any valid json value. It also means we can send up one json blob. Our server doesn't yet support sending payloads with a content-type of
Please see the PR description. This is only for settings unique to the WebUI, most of which are currently persisted in browser local storage. |
I was thinking about tracker icons and last used save path. These settings currently exist in the gui but could potentially be added to the webUI. |
Oh I misunderstood. Indeed those settings which are otherwise considered gui-only could use this. Last used save path is actually called out in the PR description and was one of the motivators for building this. |
2b8913e
to
371d09a
Compare
Well, this can also be solved by using appropriate (more detailed) data identification. Or do you have a different idea?
This would fetch and cache unrelated data (related to another client software, browser etc.) as well. So I doubt it is a good idea. |
This new API is for settings/data that will be shared among different instances of the WebUI (i.e. across different browsers/computers). The data you're describing is better left in local storage as it exists today. We don't really get any benefit to persisting it server-side if it's only ever going to be used by a single instance of the WebUI. That's also why I initially called this "settings".
My comment above also addresses this, but the data that this will be storing should't ever be "unrelated" due to a different browser. That data will continue to live in local storage. The data stored by the API should be relevant to every instance of the WebUI that's loaded. I don't think it's worth spending time on the use case of this somehow conflicting wtith alternative WebUIs because you can only run one WebUI at a time - either the official WebUI or exactly one alternative WebUI. |
c16befc
to
01fc0ce
Compare
5a8df16
to
063a9ee
Compare
063a9ee
to
6e02ff3
Compare
Feedback has been addressed. I've moved the WebUI changes out of this PR and into #23191. |
0e8f306
to
e554550
Compare
^ rebased onto master, no changes to this PR |
This provides a mechanism for persisting WebUI client preferences that are distinct from the broader qBittorrent preferences. These preferences apply exclusively to the WebUI.
e554550
to
28a2f73
Compare
Rebased onto |
Ready to merge? |
@Piccirello |
This PR adds two new endpoints for storing WebUI client data. These endpoints will allow certain data to be reused across all instances of the WebUI, regardless of browser or device. This data includes many of the preferences currently available in the Behavior tab of the Options dialog (color scheme, double click behavior, etc.), all of which are currently stored in browser local storage. This data will also include the Add Torrent dialog's default category and last used save path.
I do not expect this to be a drop-in replacement for everything currently stored in local storage, such as column widths and window sizes.
New endpoints:
GET clientdata/load
for retrieving current data/preferencesPOST clientdata/store
for setting new data. Supplied data is merged server-side with existing data. Data can be deleted by setting its value tonull
.