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

Fiqare perseo-fe improvements #419

Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
c620a0a
Fixed issue in lib/appContext.js
fiqare-emergya-dev Feb 12, 2019
b1eb8fa
Fixed issues in lib/db.js
fiqare-emergya-dev Feb 13, 2019
d38ffcc
Fixed issue in lib/models/actions.js
fiqare-emergya-dev Feb 13, 2019
f18f17b
Fixed issues in lib/models/executionsStore.js
fiqare-emergya-dev Feb 13, 2019
fb9cb75
Fixed issue in lib/models/notices.js
fiqare-emergya-dev Feb 13, 2019
d9d800d
Fixed issue in lib/models/updateAction.js
fiqare-emergya-dev Feb 13, 2019
e666027
Fixed issue in lib/models/perseo.js
fiqare-emergya-dev Feb 13, 2019
5f799c9
Fixed issue in lib/models/actionsController.js
fiqare-emergya-dev Feb 13, 2019
460c75f
Merge pull request #1 from Emergya/284633
fiqare-emergya-dev Feb 13, 2019
24bbb3f
Fixed issue #284635 in lib/models/actions.js lib/models/actionsStore.…
fiqare-emergya-dev Feb 14, 2019
c87e96f
Merge pull request #2 from Emergya/284635
fiqare-emergya-dev Feb 14, 2019
26a081e
Fixed issue #284625 in lib/routes/actionsController.js
fiqare-emergya-dev Feb 25, 2019
9fdc5b9
Merge pull request #3 from Emergya/284625
fiqare-emergya-dev Feb 25, 2019
8200b45
Merge pull request #4 from Emergya/ci
fiqare-emergya-dev Mar 6, 2019
15c1d5d
Merge branch 'telefonicaid-master'
fiqare-emergya-dev Mar 6, 2019
2e81912
Merged from telefonicaid-perseo-fe:master
fiqare-emergya-dev Mar 6, 2019
a514588
Merge pull request #6 from Emergya/master
fiqare-emergya-dev Mar 6, 2019
b8b3ce2
Merge pull request #7 from telefonicaid/master
fiqare-emergya-dev Mar 19, 2019
ca2b66c
Merge pull request #8 from Emergya/master
fiqare-emergya-dev Mar 19, 2019
ea6a05d
Merged lib/db.js and lib/routes/actionsController.js from telefonicai…
fiqare-emergya-dev Mar 19, 2019
aa23fed
Merge pull request #9 from Emergya/master
fiqare-emergya-dev Mar 19, 2019
05ac1f4
Merge pull request #10 from Emergya/ci
fiqare-emergya-dev Mar 21, 2019
88344c8
Resolver issues Db.js #292343
fiqare-emergya-dev Mar 27, 2019
2e1025f
Resolver issues actions.js #292346
fiqare-emergya-dev Mar 27, 2019
e75d07d
Resolve issues actionsStore.js #292348
fiqare-emergya-dev Mar 27, 2019
2cd53b5
Resolve issues executionsStore.js
fiqare-emergya-dev Mar 27, 2019
a3c1cc1
Resolver issues Metrics.js #292352
fiqare-emergya-dev Mar 27, 2019
c012cdc
Resolver issues Notices.js #292353
fiqare-emergya-dev Mar 27, 2019
326a6b4
Resolver issues Rules.js #292363
fiqare-emergya-dev Mar 27, 2019
9e873b8
Resolver issues RulesStore.js #292365
fiqare-emergya-dev Mar 27, 2019
9b15277
Resolver issues smppAction.js #292366
fiqare-emergya-dev Mar 27, 2019
0695fef
Resolver issus updateAction.js #292368
fiqare-emergya-dev Mar 27, 2019
c0b8505
Resolver issues visualRules.js #292387
fiqare-emergya-dev Mar 27, 2019
c11d45d
Resolver issues myutils.js #292390
fiqare-emergya-dev Mar 27, 2019
05a5208
Resolver issues visualRulesController.js #292395
fiqare-emergya-dev Mar 27, 2019
e895b69
Merge pull request #11 from Emergya/perseo-frontend-jafernandez
fiqare-emergya-dev Mar 27, 2019
590de2a
Merge branch 'master' of https://github.com/Emergya/cdti-fiqare-perse…
fiqare-emergya-dev Mar 27, 2019
53c6052
Update version of docker image
fiqare-emergya-dev Mar 27, 2019
eedd341
Merge pull request #13 from Emergya/perseo-frontend-jafernandez
fiqare-emergya-dev Mar 27, 2019
8bda3a7
Merge pull request #12 from Emergya/ci
fiqare-emergya-dev Mar 27, 2019
e4e9bca
Resolver issues db.js #292343
fiqare-emergya-dev Apr 4, 2019
01ec831
Resolver issues action.js #292346
fiqare-emergya-dev Apr 4, 2019
805219b
Resolver issues emailAction.js #293783
fiqare-emergya-dev Apr 4, 2019
32662f4
Resolver issues rules.js #292363
fiqare-emergya-dev Apr 4, 2019
4cade58
Resolver issues visualRules.js #292388
fiqare-emergya-dev Apr 4, 2019
14a0867
Merge pull request #14 from Emergya/perseo-frontend-jafernandez
fiqare-emergya-dev Apr 4, 2019
ef334a6
Resolver issues config.js
fiqare-emergya-dev Apr 4, 2019
07c164e
Fix ip for mongo in docker
fiqare-emergya-dev Apr 4, 2019
1c894b0
Merge pull request #15 from Emergya/perseo-frontend-jafernandez
fiqare-emergya-dev Apr 4, 2019
e6b731a
Added Rules Swagger
fiqare-emergya-dev Sep 24, 2019
5d3fbc4
Merge pull request #16 from Emergya/third-iteration
fiqare-emergya-dev Sep 24, 2019
862b176
Revert "Third iteration"
fiqare-emergya-dev Sep 24, 2019
c68e52d
Merge pull request #17 from Emergya/revert-16-third-iteration
fiqare-emergya-dev Sep 24, 2019
6f64b09
Merge pull request #18 from Emergya/ci
fiqare-emergya-dev Sep 24, 2019
334a59e
Added documentation for developers
fiqare-emergya-dev Sep 30, 2019
6a10db1
Merge pull request #20 from Emergya/third-iteration
fiqare-emergya-dev Sep 30, 2019
e67403a
Merge pull request #21 from Emergya/ci
fiqare-emergya-dev Sep 30, 2019
fe26c90
Added full Swagger definition
fiqare-emergya-dev Sep 30, 2019
70da2e4
Merged rulesController
fiqare-emergya-dev Sep 30, 2019
8ab124b
Merge pull request #22 from Emergya/third-iteration
fiqare-emergya-dev Sep 30, 2019
3580b61
Merge pull request #23 from Emergya/ci
fiqare-emergya-dev Sep 30, 2019
7f7ad60
Fixed Swagger
fiqare-emergya-dev Sep 30, 2019
4a5b42e
Merge pull request #24 from Emergya/master
fiqare-emergya-dev Sep 30, 2019
fd6e450
Merge pull request #25 from Emergya/ci
fiqare-emergya-dev Sep 30, 2019
b54bc43
Updated to 1.10 release from telefonicaid/perseo-fe
fiqare-emergya-dev Nov 21, 2019
c5a694f
Updated to 1.10 release from telefonicaid/perseo-fe(2)
fiqare-emergya-dev Nov 21, 2019
6f05372
Updated to 1.10 release from telefonicaid/perseo-fe(3)
fiqare-emergya-dev Nov 21, 2019
9a77dbb
Merge branch 'telefonicaid-release/1.10.0'
fiqare-emergya-dev Nov 21, 2019
5440640
Travis CI
fiqare-emergya-dev Nov 21, 2019
41f9c68
Fixed travis errors
fiqare-emergya-dev Nov 21, 2019
75aa10d
Merge pull request #1 from Emergya/fiqare-perseo-fe-improvements
fiqare-emergya-dev Nov 21, 2019
f471ce2
Fixed travis errors(2)
fiqare-emergya-dev Nov 21, 2019
14b1aa9
Fixed travis errors(3)
fiqare-emergya-dev Nov 21, 2019
e090738
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
4db0223
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
ec05fb7
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
1bfb721
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
13089b0
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
88ad953
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
dd56330
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
e71c7e6
Revert issue javascript:VariableShadowing
fiqare-emergya-dev Dec 16, 2019
97bc1f3
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
c08843e
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
94fa819
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
57334b9
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
9a0e631
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
9e975a9
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
27716c8
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
c6604b0
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
f3a905a
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
c1cddf2
Revert issue javascript:S1226
fiqare-emergya-dev Dec 16, 2019
e622aa3
Fixed rules.js
fiqare-emergya-dev Dec 16, 2019
70a972d
Fixed db IP
fiqare-emergya-dev Dec 16, 2019
bd3c7b2
Added branch to Travis build
fiqare-emergya-dev Dec 16, 2019
aa0df1d
Merge with master
fiqare-emergya-dev Dec 16, 2019
ac5620a
Merge branch 'telefonicaid-master' into fiqare-improvements-1
fiqare-emergya-dev Dec 16, 2019
4e300a4
Merge branch 'fiqare-improvements-1' into fiqare-improvements-1
vladiricoemergya Dec 16, 2019
e8d11ac
Fixed Travis
fiqare-emergya-dev Dec 16, 2019
42267ba
Fixed Travis (2)
fiqare-emergya-dev Dec 16, 2019
6e3974e
Merge pull request #2 from Emergya/fiqare-improvements-1
fiqare-emergya-dev Dec 16, 2019
08201e7
Fixed PR comments
fiqare-emergya-dev Dec 17, 2019
3020aab
Fixed TODO
fiqare-emergya-dev Dec 17, 2019
51271cd
Fixed Swagger dependencies
fiqare-emergya-dev Dec 19, 2019
ce583be
Revert ESLint docs
fiqare-emergya-dev Dec 20, 2019
d978818
Fixed indentation
fiqare-emergya-dev Jan 10, 2020
ff07d10
Fixed config.js
fiqare-emergya-dev Jan 13, 2020
0865dc8
Fixed indentation
fiqare-emergya-dev Jan 13, 2020
8371d53
Merge pull request #3 from telefonicaid/master
fiqare-emergya-dev Jan 27, 2020
9c80eb9
PR fixed
fiqare-emergya-dev Jan 28, 2020
df81a41
travis fixed
fiqare-emergya-dev Feb 3, 2020
210813b
PR fixed
fiqare-emergya-dev Feb 4, 2020
c29e89f
PR fixed
fiqare-emergya-dev Feb 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/alarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var util = require('util'),
function raise(alarm, context, message) {
var state = alarms[alarm];
context = (process.domain && process.domain.context) || {};

Copy link
Member

@fgalan fgalan Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGES_NEXT_RELEASE entries should be added regarding the changes in this documentation. Suggestion:

- Add: /api-docs endpoint providing swagger-based documentation of the HTTP endpoints exposed by Perseo FE
- Hardening: software quality improvement based on ISO25010 recommendations 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 210813b

if (typeof message === 'object' && message) {
message = util.format('%j', message);
}
Expand All @@ -43,6 +44,7 @@ function raise(alarm, context, message) {
function release(alarm, context, message) {
var state = alarms[alarm];
context = (process.domain && process.domain.context) || {};

if (typeof message === 'object' && message) {
message = util.format('%j', message);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/models/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function validateAction(axn) {
return new errors.IdAsAttribute(JSON.stringify(axnElem.parameters));
} else if (axnElem.parameters.name === 'type') {
return new errors.IdAsAttribute(JSON.stringify(axnElem.parameters));
} else {
//Added default else clause
return null;
}
}
}
Expand Down Expand Up @@ -227,6 +230,7 @@ function DoAction(event, callback) {

actionStore.Find(service, subservice, ruleName, function(err, actions) {
var localError, queue;

if (err) {
return callback(err, null);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/models/actionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ module.exports = {
localError = new errors.NotFoundAction(data);
myutils.logErrorIf(localError);
return callback(localError, null);
} else {
//Added default else clause
return callback(null, data.action);
}
return callback(null, data.action);
});
}
};
Expand Down
5 changes: 2 additions & 3 deletions lib/models/emailAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
var util = require('util'),
nodemailer = require('nodemailer'),
logger = require('logops'),
smtpTransport = require('nodemailer-smtp-transport'),
config = require('../../config'),
myutils = require('../myutils'),
alarm = require('../alarm'),
metrics = require('./metrics');

var transporter = nodemailer.createTransport(smtpTransport(config.smtp));
var transporter = nodemailer.createTransport(config.smtp);
Comment on lines -34 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change (along with the removal in L28) is actually needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function createTransport accepts the configuration as a string, so the deleted var in L28 was no necessary and redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. NTC.


function buildMailOptions(action, event) {
return {
Expand All @@ -50,7 +49,7 @@ function SendMail(action, event, callback) {

metrics.IncMetrics(event.service, event.subservice, metrics.actionEmail);

transporter.sendMail(mailOptions, function(err, info) {
transporter.sendMail(mailOptions, (err, info) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the preferred code style is currently function(error,info) over (err, info) =>, so this change probably should be rolled-back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9c80eb9

logger.debug('emailAction.SendMail %j %j %j', mailOptions, err, info);
// Not an HTTP request, so outgoingTransacion hasn't already counted and must be counted now
metrics.IncMetrics(event.service, event.subservice, metrics.outgoingTransactions);
Expand Down
3 changes: 3 additions & 0 deletions lib/models/entitiesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function findSilentEntities(service, subservice, ruleData, func, callback) {
} catch (e) {
return callback(e, null);
}
} else {
//Added default else clause
logger.debug('findSilentEntities() - Default else clause');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review indentation please (// is not aligend with logger)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@fgalan fgalan Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff shows the miss-indentation:

imagen

Maybe it's somekind of tabs vs. space issue. Tabs shouldn't be used in Perseo FE code, according to our code style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0865dc8

}
if (ruleData.type) {
criterion['_id.type'] = ruleData.type;
Expand Down
4 changes: 4 additions & 0 deletions lib/models/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function validComponent(component) {
} else if (!componentPattern.test(component)) {
err = new errors.InvalidCharacter(component);
}
else {
//Added default else clause
return err;
}
return err;
}
function validService(service) {
Expand Down
8 changes: 8 additions & 0 deletions lib/models/postAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function buildPostOptions(action, event) {
} else if (action.template) {
options.text = myutils.expandVar(action.template, event, true);
}
else {
//Added default else clause
return options;
}

return options;
}
Expand All @@ -58,6 +62,10 @@ function doIt(action, event, callback) {
} else if (options.text) {
requestOptions.body = options.text;
}
else {
//Added default else clause
logger.debug('doIt() - Default else clause');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review indent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d978818

}

metrics.IncMetrics(event.service, event.subservice, metrics.actionHttpPost);

Expand Down
27 changes: 23 additions & 4 deletions lib/models/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ var util = require('util'),
actions = require('./actions'),
namePattern = /^[a-zA-Z0-9_-]+$/,
MaxNameLength = 50,
errors = {};
errors = {},
logger = require('logops');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have all the require() together. Pleace move up (just afeter actions declaration).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9c80eb9


function validNSRule(rule) {
var checkInterval = parseInt(rule.nosignal.checkInterval, 10);
Expand All @@ -58,6 +59,9 @@ function validRule(rule) {
return new errors.InvalidRuleName(rule.name);
} else if (!rule.text && !rule.nosignal) {
return new errors.EmptyRule(JSON.stringify(rule));
} else {
//Added default else clause
logger.debug('validRule() - Default else clause');
}
if (rule.nosignal) {
//Specific checks for no-signal rules
Expand Down Expand Up @@ -218,6 +222,7 @@ module.exports = {
},
Save: function(rule, callback) {
var localError;

localError = validRule(rule);
if (localError !== null) {
myutils.logErrorIf(localError);
Expand All @@ -244,7 +249,12 @@ module.exports = {
rulesStore.Save.bind(null, rule),
function(cb) {
if (rule.nosignal) {
noSignal.AddNSRule(rule.service, rule.subservice, rule.name, rule.nosignal);
noSignal.AddNSRule(
rule.service,
rule.subservice,
rule.name,
rule.nosignal
);
}
cb(null);
}
Expand Down Expand Up @@ -294,14 +304,23 @@ module.exports = {
delR2core.bind(null, rule),
function(cb) {
if (rule.nosignal) {
noSignal.DeleteNSRule(rule.service, rule.subservice, rule.name);
noSignal.DeleteNSRule(
rule.service,
rule.subservice,
rule.name
);
}
cb(null);
},
postR2core.bind(null, rule),
function(cb) {
if (rule.nosignal) {
noSignal.AddNSRule(rule.service, rule.subservice, rule.name, rule.nosignal);
noSignal.AddNSRule(
rule.service,
rule.subservice,
rule.name,
rule.nosignal
);
}
cb(null);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/models/rulesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function search(rule, callback) {

function findAll(service, subservice, callback) {
var criterion = {};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this extra whitespace, pls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 210813b

if (typeof service === 'function') {
callback = service;
} else {
Expand Down
5 changes: 4 additions & 1 deletion lib/models/updateAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ function doRequest(action, event, token, callback) {
}
if (!err && data.body && data.body.orionError) {
err = new errors.OrionError(JSON.stringify(data.body.orionError));
} else {
callback(err, data);
}
callback(err, data);
Copy link
Member

@fgalan fgalan Feb 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is not correct... the callback() needs to be changed in any case and, after this change, it is only called when the execution flow goes by the "else" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c29e89f

}
);
}
Expand Down Expand Up @@ -266,6 +267,8 @@ function processOptionParams(action, event) {
case 'None':
theValue = null;
break;
default:
//Nothing to do
}
}
var key = myutils.expandVar(attr.name, event);
Expand Down
19 changes: 17 additions & 2 deletions lib/models/visualRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var util = require('util'),
MINOR_OR_EQUAL_THAN: ' <= ',
MATCH: ' regexp '
},
errors = {};
errors = {},
logger = require('logops');

function errorOperator(op) {
if (operatorMap[op] === undefined) {
Expand Down Expand Up @@ -118,7 +119,6 @@ function vr2rule(cardRule) {
false
)
);

break;
case 'XPATH':
errOp = errorOperator(card.conditionList[0].operator);
Expand All @@ -143,18 +143,27 @@ function vr2rule(cardRule) {
}
} else if (card.conditionList[0].parameterName === 'type') {
type = card.conditionList[0].parameterValue;
} else {
//Added default else clause
logger.debug('vr2rule() - Default else clause');
}
break;
case 'OBSERVATION':
errOp = errorOperator(card.conditionList[0].operator);

if (errOp) {
return errOp;
}

if (card.sensorData.measureName === 'id') {
return new errors.IdAsAttribute('');
} else if (card.sensorData.measureName === 'type') {
return new errors.TypeAsAttribute('');
} else {
//Added default else clause
logger.debug('vr2rule() - Default else clause');
}

conditions.push(
makeObservationCondition(
card.sensorData.measureName,
Expand All @@ -163,6 +172,7 @@ function vr2rule(cardRule) {
card.sensorData.dataType === 'Quantity'
)
);

break;
case 'LAST_MEASURE':
checkInterval = parseInt(card.timeData.interval, 10);
Expand Down Expand Up @@ -225,10 +235,15 @@ function vr2rule(cardRule) {
case 'timeElapsed': // Minimal interval for actions
action.interval = card.timeData.interval;
break;
default:
//nothing to do
}
} else {
return new errors.MissingConfigDataInTimeCard(JSON.stringify(card));
}
break;
default:
//nothing to do
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/myutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function expandObject(templateObj, dictionary) {
res[expandVar(key, dictionary)] = expandVar(templateObj[key], dictionary);
} else if (typeof templateObj[key] === 'object') {
res[expandVar(key, dictionary)] = expandObject(templateObj[key], dictionary);
} else {
//Added default else clause
logger.debug('expandObject() - Default else clause');
}
});
}
Expand Down
20 changes: 19 additions & 1 deletion lib/perseo.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ var domain = require('domain'),
serviceMiddleware = require('./middleware/service'),
errorMiddleware = require('./middleware/error'),
myutils = require('./myutils'),
d = domain.create();
d = domain.create(),
swaggerJsdoc = require('swagger-jsdoc'),
swaggerUi = require('swagger-ui-express');

function start(callbackStart) {
var context = { op: 'start', comp: constants.COMPONENT_NAME };
Expand Down Expand Up @@ -98,6 +100,22 @@ function start(callbackStart) {
versionRoutes.AddTo(app);
metricsRoutes.AddTo(app);

const options = {
definition: {
swagger: '2.0', // Specification (optional, defaults to swagger: '2.0')
info: {
title: 'Perseo Front-End', // Title (required)
version: '1.7.0-fiqare' // Version (required)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be got from packages.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9c80eb9

}
},
// Path to the API docs
apis: ['./lib/routes/*.js']
};

const specs = swaggerJsdoc(options);

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));

async.series(
[
function(callback) {
Expand Down
69 changes: 69 additions & 0 deletions lib/routes/noticesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,75 @@ function PostNotice(req, resp) {
}

function AddTo(app) {
/**
* @swagger
*
* /notices:
* post:
* tags:
* - Notices
* description: Send an event/notification to perseo
* produces:
* - application/json
* parameters:
* - name: fiware-service
* description: Fiware service.
* in: header
* required: true
* type: string
* - name: fiware-servicepath
* description: Fiware service path.
* in: header
* required: true
* type: string
* - name: body
* in: body
* schema:
* type: object
* properties:
* subscriptionId:
* type: string
* description: Subscription Id
* example:
* - 5c7e63939859f248791984e0
* data:
* type: object
* properties:
* id:
* type: string
* description: Entity Id
* example:
* - urn:ngsi-ld:Door:001
* type:
* type: string
* description: Entity type
* example:
* - Door
* state:
* type: object
* properties:
* type:
* type: string
* description: State type
* example:
* - Text
* value:
* type: string
* description: State value
* example:
* - OPEN
* metadata:
* type: object
* description: State metadata
* example:
* - {"TimeInstant":{"type":"ISO8601", "value":"2019-03-05T10:49:16.402Z"}}
* required:
* - subscriptionId
* - data
* responses:
* 200:
* description: rules
*/
app.post(config.endpoint.noticesPath, PostNotice);
}

Expand Down
Loading