Skip to content

Commit

Permalink
Add initial settings defaults check
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblenis committed Nov 23, 2019
1 parent bb262af commit 5f81e2b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
{
"name": "Event Log",
"shortName": "eventlog",
"version": "0.0.15",
"version": "0.0.16",
"author": "Ryan Blenis",
"description": "An event log plugin to view, capture, and store event logs for each endpoint",
"hasAdminPanel": true,
Expand Down
33 changes: 33 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 146,22 @@ module.exports.CreateDB = function(meshserver) {
.catch((e) => console.log('EVENTLOG: Error getting config for: ', e));
});
};
obj.checkForDefault = function() {
obj.getAllConfigSets()
.then((cfgs) => {
if (cfgs.length == 0) {
obj.updateDefaultConfig({
name: 'Default',
liveLogs: 'Application,System',
liveNum: 100,
liveEntryTypes: [2,3],
historyEnabled: true,
historyLogs: 'Application,System',
historyEntryTypes: [2,3]
});
}
});
};
});
} else { // use NeDb
Datastore = require('nedb');
Expand Down Expand Up @@ -287,6 303,23 @@ module.exports.CreateDB = function(meshserver) {
.catch((e) => console.log('EVENTLOG: Error getting config for: ', e));
});
};

obj.checkForDefault = function() {
obj.getAllConfigSets()
.then((cfgs) => {
if (cfgs.length == 0) {
obj.updateDefaultConfig({
name: 'Default',
liveLogs: 'Application,System',
liveNum: 100,
liveEntryTypes: [2,3],
historyEnabled: true,
historyLogs: 'Application,System',
historyEntryTypes: [2,3]
});
}
});
};
}


Expand Down
1 change: 1 addition & 0 deletions eventlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 47,7 @@ module.exports.eventlog = function (parent) {
// hack a persistent db here
obj.meshServer.pluginHandler.eventlog_db = require (__dirname '/db.js').CreateDB(obj.meshServer);
obj.db = obj.meshServer.pluginHandler.eventlog_db;
obj.db.checkForDefault();
};

obj.consoleaction = function() {
Expand Down

0 comments on commit 5f81e2b

Please sign in to comment.