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

Fix various onboarding issues #366

Merged
merged 10 commits into from
Mar 15, 2024
Merged

Fix various onboarding issues #366

merged 10 commits into from
Mar 15, 2024

Conversation

mihow
Copy link
Collaborator

@mihow mihow commented Mar 12, 2024

Users have been unable to create a new Deployment on their own. This is mostly because a Device, Research Site and Data Source need to be created first before creating a Deployment. Those related models are not actually required, but the form was requiring something to be selected. This PR makes several updates to address this issue.

  • Allow the Deployment form to be submitted when Device, Site & Data Source are blank
  • Set the fields to not be required on the backend
  • Create a default Device and Research Site for a Project when it is first created.

Other changes:

  • Increase the file size of user uploads from 1MB, and make standard across the site
  • Run existing doctests on utility functions, like the date parser from image file names.

Copy link

netlify bot commented Mar 12, 2024

Deploy Preview for ami-web ready!

Name Link
🔨 Latest commit 73eb7ee
🔍 Latest deploy log https://app.netlify.com/sites/ami-web/deploys/65f09d1a489c0b0008dfcc7a
😎 Deploy Preview https://deploy-preview-366--ami-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 75
Accessibility: 95
Best Practices: 92
SEO: 92
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -12,7 +12,9 @@ export const convertToFormData = (fieldValues: DeploymentFieldValues) => {
longitude: fieldValues.longitude,
research_site_id: fieldValues.siteId,
}).forEach(([key, value]) => {
data.append(key, `${value}`)
if (value && value !== 'undefined') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@annavik I am curious how these variables are getting converted to the string "undefined". Any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, the problem is the line below. JavaScript behaves like this:
Screenshot 2024-03-18 at 22 38 53

You can try it out in the console!

Copy link
Member

Choose a reason for hiding this comment

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

If we want to make sure we will not pass the string "undefined" to server, we must make sure the value is not undefined before we try make a string out of it. Pretty much what you did, but the string comparison is not necessary. I would also make sure we will not ignore numeric values equal to 0 by making the check a bit more specific.

Suggested change
if (value && value !== 'undefined') {
if (value !== undefined) {

Copy link
Member

Choose a reason for hiding this comment

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

You know because
Screenshot 2024-03-18 at 22 44 50

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we want to make sure we will not pass the string "undefined" to server, we must make sure the value is not undefined before we try make a string out of it. Pretty much what you did, but the string comparison is not necessary. I would also make sure we will not ignore numeric values equal to 0 by making the check a bit more specific.

This is what I started with, but somehow the undefined value is converted to a string before this function is called. So value !== undefined does not catch it :(

Copy link

netlify bot commented Mar 12, 2024

Deploy Preview for ami-storybook ready!

Name Link
🔨 Latest commit 73eb7ee
🔍 Latest deploy log https://app.netlify.com/sites/ami-storybook/deploys/65f09d1add3d53000855b592
😎 Deploy Preview https://deploy-preview-366--ami-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -83,7 +83,7 @@ export const DeploymentDetailsInfo = ({
<FormSection title={translate(STRING.FIELD_LABEL_SOURCE_IMAGES)}>
<FormRow>
<InputValue
label="Data source"
label={translate(STRING.FIELD_LABEL_DATA_SOURCE)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@annavik The other select fields for Site & Device have a placeholder "Pick a value", but Data Source does not. I can't see why, any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

This is because if project has no data sources registered, it's not possible to "pick a value". Then we instead disable the control with label "Not available". Does it make sense? No problem to tweak this logic, let me know :)

If project has a storage registered:
Screenshot 2024-03-18 at 22 25 07

If project has no storage registered:
Screenshot 2024-03-18 at 22 28 13

@mihow mihow merged commit f86bc55 into main Mar 15, 2024
6 checks passed
@mihow mihow deleted the fix/doctests branch March 15, 2024 01:41
@mihow
Copy link
Collaborator Author

mihow commented Mar 15, 2024

Hi @jonbeu this should fix the issue you faced when creating a new deployment. The site, device & data source are no-longer required -- but also a default device & site are created for each project now. I am anxious to see some test images from the AMI-Mini! -Michael

@mihow mihow restored the fix/doctests branch April 21, 2024 19:10
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.

2 participants