Skip to content

Commit

Permalink
Logs panel and cpp objects wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Kozłowski authored and Adam Kozłowski committed Apr 29, 2017
1 parent fe382da commit 84974d0
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 40 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title></title>
<link rel="stylesheet" href="stylesheets/application.css" />
<link rel="stylesheet" href="stylesheets/logsWindow.css" />
<link rel="stylesheet" href="stylesheets/logsPanel.css" />

<script src="javascripts/renderer/application.js" type="text/javascript"></script>
</head>
Expand Down
12 changes: 12 additions & 0 deletions app/javascripts/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ path = require('path');
json = require('../../package.json');
electron = require('electron');

const {ipcMain} = require('electron')

// Import windows creation logic
prepareMainWindow = require('./mainWindow').prepareMainWindow
prepareLogsWindow = require('./logger').prepareLogsWindow


electron.app.on('ready', function() {
Expand Down Expand Up @@ -45,3 +48,12 @@ electron.app.on('ready', function() {

var window = prepareMainWindow(electron.app, _onWindowLoaded);
});


ipcMain.on('logs_detached', (event, args) => {
console.log(args);
// Create window and attach on load
var window = prepareLogsWindow(()=> {
window.webContents.send('attach_logs_node_window', args);
});
});
27 changes: 25 additions & 2 deletions app/javascripts/main/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,35 @@ json = require('../../package.json');
electron = require('electron');


export function prepareLogsWindow(logsNode)
exports.prepareLogsWindow = function(onLoad)
{
var window;

window = new electron.BrowserWindow({
title: "Logs",
width: 400,
height: 300
});

window.loadURL('file://' + path.join(__dirname, '..', '..') + '/logsWindow.html');

window.webContents.on('did-finish-load', function(){
if (onLoad) {
onLoad();
}
});

window.on('closed', function() {
window = null;

// Re-attach

});

return window;
}

export function prepareLogsNode()
exports.prepareLogsNode = function ()
{

}
7 changes: 7 additions & 0 deletions app/javascripts/main/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ exports.prepareMainWindow = function(app, onLoad)

if (onLoad) {
onLoad();

console.log(cougar);
console.log(cougar.SerialPort());

console.log("TEST");
console.log(cougar.SerialPort().GetDevices());
console.log("TEST END");
}
});

Expand Down
11 changes: 9 additions & 2 deletions app/javascripts/renderer/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { ipcRenderer } = require('electron');
$ = require('jquery');
const $ = require('jquery');

ipcRenderer.on('loaded', function(event, data) {
document.getElementById('title').innerHTML = data.appName + ' App';
Expand All @@ -16,6 +16,9 @@ ipcRenderer.on('loaded', function(event, data) {
<button id="logsButtonInfo"><input type="checkbox" checked>INFO</input></button>
<button id="logsButtonDebug"><input type="checkbox" checked>DEBUG</input></button>
<button id="logsButtonDetach">Swap</button>
<table id="logsTable">
<thead>
<th id="logsTableHeader">Timestamp</th>
Expand All @@ -35,11 +38,15 @@ ipcRenderer.on('loaded', function(event, data) {
}
};

// Actions
// Actions --------
$("#logsButtonClear").on("click", function(){
$("#logsTable tbody").empty();
});

$("#logsButtonDetach").on("click", function(){
ipcRenderer.send('logs_detached', $("#logsTableContainer").detach());
});

$("#logsButtonError").on("click", function(){ hideWithClass("#logsButtonError", ".logsTableError") });
$("#logsButtonWarning").on("click", function(){ hideWithClass("#logsButtonWarning", ".logsTableWarning") });
$("#logsButtonInfo").on("click", function(){ hideWithClass("#logsButtonInfo", ".logsTableInfo") });
Expand Down
4 changes: 2 additions & 2 deletions app/logsWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="stylesheets/logsWindow.css" />
<!--<script src="javascripts/renderer/application.js" type="text/javascript"></script>-->
<link rel="stylesheet" href="stylesheets/logsPanel.css" />
<script src="javascripts/renderer/logsWindow.js" type="text/javascript"></script>
</head>
<body>
<div class="message">
Expand Down
19 changes: 2 additions & 17 deletions app/stylesheets/logsWindow.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@
font-size: 0.75em;
}

#logsTableContainer {
position: absolute;
left: 0;
bottom: 0;

margin: 2px;
border-top: 1px solid gray;

width: 100%;
height: 200px;
resize: vertical;

overflow-y: auto;
display: block;
}

#logsTableHeader {
color: lightgray;
font-variant: small-caps;
}

Expand All @@ -47,4 +32,4 @@

.logsTableInfo {
color: lightgreen;
}
}
Binary file modified cougar_bluetooth_lib/build/Release/cougar_bluetooth_lib.node
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion cougar_bluetooth_lib/cougar_bluetooth_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ namespace Cougar_Bluetooth {
*/
static NAN_METHOD(GetStatus)
{

Cougar_Bluetooth* obj = Nan::ObjectWrap::Unwrap<Cougar_Bluetooth>(info.Holder());

switch(obj->_cougarBluetooth->GetStatus())
Expand Down
Binary file modified cougar_lib/build/Release/obd_cougar.node
Binary file not shown.
Binary file modified cougar_lib/build/Release/obj.target/obd_cougar/obd_cougar_lib.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 84974d0

Please sign in to comment.