-
Notifications
You must be signed in to change notification settings - Fork 5
Make it easier for users to upload and explore captures #943
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
543ddf0
fix: make sure default station passes validation
annavik 936a835
feat: setup dedicated capture view
annavik 8580823
copy: streamline casing for default entities
annavik efb86b3
feat: setup and use image upload dialog
annavik 9998920
feat: show get started information in project gallery
annavik 8f75cfe
copy: streamline select placeholders
annavik 6c8652d
feat: navigate to project after creation
annavik 1b95e16
fix: tweak capture links
annavik 2b59d8e
fix: tweak default column settings for collections
annavik 2c1e35f
copy: tweak wording
annavik a97c3be
fix: bring back jobs as main menu item
annavik cfa69db
Merge branch 'main' into feat/image-upload
mihow 8feff00
fix: link to session detail
mihow 74137ef
fix: missing occurrence filter for single source images
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,14 +98,14 @@ def get_media_url(path: str) -> str: | |
|
||
def get_or_create_default_device(project: "Project") -> "Device": | ||
"""Create a default device for a project.""" | ||
device, _created = Device.objects.get_or_create(name="Default device", project=project) | ||
device, _created = Device.objects.get_or_create(name="Default Device", project=project) | ||
logger.info(f"Created default device for project {project}") | ||
return device | ||
|
||
|
||
def get_or_create_default_research_site(project: "Project") -> "Site": | ||
"""Create a default research site for a project.""" | ||
site, _created = Site.objects.get_or_create(name="Default site", project=project) | ||
site, _created = Site.objects.get_or_create(name="Default Site", project=project) | ||
logger.info(f"Created default research site for project {project}") | ||
return site | ||
|
||
|
@@ -119,6 +119,8 @@ def get_or_create_default_deployment( | |
project=project, | ||
research_site=site, | ||
device=device, | ||
latitude=0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because I noticed the default project didn't pass validation and couldn't be saved. |
||
longitude=0, | ||
) | ||
logger.info(f"Created default deployment for project {project}") | ||
return deployment | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import { Auth } from 'pages/auth/auth' | |
import { Login } from 'pages/auth/login' | ||
import { ResetPassword } from 'pages/auth/reset-password' | ||
import { ResetPasswordConfirm } from 'pages/auth/reset-password-confirm' | ||
import { CollectionDetails } from 'pages/collection-details/collection-details' | ||
import { Captures } from 'pages/captures/captures' | ||
import { Deployments } from 'pages/deployments/deployments' | ||
import { Jobs } from 'pages/jobs/jobs' | ||
import { Occurrences } from 'pages/occurrences/occurrences' | ||
|
@@ -108,7 +108,6 @@ export const App = () => ( | |
/> | ||
<Route path="summary" element={<Summary />} /> | ||
<Route path="collections" element={<Collections />} /> | ||
<Route path="collections/:id" element={<CollectionDetails />} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setup redirect route? |
||
<Route path="exports/:id?" element={<Exports />} /> | ||
<Route | ||
path="processing-services/:id?" | ||
|
@@ -124,6 +123,7 @@ export const App = () => ( | |
</Route> | ||
<Route path="jobs/:id?" element={<Jobs />} /> | ||
<Route path="deployments/:id?" element={<Deployments />} /> | ||
<Route path="captures" element={<Captures />} /> | ||
<Route path="sessions" element={<Sessions />} /> | ||
<Route path="sessions/:id" element={<SessionDetails />} /> | ||
<Route path="occurrences/:id?" element={<Occurrences />} /> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useQueryClient } from '@tanstack/react-query' | ||
import { API_ROUTES, SUCCESS_TIMEOUT } from 'data-services/constants' | ||
import { useState } from 'react' | ||
import { useUploadCapture } from './useUploadCapture' | ||
|
||
type Result = PromiseSettledResult<any> | ||
|
||
const isRejected = (result: Result) => result.status === 'rejected' | ||
|
||
export const useUploadCaptures = (onSuccess?: () => void) => { | ||
const queryClient = useQueryClient() | ||
const [results, setResults] = useState<Result[]>() | ||
const { uploadCapture, isLoading, isSuccess, reset } = useUploadCapture( | ||
() => { | ||
setTimeout(() => { | ||
reset() | ||
}, SUCCESS_TIMEOUT) | ||
} | ||
) | ||
|
||
const error = results?.some(isRejected) | ||
? 'Not all images could not be uploaded, please retry.' | ||
: undefined | ||
|
||
return { | ||
isLoading, | ||
isSuccess, | ||
error, | ||
uploadCaptures: async (params: { | ||
projectId: string | ||
deploymentId: string | ||
files: File[] | ||
}) => { | ||
const promises = params.files | ||
.filter((_, index) => { | ||
if (error) { | ||
// Only retry rejected requests | ||
return results?.[index]?.status === 'rejected' | ||
} | ||
|
||
return true | ||
}) | ||
.map((file) => | ||
uploadCapture({ | ||
projectId: params.projectId, | ||
deploymentId: params.deploymentId, | ||
file, | ||
}) | ||
) | ||
|
||
setResults(undefined) | ||
const updatesResults = await Promise.allSettled(promises) | ||
setResults(updatesResults) | ||
|
||
if (!updatesResults?.some(isRejected)) { | ||
queryClient.invalidateQueries([API_ROUTES.CAPTURES]) | ||
queryClient.invalidateQueries([API_ROUTES.DEPLOYMENTS]) | ||
queryClient.invalidateQueries([API_ROUTES.SUMMARY]) | ||
queryClient.invalidateQueries([API_ROUTES.PROJECTS, params.projectId]) | ||
onSuccess?.() | ||
} | ||
}, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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 thought you preferred the other case!
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.
Haha I have no preference really, I just want things to be consistent. I noticed that for auto created entities, it seems we often use Capitalized Case (Default Station, All Images, etc.).