mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-archive.git
synced 2025-01-25 19:36:17 +00:00
”2016-08-08”
This commit is contained in:
parent
f6d82ad2c1
commit
fac5f7cd45
@ -34,6 +34,10 @@ var heating_v1 = require('./routes/heating_v1');
|
||||
var projector_v1 = require('./routes/projector_v1');
|
||||
var isProduction = false;
|
||||
|
||||
var mdotApi = require('./lib/mdot/api.js');
|
||||
|
||||
|
||||
|
||||
|
||||
function restartTimer() {
|
||||
// Ibm / mqtt things go a bit weird if left on for too long so restart the server
|
||||
@ -133,6 +137,9 @@ app.post('/api/calendar/extend', function(req, res) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Events and sockets
|
||||
|
||||
busEmitter.on('clientConnected', (socketSet) => {
|
||||
@ -256,6 +263,10 @@ app.post('/api/v1/extend', function(req, res) {
|
||||
|
||||
});
|
||||
|
||||
mdotApi(app);
|
||||
|
||||
//app.get('/api/mdot/:id', mDot.getData);
|
||||
|
||||
app.listen(3000, function() {
|
||||
logger.info('Express listening on 3000');
|
||||
restartTimer();
|
||||
|
@ -212,8 +212,9 @@
|
||||
console.log(fetchObj.data);
|
||||
}
|
||||
if (this.model.has('device')) {
|
||||
//FetchObj.data = $.param({key:'"'+ this.model.get('device') + '"'});
|
||||
this.collection.url = 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/mDot/devices/' + this.model.get('device');
|
||||
// FetchObj.data = $.param({key:'"'+ this.model.get('device') + '"'});
|
||||
// this.collection.url = 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/mDot/devices/' + this.model.get('device');
|
||||
this.collection.url = '/api/mdot/' + this.model.get('device');
|
||||
// this.collection.url = 'http://127.0.0.1:5984/mdot/_design/getDevice/_view/getDevice';
|
||||
this.collection.fetch(fetchObj);
|
||||
} else {
|
||||
|
47
smartoffice/SODashServer/SODashServer/lib/mdot/api.js
Normal file
47
smartoffice/SODashServer/SODashServer/lib/mdot/api.js
Normal file
@ -0,0 +1,47 @@
|
||||
var logger = require('log4js').getLogger();
|
||||
var util = require('util');
|
||||
|
||||
var mdot = require('./mdot.js');
|
||||
|
||||
module.exports = function(app) {
|
||||
var express = require('express');
|
||||
var mdotRouter = express.Router();
|
||||
|
||||
mdotRouter.get('/:id', function(req, res) {
|
||||
console.log(req.headers);
|
||||
|
||||
var data = {};
|
||||
logger.debug('mDot-GetData');
|
||||
logger.debug(req);
|
||||
|
||||
if (!req.params.id) {
|
||||
logger.error('MDot','Missing required paramter');
|
||||
res.status(400).send({
|
||||
status: 'error',
|
||||
error: 'missing required parameter'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(req.params.id);
|
||||
|
||||
if (req.params.hasOwnProperty('id')) {
|
||||
data.id = req.params.id;
|
||||
|
||||
logger.debug(data);
|
||||
|
||||
|
||||
mdot.doGet()
|
||||
.then(() => {
|
||||
'use strict';
|
||||
console.log('outside the promise');
|
||||
});
|
||||
|
||||
//logger.debug(util.inspect(mdot,{showHidden:true}));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
app.use('/api/mdot/', mdotRouter);
|
||||
};
|
||||
|
18
smartoffice/SODashServer/SODashServer/lib/mdot/mdot.js
Normal file
18
smartoffice/SODashServer/SODashServer/lib/mdot/mdot.js
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
var logger = require('log4js').getLogger();
|
||||
|
||||
|
||||
var self = module.exports = {
|
||||
|
||||
|
||||
doGet : function(data) {
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
logger.debug('doGet Promise');
|
||||
resolve('');
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user