Skip to content
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

Merged

Conversation

mitchross
Copy link
Contributor

@mitchross mitchross commented Apr 13, 2021

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.

Copy link
Contributor

@paularmstrong paularmstrong left a 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

docker-compose.yml Outdated Show resolved Hide resolved
docker/Dockerfile.base Outdated Show resolved Hide resolved
frigate/edgetpu.py Outdated Show resolved Hide resolved
frigate/http.py Outdated Show resolved Hide resolved
web/src/routes/Event.jsx Outdated Show resolved Hide resolved
web/src/routes/Event.jsx Outdated Show resolved Hide resolved
web/src/routes/Event.jsx Outdated Show resolved Hide resolved
@mitchross
Copy link
Contributor Author

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!

@mitchross
Copy link
Contributor Author

@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.

@mitchross
Copy link
Contributor Author

@paularmstrong I just got back from vacation. Any more changes you need from me?

@mitchross
Copy link
Contributor Author

@paularmstrong merge conflicts resolved. Would you please re-review? Thanks!

Copy link
Contributor

@paularmstrong paularmstrong left a 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' });
Copy link
Contributor

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';

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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;

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an empty response on this. Do 204s not allow response body, perhaps?
Screen Shot 2021-05-10 at 8 22 08 AM

Copy link
Contributor Author

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

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mitchross
Copy link
Contributor Author

@paularmstrong Ready for re-re-re-review :)

Docker local issues can be resolved via #1076

@paularmstrong
Copy link
Contributor

Still having that CORS issue, otherwise looks great!

@paularmstrong paularmstrong self-requested a review May 12, 2021 14:25
Copy link
Contributor

@paularmstrong paularmstrong left a 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!

@paularmstrong
Copy link
Contributor

This branch cannot be rebased due to conflicts

Sorry, one last rebase to get things in order?

@mitchross
Copy link
Contributor Author

This branch cannot be rebased due to conflicts

Sorry, one last rebase to get things in order?

@paularmstrong
Everything is upto date... Any suggestions?
image

@paularmstrong
Copy link
Contributor

Huh. That's weird.

Screen Shot 2021-05-12 at 07 39 17

I would try manually locally:

git remote add upstream https://github.com/blakeblackshear/frigate.git
git fetch upstream
git rebase upstream/release-0.9.0

@mitchross
Copy link
Contributor Author

Huh. That's weird.

Screen Shot 2021-05-12 at 07 39 17

I would try manually locally:

git remote add upstream https://github.com/blakeblackshear/frigate.git
git fetch upstream
git rebase upstream/release-0.9.0

@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 paularmstrong merged commit ebb6d34 into blakeblackshear:release-0.9.0 May 12, 2021
@paularmstrong
Copy link
Contributor

🎉

@mitchross
Copy link
Contributor Author

🎉

@paularmstrong Happy to help on whatever is next... Id like to add sorting to the events view so I can filter on time.

herostrat pushed a commit to herostrat/frigate that referenced this pull request Jun 13, 2021
herostrat pushed a commit to herostrat/frigate that referenced this pull request Jun 13, 2021
herostrat pushed a commit to herostrat/frigate that referenced this pull request Jun 13, 2021
sinamics pushed a commit to sinamics/frigate that referenced this pull request Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants