Fixed or disabled warnings

This commit is contained in:
baldo 2017-05-06 17:31:34 +02:00
parent 94a51921fd
commit 3d6fb5feec
11 changed files with 45 additions and 38 deletions

View file

@ -12,7 +12,7 @@ angular.module('ffffng')
$scope.monitoringInfo = {};
$scope.monitoringStatus = 'loading';
MonitoringService.confirm($routeParams['token'])
MonitoringService.confirm($routeParams.token)
.then(
function (response) {
// success

View file

@ -12,7 +12,7 @@ angular.module('ffffng')
$scope.monitoringInfo = {};
$scope.monitoringStatus = 'loading';
MonitoringService.disable($routeParams['token'])
MonitoringService.disable($routeParams.token)
.then(
function (response) {
// success

View file

@ -5,7 +5,7 @@ angular.module('ffffng')
var ctrl = function ($scope) {
$scope.version = '?';
$http.get('/api/version')
.then(function (result) { $scope.version = result.data.version; })
.then(function (result) { $scope.version = result.data.version; });
};
return {

View file

@ -120,8 +120,8 @@ angular.module('ffffng')
};
$scope.monitoringInitialConfirmationRequired = function () {
return $scope.node.monitoring
&& ($scope.action === 'create' || $scope.node.email !== initialEmail || !initialMonitoring);
return $scope.node.monitoring &&
($scope.action === 'create' || $scope.node.email !== initialEmail || !initialMonitoring);
};
$scope.monitoringConfirmationPending = function () {
@ -137,8 +137,8 @@ angular.module('ffffng')
var doSubmit = function (node) {
if ($scope.nodeForm.$invalid) {
var firstInvalid = _.filter($element.find('form').find('input'), function (input) {
return (input.type === 'text' || input.type === 'email')
&& $scope.nodeForm[input.name].$invalid;
return (input.type === 'text' || input.type === 'email') &&
$scope.nodeForm[input.name].$invalid;
})[0];
if (firstInvalid) {
$window.scrollTo(0, $window.pageYOffset + firstInvalid.getBoundingClientRect().top - 100);

View file

@ -11,7 +11,7 @@ angular.module('ffffng').factory('app', function (fs, config, _) {
// urls beneath /internal are protected
var internalAuth = auth.basic(
{
realm: "Knotenformular - Intern"
realm: 'Knotenformular - Intern'
},
function (username, password, callback) {
callback(

View file

@ -126,6 +126,8 @@ if (fs.existsSync(configJSONFile)) {
process.exit(1);
}
var _ = require('lodash');
function stripTrailingSlash(obj, field) {
var url = obj[field];
if (_.isString(url) && _.last(url) === '/') {

View file

@ -29,10 +29,10 @@ function applyPatch(db, file, callback) {
return callback(null);
}
var sql = 'BEGIN TRANSACTION;\n'
+ contents.toString() + '\n'
+ 'INSERT INTO schema_version (version) VALUES (\'' + version + '\');\n'
+ 'END TRANSACTION;';
var sql = 'BEGIN TRANSACTION;\n' +
contents.toString() + '\n' +
'INSERT INTO schema_version (version) VALUES (\'' + version + '\');\n' +
'END TRANSACTION;';
db.exec(sql, function (err) {
if (err) {
@ -50,10 +50,10 @@ function applyPatch(db, file, callback) {
function applyMigrations(db, callback) {
Logger.tag('database', 'migration').info('Migrating database...');
var sql = 'BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS schema_version (\n'
+ ' version VARCHAR(255) PRIMARY KEY ASC,\n'
+ ' applied_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL\n'
+ '); END TRANSACTION;';
var sql = 'BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS schema_version (\n' +
' version VARCHAR(255) PRIMARY KEY ASC,\n' +
' applied_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL\n' +
'); END TRANSACTION;';
db.exec(sql, function (err) {
if (err) {
return callback(err);

View file

@ -21,7 +21,9 @@ angular.module('ffffng')
return _.template(fs.readFileSync(snippetFile).toString())(deepExtend(
{},
// jshint -W040
this, // parent data
// jshint +W040
data,
templateFunctions
));
@ -30,7 +32,7 @@ angular.module('ffffng')
function snippet(name) {
return function (data) {
return renderSnippet.bind(this)(name, data);
}
};
}
function renderLink(href, text) {
@ -76,7 +78,7 @@ angular.module('ffffng')
},
render: function (mailOptions, callback) {
var templatePathPrefix = templateBasePath + '/' + mailOptions.email
var templatePathPrefix = templateBasePath + '/' + mailOptions.email;
async.parallel({
subject: _.partial(fs.readFile, templatePathPrefix + '.subject.txt'),

View file

@ -65,7 +65,9 @@ angular.module('ffffng')
.tag('monitoring', 'information-retrieval')
.debug('Node is known in monitoring: %s', nodeData.mac);
// jshint -W106
if (!moment(row.import_timestamp).isBefore(nodeData.importTimestamp)) {
// jshint +W106
Logger
.tag('monitoring', 'information-retrieval')
.debug('No new data for node, skipping: %s', nodeData.mac);
@ -108,7 +110,9 @@ angular.module('ffffng')
nodeDataForStoring = {
mac: node.mac,
state: 'OFFLINE',
// jshint -W106
lastSeen: _.isUndefined(row) ? moment() : moment.unix(row.last_seen),
// jshint +W106
importTimestamp: moment()
};
} else {
@ -129,7 +133,7 @@ angular.module('ffffng')
Logger.tag('monitoring', 'information-retrieval').debug('Parsing nodes.json...');
function parseTimestamp(timestamp) {
if (!_.isString(json.timestamp)) {
if (!_.isString(timestamp)) {
return moment.invalid();
}
return moment.utc(timestamp);
@ -277,7 +281,9 @@ angular.module('ffffng')
mailType,
{
node: node,
// jshint -W106
lastSeen: nodeState.last_seen,
// jshint +W106
disableUrl: UrlBuilder.monitoringDisableUrl(nodeSecrets)
},
@ -361,9 +367,7 @@ angular.module('ffffng')
* descriptive string that stores, which was the last mail type, stored in the database as last_status_mail_type
*/
var previousType =
mailNumber === 1
? 'monitoring-online-again'
: ('monitoring-offline-' + (mailNumber - 1));
mailNumber === 1 ? 'monitoring-online-again' : ('monitoring-offline-' + (mailNumber - 1));
// the first time the first offline mail is send, there was no mail before
var allowNull = mailNumber === 1 ? ' OR last_status_mail_type IS NULL' : '';
@ -773,5 +777,5 @@ angular.module('ffffng')
}
);
}
}
};
});

View file

@ -206,7 +206,7 @@ angular.module('ffffng')
function deleteNodeFile(token, callback) {
findNodeFiles({ token: token }, function (err, files) {
if (err) {
Logger.tag('node', 'delete').error('Could not find node file: ' + file, error);
Logger.tag('node', 'delete').error('Could not find node file: ' + files, err);
return callback({data: 'Could not delete node.', type: ErrorTypes.internalError});
}
@ -218,7 +218,7 @@ angular.module('ffffng')
fs.unlinkSync(files[0]);
}
catch (error) {
Logger.tag('node', 'delete').error('Could not delete node file: ' + file, error);
Logger.tag('node', 'delete').error('Could not delete node file: ' + files, error);
return callback({data: 'Could not delete node.', type: ErrorTypes.internalError});
}
@ -256,8 +256,8 @@ angular.module('ffffng')
_.each(entries, function (value, key) {
if (key === 'mac') {
node['mac'] = value;
node['mapId'] = _.toLower(value).replace(/:/g, '')
node.mac = value;
node.mapId = _.toLower(value).replace(/:/g, '');
} else if (key === 'monitoring') {
var active = value === 'aktiv';
var pending = value === 'pending';
@ -320,7 +320,7 @@ angular.module('ffffng')
},
function (err) {
if (err) {
Logger.tag('monitoring', 'confirmation').error('Could not enqueue confirmation mail.', error);
Logger.tag('monitoring', 'confirmation').error('Could not enqueue confirmation mail.', err);
return callback({data: 'Internal error.', type: ErrorTypes.internalError});
}
@ -377,7 +377,7 @@ angular.module('ffffng')
} else {
// monitoring is still enabled
if (currentNode.email != node.email) {
if (currentNode.email !== node.email) {
// new email so we need a new token and a reconfirmation
monitoringConfirmed = false;
monitoringToken = generateToken();
@ -528,7 +528,7 @@ angular.module('ffffng')
});
callback(null, nodeStatistics);
})
});
}
};
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('ffffng').factory('Resources', function (_, Constraints, Validator, ErrorTypes) {
angular.module('ffffng').factory('Resources', function (_, Constraints, Validator, ErrorTypes, Logger) {
function respond(res, httpCode, data, type) {
switch (type) {
case 'html':
@ -24,7 +24,7 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
return {
query: 'ORDER BY ' + sortField + ' ' + (restParams._sortDir === 'ASC' ? 'ASC' : 'DESC'),
params: []
}
};
}
function limitOffsetClause(restParams) {
@ -41,7 +41,7 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
return str
.replace(/\\/g, '\\\\')
.replace(/%/g, '\\%')
.replace(/_/g, '\\_')
.replace(/_/g, '\\_');
}
function filterCondition(restParams, filterFields) {
@ -49,7 +49,7 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
return {
query: '1 = 1',
params: []
}
};
}
var query = _.join(
@ -74,9 +74,8 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
var values = {};
_.each(_.keys(constraints), function (key) {
var value = data[key];
values[key] = _.isUndefined(value) && !_.isUndefined(constraints[key].default)
? constraints[key].default
: value;
values[key] =
_.isUndefined(value) && !_.isUndefined(constraints[key].default) ? constraints[key].default : value;
});
return values;
}
@ -207,7 +206,7 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
return {
query: filter.query + ' ' + orderBy.query + ' ' + limitOffset.query,
params: _.concat(filter.params, orderBy.params, limitOffset.params)
}
};
},
success: function (res, data) {