Wakoma / nimble

The nimble. An open source, rapidly deployable, wireless mesh network.
CERN Open Hardware Licence Version 2 - Strongly Reciprocal
56 stars 9 forks source link

Fixed the server and added some base features for demos #70

Closed jmwright closed 1 month ago

jmwright commented 1 month ago

With the exception of allowing download of individual components (which might end up being a #wontfix anyway), the server is fixed and has a couple of new features.

  1. The component drop downs are now populated based on the devices.json file, and any components that are missing necessary metadata ("HeightUnits") are filtered out so that you cannot generate a broken config.
  2. There is a 3D preview that loads the generated glTF (*.glb) file for the assembly. This 3D preview should dynamically update whenever a new build is finished generating (at the same time the zip file should download).

This is a contrived screenshot. The preview actually works, and has full 3D mouse controls. Screenshot from 2024-05-21 14-38-47

This server is still a mess in some ways. The generate call blocks, and special care will be needed to make that work async without breaking the server framework (it is weird about spinning off threads from within it's own threads). This means that it is not ready for multiple simultaneous users. However, it should work fine for a local demo on a laptop.

Caching is still in place, but works differently than before. Both the build zip file and the glTF file are both cached.

@julianstirling If you get a chance, you could see if you can get this running on your local machine. The requirements.txt in the server directory has been updated, and is what I am running on.

julianstirling commented 1 month ago

It works! image

Is it possible to add the assembly-docs folder to the cache? And then make a simple server route that serves from this directory? I think it would be great if once generated, the rack pops up and underneath there was a big button saying something like "Go to assembly documentation" and perhaps a smaller one that was "download zip".

julianstirling commented 1 month ago

Also.. the preview is upside down, but the controls are gimbal locked so you can't spin it the right way up.

jmwright commented 1 month ago

Is it possible to add the assembly-docs folder to the cache? And then make a simple server route that serves from this directory?

That should be possible. I'll give it a try.

Also.. the preview is upside down, but the controls are gimbal locked so you can't spin it the right way up.

Yeah, I haven't figured out the model-viewer options to fix the gimbal lock yet. I can at least set the view to be right side up by default with the view direction settings.

jmwright commented 1 month ago

@julianstirling I fixed the issue with the preview being upside down. Hosting the resulting assembly-docs directory will take a little longer.

Screenshot from 2024-05-22 06-57-37

jmwright commented 1 month ago

Something else that should not be too hard, is to start with no drop downs. There would be an add button for each component type, something like Add Access Point, Add Router, Add Server and Add Switch. Clicking an Add * button would add a corresponding drop down. Then the rack can be built in any order, with any mix of components.

jmwright commented 1 month ago

@julianstirling Your suggestions have been implemented.

  1. Fix the view being upside down.
  2. Add a button to view the generated assembly documentation.

In addition, I have renamed test_page to configurator because I think we've gone past the test_page stage.

Screenshot from 2024-05-22 10-02-16

I think I'll go ahead and take a shot at making the drop downs configurable.

jmwright commented 1 month ago

Ok, there are improvements that could be made, but I am going to stop and wait for feedback. The UI is dynamic now, allowing for arbitrarily complex racks to be configured. Setting a drop down to None will cause it to be removed/ignored. There is no reordering of rack components, so you have to remove components and re-add them if you make a mistake in ordering.

One question I have is whether or not the rack's CAD model is being built in the right order relative to the order of the drop downs in the UI. I'm not sure if it should be bottom-up or top-down relative to how the controls are arranged in the UI.

Screenshot from 2024-05-22 11-30-11

jmwright commented 1 month ago

@julianstirling If you want to completely clear the cache during testing (start from scratch), delete the contents of the _cache_ and server/static/builds directories. I copy the cached assembly-docs directories to the static directory for now rather than creating dynamic static directories via the web framework.

The cache is keyed on the existence of the build zip file that gets sent to the client, so a dirty cache clear can be completed by deleting the zip file, which should trigger a new build. All the other directories for that specific configuration should be re-created. If the order of the components in the config is changed, it should be treated as a completely different build.

jmwright commented 1 month ago

How do I actually suggest code changes rather than just adding comments?

Click the commit diff button shown below and then edit the contents inside the suggestion block.

Screenshot from 2024-05-23 07-48-44

jmwright commented 1 month ago

@julianstirling I think all the comments have been resolved now. I also moved the loading spinner up to the same area as the 3D preview, and toggle the visibility now so that it does not look like a left-over preview belongs to a new config. It causes a quick flash when requesting a cached config while running locally, but I think that is the price we pay for making sure users are not seeing old previews for new configs while the new preview is loading.

julianstirling commented 1 month ago

Perfect. Merge is approved so feel free to merge when you are ready.