CadQuery MVP integration #281

Merged
Irev-Dev merged 15 commits from kurt/274 into main 2021-04-27 11:53:52 +02:00
Irev-Dev commented 2021-04-26 10:08:34 +02:00 (Migrated from github.com)

Preview Link

I also did a bit of tidy up work, and decided to make the new IDE a little more accessible from the main website. This stuff is still in development, but the other main Cad package on the website we plan on deprecating soon anyway so now the bug plus button has the following options.
image
The IDE looks like this now (not it's final form, but just some quick bits of tidy up).
image

@jmwright, I think I'm going to have to move on from the lamda-docker images, I picked them originally because I liked the idea of not having to think about scaling, and being charged very little in the mean time. but they

  • have been a pain to set up
  • have made the local dev setup super messy
  • and the final straw is that they have a response limit of 10mb, I hope most requests are less than that but the fact is 3d meshes can get large and that is going to be limiting.
    Since it's working atm, I'll leave it as is, but will also be thinking and researching a little as to what I think a good way to deploy things are, open to input, especially since you mentioned caching benefits earlier.

@franknoirot, your call on if you want to review any of the frontend stuff on this one. The main thing I did was get rid of the store middle where and added "thunks" instead as I was having more issues with stale state and thunks mostly solved with (with one hacky bit, but the hackiness shouldn't spread), I've sprinkled a few comments around the place.

### [Preview Link](https://deploy-preview-277--cadhubxyz.netlify.app/) I also did a bit of tidy up work, and decided to make the new IDE a little more accessible from the main website. This stuff is still in development, but the other main Cad package on the website we plan on deprecating soon anyway so now the bug plus button has the following options. ![image](https://user-images.githubusercontent.com/29681384/116057716-6a2afb00-a6c2-11eb-9fe2-a0dfab3100ca.png) The IDE looks like this now (not it's final form, but just some quick bits of tidy up). ![image](https://user-images.githubusercontent.com/29681384/116057952-abbba600-a6c2-11eb-926b-ef660574768d.png) @jmwright, I think I'm going to have to move on from the lamda-docker images, I picked them originally because I liked the idea of not having to think about scaling, and being charged very little in the mean time. but they - have been a pain to set up - have made the local dev setup super messy - and the final straw is that they have a response limit of 10mb, I hope most requests are less than that but the fact is 3d meshes can get large and that is going to be limiting. Since it's working atm, I'll leave it as is, but will also be thinking and researching a little as to what I think a good way to deploy things are, open to input, especially since you mentioned caching benefits earlier. @franknoirot, your call on if you want to review any of the frontend stuff on this one. The main thing I did was get rid of the store middle where and added "thunks" instead as I was having more issues with stale state and thunks mostly solved with (with one hacky bit, but the hackiness shouldn't spread), I've sprinkled a few comments around the place.
Irev-Dev (Migrated from github.com) reviewed 2021-04-26 11:16:29 +02:00
@@ -13,6 +13,7 @@
]
},
"dependencies": {
"@headlessui/react": "^1.0.0",
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:10:40 +02:00

Yay, I've been waiting for this 1.0 release. I had been using material-UI which I'd like to stop doing.

Yay, I've been waiting for this 1.0 release. I had been using material-UI which I'd like to stop doing.
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:12:50 +02:00

I'm using "vs-dark" theme for the editor, only because I think a dark theme make sense since it's the general preference for most devs when it comes to editors at least, happy to load a nicer theme, but for now any dark theme will do. The following are some colors to match this theme for the console. Not crucial but also not hard to do.

I'm using "vs-dark" theme for the editor, only because I think a dark theme make sense since it's the general preference for most devs when it comes to editors at least, happy to load a nicer theme, but for now any dark theme will do. The following are some colors to match this theme for the console. Not crucial but also not hard to do.
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:15:22 +02:00

maybe should have added this as variable like the others to denote its to match the vs-dark theme. The grays in tailwind are very cool/blue and clash a little IMO, (Actually I think tailwind 2.0 has much more grays but anyway).

maybe should have added this as variable like the others to denote its to match the vs-dark theme. The grays in tailwind are very cool/blue and clash a little IMO, (Actually I think tailwind 2.0 has much more grays but anyway).
@@ -35,3 +28,3 @@
if (key === 's' && (ctrlKey || metaKey)) {
event.preventDefault()
dispatch({ type: 'render', payload: { code: state.code } })
thunkDispatch((dispatch, getState) => {
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:16:57 +02:00

Hash logic has been moved to the toolbar.

Hash logic has been moved to the toolbar.
@@ -49,2 +66,4 @@
defaultLanguage={ideTypeToLanguageMap[state.ideType] || 'cpp'}
language={ideTypeToLanguageMap[state.ideType] || 'cpp'}
onChange={handleCodeChange}
/>
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:18:06 +02:00

I wanted this loading message to be light text on dark background to match roughly the theme of the editor, but I there must be very specific styles that force it to be white, I didn't bother digging into it too much.

I wanted this loading message to be light text on dark background to match roughly the theme of the editor, but I there must be very specific styles that force it to be white, I didn't bother digging into it too much.
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:20:10 +02:00

This is where the stl is loaded in for CadQuery.

This is where the stl is loaded in for CadQuery.
@@ -0,0 +1,48 @@
import { Link, routes } from '@redwoodjs/router'
import Svg from 'src/components/Svg/Svg'
import { Popover } from '@headlessui/react'
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:21:47 +02:00

I think the <Menu /> component would have made more sense from headlessui, but I got it working with Popover first and when I tried swapping to Menu, I was just fighting to get the styles to not do weird things 🤷

I think the `<Menu />` component would have made more sense from headlessui, but I got it working with Popover first and when I tried swapping to Menu, I was just fighting to get the styles to not do weird things 🤷
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:24:57 +02:00

Sorry. My fault.
The controller needing to be call more than once with different settings (first the camera, and the viewport size) was confusing, and I can imagine think WTF down the road, I just put these details in the store as well as you originally did @franknoirot. much more straight forward.

Sorry. My fault. The controller needing to be call more than once with different settings (first the camera, and the viewport size) was confusing, and I can imagine think WTF down the road, I just put these details in the store as well as you originally did @franknoirot. much more straight forward.
@@ -5,0 +7,4 @@
? actionOrThunk(dispatch, getState)
: dispatch(actionOrThunk)
}
Irev-Dev (Migrated from github.com) commented 2021-04-26 10:26:03 +02:00

I think redux thunks might be a little more complex than this, but not by much. Basically you can use this like a normal dispatch, but if you want to something async you just pass it a function instead, you would have already scrolled passed examples.

I think redux thunks might be a little more complex than this, but not by much. Basically you can use this like a normal dispatch, but if you want to something async you just pass it a function instead, you would have already scrolled passed examples.
Irev-Dev (Migrated from github.com) reviewed 2021-04-26 11:18:02 +02:00
Irev-Dev (Migrated from github.com) commented 2021-04-26 11:18:02 +02:00

This is the one hacky thing I did in regards to the thunks. I'm okay with it since now all the new thunks can use the getState function() and shouldn't need to implement more hacks.

This is the one hacky thing I did in regards to the thunks. I'm okay with it since now all the new thunks can use the getState function() and shouldn't need to implement more hacks.
jmwright commented 2021-04-26 15:11:06 +02:00 (Migrated from github.com)

@Irev-Dev This looks great. I did try to copy the CadQuery braille example into the editor, but every time I click Render I get "network error" in the CadHub console. I'm not sure if it's related the the lambda result size limitations you mentioned above, or if there is something in my script that's causing a problem. I've posted the error from Firefox's developer console below.

XHRPOSThttps://t7wdlz8ztf.execute-api.us-east-1.amazonaws.com/dev2/cadquery/stl
[HTTP/2 502 Bad Gateway 1537ms]

	
POST
	https://t7wdlz8ztf.execute-api.us-east-1.amazonaws.com/dev2/cadquery/stl
Status502
Bad Gateway
VersionHTTP/2
Transferred507 B (36 B size)
Referrer Policystrict-origin-when-cross-origin

    	
    content-length
    	36
    content-type
    	application/json
    date
    	Mon, 26 Apr 2021 13:07:16 GMT
    via
    	1.1 9750fb05bdbea09766e7d3b62ad12c45.cloudfront.net (CloudFront)
    x-amz-apigw-id
    	eZIocHf6oAMF90w=
    x-amz-cf-id
    	ZBrUAMRlFJW5SnvSzBYxCHD-RIa8RG-jgIJ8a35s5it1I7VeBaZzGA==
    x-amz-cf-pop
    	ORD52-C1
    x-amzn-errortype
    	InternalServerErrorException
    x-amzn-requestid
    	920d2665-9166-4349-bdf9-7e594962c0d1
    x-cache
    	Error from cloudfront
    X-Firefox-Spdy
    	h2
    	
    Accept
    	*/*
    Accept-Encoding
    	gzip, deflate, br
    Accept-Language
    	en-US,en;q=0.5
    Connection
    	keep-alive
    Content-Length
    	6404
    Content-Type
    	application/json
    Host
    	t7wdlz8ztf.execute-api.us-east-1.amazonaws.com
    Origin
    	https://deploy-preview-277--cadhubxyz.netlify.app
    Referer
    	https://deploy-preview-277--cadhubxyz.netlify.app/
    TE
    	Trailers
    User-Agent
    	Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
@Irev-Dev This looks great. I did try to copy the CadQuery [braille example](https://github.com/CadQuery/cadquery-contrib/blob/master/examples/Braille.py) into the editor, but every time I click `Render` I get "network error" in the CadHub console. I'm not sure if it's related the the lambda result size limitations you mentioned above, or if there is something in my script that's causing a problem. I've posted the error from Firefox's developer console below. ``` XHRPOSThttps://t7wdlz8ztf.execute-api.us-east-1.amazonaws.com/dev2/cadquery/stl [HTTP/2 502 Bad Gateway 1537ms] POST https://t7wdlz8ztf.execute-api.us-east-1.amazonaws.com/dev2/cadquery/stl Status502 Bad Gateway VersionHTTP/2 Transferred507 B (36 B size) Referrer Policystrict-origin-when-cross-origin content-length 36 content-type application/json date Mon, 26 Apr 2021 13:07:16 GMT via 1.1 9750fb05bdbea09766e7d3b62ad12c45.cloudfront.net (CloudFront) x-amz-apigw-id eZIocHf6oAMF90w= x-amz-cf-id ZBrUAMRlFJW5SnvSzBYxCHD-RIa8RG-jgIJ8a35s5it1I7VeBaZzGA== x-amz-cf-pop ORD52-C1 x-amzn-errortype InternalServerErrorException x-amzn-requestid 920d2665-9166-4349-bdf9-7e594962c0d1 x-cache Error from cloudfront X-Firefox-Spdy h2 Accept */* Accept-Encoding gzip, deflate, br Accept-Language en-US,en;q=0.5 Connection keep-alive Content-Length 6404 Content-Type application/json Host t7wdlz8ztf.execute-api.us-east-1.amazonaws.com Origin https://deploy-preview-277--cadhubxyz.netlify.app Referer https://deploy-preview-277--cadhubxyz.netlify.app/ TE Trailers User-Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0 ```
Irev-Dev commented 2021-04-26 22:05:58 +02:00 (Migrated from github.com)

@jmwright No this seems like a different issue. Seems like it might be a edge case specific this braille example.
The following at least renders something

from __future__ import division

from collections import namedtuple

import cadquery as cq

text_lines = [u'⠠']
horizontal_interdot = 2.5
vertical_interdot = 2.5
horizontal_intercell = 6
vertical_interline = 10
dot_height = 0.5
dot_diameter = 1.3

base_thickness = 1.5

BrailleCellGeometry = namedtuple('BrailleCellGeometry',
                                 ('horizontal_interdot',
                                  'vertical_interdot',
                                  'intercell',
                                  'interline',
                                  'dot_height',
                                  'dot_diameter'))


class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __len__(self):
        return 2

    def __getitem__(self, index):
        return (self.x, self.y)[index]

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


def braille_to_points(text, cell_geometry):
    mask1 = 0b00000001
    mask2 = 0b00000010
    mask3 = 0b00000100
    mask4 = 0b00001000
    mask5 = 0b00010000
    mask6 = 0b00100000
    mask7 = 0b01000000
    mask8 = 0b10000000
    masks = (mask1, mask2, mask3, mask4, mask5, mask6, mask7, mask8)

    w = cell_geometry.horizontal_interdot
    h = cell_geometry.vertical_interdot
    pos1 = Point(0, 2 * h)
    pos2 = Point(0, h)
    pos3 = Point(0, 0)
    pos4 = Point(w, 2 * h)
    pos5 = Point(w, h)
    pos6 = Point(w, 0)
    pos7 = Point(0, -h)
    pos8 = Point(w, -h)
    pos = (pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8)

    blank = u' '
    points = []
    character_origin = 0
    for c in text:
        for m, p in zip(masks, pos):
            delta_to_blank = ord(c) - ord(blank)
            if (m & delta_to_blank):
                points.append(p + Point(character_origin, 0))
        character_origin += cell_geometry.intercell
    return points


def get_plate_height(text_lines, cell_geometry):
    return (2 * cell_geometry.vertical_interdot +
            2 * cell_geometry.vertical_interdot +
            (len(text_lines) - 1) * cell_geometry.interline)


def get_plate_width(text_lines, cell_geometry):
    max_len = max([len(t) for t in text_lines])
    return (2 * cell_geometry.horizontal_interdot +
            cell_geometry.horizontal_interdot +
            (max_len - 1) * cell_geometry.intercell)


def get_cylinder_radius(cell_geometry):

    h = cell_geometry.dot_height
    r = cell_geometry.dot_diameter / 2
    return (r ** 2 + h ** 2) / 2 / h


def get_base_plate_thickness(plate_thickness, cell_geometry):
    return (plate_thickness +
            get_cylinder_radius(cell_geometry) -
            cell_geometry.dot_height)


def make_base(text_lines, cell_geometry, plate_thickness):
    base_width = get_plate_width(text_lines, cell_geometry)
    base_height = get_plate_height(text_lines, cell_geometry)
    base_thickness = get_base_plate_thickness(plate_thickness, cell_geometry)
    base = cq.Workplane('XY').box(base_width, base_height, base_thickness,
                                  centered=(False, False, False))
    return base


def make_embossed_plate(text_lines, cell_geometry):

    base = make_base(text_lines, cell_geometry, base_thickness)

    dot_pos = []
    base_width = get_plate_width(text_lines, cell_geometry)
    base_height = get_plate_height(text_lines, cell_geometry)
    y = base_height - 3 * cell_geometry.vertical_interdot
    line_start_pos = Point(cell_geometry.horizontal_interdot, y)
    for text in text_lines:
        dots = braille_to_points(text, cell_geometry)
        dots = [p + line_start_pos for p in dots]
        dot_pos += dots
        line_start_pos += Point(0, -cell_geometry.interline)

    r = get_cylinder_radius(cell_geometry)
    base = base.faces('>Z').vertices('<XY').workplane() \
        .pushPoints(dot_pos).circle(r) \
        .extrude(r)
    # Make a fillet almost the same radius to get a pseudo spherical cap.
    base = base.faces('>Z').edges() \
        .fillet(r - 0.001)
    hidding_box = cq.Workplane('XY').box(
        base_width, base_height, base_thickness, centered=(False, False, False))
    result = hidding_box.union(base)
    return result

_cell_geometry = BrailleCellGeometry(
    horizontal_interdot,
    vertical_interdot,
    horizontal_intercell,
    vertical_interline,
    dot_height,
    dot_diameter)

# if base_thickness < get_cylinder_radius(_cell_geometry):
#     raise ValueError('Base thickness should be at least {}'.format(dot_height))

show_object(make_embossed_plate(text_lines, _cell_geometry))

image

But obviously I've messed up your script.
I get SyntaxError: Unexpected token in JSON at position XXX so an issues with serialising and deserialising.
it seems it doesn't like the lines text_lines = [u'⠠ ⠉ ⠁ ⠙ ⠠ ⠟ ⠥ ⠻ ⠽'] and I think blank = u'⠀' as well.

Edit: looks like it's a problem with base64 and utf-8
https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings

Edit2: I've asked some friends who know a bit more about aws infra, and they've got a suggestion for how to overcome the 10mb limit by using s3 signed urls or something. I'm yet to look into it but it sounds promising, but I think it might fix this issue as a side effect as the base64 encoding has to do with this line and is because I was/am to returning the 3d mesh (or image for openscad) directly which will not be needed if I use the s3 option.

@jmwright No this seems like a different issue. Seems like it might be a edge case specific this braille example. The following at least renders something ```python from __future__ import division from collections import namedtuple import cadquery as cq text_lines = [u'⠠'] horizontal_interdot = 2.5 vertical_interdot = 2.5 horizontal_intercell = 6 vertical_interline = 10 dot_height = 0.5 dot_diameter = 1.3 base_thickness = 1.5 BrailleCellGeometry = namedtuple('BrailleCellGeometry', ('horizontal_interdot', 'vertical_interdot', 'intercell', 'interline', 'dot_height', 'dot_diameter')) class Point(object): def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Point(self.x + other.x, self.y + other.y) def __len__(self): return 2 def __getitem__(self, index): return (self.x, self.y)[index] def __str__(self): return '({}, {})'.format(self.x, self.y) def braille_to_points(text, cell_geometry): mask1 = 0b00000001 mask2 = 0b00000010 mask3 = 0b00000100 mask4 = 0b00001000 mask5 = 0b00010000 mask6 = 0b00100000 mask7 = 0b01000000 mask8 = 0b10000000 masks = (mask1, mask2, mask3, mask4, mask5, mask6, mask7, mask8) w = cell_geometry.horizontal_interdot h = cell_geometry.vertical_interdot pos1 = Point(0, 2 * h) pos2 = Point(0, h) pos3 = Point(0, 0) pos4 = Point(w, 2 * h) pos5 = Point(w, h) pos6 = Point(w, 0) pos7 = Point(0, -h) pos8 = Point(w, -h) pos = (pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8) blank = u' ' points = [] character_origin = 0 for c in text: for m, p in zip(masks, pos): delta_to_blank = ord(c) - ord(blank) if (m & delta_to_blank): points.append(p + Point(character_origin, 0)) character_origin += cell_geometry.intercell return points def get_plate_height(text_lines, cell_geometry): return (2 * cell_geometry.vertical_interdot + 2 * cell_geometry.vertical_interdot + (len(text_lines) - 1) * cell_geometry.interline) def get_plate_width(text_lines, cell_geometry): max_len = max([len(t) for t in text_lines]) return (2 * cell_geometry.horizontal_interdot + cell_geometry.horizontal_interdot + (max_len - 1) * cell_geometry.intercell) def get_cylinder_radius(cell_geometry): h = cell_geometry.dot_height r = cell_geometry.dot_diameter / 2 return (r ** 2 + h ** 2) / 2 / h def get_base_plate_thickness(plate_thickness, cell_geometry): return (plate_thickness + get_cylinder_radius(cell_geometry) - cell_geometry.dot_height) def make_base(text_lines, cell_geometry, plate_thickness): base_width = get_plate_width(text_lines, cell_geometry) base_height = get_plate_height(text_lines, cell_geometry) base_thickness = get_base_plate_thickness(plate_thickness, cell_geometry) base = cq.Workplane('XY').box(base_width, base_height, base_thickness, centered=(False, False, False)) return base def make_embossed_plate(text_lines, cell_geometry): base = make_base(text_lines, cell_geometry, base_thickness) dot_pos = [] base_width = get_plate_width(text_lines, cell_geometry) base_height = get_plate_height(text_lines, cell_geometry) y = base_height - 3 * cell_geometry.vertical_interdot line_start_pos = Point(cell_geometry.horizontal_interdot, y) for text in text_lines: dots = braille_to_points(text, cell_geometry) dots = [p + line_start_pos for p in dots] dot_pos += dots line_start_pos += Point(0, -cell_geometry.interline) r = get_cylinder_radius(cell_geometry) base = base.faces('>Z').vertices('<XY').workplane() \ .pushPoints(dot_pos).circle(r) \ .extrude(r) # Make a fillet almost the same radius to get a pseudo spherical cap. base = base.faces('>Z').edges() \ .fillet(r - 0.001) hidding_box = cq.Workplane('XY').box( base_width, base_height, base_thickness, centered=(False, False, False)) result = hidding_box.union(base) return result _cell_geometry = BrailleCellGeometry( horizontal_interdot, vertical_interdot, horizontal_intercell, vertical_interline, dot_height, dot_diameter) # if base_thickness < get_cylinder_radius(_cell_geometry): # raise ValueError('Base thickness should be at least {}'.format(dot_height)) show_object(make_embossed_plate(text_lines, _cell_geometry)) ``` ![image](https://user-images.githubusercontent.com/29681384/116143052-f9b1c780-a71d-11eb-9868-aa9e8d136226.png) But obviously I've messed up your script. I get `SyntaxError: Unexpected token in JSON at position XXX` so an issues with serialising and deserialising. it seems it doesn't like the lines `text_lines = [u'⠠ ⠉ ⠁ ⠙ ⠠ ⠟ ⠥ ⠻ ⠽']` and I think `blank = u'⠀'` as well. Edit: looks like it's a problem with base64 and utf-8 https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings Edit2: I've asked some friends who know a bit more about aws infra, and they've got a suggestion for how to overcome the 10mb limit by using s3 signed urls or something. I'm yet to look into it but it sounds promising, but I think it might fix this issue as a side effect as the base64 encoding has to do with [this line](https://github.com/Irev-Dev/cadhub/blob/main/api/src/docker/serverless.yml#L23) and is because I was/am to returning the 3d mesh (or image for openscad) directly which will not be needed if I use the s3 option.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 04:42:16 +02:00
@@ -6,0 +10,4 @@
element.scrollTop = element.scrollHeight - element.clientHeight
}
}, [state.consoleMessages])
Irev-Dev (Migrated from github.com) commented 2021-04-27 04:42:16 +02:00

This effect scrolls the console to the bottom whenever there is a new message. Users can still scroll up to look at history, it just snaps back down next message. We might want to add a checkbox to turn off/on this functionality, but I think this is a good default and unless someone complains about it, might as well stay as is.

This effect scrolls the console to the bottom whenever there is a new message. Users can still scroll up to look at history, it just snaps back down next message. We might want to add a checkbox to turn off/on this functionality, but I think this is a good default and unless someone complains about it, might as well stay as is.
franknoirot (Migrated from github.com) reviewed 2021-04-27 06:51:25 +02:00
@@ -0,0 +1,48 @@
import { Link, routes } from '@redwoodjs/router'
import Svg from 'src/components/Svg/Svg'
import { Popover } from '@headlessui/react'
franknoirot (Migrated from github.com) commented 2021-04-27 06:51:25 +02:00

I'll try to make a note of this for future UI work! To check out the Menu component.

I'll try to make a note of this for future UI work! To check out the Menu component.
franknoirot (Migrated from github.com) reviewed 2021-04-27 06:55:17 +02:00
franknoirot (Migrated from github.com) commented 2021-04-27 06:55:17 +02:00

All good all good!

All good all good!
franknoirot (Migrated from github.com) approved these changes 2021-04-27 07:29:08 +02:00
franknoirot (Migrated from github.com) left a comment

Just left some comments in to flag for myself for future UI work, but this is looking great!

Just left some comments in to flag for myself for future UI work, but this is looking great!
@@ -33,3 +31,3 @@
const tempFile = await makeFile(file)
const tempFile = await makeFile(file, '.scad', nanoid)
try {
franknoirot (Migrated from github.com) commented 2021-04-27 07:02:30 +02:00

You've managed to make this backend code really readable even without me having run it before, cheers.

You've managed to make this backend code really readable even without me having run it before, cheers.
@@ -37,3 +37,3 @@
<Router>
<Route path="/dev-ide" page={DevIdePage} name="devIde" />
<Route path="/dev-ide/{cadPackage}" page={DevIdePage} name="devIde" />
<Route path="/policies/privacy-policy" page={PrivacyPolicyPage} name="privacyPolicy" />
franknoirot (Migrated from github.com) commented 2021-04-27 07:06:23 +02:00

Question about this @Irev-Dev : is this inclusion of the CAD package in the URL only for this Dev stage, or are you envisioning the package being encoded into people's project URLs? I think it can definitely work just checking your vision.

Question about this @Irev-Dev : is this inclusion of the CAD package in the URL only for this Dev stage, or are you envisioning the package being encoded into people's project URLs? I think it can definitely work just checking your vision.
@@ -6,0 +10,4 @@
element.scrollTop = element.scrollHeight - element.clientHeight
}
}, [state.consoleMessages])
franknoirot (Migrated from github.com) commented 2021-04-27 07:08:02 +02:00

