Skip to content

Commit c9f09da

Browse files
authored
Assimilate model dashboard (#376)
* clone ui over, remove its git history * Make nvmrc in granary-ui a symlink * Install elm and elm format in scripts/update * Add frontend building to scripts/update * Serve model dashboard from Granary server * serve from granary server * spelling * build frontend in ci _better_ * update readmes * Add missing dependency * map root to index * make sure elm-stuff dir exists before first container compile
1 parent ed358ce commit c9f09da

23 files changed

+20103
-21
lines changed

README.md

+77-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ An API project that uses http4s and doobie
88

99
## Quick Setup
1010
```
11+
nvm use
12+
./scripts/setup
1113
./scripts/update
1214
```
1315

14-
Then `ssh` into the machine when that is complete and start the server with `./scripts/server`. In another shell inside the VM you should be able to make a request:
15-
16-
`http :8080/api/hello/world`
16+
Then start the server with `[AWS_PROFILE=<profile>] [AWS_REGION=<region>] ./scripts/server`.
17+
You should then be able to hit `localhost:8080/index.html` in a browser.
1718

1819
## Developing
1920

21+
### API development
22+
2023
It's easier to test changes with the API with [HTTPie](https://httpie.org/) and the
2124
[HTTPie JWT Auth plugin](https://github.com/teracyhq/httpie-jwt-auth) in order to make
2225
authentication with APIs as seamless as possible. All following commands assume
@@ -25,23 +28,90 @@ you have those available.
2528
To add a token for use with HTTPie, use `./scripts/dbshell` to insert a token like this:
2629
`insert into tokens (id) values (uuid_generate_v4());`
2730

28-
### Nexus Repository Manager
31+
#### Nexus Repository Manager
2932

3033
When developing at the Azavea office, strongly consider use of the Nexus proxy. This is automatically configured in project setup. If you are not connected to the `vpn` you will need to disable it by deleting or moving `.sbtopts`.
3134

32-
### Project Organization
35+
#### Project Organization
3336

3437
By default the backend is organized into 3 subprojects:
3538
- api: handles all routes, authentication, and services
3639
- datamodel: case classes for data the api operates on
3740
- database: handles database interaction with models
3841

39-
### Migrations
42+
#### Migrations
4043
This project uses [flyway](https://flywaydb.org/) for migrations. The migrations are stored in the database subproject (`database/src/main/resources/db/migrations`). For information on the naming and formatting conventions consult the [documentation](https://flywaydb.org/documentation/migrations#naming). Each migration should be `sql` and generally follows the format of `V<number>__<description>.aql`.
4144

4245
Running migrations and other tasks are managed through `./scripts/migrate`.
4346

44-
### Development workflow
47+
#### Development workflow
4548
Usually at least two terminals should be open for doing development. The first terminal is where `sbt` should be run (`./scripts/console sbt`). In this terminal tests can be run, projects compiled, and the server assembled.
4649

4750
The other terminal is where the server should be run `./scripts/server` or other one-off commands. To see changes you made to the API live you will need to first `assemble` the `jar` for the `api` server.
51+
52+
### UI Development
53+
54+
You can find files for the user interface under [`granary-ui/`](./granary-ui). To get set up with Elm, you'll
55+
want to make sure a few things are on your path. If you followed the [Quick Setup](#quick-setup) instructions, you have these already.
56+
57+
- [`elm-format`](https://github.com/avh4/elm-format)
58+
- [`elm`](https://guide.elm-lang.org/install/elm.html)
59+
60+
Currently, the entire UI application lives in a single file. The reason for that is the note under
61+
[Culture Shock](https://guide.elm-lang.org/webapps/structure.html) in the Elm guide, specifically:
62+
63+
> In JavaScript, the longer your file is, the more likely you have some sneaky mutation that will cause a really difficult bug. But in Elm, that is not possible! Your file can be 2000 lines long and that still cannot happen.
64+
65+
That may change as we separate pages.
66+
67+
#### First steps in this app
68+
69+
Like any of our recent frontend applications, start with `nvm use`. Whenever you make changes that you'd
70+
like to see served, run `./scripts/update --frontend`. This will:
71+
72+
- recompile the application if that somehow hasn't already happened via your editor
73+
- build the `index.html` page to serve
74+
- copy everything in `granary-ui/public` into the magic directory under `api/src/main/resources/`.
75+
76+
Hot reloading is disabled because we're serving the application from Http4s instead of with Webpack,
77+
but you don't have to restart the server when you make changes and compilation is _really_ fast, so
78+
it's really not so bad.
79+
80+
#### Editor setup
81+
82+
There are a number of good editor integrations available for Elm. The one I'm
83+
most used to is the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=Elmtooling.elm-ls-vscode), which
84+
uses the Language Server Protocol and therefore feels very familiar to Scala/TypeScript development in VSCode.
85+
86+
If you don't want to use VSCode, there are a number of other plugins listed [here](https://github.com/elm/editor-plugins).
87+
Anecdotally, the community seems really to like the IntelliJ plugin. I think @pcaisse has had some luck with the Vim plugin.
88+
I've had some luck with the emacs plugin in my old Spacemacs days, but it's been a while so I have no idea what that's like
89+
at this point.
90+
91+
You may end up in an annoying situation where the VSCode plugin and `nvm` stop getting along and VSCode can't find
92+
your elm binaries. In that case, you can specify the path to `elm-format` and `elm` in the settings:
93+
94+
- press `Ctrl + ,`
95+
- search `elm`
96+
- use `which foo` to find the path that `nvm` knows about and fill it in in the appropriate box
97+
98+
#### Adding a dependency
99+
100+
Elm dependencies are fully managed. If you want to add one, use
101+
`elm-install <maintainer>/<package-name>`. For example, to install the
102+
`elm-ui-framework` pacakge, you'd enter:
103+
104+
```bash
105+
$ elm install Orasund/elm-ui-framework
106+
```
107+
108+
You'll then be prompted to confirm that Elm's plan is a good one, then you're
109+
good to go.
110+
111+
#### Elm getting started
112+
113+
If you'd like a quick introduction to Elm, the [Architecture](https://guide.elm-lang.org/architecture/)
114+
and [Types](https://guide.elm-lang.org/types/) sections of the guide should be
115+
helpful. They'll at least help you get used to what the syntax looks like.
116+
If you'd like to learn about the Elm runtime, the [Commands and Subscriptions](https://guide.elm-lang.org/effects/)
117+
section is a good guide.
14.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)