From e78a5aee32d0494568e3934cd561fade62a13bc6 Mon Sep 17 00:00:00 2001 From: Carlos Romero Brox Date: Thu, 23 May 2013 17:32:39 +0200 Subject: [PATCH] Fix #137 Type and org info in GET /queue --- lib/agent.js | 10 +++++----- lib/agentLogic.js | 10 +++++----- lib/prefixer.js | 8 ++++++-- lib/views/queues.jade | 4 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/agent.js b/lib/agent.js index e07bc43..763963c 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -83,12 +83,12 @@ var start = function start(done) { emitter = emitterModule.getEmitter(); app = express(); - app.prefix = 'UNSEC:'; + app.prefix = 'UNSEC'; app.port = config.agent.port; app._backlog = 2048; apps.push(app); - var secureOptions; + var secureOptions, options; dirModule = path.dirname(module.filename); logger.info('config.enableSecure', config.enableSecure); @@ -114,7 +114,7 @@ var start = function start(done) { fs.statSync(secureOptions.key).isFile() && fs.statSync(secureOptions.cert).isFile()) { - var options = { + options = { key: fs.readFileSync(secureOptions.key), cert: fs.readFileSync(secureOptions.cert) }; @@ -126,7 +126,7 @@ var start = function start(done) { appSec = express(); appSec.secOptions = options; - appSec.prefix = 'SEC:'; + appSec.prefix = 'SEC'; appSec.isSecure = true; appSec.port = Number(config.agent.port) + 1; @@ -157,7 +157,7 @@ var start = function start(done) { app.server = http.createServer(app).listen(app.port); } configureSocketIO(app); - logger.info('PopBox listening on', app.prefix + app.port); + logger.info('PopBox listening on', app.prefix + ':' + app.port); }); } }); diff --git a/lib/agentLogic.js b/lib/agentLogic.js index 3d02d44..376c76a 100644 --- a/lib/agentLogic.js +++ b/lib/agentLogic.js @@ -312,11 +312,11 @@ function queueSize(req, res) { } function getQueue(req, res) { - 'use strict'; - var queueId = req.param('id'); - var prefix = req.prefix; - req.template = 'queues.jade'; + var queueId = req.param('id'), + prefix = req.prefix; + + req.template = 'queues.jade'; dataSrv.getQueue(prefix, queueId, function onGetQueue(err, hQ, lQ, lastPop, blocked) { if (err) { @@ -338,7 +338,7 @@ function getQueue(req, res) { req.info ]); res.send({ok: true, host: req.headers.host, lastPop: lastPop, blocked: blocked, - size: hQ.length + lQ.length, high: hQ, low: lQ }); + size: hQ.length + lQ.length, high: hQ, low: lQ , type: req.type, org: req.org}); } }); } diff --git a/lib/prefixer.js b/lib/prefixer.js index 6ec391f..448b2b4 100644 --- a/lib/prefixer.js +++ b/lib/prefixer.js @@ -18,11 +18,15 @@ For those usages not covered by the GNU Affero General Public License please contact with::dtc_support@tid.es */ +'use strict'; + var config = require('./config.js'); -function prefixer(prefix) { - 'use strict'; +function prefixer(type) { + var prefix = type + ":"; return function (req, res, next) { var orgName = config.oauthIdToken || req.param('id_org'); + req.type = type; + req.org = orgName; req.prefix = (orgName ? orgName + ':' : '') + prefix; next(); }; diff --git a/lib/views/queues.jade b/lib/views/queues.jade index 7f4bdd8..2d52ca7 100644 --- a/lib/views/queues.jade +++ b/lib/views/queues.jade @@ -13,6 +13,10 @@ p last pop: end p Blocked: span#blocked #{blocked} +p Type: + span#type #{type} +p Org: + span#org #{org} p HIGH PRIORITY QUEUES - var baseurl ='http://'+host+'/trans/' #high