Hey nice! So few lines of code. Yeah that should be configurable in future: that's one of those less-technical bits I can deal with for you coming up, so you don't have to waste time on it.

Hey nice! So few lines of code. Yeah that should be configurable in future: that's one of those less-technical bits I can deal with for you coming up, so you don't have to waste time on it.
franknoirot (Migrated from github.com) commented 2021-04-27 07:10:40 +02:00

Similar to with the IdeConsole? I can make a note of it if you like.

Similar to with the IdeConsole? I can make a note of it if you like.
@@ -42,0 +45,4 @@
<div
className="text-gray-700 font-ropa-sans relative"
style={{ backgroundColor: 'red' }}
>
franknoirot (Migrated from github.com) commented 2021-04-27 07:13:41 +02:00

I had missed you added this, what a great addition! And for it to be agnostic of the CAD package; this is the kind of unifying stuff that's gonna make it so nice to switch between packages.

I had missed you added this, what a great addition! And for it to be agnostic of the CAD package; this is the kind of unifying stuff that's gonna make it so nice to switch between packages.
@@ -49,2 +66,4 @@
defaultLanguage={ideTypeToLanguageMap[state.ideType] || 'cpp'}
language={ideTypeToLanguageMap[state.ideType] || 'cpp'}
onChange={handleCodeChange}
/>
franknoirot (Migrated from github.com) commented 2021-04-27 07:12:39 +02:00

