Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on variable name spaces #22

Closed
gregwaehner opened this issue Jun 25, 2014 · 5 comments
Closed

Question on variable name spaces #22

gregwaehner opened this issue Jun 25, 2014 · 5 comments
Labels

Comments

@gregwaehner
Copy link
Contributor

Hey there - been working on consolidating the db config and the new bg thresholds into a single config file tonight. I modified server.js to suck in the name/value pairs. Where I'm stuck is figuring out how to get the "bgLow" and "bgHigh" variables accessible to /js/client.js... which is still executed on the server-side.

In my servlet and JSP days I had page and session and global contexts to place variables, but I can't quite figure out how to do it in this context. I'm new to node.js and searched around but there's a lot about Express, but it doesn't appear to be doing that.

Can you point me in the right direction? I'm really trying to get this done in order to make available "step 1" of the improved user configuration. I know discussion included a gui, putting into a db, etc... but I'm trying to take one step at a time.

Update 6/25 1pm ET: I went into client.js and replaced the bg values of 80 with "bgLow" and 180 with "bgHigh". Then I created two new variables within client.js (taking server.js out of the equation) for bgLow (70) and bgHigh (200) to visually confirm the lines on the graph are updated -- but they remain 80 and 180. So I'm trying to understand if I could be getting whacked by the nodeStatic caching? I can hit the /nightscout.appcache and see the cache configuration, and the setting is for 30 days or something.

Here's an example of what I'm doing...

// add a y-axis line that shows the low bg threshold
focus.append('line')
.attr('class', 'low-line')
.attr('x1', xScale(dataRange[0]))
.attr('y1', yScale(bgLow))
.attr('x2', xScale(dataRange[1]))
.attr('y2', yScale(bgLow))
// .attr('y2', yScale(80))
.style('stroke-dasharray', ('3, 3'))
.attr('stroke', 'grey');

So...

  1. Am I editing the correct file (client.js)?
  2. Is there a way to force clear the cache (rather than comment out the code)?

Thanks

  • Greg
@bewest
Copy link
Member

bewest commented Jun 26, 2014

Typical way to do this is to create a new endpoint:
/config.json, and register a new endpoint handler to dump those out as a valid json datastructure.

The in client.js, we'll make an ajax request to /config.json to fetch the config json over http.

@bewest
Copy link
Member

bewest commented Jun 26, 2014

Would be simpler to put a <script src="/config.js"></script> and have the /config.js endpoint dump eg window.nightscoutConfig = { foo: 'bar'}; or something also. Then you can refer to nightscoutConfig in client.js.

@jasoncalabrese
Copy link
Member

I'd rather store this stuff in mongo than force everyone to edit a configuration file. Also the alerts aren't triggered off the high/low lines now so there will be some confusion with that.

@brianhanifin
Copy link
Contributor

Sorry if I am being overzealous by closing this, the amount of open issues is messing with my "ADD". ;) You are welcome to reopen it if you like.

@jasoncalabrese
Copy link
Member

Makea send to close, I think the settings api will take care of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants