Skip to content

Commit

Permalink
Add table-based build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan770 committed May 22, 2018
1 parent de873dd commit f93bb44
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 14 deletions.
29 changes: 22 additions & 7 deletions construct.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@
</head>

<body>
<div class="row">
<div class="input-field inline col s12">
<input id="sql_inline" type="text" class="validate">
<label for="sql_inline">SQL</label>
<span class="helper-text" data-error="SQL syntax error" data-success="No errors found"></span>
</div>
</div>
<table id="build">
<thead>
<tr>
<th>Column</th>
<th>Row</th>
</tr>
</thead>

<tbody>
</tbody>
</table>
<script>
const electron = require('electron')
const ipc = require('electron').ipcRenderer
ipc.on('build', function(event, arg1, arg2) {
build_add(arg1, arg2)
})
ipc.on('clear', function(event) {
build_clear()
})
</script>
<script src="js/build.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>

Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<input id="prevValue" name="prevValue" type="hidden">
<a class="waves-effect waves-light btn" id="run" name="run">Run</a>
<a class="waves-effect waves-teal btn-flat" id="prevButton" name="prevButton">Previous command</a>
<!-- <a class="waves-effect waves-teal btn-flat" id="assistantButton" name="assistantButton">Assistant</a> -->
<a class="waves-effect waves-teal btn-flat" id="buildButton" name="buildButton">Build result</a>
<div class="chip right" id="chip_cmd" title="Use 'help' to get available commands">
No command assigned
</div>
Expand Down Expand Up @@ -57,7 +57,7 @@
const paraminput = document.getElementById('param')
const prevValue = document.getElementById('prevValue')
const prevButton = document.getElementById('prevButton')
const assistantButton = document.getElementById('assistantButton')
const buildButton = document.getElementById('buildButton')
const pingObj = document.getElementById("ping")
const pjson = require('./package.json');

Expand Down Expand Up @@ -142,9 +142,9 @@
}
});

/* assistantButton.addEventListener("click" , function (e) {
ipc.send('assistant')
}) */
buildButton.addEventListener("click" , function (e) {
ipc.send('buildOpen')
})

cmd.addEventListener("keyup", function(e) {
var split = cmd.value.split(" ");
Expand Down
15 changes: 15 additions & 0 deletions js/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function build_add (c1, c2) {
let table = document.getElementById("build");
let row = table.insertRow(1);
let cell1 = row.insertCell(0);
let cell2 = row.insertCell(1);
cell1.innerHTML = `${c1}`;
cell2.innerHTML = `${c2}`;
}

function build_clear () {
let table = document.getElementById("build");
while(table.rows.length > 1) {
table.deleteRow(1);
}
}
5 changes: 4 additions & 1 deletion js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ function querydb(host, user, password, query, database, port, build) {
throw err
} else {
if (build == 1) {
ipc.send("build_clear")
Object.keys(result).forEach(function(key) {
var row = result[key];
Object.keys(row).forEach(function(key) {
appendLog(key + ' // ' + row[key], "BUILD");
// appendLog(key + ' // ' + row[key], "BUILD");
ipc.send("build", key, row[key])
});
});
appendLog("Build completed!", "BUILD")
} else {
appendLog('Result(JSON): ' + JSON.stringify(result), 'QUERYDB')
}
Expand Down
10 changes: 9 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ ipc.on('exit', function(event) {
app.exit()
})

ipc.on('assistant', function(event) {
ipc.on('buildOpen', function(event) {
assistantWin.show()
})

ipc.on('build', function(event, arg1, arg2) {
assistantWin.webContents.send('build', arg1, arg2);
})

ipc.on('build_clear', function(event) {
assistantWin.webContents.send('clear');
})

0 comments on commit f93bb44

Please sign in to comment.