Is there somewhere we can gather up these low-priority frontend things for me to go through and clean up for you? I think that might be a good way for me to be useful.

Is there somewhere we can gather up these low-priority frontend things for me to go through and clean up for you? I think that might be a good way for me to be useful.
franknoirot (Migrated from github.com) commented 2021-04-27 07:20:21 +02:00

Tiny thing for future, this key might want to be package-agnostic at some point.

Tiny thing for future, this key might want to be package-agnostic at some point.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 10:49:11 +02:00
@@ -49,2 +66,4 @@
defaultLanguage={ideTypeToLanguageMap[state.ideType] || 'cpp'}
language={ideTypeToLanguageMap[state.ideType] || 'cpp'}
onChange={handleCodeChange}
/>
Irev-Dev (Migrated from github.com) commented 2021-04-27 10:49:11 +02:00

Not real sure, might be worth having a chat about where to put what. my intuition says there's no problem with lots of little issues for things you want to get to.

Not real sure, might be worth having a chat about where to put what. my intuition says there's no problem with lots of little issues for things you want to get to.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 10:49:17 +02:00
@@ -37,3 +37,3 @@
<Router>
<Route path="/dev-ide" page={DevIdePage} name="devIde" />
<Route path="/dev-ide/{cadPackage}" page={DevIdePage} name="devIde" />
<Route path="/policies/privacy-policy" page={PrivacyPolicyPage} name="privacyPolicy" />
Irev-Dev (Migrated from github.com) commented 2021-04-27 10:49:17 +02:00

