mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2025-07-17 20:33:48 +02:00
Added fixture search
This commit is contained in:
16
index.js
16
index.js
@ -157,6 +157,7 @@ function rebuildFixtureLib() {
|
|||||||
db.run(sqlDyn);
|
db.run(sqlDyn);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
db.close()
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,6 +477,21 @@ function init() {
|
|||||||
} else if (String(arg).includes("FIXTURE:initDB")) {
|
} else if (String(arg).includes("FIXTURE:initDB")) {
|
||||||
rebuildFixtureLib()
|
rebuildFixtureLib()
|
||||||
event.returnValue = "";
|
event.returnValue = "";
|
||||||
|
} else if (String(arg).includes("FIXTURE:search")) {
|
||||||
|
term = String(arg).split("|")[1];
|
||||||
|
sqlQ = "SELECT * FROM fixtures WHERE Name LIKE '%" + term + "%' or LongName LIKE '%" + term + "%' or ShortName LIKE '%" + term + "%' or Manufacturer LIKE '%" + term + "%';"
|
||||||
|
console.log(sqlQ)
|
||||||
|
let db = new sqlite3.Database("usrStore/fixtureDB.sqlite");
|
||||||
|
db.all(sqlQ, [], (err, rows) => {
|
||||||
|
console.log("ALIVE");
|
||||||
|
if (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
event.returnValue = rows;
|
||||||
|
console.log(rows)
|
||||||
|
});
|
||||||
|
db.close()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event.returnValue = "ERR:UNKNOW_CMD";
|
event.returnValue = "ERR:UNKNOW_CMD";
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,90 @@
|
|||||||
|
<style>
|
||||||
|
table {
|
||||||
|
font-family: arial, sans-serif;
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
height: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th {
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.cust {
|
||||||
|
overflow-y: scroll;
|
||||||
|
height: 80%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<h1>Fixtures</h1>
|
<h1>Fixtures</h1>
|
||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Back</button>
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Back</button>
|
||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "FIXTURE:initDB");'>Do magic init stuff</button><br><br>
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "FIXTURE:initDB");'>Do magic init stuff</button><br><br>
|
||||||
<input type = "text" placeholder="Search fixture libary"></input><br>
|
<input type = "text" placeholder="Search fixture libary" id="libSearch"></input><br>
|
||||||
|
<div class="cust">
|
||||||
|
<table id="fixtureList">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Manufacturer:</th>
|
||||||
|
<th>Description:</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
firstState = document.getElementById("libSearch").value
|
||||||
|
setInterval(function(){
|
||||||
|
temp = document.getElementById("libSearch").value
|
||||||
|
if(temp != firstState){
|
||||||
|
outy = ipcRenderer.sendSync("synchronous-message", "FIXTURE:search|" + temp);
|
||||||
|
console.log(outy)
|
||||||
|
elm = document.getElementById("fixtureList")
|
||||||
|
elm.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Manufacturer</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
`
|
||||||
|
i = 0
|
||||||
|
while(i<outy.length){
|
||||||
|
text = ""
|
||||||
|
text += "<tr>"
|
||||||
|
text += "<td>" + outy[i].LongName + "</td>"
|
||||||
|
text += "<td>" + outy[i].Manufacturer + "</td>"
|
||||||
|
text += "<td>" + outy[i].Description + "</td>"
|
||||||
|
text += "</tr>"
|
||||||
|
elm.innerHTML += text
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
firstState = temp
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -201,209 +201,93 @@
|
|||||||
|
|
||||||
<!--</body>
|
<!--</body>
|
||||||
</html>-->
|
</html>-->
|
||||||
<!DOCTYPE html>
|
<style>
|
||||||
<html>
|
table {
|
||||||
<head>
|
font-family: arial, sans-serif;
|
||||||
<meta charset="UTF-8" />
|
border-collapse: collapse;
|
||||||
<title>Enlight - Screen 1</title>
|
width: 100%;
|
||||||
<!--<meta
|
overflow-y: scroll;
|
||||||
http-equiv="Content-Security-Policy"
|
height: 80%;
|
||||||
content="script-src 'self' 'unsafe-inline';"
|
}
|
||||||
/>-->
|
|
||||||
<script src="static/jquery-1.7.1.min.js" type="text/javascript"></script>
|
td, th {
|
||||||
<script src="static/js/helper.js" type="text/javascript"></script>
|
border: 1px solid #dddddd;
|
||||||
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>*-->
|
text-align: left;
|
||||||
<link href="static/default.css" rel="stylesheet" />
|
padding: 8px;
|
||||||
<link
|
|
||||||
href="static/fontawesome-free-5.15.1-web/css/all.css"
|
}
|
||||||
rel="stylesheet"
|
.cust {
|
||||||
/>
|
overflow-y: scroll;
|
||||||
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">-->
|
height: 80%;
|
||||||
</head>
|
}
|
||||||
<body>
|
</style>
|
||||||
<!--<div id="header-bar" class="header-bar">
|
|
||||||
<div class="areaRight">
|
<h1>Fixtures</h1>
|
||||||
<network>
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Back</button>
|
||||||
<i
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "FIXTURE:initDB");'>Do magic init stuff</button><br><br>
|
||||||
class="fas fa-network-wired"
|
<input type = "text" placeholder="Search fixture libary" id="libSearch"></input><br>
|
||||||
id="networkBtn"
|
<div class="cust">
|
||||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");'
|
<table id="fixtureList">
|
||||||
></i>
|
<tr>
|
||||||
<div id="networkDropdown" class="dropdown-content"></div>
|
<th>Name</th>
|
||||||
</network>
|
<th>Manufacturer:</th>
|
||||||
<battery id="battery" class="fa"></battery>
|
<th>Description:</th>
|
||||||
<clock id="clock" class="header-clock"></clock>
|
</tr>
|
||||||
<i
|
<tr>
|
||||||
class="fa-spin loader1 fa"
|
<td> </td>
|
||||||
style="font-size: 18px; padding-right: 4px"
|
<td> </td>
|
||||||
id="loader"
|
<td> </td>
|
||||||
></i
|
</tr>
|
||||||
>
|
<tr>
|
||||||
</div>
|
<td> </td>
|
||||||
</div>
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var loaderInUse = true;
|
firstState = document.getElementById("libSearch").value
|
||||||
const { ipcRenderer } = require("electron");
|
setInterval(function(){
|
||||||
setInterval(function () {
|
temp = document.getElementById("libSearch").value
|
||||||
// Pulling general info from main thread
|
if(temp != firstState){
|
||||||
loadOverride = ipcRenderer.sendSync(
|
outy = ipcRenderer.sendSync("synchronous-message", "FIXTURE:search|" + temp);
|
||||||
"synchronous-message",
|
console.log(outy)
|
||||||
"loadOverride"
|
elm = document.getElementById("fixtureList")
|
||||||
);
|
elm.innerHTML = `
|
||||||
if (!loaderInUse) {
|
<tr>
|
||||||
if (loadOverride) {
|
<th>Name</th>
|
||||||
document.getElementById("loader").innerHTML = "";
|
<th>Manufacturer</th>
|
||||||
} else {
|
<th>Description</th>
|
||||||
document.getElementById("loader").innerHTML = "";
|
</tr>
|
||||||
|
`
|
||||||
|
i = 0
|
||||||
|
while(i<outy.length){
|
||||||
|
text = ""
|
||||||
|
text += "<tr>"
|
||||||
|
text += "<td>" + outy[i].LongName + "</td>"
|
||||||
|
text += "<td>" + outy[i].Manufacturer + "</td>"
|
||||||
|
text += "<td>" + outy[i].Description + "</td>"
|
||||||
|
text += "</tr>"
|
||||||
|
elm.innerHTML += text
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
firstState = temp
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500)
|
||||||
|
|
||||||
// Network info
|
|
||||||
var allNetworkNames = [];
|
|
||||||
function buildNetworkDropDown() {
|
|
||||||
loaderInUse = true;
|
|
||||||
document.getElementById("loader").innerHTML = "";
|
|
||||||
allNetworks = ipcRenderer.sendSync(
|
|
||||||
"synchronous-message",
|
|
||||||
"getNetworks"
|
|
||||||
);
|
|
||||||
lastNetwork = ipcRenderer.sendSync(
|
|
||||||
"synchronous-message",
|
|
||||||
"getMainNetwork"
|
|
||||||
);
|
|
||||||
allNetworkNames = [];
|
|
||||||
console.log(lastNetwork);
|
|
||||||
i = 0;
|
|
||||||
var dropDown = document.getElementById("networkDropdown");
|
|
||||||
dropDown.innerHTML = "";
|
|
||||||
while (i < allNetworks.length) {
|
|
||||||
temp =
|
|
||||||
"<a id='networkEntry" +
|
|
||||||
String(i) +
|
|
||||||
"' onclick='selectNewNetwork(" +
|
|
||||||
String(i) +
|
|
||||||
")'> " +
|
|
||||||
encode_html(allNetworks[i].ifaceName) +
|
|
||||||
"</a>";
|
|
||||||
dropDown.innerHTML += temp;
|
|
||||||
allNetworkNames.push(allNetworks[i].ifaceName);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (does_list_contain(allNetworkNames, lastNetwork)) {
|
|
||||||
nameOfElm =
|
|
||||||
"networkEntry" + String(allNetworkNames.indexOf(lastNetwork));
|
|
||||||
networkEntryElm = document.getElementById(nameOfElm);
|
|
||||||
networkEntryElm.innerHTML = networkEntryElm.innerHTML.replace(
|
|
||||||
" ",
|
|
||||||
"✔"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.warn("Network is no longer valid");
|
|
||||||
ipcRenderer.sendSync(
|
|
||||||
"synchronous-message",
|
|
||||||
"state:networkNoLongerValid"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
loaderInUse = false;
|
|
||||||
document.getElementById("loader").innerHTML = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectNewNetwork(id) {
|
|
||||||
idAsNumber = parseInt(id);
|
|
||||||
newNetwork = allNetworkNames[id];
|
|
||||||
ipcRenderer.sendSync(
|
|
||||||
"synchronous-message",
|
|
||||||
"set:newNetwork|" + newNetwork
|
|
||||||
);
|
|
||||||
buildNetworkDropDown();
|
|
||||||
|
|
||||||
nameOfElm = "networkEntry" + String(idAsNumber);
|
|
||||||
networkEntryElm = document.getElementById(nameOfElm);
|
|
||||||
networkEntryElm.innerHTML = networkEntryElm.innerHTML.replace(
|
|
||||||
" ",
|
|
||||||
"✔"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
buildNetworkDropDown();
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
|
||||||
// Battery info screen
|
|
||||||
batteryExists = ipcRenderer.sendSync("synchronous-message", "hasBattery"); // prints "pong"
|
|
||||||
var batteryShowdStart = false;
|
|
||||||
if (batteryExists) {
|
|
||||||
batteryLevel = ipcRenderer.sendSync(
|
|
||||||
"synchronous-message",
|
|
||||||
"getBatteryLevel"
|
|
||||||
);
|
|
||||||
|
|
||||||
//Setup regular updates
|
|
||||||
setInterval(function () {
|
|
||||||
batteryLevel = parseInt(
|
|
||||||
ipcRenderer.sendSync("synchronous-message", "getBatteryLevel")
|
|
||||||
);
|
|
||||||
|
|
||||||
batteryShowdStart = true;
|
|
||||||
if (batteryLevel > 75) {
|
|
||||||
document.getElementById("battery").innerHTML = "";
|
|
||||||
} else if (batteryLevel <= 75 && batteryLevel > 50) {
|
|
||||||
document.getElementById("battery").innerHTML = "";
|
|
||||||
} else if (batteryLevel <= 50 && batteryLevel > 25) {
|
|
||||||
document.getElementById("battery").innerHTML = "";
|
|
||||||
} else if (batteryLevel <= 25 && batteryLevel > 5) {
|
|
||||||
document.getElementById("battery").innerHTML = "";
|
|
||||||
} else {
|
|
||||||
document.getElementById("battery").innerHTML = "";
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
} else {
|
|
||||||
batteryShowdStart = true;
|
|
||||||
}
|
|
||||||
if (batteryShowdStart) {
|
|
||||||
document.getElementById("loader").innerHTML = "";
|
|
||||||
loaderInUse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setInterval(function () {
|
|
||||||
var date = new Date();
|
|
||||||
hour = updateTime(date.getHours());
|
|
||||||
min = updateTime(date.getMinutes());
|
|
||||||
sec = updateTime(date.getSeconds());
|
|
||||||
document.getElementById("clock").innerHTML =
|
|
||||||
hour + ":" + min + ":" + sec;
|
|
||||||
}, 500);
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
window.onclick = function (event) {
|
|
||||||
if (!event.target.matches("#networkBtn")) {
|
|
||||||
var dropdowns = document.getElementsByClassName("dropdown-content");
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < dropdowns.length; i++) {
|
|
||||||
var openDropdown = dropdowns[i];
|
|
||||||
if (openDropdown.classList.contains("show")) {
|
|
||||||
openDropdown.classList.remove("show");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>-->
|
|
||||||
<!--<iframe src="header.html" class="headerIframe"></iframe>-->
|
|
||||||
<h1>Hello World!</h1>
|
|
||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.session");'>Session screen</button>
|
|
||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.fixtures");'>Fixture screen</button>
|
|
||||||
We are using node
|
|
||||||
<script>
|
|
||||||
document.write(process.versions.node);
|
|
||||||
</script>
|
|
||||||
, Chrome
|
|
||||||
<script>
|
|
||||||
document.write(process.versions.chrome);
|
|
||||||
</script>
|
|
||||||
, and Electron
|
|
||||||
<script>
|
|
||||||
document.write(process.versions.electron);
|
|
||||||
</script>
|
|
||||||
.
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user