untangled

NEW CHANNEL: #fulcro
cjmurphy 2016-08-15T03:20:56.000458Z

Regarding deploying webapps where apache2 is the front end to the Internet. Once a webapp server process is up and running there's an extra step that a file in /etc/apache2/sites-enabled needs to be altered to do the final routing to the outside world. For Scala.js and Sente server processes the following approach has worked fine:

ProxyPass /app-name <http://0.0.0.0:8082/app-name>
 ProxyPassReverse /app-name <http://0.0.0.0:8082/app-name>
However this approach doesn't work with Untangled. I can deploy one Untangled webapp. But I can't seem to be able to deploy more than one. I always get stuck at the point where messages to the Chrome dev console say that /api can't be found. I don't want /api to be looked for, but rather /app-name/api.

grzm 2016-08-15T13:53:26.000462Z

@cjmurphy: It looks like you can supply a different networking object to the untangled client which allows you to specify the server endpoint it talks to: https://github.com/untangled-web/untangled-client/blob/master/src/untangled/client/core.cljs#L20

grzm 2016-08-15T13:55:10.000464Z

On the untangled-server side, it looks like the route is hard-coded in the handler, though there may be a way to fake it with supplying extra routes. Or fork untangled-server. Or just use the Om Next library directly in your own backend.

tony.kay 2016-08-15T18:20:51.000465Z

@cjmurphy: You could use mod_rewrite. You're generally correct that we could provide more customization of the URL supported by the webapp itself. You could do as @grzm suggests. Not difficult, either. I'd be glad to entertain a PR on untangled-server to configure the API endpoint via the configuration file. It is a relatively simple change, since the config is injected. My basic approach at the moment would be to suggest offloading this as an operation concern (e.g. mod_rewrite).

tony.kay 2016-08-15T18:21:34.000466Z

ah, but you'd need at least virtual hosting. In other words route to the apps by vhost name instead of path in URL

grzm 2016-08-15T19:25:25.000467Z

I'm updating initial state, passing in a current-user id in a method similar to that laid out by the open-id client (https://github.com/untangled-web/untangled-client/blob/master/src/untangled/openid_client.cljs)

grzm 2016-08-15T19:26:13.000469Z

I then get a warning when I also add an initial state to my root element. Is there a better way for me to get the current-user id into the app state?

grzm 2016-08-15T19:28:19.000470Z

I guess I could just take the all the initial app state that I would put in the initial element and also inject that at the same time I'm adding the current-user, though that seems kinda hacky.

grzm 2016-08-15T19:44:37.000471Z

@tony.kay: any reason you use clz instead of this when referring to the component in initial-state function definitions?

tony.kay 2016-08-15T20:06:44.000473Z

@grzm to stress the fact that it is created initially, which means you're passing in the component class, not a component instance (from a factory).

grzm 2016-08-15T20:07:22.000474Z

@tony.kay: What's the mnemonic? Class?

tony.kay 2016-08-15T20:07:29.000475Z

ah, yes...class

tony.kay 2016-08-15T20:07:48.000476Z

I'm allergic to using the word class, since it is reserved in so many languages 😉

grzm 2016-08-15T20:07:54.000477Z

Understood 🙂

grzm 2016-08-15T20:09:10.000478Z

It's a departure from the use of this for all of the the other static functions like IQuery/query, which confused me at first.

tony.kay 2016-08-15T20:09:25.000479Z

@jasonjckn: not sure why that would be.

tony.kay 2016-08-15T20:10:19.000480Z

@grzm My thinking was that ident, for example, is used with component instances...e.g. with data plugged in.

2016-08-15T20:10:52.000481Z

it's interesting how it does it just for the first key in the vector

tony.kay 2016-08-15T20:11:15.000482Z

@grzm you need that extra arg because it is a protocol, but since it is "static", it is a little odd with respect to the OOP ideas.

tony.kay 2016-08-15T20:11:32.000483Z

you could be passing the class as the "instance", or an actual instance

tony.kay 2016-08-15T20:12:46.000484Z

@jasonjckn: It was a pretty simple change, so I'm not sure why it would not work right. Feel free to submit an issue. I've been crazy busy, so if you see the problem feel free to send a PR

grzm 2016-08-15T20:12:53.000485Z

gotcha

2016-08-15T20:12:54.000486Z

k

grzm 2016-08-15T20:13:02.000487Z

yeah, ident is a little strange

2016-08-15T20:13:10.000488Z

yah I tried to see if it was a quick fix, but on first inspection the source code looked right

2016-08-15T20:13:23.000489Z

i'll maybe take another look

2016-08-15T20:13:35.000490Z

not a huge deal eitherway

tony.kay 2016-08-15T20:14:21.000491Z

perhaps your diff alg is off?

tony.kay 2016-08-15T20:17:11.000492Z

Remember that the global marker (at the root) is still set

tony.kay 2016-08-15T20:17:55.000493Z

@jasonjckn: I'm not familiar with your app or output...

2016-08-15T20:18:24.000494Z

my diff algo is your diff algo from untangled-spec

2016-08-15T20:18:35.000495Z

i think the marker is definitely there

tony.kay 2016-08-15T20:18:37.000496Z

ah...well, isn't it just showing the global marker?

2016-08-15T20:18:53.000498Z

what's the global marker? ui/loading-data?

tony.kay 2016-08-15T20:18:57.000499Z

yes

2016-08-15T20:19:19.000500Z

yah that show sup in the diff algo too, but i don't care about that, I care about how :env-vars is getting a marker

tony.kay 2016-08-15T20:19:19.000501Z

marker false means you don't want loading markers placed where the data is targeted

tony.kay 2016-08-15T20:19:30.000502Z

The global marker is for showing a global "loading/network" indicator

tony.kay 2016-08-15T20:19:37.000503Z

the latter is always updated

tony.kay 2016-08-15T20:20:01.000504Z

e.g. load-field would put a loading marker on some deep spot in your app state

2016-08-15T20:20:12.000506Z

there's the marker that shows up, even with :marker false

tony.kay 2016-08-15T20:20:45.000507Z

ah, I see

2016-08-15T20:20:49.000508Z

here's the code

(df/load-data reconciler [:env-vars :login-profile :entitlements] :marker false)

tony.kay 2016-08-15T20:20:55.000509Z

yeah, that does look like a marker inside of your data

2016-08-15T20:20:57.000510Z

as I said it only shows up for :env-vars interestingly

2016-08-15T20:21:12.000511Z

the other keys are loaded without markers

tony.kay 2016-08-15T20:22:04.000512Z

Yeah, submit an issue on it. I think the code may be only touching the first thing queried...which might be a separate issue.

tony.kay 2016-08-15T20:22:38.000513Z

I don't remember...I assume you've checked that :marker is the correct option name 🙂

2016-08-15T20:29:54.000515Z

i'll create an issue, yah I checked that