Good question, I think there's no harm in having cad-package in the url for new/draft parts, (I'm thinking we'll keep the swap over to the draft url that CascadeStudio currently uses at some point!?). But for saved parts, we'll be pulling information about what cad-package from the db along with the code so I think for that the URL will be the same as what is now for CascadeStudio userName/partName.
I don't think we've talked about it, but I think for parts that are hosted on github, in order for users to make the integration work they will need to include a cadhub.json in the root of the project (I'm leaning towards json, but could be yml or toml). It will be a place for us to get some meta information, the project title, the cad-package, and probably the entry/main file i.e "main": "./src/cool.scad" is what I can think of the top of my head (We'll need docs for these details). Maybe a Cadhub version too, incase we change the way the github integration works we might still be able to support the old integration style anyway getting ahead of myself. I was just trying to say for projects like this where they are not stored in our db but on github we can put insist on the cad-package info being in the repo (we could store meta-data in our db about projects but I think that defeats the purpose, better to have the repo to contain all the config).

Sorry I've already written too much, considerations for what's in this PR and the cad-package in the URL, If I wanted to instead put that info in the data-store. I would have had to add the context provider much higher in the app hierarchy. This is because the nav-bar where the plus button is, is higher than the ide right. That would be a fine thing to do and honestly I think it's only a matter of time before we do, but for the sake of not having to do that for this change I put it in the URL, and I like I said I don't see any harm for it staying there, unless you can think of one? but I wouldn't say I have a vision for it though haha.

