Start logging on client side

This commit is contained in:
Matt 2016-04-12 22:51:47 -04:00
parent d0aea38b3f
commit 59308536f6
6 changed files with 134 additions and 37 deletions

3
app/.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/* node_modules/*
logs/*

View File

@ -1,6 +1,16 @@
#log{ #footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 100px; height: 150px;
} }
#log {
position: fixed;
width: 600px;
height: 150px;
}
#status {
position: fixed;
width: 100px;
right: 0;
}

View File

@ -4,12 +4,13 @@
position: fixed; position: fixed;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 100px; height: 150px;
} }
#log{ #log{
position: fixed; position: fixed;
width: 700px; width: 600px;
height: 150px;
} }
#status{ #status{

View File

@ -65,31 +65,61 @@ var ipcRenderer = require('electron').ipcRenderer,
log = {}; log = {};
//console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) ); //console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) );
log.time = 'MM/DD/YY-HH:mm:ss';
log.count = 0;
log.init = function () { log.init = function () {
'use strict'; 'use strict';
$('#log').w2grid({ $('#log').w2grid({
name : 'log', name : 'log',
columns: [ columns: [
{ field: 'time', caption: 'Time', size: '20%' }, { field: 'time', caption: 'Time', size: '22%' },
{ field: 'action', caption: 'Action', size: '60%' }, { field: 'action', caption: 'Action', size: '58%' },
{ field: 'service', caption: 'Service', size: '20%' }, { field: 'service', caption: 'Service', size: '20%' },
{ field: 'status', caption: 'Status', size: '10%' }, { field: 'status', caption: 'Status', size: '10%' },
], ],
records: [ records: []
{ recid: 1, time: '4/11/2016', action: 'Started app', service: 'MAIN', status: true } });
] //{ recid: 1, time: moment().format(log.time), action: 'Started app', service: 'MAIN', status: true }
log.info('Started app', 'MAIN', true);
};
log.listen = function () {
ipcRender.on('log', function (event, arg) {
console.log(arg);
return event.returnValue = true;
}); });
}; };
log.display = function () { log.display = function (action, service, status, time) {
'use strict'; 'use strict';
var obj = {
recid : log.count++,
time : time,
action : action,
service : service,
status : status
}
if (typeof time === 'undefined') {
obj.time = moment().format(log.time);
}
w2ui['log'].add(obj);
$('#log').animate({ scrollTop: $('#log').prop('scrollHeight')}, 100);
return obj;
}; };
log.report = function () { log.report = function (obj) {
'use strict'; 'use strict';
ipcRenderer.sendSync('log', obj);
}; };
log.info = function (action, service, status, time) {
'use strict';
var obj = log.display(action, service, status, time);
log.report(obj);
console.log(obj);
};
//color = [0,0,0]
light.set = function (color) { light.set = function (color) {
'use strict'; 'use strict';
console.log('color: ' + color.join(',')); console.log('color: ' + color.join(','));

View File

@ -14,6 +14,7 @@ var mainWindow;
var init = function () { var init = function () {
createWindow(); createWindow();
log.init();
mcopy.arduino.init(function (success) { mcopy.arduino.init(function (success) {
if (success) { if (success) {
mcopy.arduino.connect(function () { mcopy.arduino.connect(function () {
@ -54,3 +55,21 @@ ipcMain.on('light', function(event, arg) {
// //
event.returnValue = true; event.returnValue = true;
}); });
var log = {};
log.init = function () {
'use strict';
log.listen();
};
log.display = function () {
'use strict';
ipcMain.sendSync({});
};
log.listen = function () {
'use strict';
ipcMain.on('log', function (event, arg) {
console.log(arg);
event.returnValue = true;
});
};

View File

@ -1,8 +1,63 @@
var ipcRenderer = require('electron').ipcRenderer, var ipcRenderer = require('electron').ipcRenderer,
light = {}; light = {},
log = {};
//console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) ); //console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) );
log.time = 'MM/DD/YY-HH:mm:ss';
log.count = 0;
log.init = function () {
'use strict';
$('#log').w2grid({
name : 'log',
columns: [
{ field: 'time', caption: 'Time', size: '22%' },
{ field: 'action', caption: 'Action', size: '58%' },
{ field: 'service', caption: 'Service', size: '20%' },
{ field: 'status', caption: 'Status', size: '10%' },
],
records: []
});
//{ recid: 1, time: moment().format(log.time), action: 'Started app', service: 'MAIN', status: true }
log.info('Started app', 'MAIN', true);
};
log.listen = function () {
ipcRender.on('log', function (event, arg) {
console.log(arg);
return event.returnValue = true;
});
};
log.display = function (action, service, status, time) {
'use strict';
var obj = {
recid : log.count++,
time : time,
action : action,
service : service,
status : status
}
if (typeof time === 'undefined') {
obj.time = moment().format(log.time);
}
w2ui['log'].add(obj);
$('#log').animate({ scrollTop: $('#log').prop('scrollHeight')}, 100);
return obj;
};
log.report = function (obj) {
'use strict';
ipcRenderer.sendSync('log', obj);
};
log.info = function (action, service, status, time) {
'use strict';
var obj = log.display(action, service, status, time);
log.report(obj);
console.log(obj);
};
//color = [0,0,0]
light.set = function (color) { light.set = function (color) {
'use strict'; 'use strict';
console.log('color: ' + color.join(',')); console.log('color: ' + color.join(','));
@ -23,24 +78,5 @@ var init = function () {
{ type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' } { type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' }
] ]
}); });
$('#log').w2grid({ log.init();
name : 'myGrid',
columns: [
{ field: 'fname', caption: 'First Name', size: '30%' },
{ field: 'lname', caption: 'Last Name', size: '30%' },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'sdate', caption: 'Start Date', size: '120px' },
],
records: [
{ recid: 1, fname: 'John', lname: 'Doe', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 3, fname: 'Jin', lname: 'Franson', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 4, fname: 'Susan', lname: 'Ottie', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 5, fname: 'Kelly', lname: 'Silver', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 6, fname: 'Francis', lname: 'Gatos', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 7, fname: 'Mark', lname: 'Welldo', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 8, fname: 'Thomas', lname: 'Bahh', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
{ recid: 9, fname: 'Sergei', lname: 'Rachmaninov', email: 'jdoe@gmail.com', sdate: '4/3/2012' }
]
});
}; };