-
Notifications
You must be signed in to change notification settings - Fork 356
Conversation
Please see this as proposal on how to implement automatic/random colors for tags while keeping the current set of hard coded colors in place (at least in the frontend). Bear with me as I have even less Angular knowledge than Django and just tried to get away with as few changes as possible. :-) AIUI you want to change to a color picking system anyways in the future, which could also play well with this. fixes the-paperless-project#51
adfdc63
to
26784a5
Compare
Hello, and thanks again for contributing! (Don't worry too much about the coverage report) The next release is already kinda packed with goodies, and I want to get this wrapped up, so I'll look into this alter. |
Sure, no rush. Let me know if you want anything changed. |
|
||
getColor(id) { | ||
return TAG_COLOURS.find(c => c.id == id) | ||
var color = TAG_COLOURS.find(c => c.id == id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we mix US and British English spelling for color (colour)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I'm happy to clean that up once/if the general approach is accepted.
@jonaswinkler did you had the time to think about this by chance? Would you accept the approach in general? I could rebase and fix the spelling then. |
I want to look into this again and need some input. The gist of it is that the field As far as I'm aware, your app is the only client that extensively uses the API. Are you using this field in your app? Would you mind me changing that? The more compatible approach would be to
|
Yes, the app is currently using that field. Your workaround seems useful although it probably needs a lot of code to find the closest original colour. I guess App updates are usually installed within weeks at most so I guess you can drop For future changes it might be better to send an |
True.
Hm. I'll add API versioning. Time to learn something new! There's support for that in the framework, and I'm apparently able to alter the behavior based on what version is requested. Old clients get the old version, new clients get fancy color codes. |
Alright, I implemented a client-side change assuming the JSON key will be named "colour_code". It still works for the old API so I'm going to push an update. I wonder if there is an easier way than to maintain backwards-compatibility client-side as well as server-side 😄 |
Wait. |
Okay 😄 I ran into a new kind of dependency hell anyway. Is there anything else that I would need to change? |
I am about to implement versioning according to the documentation (https://www.django-rest-framework.org/api-guide/versioning/#acceptheaderversioning). This will ensure backward compatibility of all (older) clients with all servers.
@bauerj Adding that versioned Accept header to every request is fairly simple in the front end - how's that on your end? |
Looks like the app has to maintain backwards-compatibility for old servers and the server has to maintain backwards-compatibility for old clients then 😅 I wonder what happens if the client requests an API version 3. Would the server just use the v2 API or would it raise an error?
Yes, that would be simple as well. |
Newer servers will respond with "406 Not Acceptable", and an error message in the body.
Not at all! You simply build your app to target one of the versions, and expect the server to respond with data from that version. The apps that are currently running out there will continue to request v1. When you update your app to use the new color fields, simply request version 2, and the server will serve data from that version, even if newer API versions appear in the future. I'll update the API docs with specifics once that's done. |
Heh, on the plus side it looks dope. |
With this you could verify whether your app is compatible with any given server, right? |
Well, for the time being we still need to support Paperless and Paperless NG API version 1 servers. I don't think it would be a good idea to force users to upgrade their server after an automatic app update. While app updates are usually installed by almost all users after 1-2 days, server updates can take a lot longer since there is no integrated update mechanism. However, this versioning scheme is still useful for other clients.
I'm not sure if this is a good idea. Imagine we have API version 10 some time in the future but the user would still use an old server that only supports version 2 of the API. Then the app would have to request data using API versions 10-2, causing 8 requests to find the common API version. Or does the 406 response contain an X-API-Version header with the newest API? |
I'm not sure either how to do this properly. Every response to authenticated requests will contain |
What should I do when the client requests a version that the server does not (yet) have? The current state of things on the |
…uage-da-dk Enabled the Danish (da-dk) translations
Fixes incorrect jonaswinkler#83 and jonaswinkler#84
Please see this as proposal on how to implement automatic/random colors
for tags while keeping the current set of hard coded colors in place (at
least in the frontend).
Bear with me as I have even less Angular knowledge than Django and just
tried to get away with as few changes as possible. :-) AIUI you want to
change to a color picking system anyways in the future, which could also
play well with this.
fixes #51