Good question, I think there's no harm in having cad-package in the url for new/draft parts, (I'm thinking we'll keep the swap over to the draft url that CascadeStudio currently uses at some point!?). But for saved parts, we'll be pulling information about what cad-package from the db along with the code so I think for that the URL will be the same as what is now for CascadeStudio `userName/partName`. I don't think we've talked about it, but I think for parts that are hosted on github, in order for users to make the integration work they will need to include a `cadhub.json` in the root of the project (I'm leaning towards json, but could be yml or toml). It will be a place for us to get some meta information, the project title, the cad-package, and probably the entry/main file i.e `"main": "./src/cool.scad"` is what I can think of the top of my head (We'll need docs for these details). Maybe a Cadhub version too, incase we change the way the github integration works we might still be able to support the old integration style anyway getting ahead of myself. I was just trying to say for projects like this where they are not stored in our db but on github we can put insist on the cad-package info being in the repo (we could store meta-data in our db about projects but I think that defeats the purpose, better to have the repo to contain all the config). Sorry I've already written too much, considerations for what's in this PR and the cad-package in the URL, If I wanted to instead put that info in the data-store. I would have had to add the context provider much higher in the app hierarchy. This is because the nav-bar where the plus button is, is higher than the ide right. That would be a fine thing to do and honestly I think it's only a matter of time before we do, but for the sake of not having to do that for this change I put it in the URL, and I like I said I don't see any harm for it staying there, unless you can think of one? but I wouldn't say I have a vision for it though haha.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 10:49:20 +02:00
@@ -0,0 +1,48 @@
import { Link, routes } from '@redwoodjs/router'
import Svg from 'src/components/Svg/Svg'
import { Popover } from '@headlessui/react'
Irev-Dev (Migrated from github.com) commented 2021-04-27 10:49:20 +02:00

