Skip to content

Commit

Permalink
Fix all issues from ESLint (nightscout#4730)
Browse files Browse the repository at this point in the history
* Cherry picks the ES language changes from nightscout#4690

* Fix small issues found in linting

* * Fix all but one eslint complaint in the bundled code
* Add eslint and js-beautify rc files into the repo
  • Loading branch information
sulkaharo authored Jul 17, 2019
1 parent b04476e commit 8f25a6e
Show file tree
Hide file tree
Showing 36 changed files with 2,574 additions and 2,953 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
"plugins": [ ],
"extends": [
"eslint:recommended"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"jquery": true
}
};
16 changes: 16 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"indent_size": 2
, "indent_char": " "
, "comma_first": true
, "keep-array-indentation": true
, "space_after_named_function": true
, "space_after_anon_function": true
, "end_with_newline": true
, "brace_style": "collapse,preserve-inline"
, "space_in_brace": true
, "space-in-paren": false
, "break-chained-methods": false
, "max-preserve-newlines": 2
, "space-after-anon-function": false
, "indent-empty-lines": false
}
70 changes: 35 additions & 35 deletions lib/admin_plugins/cleanstatusdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,93 @@ var cleanstatusdb = {
, pluginType: 'admin'
};

function init() {
function init () {
return cleanstatusdb;
}

module.exports = init;

cleanstatusdb.actions = [
{
name: 'Delete all documents from devicestatus collection'
, description: 'This task removes all documents from devicestatus collection. Useful when uploader battery status is not properly updated.'
, buttonLabel: 'Delete all documents'
, confirmText: 'Delete all documents from devicestatus collection?'
{
name: 'Delete all documents from devicestatus collection'
, description: 'This task removes all documents from devicestatus collection. Useful when uploader battery status is not properly updated.'
, buttonLabel: 'Delete all documents'
, confirmText: 'Delete all documents from devicestatus collection?'
}
, {
name: 'Delete all documents from devicestatus collection older than 30 days'
, description: 'This task removes all documents from devicestatus collection that are older than 30 days. Useful when uploader battery status is not properly updated.'
, buttonLabel: 'Delete old documents'
, confirmText: 'Delete old documents from devicestatus collection?'
, preventClose: true
, {
name: 'Delete all documents from devicestatus collection older than 30 days'
, description: 'This task removes all documents from devicestatus collection that are older than 30 days. Useful when uploader battery status is not properly updated.'
, buttonLabel: 'Delete old documents'
, confirmText: 'Delete old documents from devicestatus collection?'
, preventClose: true
}
];

cleanstatusdb.actions[0].init = function init(client, callback) {
cleanstatusdb.actions[0].init = function init (client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_0_status');

$status.hide().text(translate('Loading database ...')).fadeIn('slow');
$.ajax('/api/v1/devicestatus.json?count=500', {
headers: client.headers()
, success: function (records) {
, success: function(records) {
var recs = (records.length === 500 ? '500+' : records.length);
$status.hide().text(translate('Database contains %1 records',{ params: [recs] })).fadeIn('slow');
$status.hide().text(translate('Database contains %1 records', { params: [recs] })).fadeIn('slow');
}
, error: function () {
, error: function() {
$status.hide().text(translate('Error loading database')).fadeIn('slow');
}
}).done(function () { if (callback) { callback(); } });
}).done(function() { if (callback) { callback(); } });
};

cleanstatusdb.actions[0].code = function deleteRecords(client, callback) {
cleanstatusdb.actions[0].code = function deleteRecords (client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_0_status');

if (!client.hashauth.isAuthenticated()) {
alert(translate('Your device is not authenticated yet'));
if (callback) {
callback();
}
return;
};
}

$status.hide().text(translate('Deleting records ...')).fadeIn('slow');
$.ajax({
method: 'DELETE'
method: 'DELETE'
, url: '/api/v1/devicestatus/*'
, headers: client.headers()
}).done(function success () {
$status.hide().text(translate('All records removed ...')).fadeIn('slow');
if (callback) {
callback();
}
}).fail(function fail() {
}).fail(function fail () {
$status.hide().text(translate('Error')).fadeIn('slow');
if (callback) {
callback();
}
});
};

cleanstatusdb.actions[1].init = function init(client, callback) {
cleanstatusdb.actions[1].init = function init (client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_1_status');

$status.hide();

var numDays = '<br/>'
+ '<label for="admin_devicestatus_days">'
+ translate('Number of Days to Keep:')
+ ' <input id="admin_devicestatus_days" value="30" size="3" min="1"/>'
+ '</label>';
var numDays = '<br/>' +
'<label for="admin_devicestatus_days">' +
translate('Number of Days to Keep:') +
' <input id="admin_devicestatus_days" value="30" size="3" min="1"/>' +
'</label>';

$('#admin_' + cleanstatusdb.name + '_1_html').html(numDays);

if (callback) { callback(); }
};

cleanstatusdb.actions[1].code = function deleteOldRecords(client, callback) {
cleanstatusdb.actions[1].code = function deleteOldRecords (client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_1_status');
var numDays = Number($('#admin_devicestatus_days').val());
Expand All @@ -117,17 +117,17 @@ cleanstatusdb.actions[1].code = function deleteOldRecords(client, callback) {

$status.hide().text(translate('Deleting records ...')).fadeIn('slow');
$.ajax('/api/v1/devicestatus/?find[created_at][$lte]=' + dateStr, {
method: 'DELETE'
method: 'DELETE'
, headers: client.headers()
, success: function (retVal) {
$status.text(translate('%1 records deleted',{ params: [retVal.n] }));
, success: function(retVal) {
$status.text(translate('%1 records deleted', { params: [retVal.n] }));
}
, error: function () {
, error: function() {
$status.hide().text(translate('Error')).fadeIn('slow');
}
}).done(function success () {
if (callback) { callback(); }
}).fail(function fail() {
}).fail(function fail () {
if (callback) { callback(); }
});
};
Loading

0 comments on commit 8f25a6e

Please sign in to comment.