mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-09 07:43:39 +00:00
add Network Info window
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
<button class="left" id="refresh-device-button" title="Refresh Device" disabled>
|
||||
<img src="src/img/outline_refresh_white_18dp.png" />
|
||||
</button>
|
||||
<button class="right" id="network-info-button"><img src="src/img/outline_info_white_18dp.png" /></button>
|
||||
</div>
|
||||
|
||||
<div id="device-settings">
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
const {
|
||||
app,
|
||||
BrowserWindow,
|
||||
Menu,
|
||||
ipcMain,
|
||||
nativeTheme,
|
||||
dialog,
|
||||
} = require('electron');
|
||||
const { app, BrowserWindow, Menu, ipcMain, nativeTheme, dialog } = require('electron');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const path = require('path');
|
||||
|
||||
@@ -16,6 +9,7 @@ let autoUpdate = false;
|
||||
let manualUpdateCheck = false;
|
||||
let menuObj;
|
||||
let mainWindow;
|
||||
let networkInfoWindow;
|
||||
|
||||
const menuTemplate = [
|
||||
...(isMac ? [{ role: 'appMenu' }] : []),
|
||||
@@ -95,10 +89,7 @@ const menuTemplate = [
|
||||
id: 'devicePin',
|
||||
enabled: false,
|
||||
click(menuItem, window, event) {
|
||||
mainWindow.webContents.send(
|
||||
'setActiveDevicePinned',
|
||||
menuItem.checked
|
||||
);
|
||||
mainWindow.webContents.send('setActiveDevicePinned', menuItem.checked);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -166,6 +157,18 @@ const windowWin = {
|
||||
},
|
||||
};
|
||||
|
||||
const networkInfoWin = {
|
||||
width: 700,
|
||||
height: 350,
|
||||
backgroundColor: '#333333',
|
||||
show: false,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
preload: path.join(__dirname, 'networkInterfaces.js'),
|
||||
},
|
||||
};
|
||||
|
||||
if (isWin) {
|
||||
app.setAppUserModelId(app.name);
|
||||
}
|
||||
@@ -236,13 +239,19 @@ ipcMain.on('setAutoUpdate', (event, _autoUpdate) => {
|
||||
autoUpdate = _autoUpdate;
|
||||
|
||||
// update menu item for enabling/disabling auto update
|
||||
menuTemplate[menuTemplate.length - 1].submenu[2].label = autoUpdate
|
||||
? 'Disable Auto Update'
|
||||
: 'Enable Auto Update';
|
||||
menuTemplate[menuTemplate.length - 1].submenu[2].label = autoUpdate ? 'Disable Auto Update' : 'Enable Auto Update';
|
||||
menuObj = Menu.buildFromTemplate(menuTemplate);
|
||||
Menu.setApplicationMenu(menuObj);
|
||||
});
|
||||
|
||||
ipcMain.on('openNetworkInfoWindow', (event, arg) => {
|
||||
if (!networkInfoWindow || (networkInfoWindow && networkInfoWindow.isDestroyed())) {
|
||||
networkInfoWindow = new BrowserWindow(networkInfoWin);
|
||||
networkInfoWindow.loadFile('networkInterfaces.html');
|
||||
}
|
||||
networkInfoWindow.show();
|
||||
});
|
||||
|
||||
// this can be set to true to bypass the download update dialog and skip straight to install prompt
|
||||
autoUpdater.autoDownload = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Network Information</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0px;
|
||||
color: white;
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont;
|
||||
user-select: none;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 12px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
background-color: rgba(100, 100, 100, 0.3);
|
||||
border-top: #868686 1px solid;
|
||||
border-bottom: #444 1px solid;
|
||||
border-right: #868686 1px solid;
|
||||
font-weight: normal;
|
||||
height: 36px;
|
||||
}
|
||||
td {
|
||||
border-bottom: dimgray 1px solid;
|
||||
}
|
||||
p {
|
||||
color: #a0a0a0;
|
||||
margin: 17px 13px;
|
||||
font-size: 14px;
|
||||
}
|
||||
button {
|
||||
box-sizing: content-box;
|
||||
height: 25px;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 1px 10px;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
|
||||
color: white;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
button:hover {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
button:focus {
|
||||
outline: none;
|
||||
}
|
||||
span {
|
||||
border-radius: 4px;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
.if-en {
|
||||
background-color: #1565c0;
|
||||
}
|
||||
.if-ut {
|
||||
background-color: #bf360c;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</html>
|
||||
<p>Attached Network Interfaces:</p>
|
||||
<button onclick="location.reload()">Refresh</button>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>IP Address</th>
|
||||
<th>Subnet Mask</th>
|
||||
<th>Searchable Addresses</th>
|
||||
</tr>
|
||||
<tbody id="network-interfaces"></tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
window.init();
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
const SEARCH = require('./src/search.js');
|
||||
|
||||
window.init = function init() {
|
||||
const networkInterfaces = SEARCH.getNetworkInterfaces();
|
||||
let html = '';
|
||||
|
||||
for (let i = 0; i < Object.keys(networkInterfaces).length; i++) {
|
||||
const interfaceID = Object.keys(networkInterfaces)[i];
|
||||
const interfaceObj = networkInterfaces[interfaceID];
|
||||
console.log(interfaceObj);
|
||||
|
||||
html += `<tr><td><span class="if-${interfaceID.substring(0, 2)}">${interfaceID}</span></td>`;
|
||||
html += `<td>${interfaceObj[0].address}</td>`;
|
||||
html += `<td>${interfaceObj[0].netmask}</td>`;
|
||||
html += `<td>${interfaceObj[0].firstSearchAddress} - ${interfaceObj[0].lastSearchAddress}</td>`;
|
||||
html += `</tr>`;
|
||||
|
||||
document.getElementById('network-interfaces').innerHTML = html;
|
||||
}
|
||||
};
|
||||
@@ -106,6 +106,11 @@ window.init = function init() {
|
||||
SAVESLOTS.saveAll();
|
||||
};
|
||||
|
||||
document.getElementById('network-info-button').onclick = function fooBar(e) {
|
||||
ipcRenderer.send('openNetworkInfoWindow');
|
||||
console.log('FOO');
|
||||
};
|
||||
|
||||
document.onkeyup = function keyUp(e) {
|
||||
if (e.key === 'ArrowUp') {
|
||||
VIEW.selectPreviousDevice();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 210 B |
+4
-1
@@ -27,6 +27,9 @@ a {
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#main {
|
||||
box-sizing: border-box;
|
||||
@@ -133,7 +136,7 @@ a {
|
||||
/* position: absolute;
|
||||
bottom: 210px;
|
||||
left: 0px;*/
|
||||
width: 100%;
|
||||
width: 262px;
|
||||
height: 30px;
|
||||
padding-right: 10px;
|
||||
/*background: linear-gradient(#2f2f2f 0%, #2c2c2c 100%);*/
|
||||
|
||||
@@ -28,6 +28,8 @@ function getServers() {
|
||||
const last = ip.toLong(subnet.lastAddress) - 1;
|
||||
// console.log(`range ${subnet.firstAddress} - ${subnet.lastAddress}`);
|
||||
address.broadcastAddress = subnet.broadcastAddress;
|
||||
address.firstSearchAddress = subnet.firstAddress;
|
||||
address.lastSearchAddress = subnet.lastAddress;
|
||||
|
||||
if (!validInterfaces[key]) {
|
||||
validInterfaces[key] = [];
|
||||
|
||||
Reference in New Issue
Block a user