I'm not sure what we're missing out on by using the popover instead, probably some good accessibility defaults. I say I think menu would be better just from the description of when menu and popover should be used from the docs.

I'm not sure what we're missing out on by using the popover instead, probably some good accessibility defaults. I say I think menu would be better just from the description of when menu and popover should be used from the docs.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 10:53:38 +02:00
Irev-Dev (Migrated from github.com) commented 2021-04-27 10:53:37 +02:00

Good point, I centralised these things a bit more in 924de4c
We could put new colors into the tailwind config, but I wasn't sure it was worth it without properly picking a theme.

Good point, I centralised these things a bit more in 924de4c We could put new colors into the tailwind config, but I wasn't sure it was worth it without properly picking a theme.
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 10:53:59 +02:00
Irev-Dev (Migrated from github.com) commented 2021-04-27 10:53:58 +02:00

Yup fixed this up.

Yup fixed this up.
jmwright (Migrated from github.com) reviewed 2021-04-27 12:04:42 +02:00
@@ -37,3 +37,3 @@
<Router>
<Route path="/dev-ide" page={DevIdePage} name="devIde" />
<Route path="/dev-ide/{cadPackage}" page={DevIdePage} name="devIde" />
<Route path="/policies/privacy-policy" page={PrivacyPolicyPage} name="privacyPolicy" />
jmwright (Migrated from github.com) commented 2021-04-27 12:04:42 +02:00

