Commit 61ece13174e5bdc3882d5fc3150dd93e24055deb

Authored by Adhidarma Hadiwinoto
1 parent c07af346e0
Exists in master and in 1 other branch webadmin

res.locals.config

Showing 3 changed files with 7 additions and 7 deletions Side-by-side Diff

lib/webadmin/index.js
... ... @@ -10,10 +10,6 @@ const logger = require('komodo-sdk/logger');
10 10 const routerConfig = require('./router/config');
11 11  
12 12 const app = express();
13   -app.use((req, res, next) => {
14   - res.locals.main_config = config;
15   - next();
16   -});
17 13  
18 14 nunjucks.configure('./webadmin-views', {
19 15 autoescape: true,
... ... @@ -37,6 +33,11 @@ const accessLogStream = rfs.createStream(
37 33  
38 34 app.use(morgan('combined', { stream: accessLogStream }));
39 35  
  36 +app.use((req, res, next) => {
  37 + res.locals.config = config;
  38 + next();
  39 +});
  40 +
40 41 app.get('/', (req, res) => {
41 42 res.redirect('/config/modem');
42 43 });
lib/webadmin/router/config.js
... ... @@ -16,7 +16,6 @@ async function writeConfigFile() {
16 16  
17 17 function pageMain(req, res) {
18 18 res.render('config.index.html', {
19   - config: JSON.stringify(config, null, 4),
20 19 modems: orderBy(config.modems, [(v) => v.name], ['asc']),
21 20 baseUrl: req.baseUrl,
22 21 });
webadmin-views/template.starter.html
... ... @@ -7,7 +7,7 @@
7 7 <meta name="description" content="">
8 8 <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
9 9 <meta name="generator" content="Jekyll v3.8.6">
10   - <title>{{ main_config.name }}</title>
  10 + <title>{{ config.name }}</title>
11 11  
12 12 <!-- Bootstrap core CSS -->
13 13 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
... ... @@ -44,7 +44,7 @@
44 44 </head>
45 45 <body>
46 46 <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
47   - <a class="navbar-brand" href="#">{{ main_config.name }}</a>
  47 + <a class="navbar-brand" href="#">{{ config.name }}</a>
48 48 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
49 49 <span class="navbar-toggler-icon"></span>
50 50 </button>