-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Delete events v2 #991
Delete events v2 #991
Conversation
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.
Sorry for the delay! I haven't had a chance to test manually yet, but got a minute to provide some initial feedback. Overall, looks good, pending a few changes and manual testing
minor: What editor are you using? There are some weird formatting/spacing issues in here. If you are using vscode, the devcontainer in the release-0.9.0 branch should have everything set appropriately for you
Also, please run cd web && npm run lint
to auto-fix the lint issues
I was going to ask about this... Yea VScode, ill run lint! |
@paularmstrong believe all comments are addressed now... Side note @shivanetd is a reactjs / fullstack dev who is a friend of mine. He is willing to do the snackbar/optimistic work. Perhaps after this branch is merged and 9.0 is released you can outline a plan ( https://github.com/blakeblackshear/frigate/projects/2 ) of UI components you want and refactoring and we can team up to implement. |
@paularmstrong I just got back from vacation. Any more changes you need from me? |
@paularmstrong merge conflicts resolved. Would you please re-review? Thanks! |
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.
Sorry for the delay, life has gotten pretty busy. I'm having issues testing this and it seems to stem from the problems noted inline
|
||
let success; | ||
try { | ||
const response = await fetch(`${apiHost}/api/events/${eventId}`, { method: 'DELETE' }); |
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.
I'm getting a CORS error here when running dev mode (web and backend on separate ports – which would also mean that anyone trying to build on the API externall)
Might need to add this to the nginx.conf
in the api section, but needs testing. I'm having some system issues making docker builds problematic:
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
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.
I think the recent merge of #1055 broke this. The change was rather large and I did a sync merge. Thanks for calling this out, ill try the approach here in ngnix.
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.
This is resolved, the 204 in the python code caused all sorts of issues, using a 200 is working.
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.
Still getting a CORS error while using a different host/port. Adding the line I mentioned to nginx/nginx.conf:115
clears up the issue.
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.
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
index 51842cb..06760a0 100644
--- a/nginx/nginx.conf
+++ b/nginx/nginx.conf
@@ -112,6 +112,7 @@ http {
location /api/ {
add_header 'Access-Control-Allow-Origin' '*';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header Cache-Control "no-store";
proxy_pass http:https://frigate_api/;
proxy_pass_request_headers on;
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.
Weird. I had that, didn't resolve it. Switched to 200 and removed that line and it fixed it.... No a big deal, I just added it back as I see no harm and logically it makes sense to have.
frigate/http.py
Outdated
media.unlink(missing_ok=True) | ||
|
||
event.delete_instance() | ||
return make_response(jsonify({"success": True, "message": "Event" + id + " deleted"}),204) |
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.
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.
204s have nobody by design. If we want an entity returned we can use 200. Its up to you. Maybe to fix the issue below we can use 200 and a empty body.
https://stackoverflow.com/questions/2342579/http-status-code-for-update-and-delete
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.
resolved.
setDeleteStatus(FetchStatus.ERROR); | ||
} | ||
|
||
if (success) { |
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.
Clicking "delete", I get the 204 response back from the API, but the box never disappears. Appears to be because of the 204 "NO CONTENT" issue from above, the code is jumping to the catch
block and so it's marked as no success.
When this happens (there's an error), there's also no indication of what's going on. It just looks like the request was not made. We should have some sort of error case shown as well as fixing the above.
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.
This is resolved, the 204 in the python code caused all sorts of issues, using a 200 is working.
@paularmstrong Ready for re-re-re-review :) Docker local issues can be resolved via #1076 |
Still having that CORS issue, otherwise looks great! |
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.
Thanks for sticking with it!
Sorry, one last rebase to get things in order? |
@paularmstrong |
…Dialog component for confirmation. Redirect to event list after delete
Co-authored-by: Paul Armstrong <[email protected]>
93680d9
to
81a4128
Compare
@paularmstrong Try now, i did the local rebase. Usually I let gitkraken/github desktop do its work for me, but idk had to manually do it. I re-ran it locally and all was good. |
🎉 |
@paularmstrong Happy to help on whatever is next... Id like to add sorting to the events view so I can filter on time. |
Co-authored-by: Scott Roach <[email protected]> Co-authored-by: Paul Armstrong <[email protected]>
Co-authored-by: Scott Roach <[email protected]> Co-authored-by: Paul Armstrong <[email protected]>
Co-authored-by: Scott Roach <[email protected]> Co-authored-by: Paul Armstrong <[email protected]>
Co-authored-by: Scott Roach <[email protected]> Co-authored-by: Paul Armstrong <[email protected]>
Continuation of #858
This is a fork of 858 from @ScottRoach and just adding minor details... We can use this PR for extra notes/cleanup
@paularmstrong - I did not go optimistic route.... Figured you can modify/set pattern in a future refactor + snackbar. I just took your patch suggestion and tested it.