I think for parts that are hosted on github, in order for users to make the integration work they will need to include a cadhub.json in the root of the project

Maybe in the future it could also have an array of files/directories that are dependencies so they can be collected by CadHub before execution?

I was just trying to say for projects like this where they are not stored in our db but on github we can put insist on the cad-package info being in the repo (we could store meta-data in our db about projects but I think that defeats the purpose, better to have the repo to contain all the config).

In the future for performance reasons, would it make sense to cache the CodeCAD from GitHub on your side and only update that when a change is pushed to the main branch?

> I think for parts that are hosted on github, in order for users to make the integration work they will need to include a cadhub.json in the root of the project Maybe in the future it could also have an array of files/directories that are dependencies so they can be collected by CadHub before execution? > I was just trying to say for projects like this where they are not stored in our db but on github we can put insist on the cad-package info being in the repo (we could store meta-data in our db about projects but I think that defeats the purpose, better to have the repo to contain all the config). In the future for performance reasons, would it make sense to cache the CodeCAD from GitHub on your side and only update that when a change is pushed to the main branch?
Irev-Dev (Migrated from github.com) reviewed 2021-04-27 12:34:50 +02:00
@@ -37,3 +37,3 @@
<Router>
<Route path="/dev-ide" page={DevIdePage} name="devIde" />
<Route path="/dev-ide/{cadPackage}" page={DevIdePage} name="devIde" />
<Route path="/policies/privacy-policy" page={PrivacyPolicyPage} name="privacyPolicy" />
Irev-Dev (Migrated from github.com) commented 2021-04-27 12:34:49 +02:00

