Start logging on client side
This commit is contained in:
parent
d0aea38b3f
commit
59308536f6
|
@ -1 +1,2 @@
|
|||
node_modules/*
|
||||
node_modules/*
|
||||
logs/*
|
|
@ -1,6 +1,16 @@
|
|||
#log{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
#footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
}
|
||||
#log {
|
||||
position: fixed;
|
||||
width: 600px;
|
||||
height: 150px;
|
||||
}
|
||||
#status {
|
||||
position: fixed;
|
||||
width: 100px;
|
||||
right: 0;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
#log{
|
||||
position: fixed;
|
||||
width: 700px;
|
||||
width: 600px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
#status{
|
||||
|
|
|
@ -65,31 +65,61 @@ var ipcRenderer = require('electron').ipcRenderer,
|
|||
log = {};
|
||||
//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: '20%' },
|
||||
{ field: 'action', caption: 'Action', size: '60%' },
|
||||
{ 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: '4/11/2016', action: 'Started app', service: 'MAIN', status: true }
|
||||
]
|
||||
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 () {
|
||||
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 () {
|
||||
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) {
|
||||
'use strict';
|
||||
console.log('color: ' + color.join(','));
|
||||
|
|
19
app/main.js
19
app/main.js
|
@ -14,6 +14,7 @@ var mainWindow;
|
|||
|
||||
var init = function () {
|
||||
createWindow();
|
||||
log.init();
|
||||
mcopy.arduino.init(function (success) {
|
||||
if (success) {
|
||||
mcopy.arduino.connect(function () {
|
||||
|
@ -54,3 +55,21 @@ ipcMain.on('light', function(event, arg) {
|
|||
//
|
||||
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;
|
||||
});
|
||||
};
|
|
@ -1,8 +1,63 @@
|
|||
var ipcRenderer = require('electron').ipcRenderer,
|
||||
light = {};
|
||||
light = {},
|
||||
log = {};
|
||||
//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) {
|
||||
'use strict';
|
||||
console.log('color: ' + color.join(','));
|
||||
|
@ -23,24 +78,5 @@ var init = function () {
|
|||
{ type: 'button', id: 'item5', group: '1', caption: 'Settings', icon: 'fa-home' }
|
||||
]
|
||||
});
|
||||
$('#log').w2grid({
|
||||
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' }
|
||||
]
|
||||
});
|
||||
log.init();
|
||||
};
|
Loading…
Reference in New Issue