diff --git a/README.md b/README.md
index 69cbc06..eb4248b 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,59 @@
-# Redwood
+# CadHub
-> **WARNING:** RedwoodJS software has not reached a stable version 1.0 and should not be considered suitable for production use. In the "make it work; make it right; make it fast" paradigm, Redwood is in the later stages of the "make it work" phase.
+CadHub aims to be a community website for javascript based code-cad. Currently trying to integrate [cascadeStudio](https://zalo.github.io/CascadeStudio/), but if successful plan to also integrate [JSCAD](https://openjscad.org/).
+OpenScad has proven code-cad a much loved formate for cad-modeling. Joining code-cad to a mature language like javascript that has a package manager (npm) plus a community hub for sharing cad models like CadHub, we're going to build a thriving community.
+
+
+
+
## Getting Started
-- [Tutorial](https://redwoodjs.com/tutorial/welcome-to-redwood): getting started and complete overview guide.
-- [Docs](https://redwoodjs.com/docs/introduction): using the Redwood Router, handling assets and files, list of command-line tools, and more.
-- [Redwood Community](https://community.redwoodjs.com): get help, share tips and tricks, and collaborate on everything about RedwoodJS.
-### Setup
+Because we're integrating cascadeStudio, this is done some what crudely for the time being, so you'll need to clone the repo with submodules.
-We use Yarn as our package manager. To get the dependencies installed, just do this in the root directory:
+```terminal
+git clone --recurse-submodules -j8 git@github.com:Irev-Dev/cadhub.git
+# or
+git clone --recurse-submodules -j8 https://github.com/Irev-Dev/cadhub.git
+```
+Install dependencies
```terminal
yarn install
```
-### Fire it up
-
-```terminal
-yarn redwood dev
+Initialise the db
+``` terminal
+yarn rw db up
```
-Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on `http://localhost:8911` and are also proxied to `http://localhost:8910/.redwood/functions/*`.
+### Fire up dev
+```terminal
+yarn rw dev
+```
+
+Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on `http://localhost:8911` and are also proxied to `http://localhost:8910/.redwood/functions/*`.
+
+You may need to register a account depending on what issue you are trying to tackle, This can be done by clicking the login button on the top right. This will open up netlify's idenitiy modal asking for the websites url, since it will notice you developing locally. Enter `https://cadhub.xyz/` than use you email, verify your email and you should be set.
+(some routes are protected, but permissions is a big area that needs a lot of work in the near future, so it's in a very incomplete state atm)
+
+### Note:
+We're using [RedwoodJS](https://redwoodjs.com/), this is perhaps unwise since they haven't reached 1.0 yet, however with their aim to release 1.0 by the end of the year, it shouldn't be too difficult to port changes over the coming months.
+If you not familiar with Redwood, never fear the main bit of tech it uses is React, Graphql(apollo) and serverless/lamdas, depending on what part of the app you want to help with, so long as you know you way around these bits of tech you should be fine with some light referencing of the RedWood docs
+
+### Extra Redwood docs, i.e. getting familiar with the frame work.
+- [Tutorial](https://redwoodjs.com/tutorial/welcome-to-redwood): getting started and complete overview guide.
+- [Docs](https://redwoodjs.com/docs/introduction): using the Redwood Router, handling assets and files, list of command-line tools, and more.
+- [Redwood Community](https://community.redwoodjs.com): get help, share tips and tricks, and collaborate on everything about RedwoodJS.
+
+## Styles
+
+We're using tailwind utility classes so please try and use them as much as possible. Again if you not familiar, the [tailwind search](https://tailwindcss.com/) is fantastic, so searching for the css property you want to use will lead you to the correct class 99% of the time.
+
+## Designs
+
+In progress, though can be [seen on Figma](https://www.figma.com/file/VUh53RdncjZ7NuFYj0RGB9/CadHub?node-id=0%3A1)
+
+
+
+
diff --git a/api/src/functions/identity-signup.js b/api/src/functions/identity-signup.js
index 9524495..6b52938 100644
--- a/api/src/functions/identity-signup.js
+++ b/api/src/functions/identity-signup.js
@@ -1,9 +1,52 @@
-import { createUser } from 'src/services/users/users.js'
+import { createUserInsecure } from 'src/services/users/users.js'
export const handler = async (req, _context) => {
const body = JSON.parse(req.body)
console.log(body)
console.log(_context)
+ // DUMP FROM THE LOGS ABOVE
+ /*
+ 5:09:30 AM: 2020-10-19T18:09:30.011Z 9da27e24-b6ec-404e-8e7d-25b5d323b67a INFO {
+ event: 'signup',
+ instance_id: '403b7d63-17f9-48f1-a85f-3d6b41c7dad1',
+ user: {
+ id: '641222ee-3e61-4253-8c11-9f764779bcc5',
+ aud: '',
+ role: '',
+ email: 'k.hutten@protonmail.ch',
+ confirmation_sent_at: '2020-10-19T18:09:01Z',
+ app_metadata: { provider: 'email' },
+ user_metadata: { full_name: 'sick_dog' },
+ created_at: '2020-10-19T18:09:01Z',
+ updated_at: '2020-10-19T18:09:01Z'
+ }
+ }
+ 5:09:30 AM: 2020-10-19T18:09:30.011Z 9da27e24-b6ec-404e-8e7d-25b5d323b67a INFO {
+ callbackWaitsForEmptyEventLoop: [Getter/Setter],
+ succeed: [Function],
+ fail: [Function],
+ done: [Function],
+ functionVersion: '$LATEST',
+ functionName: 'ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c',
+ memoryLimitInMB: '1024',
+ logGroupName: '/aws/lambda/ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c',
+ logStreamName: '2020/10/19/[$LATEST]af6ff2c067da44268b4a0c9d1e4ca1ea',
+ clientContext: {
+ custom: {
+ netlify: 'eyJpZGVudGl0eSI6eyJ1cmwiOiJodHRwczovL2FuZ3J5LWRpamtzdHJhLTAzMWExMC5uZXRsaWZ5LmFwcC8ubmV0bGlmeS9pZGVudGl0eSIsInRva2VuIjoiZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmxlSEFpT2pFMk1ETXhNekV3TWprc0luTjFZaUk2SWpBaWZRLk54Q0hmb0I2aDRpc0V6NnpJREhWbThLTU5hcEZrb3g0dTFXS2dTemhzUncifSwic2l0ZV91cmwiOiJodHRwczovL2FuZ3J5LWRpamtzdHJhLTAzMWExMC5uZXRsaWZ5LmFwcCJ9'
+ },
+ identity: {
+ url: 'https://angry-dijkstra-031a10.netlify.app/.netlify/identity',
+ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDMxMzEwMjksInN1YiI6IjAifQ.NxCHfoB6h4isEz6zIDHVm8KMNapFkox4u1WKgSzhsRw'
+ }
+ },
+ identity: undefined,
+ invokedFunctionArn: 'arn:aws:lambda:us-east-1:012533533302:function:ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c',
+ awsRequestId: '9da27e24-b6ec-404e-8e7d-25b5d323b67a',
+ getRemainingTimeInMillis: [Function: getRemainingTimeInMillis]
+ }
+ 5:09:30 AM: Duration: 5.78 ms Memory Usage: 69 MB Init Duration: 199.35 ms
+ */
const eventType = body.event
const user = body.user
@@ -13,15 +56,17 @@ export const handler = async (req, _context) => {
if (eventType === 'signup') {
roles.push('user')
- const hi = {
- email: 'kurt.hutten@gmail.com',
- image: '',
- bio: ''
- }
+ // const hi = {
+ // email: 'kurt.hutten@gmail.com',
+ // image: '',
+ // bio: ''
+ // }
const input = {
email,
+ bio: 'default bio'
+ // full_name: user.user_metadata.full_name
}
- createUser({input})
+ await createUserInsecure({input})
return {
statusCode: 200,
diff --git a/api/src/services/users/users.js b/api/src/services/users/users.js
index f3875f8..3d3675c 100644
--- a/api/src/services/users/users.js
+++ b/api/src/services/users/users.js
@@ -14,9 +14,11 @@ export const user = ({ id }) => {
}
export const createUser = ({ input }) => {
- console.log(input)
- console.log(JSON.stringify(input))
requireAuth({ role: 'admin' })
+ return createUserInsecure({input})
+}
+
+export const createUserInsecure = ({ input }) => {
return db.user.create({
data: input,
})
diff --git a/web/package.json b/web/package.json
index db3c665..a9942bc 100644
--- a/web/package.json
+++ b/web/package.json
@@ -18,6 +18,7 @@
"@redwoodjs/forms": "^0.19.2",
"@redwoodjs/router": "^0.19.2",
"@redwoodjs/web": "^0.19.2",
+ "cloudinary-react": "^1.6.7",
"controlkit": "^0.1.9",
"golden-layout": "^1.5.9",
"jquery": "^3.5.1",
@@ -28,6 +29,8 @@
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
+ "react-dropzone": "^11.2.1",
+ "react-image-crop": "^8.6.6",
"rich-markdown-editor": "^11.0.2",
"styled-components": "^5.2.0",
"three": "^0.118.3"
diff --git a/web/src/components/PartForm/ImageUploader.js b/web/src/components/PartForm/ImageUploader.js
new file mode 100644
index 0000000..4809ec0
--- /dev/null
+++ b/web/src/components/PartForm/ImageUploader.js
@@ -0,0 +1,119 @@
+import React, { useCallback, useState } from "react";
+import { useDropzone } from "react-dropzone";
+import Button from "@material-ui/core/Button";
+import axios from 'axios'
+import ReactCrop from 'react-image-crop'
+import { Dialog } from '@material-ui/core'
+import { Image as CloudinaryImage } from 'cloudinary-react'
+import 'react-image-crop/dist/ReactCrop.css'
+import Svg from 'src/components/Svg/Svg.js'
+
+const CLOUDINARY_UPLOAD_PRESET = "CadHub_project_images";
+const CLOUDINARY_UPLOAD_URL = "https://api.cloudinary.com/v1_1/irevdev/upload/?custom_coordinates=10,10,20,20";
+
+export default function ImageUploader({ onImageUpload, imageUrl }) {
+ const [isModalOpen, setIsModalOpen] = useState(false)
+ const [file, setFile] = useState()
+ const [cloudinaryId, setCloudinaryId] = useState(imageUrl)
+ const [imageObj, setImageObj] = useState()
+ const [crop, setCrop] = useState({
+ aspect: 16 / 9,
+ unit: '%',
+ width: 100,
+ });
+ async function handleImageUpload() {
+ const croppedFile = await getCroppedImg(imageObj, crop, 'avatar')
+ console.log(croppedFile)
+ const imageData = new FormData();
+ imageData.append('upload_preset', CLOUDINARY_UPLOAD_PRESET);
+ imageData.append('file', croppedFile);
+ let upload = axios.post(CLOUDINARY_UPLOAD_URL, imageData)
+ try {
+ const { data } = await upload
+ if (data && data.public_id !== "") {
+ onImageUpload({cloudinaryPublicId: data.public_id})
+ setCloudinaryId(data.public_id)
+ setIsModalOpen(false)
+ }
+ } catch (e) {
+ console.error('ERROR', e)
+ }
+ }
+ // Drag and Drop
+ const onDrop = useCallback(acceptedFiles => {
+ setIsModalOpen(true)
+ const fileReader = new FileReader()
+ fileReader.onload = () => {
+ setFile(fileReader.result)
+ }
+ fileReader.readAsDataURL(acceptedFiles[0])
+ }, []);
+
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });
+ return (
+