Maybe in the future it could also have an array of files/directories that are dependencies so they can be collected by CadHub before execution?

Maybe, I know that it's possible to do a shallow clone, so maybe that will be fast enough that won't need an array of files but I guess performance might be the decider. In an ideal world I would prefer not to as that feels like an implementation leak to me, but we'll see.

In the future for performance reasons, would it make sense to cache the CodeCAD from GitHub on your side and only update that when a change is pushed to the main branch?

I think long term some kind of caching makes sense. A friend of mine suggested "you can make the lambda post a SQS message and then use the docker container to process an SQS queue" so if I stick with AWS that might be an option that's more cache friendly than the current docker-lamda setup.

> Maybe in the future it could also have an array of files/directories that are dependencies so they can be collected by CadHub before execution? Maybe, I know that it's possible to do a shallow clone, so maybe that will be fast enough that won't need an array of files but I guess performance might be the decider. In an ideal world I would prefer not to as that feels like an implementation leak to me, but we'll see. > In the future for performance reasons, would it make sense to cache the CodeCAD from GitHub on your side and only update that when a change is pushed to the main branch? I think long term some kind of caching makes sense. A friend of mine suggested "you can make the lambda post a SQS message and then use the docker container to process an SQS queue" so if I stick with AWS that might be an option that's more cache friendly than the current docker-lamda setup.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: h3n3/cadhub#281