From 825b0fb22f75dbfd0b955037ad1f64e365fef6dd Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 19 Apr 2018 20:46:01 +0100 Subject: [PATCH] Update locales module to new structure --- red/api/editor/index.js | 5 ++--- red/api/editor/locales.js | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/red/api/editor/index.js b/red/api/editor/index.js index d204d9411..10f3c70b7 100644 --- a/red/api/editor/index.js +++ b/red/api/editor/index.js @@ -83,7 +83,7 @@ module.exports = { // Locales var locales = require("./locales"); - locales.init(runtime); + locales.init(runtimeAPI); editorApp.get('/locales/nodes',locales.getAllNodes,apiUtil.errorHandler); editorApp.get(/locales\/(.+)\/?$/,locales.get,apiUtil.errorHandler); @@ -124,6 +124,5 @@ module.exports = { }); }, stop: comms.stop, - publish: comms.publish, - registerLibrary: library.register + publish: comms.publish } diff --git a/red/api/editor/locales.js b/red/api/editor/locales.js index 32bfa5c80..464933d90 100644 --- a/red/api/editor/locales.js +++ b/red/api/editor/locales.js @@ -16,13 +16,14 @@ var fs = require('fs'); var path = require('path'); //var apiUtil = require('../util'); -var i18n; -var redNodes; + +var i18n = require("../../util").i18n; // TODO: separate module + +var runtimeAPI; module.exports = { - init: function(runtime) { - i18n = runtime.i18n; - redNodes = runtime.nodes; + init: function(_runtimeAPI) { + runtimeAPI = _runtimeAPI; }, get: function(req,res) { var namespace = req.params[0]; @@ -40,13 +41,17 @@ module.exports = { }, getAllNodes: function(req,res) { var lngs = req.query.lng; - var nodeList = redNodes.getNodeList(); - var result = {}; - nodeList.forEach(function(n) { - if (n.module !== "node-red") { - result[n.id] = i18n.catalog(n.id,lngs)||{}; - } - }); - res.json(result); + var opts = { + user: req.user + } + runtimeAPI.nodes.getNodeList(opts).then(function(nodeList) { + var result = {}; + nodeList.forEach(function(n) { + if (n.module !== "node-red") { + result[n.id] = i18n.catalog(n.id,lngs)||{}; + } + }); + res.json(result); + }) } }