Merge branch 'develop' of https://github.com/Superalgos/Superalgos into develop
This commit is contained in:
commit
24100041c2
6 files changed
+4153
-1616
No files matched your search
@@ -1,4 +1,3 @@
|
||||
const {graphql} = require("@octokit/graphql");
|
||||
exports.newHttpInterface = function newHttpInterface() {
|
||||
|
||||
/*
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -819,8 +819,8 @@
|
||||
"id": "b7c934fd-8031-4615-bf9c-94280e452511",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31142.160562311805,
|
||||
"y": 28850
|
||||
"x": 31012.25675174414,
|
||||
"y": 28775
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 30882.352941176472,
|
||||
@@ -831,7 +831,7 @@
|
||||
"isFrozen": false,
|
||||
"isCollapsed": true,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"distanceToParent": 2,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
@@ -863,7 +863,152 @@
|
||||
"name": "New Weight Votes Switch",
|
||||
"config": "{}",
|
||||
"project": "Governance",
|
||||
"weightVotesSwitch": [],
|
||||
"weightVotesSwitch": [
|
||||
{
|
||||
"type": "Weight Votes Switch",
|
||||
"name": "Weight Votes - Mentorship",
|
||||
"config": "{}",
|
||||
"project": "Governance",
|
||||
"weightVotesSwitch": [],
|
||||
"poolWeightVotes": [
|
||||
{
|
||||
"type": "Pool Weight Vote",
|
||||
"name": "Mentorship Rewards Pool",
|
||||
"config": "{\n\"percentage\": 90\n}",
|
||||
"project": "Governance",
|
||||
"id": "2a573cd8-f8d6-4b36-9f09-986902a25427",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31144.852941176472,
|
||||
"y": 28870.096189432334
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31482.352941176472,
|
||||
"y": 28870.096189432334
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 4,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
},
|
||||
"referenceParent": {
|
||||
"type": "Pool",
|
||||
"name": "Mentorship Rewards",
|
||||
"id": "53ddcc36-f693-4193-8284-999a88f1c944"
|
||||
},
|
||||
"referenceParentCombinedNodePath": [
|
||||
[
|
||||
"Superalgos",
|
||||
"Pools"
|
||||
],
|
||||
[
|
||||
"Governance Programs",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Community Building Programs",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Mentorship Program",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Mentorship Rewards",
|
||||
"Pool"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Pool Weight Vote",
|
||||
"name": "Mentorship Bonus Pool",
|
||||
"config": "{}",
|
||||
"project": "Governance",
|
||||
"id": "44ffa08c-ebcc-4ca2-833a-d7e4a4a96841",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31651.102941176472,
|
||||
"y": 28577.812615655086
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31482.352941176472,
|
||||
"y": 28870.096189432334
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 4,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
},
|
||||
"referenceParent": {
|
||||
"type": "Pool",
|
||||
"name": "Mentorship Bonus",
|
||||
"id": "ff1e4a84-3363-4348-ad15-31a34898fa82"
|
||||
},
|
||||
"referenceParentCombinedNodePath": [
|
||||
[
|
||||
"Superalgos",
|
||||
"Pools"
|
||||
],
|
||||
[
|
||||
"Governance Programs",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Community Building Programs",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Mentorship Program",
|
||||
"Pool Class"
|
||||
],
|
||||
[
|
||||
"Mentorship Bonus",
|
||||
"Pool"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"assetWeightVotes": [],
|
||||
"featureWeightVotes": [],
|
||||
"positionWeightVotes": [],
|
||||
"id": "af870025-4eac-4adf-b929-67b76bfac227",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31482.352941176472,
|
||||
"y": 28870.096189432334
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31594.852941176472,
|
||||
"y": 29064.951905283833
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"poolWeightVotes": [],
|
||||
"assetWeightVotes": [],
|
||||
"featureWeightVotes": [],
|
||||
@@ -876,12 +1021,12 @@
|
||||
"id": "5b8b92d0-1df5-45f1-9ae7-75c87a8302db",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31482.352941176472,
|
||||
"y": 29000
|
||||
"x": 31819.852941176472,
|
||||
"y": 29064.951905283833
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31407.352941176472,
|
||||
"y": 29129.903810567666
|
||||
"x": 31594.852941176472,
|
||||
"y": 29064.951905283833
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
@@ -943,11 +1088,11 @@
|
||||
"id": "37a9c875-a9bc-4ab1-a00e-f248f818f311",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31407.352941176472,
|
||||
"y": 29129.903810567666
|
||||
"x": 31594.852941176472,
|
||||
"y": 29064.951905283833
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31332.352941176472,
|
||||
"x": 31482.352941176472,
|
||||
"y": 29259.807621135333
|
||||
},
|
||||
"floatingObject": {
|
||||
@@ -975,11 +1120,11 @@
|
||||
"id": "e8e3f63a-b9fb-47d7-8fc9-c0634a0f2425",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31407.352941176472,
|
||||
"y": 29389.711431703
|
||||
"x": 31594.852941176472,
|
||||
"y": 29454.663336986832
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 31332.352941176472,
|
||||
"x": 31482.352941176472,
|
||||
"y": 29259.807621135333
|
||||
},
|
||||
"floatingObject": {
|
||||
@@ -999,7 +1144,7 @@
|
||||
"id": "352b5f30-d971-478b-9085-4c9ff9ddb388",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 31332.352941176472,
|
||||
"x": 31482.352941176472,
|
||||
"y": 29259.807621135333
|
||||
},
|
||||
"targetPosition": {
|
||||
@@ -1011,7 +1156,7 @@
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"distanceToParent": 4,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
@@ -1322,7 +1467,7 @@
|
||||
"financialPrograms": {
|
||||
"type": "Financial Programs",
|
||||
"name": "New Financial Programs",
|
||||
"config": "{\"percentage\": 35}",
|
||||
"config": "{\n \"percentage\": 35\n}",
|
||||
"project": "Governance",
|
||||
"stakingProgram": {
|
||||
"type": "Staking Program",
|
||||
@@ -1420,8 +1565,8 @@
|
||||
"id": "a851317c-1283-40e1-9434-a78c5c88caaa",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 30102.930077770474,
|
||||
"y": 28250
|
||||
"x": 30232.83388833814,
|
||||
"y": 28325
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 30362.737698905807,
|
||||
@@ -1432,7 +1577,7 @@
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"distanceToParent": 2,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
@@ -1517,7 +1662,7 @@
|
||||
"id": "899f92f8-5e00-42a0-8316-10c95dd2a6b1",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 30582.352941176472,
|
||||
"x": 30732.352941176472,
|
||||
"y": 28400
|
||||
},
|
||||
"targetPosition": {
|
||||
@@ -1529,7 +1674,7 @@
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"distanceToParent": 2,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
"id": "e2dec054-20c2-426e-8303-4a6f475a02e0",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19237,
|
||||
"y": 8865.077136594007
|
||||
"x": 18867.384757729335,
|
||||
"y": 9044.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
"y": 9124.884757729338
|
||||
"x": 19127.192378864667,
|
||||
"y": 9194.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
@@ -49,12 +49,12 @@
|
||||
"id": "80ffa07e-7b69-4d76-a315-67ca38b1d340",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19387,
|
||||
"y": 9124.884757729338
|
||||
"x": 19127.192378864667,
|
||||
"y": 9194.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19537,
|
||||
"y": 9384.692378864669
|
||||
"x": 19387,
|
||||
"y": 9344.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
@@ -78,15 +78,15 @@
|
||||
"type": "Tokens Awarded",
|
||||
"name": "New Tokens Awarded",
|
||||
"project": "Governance",
|
||||
"id": "c4ed9b78-6a1f-44fc-b9dd-29b54a5b40a5",
|
||||
"id": "96a3ff2b-49de-4fb5-9bbf-921973ce770f",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 20137,
|
||||
"y": 9384.692378864669
|
||||
"x": 19906.615242270665,
|
||||
"y": 9044.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19837,
|
||||
"y": 9384.692378864669
|
||||
"x": 19646.807621135333,
|
||||
"y": 9194.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
@@ -104,12 +104,12 @@
|
||||
"id": "22e35987-f640-40cf-b9e2-fe3af87b5bfd",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19837,
|
||||
"y": 9384.692378864669
|
||||
"x": 19646.807621135333,
|
||||
"y": 9194.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19537,
|
||||
"y": 9384.692378864669
|
||||
"x": 19387,
|
||||
"y": 9344.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
@@ -127,8 +127,8 @@
|
||||
"id": "83f57cc3-8e3f-40a6-9f79-15ecd7732094",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19537,
|
||||
"y": 9384.692378864669
|
||||
"x": 19387,
|
||||
"y": 9344.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
@@ -530,8 +530,8 @@
|
||||
"id": "cecc4fa4-4486-4785-8f98-27d5b4e6f6b8",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19537,
|
||||
"y": 9904.307621135331
|
||||
"x": 19687,
|
||||
"y": 9644.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
@@ -550,6 +550,91 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"liquidityPrograms": {
|
||||
"type": "Liquidity Programs",
|
||||
"name": "New Liquidity Programs",
|
||||
"config": "{}",
|
||||
"project": "Governance",
|
||||
"liquidityProgram": [
|
||||
{
|
||||
"type": "Liquidity Program",
|
||||
"name": "New Liquidity Program",
|
||||
"config": "{\n \"asset\": \"BUSD\"\n}",
|
||||
"project": "Governance",
|
||||
"tokensAwarded": {
|
||||
"type": "Tokens Awarded",
|
||||
"name": "New Tokens Awarded",
|
||||
"project": "Governance",
|
||||
"id": "5dc56466-4214-467c-b3c1-13d38ebff7d8",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19387,
|
||||
"y": 10544.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
"y": 10244.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "a438ce8c-3836-4043-a171-143a009821ce",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19387,
|
||||
"y": 10244.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
"y": 9944.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "8ef4f8b3-42e2-4484-84e2-92292bba8415",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 19387,
|
||||
"y": 9944.5
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 19387,
|
||||
"y": 9644.5
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
},
|
||||
"uiObject": {
|
||||
"isRunning": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "2f247174-4c0a-4a8b-9b21-33504b7e6be7",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
|
||||
+9
-62
@@ -10,7 +10,7 @@
|
||||
.log-warn { color: orange }
|
||||
.log-error { color: red }
|
||||
.log-info { color: skyblue }
|
||||
.log-log { color: silver }
|
||||
.log-log { color: silver}
|
||||
|
||||
.log-warn, .log-error { font-weight: bold; }
|
||||
</style>
|
||||
@@ -24,75 +24,22 @@
|
||||
<script>
|
||||
window.onload = () => {
|
||||
window.api.receive('fromMain', (data) => {
|
||||
//const consoleLine = document.createElement('span')
|
||||
//const consoleLineText = document.createTextNode(data)
|
||||
//consoleLine.appendChild(consoleLineText)
|
||||
if(data.includes('[ERROR]')) {
|
||||
//const consoleLine = document.createElement('span')
|
||||
document.getElementById('log').insertAdjacentHTML('beforeend', "<span class=\"log-error\">" + data + "</span><br>");
|
||||
}
|
||||
if(data.includes('[WARN]')) {
|
||||
//consoleLineText.style.cssText = "color: orange; font-weight: bold;"
|
||||
else if(data.includes('[WARN]')) {
|
||||
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-warn\">" + data + "</span><br>");
|
||||
}
|
||||
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-info\">" + data + "</span><br>");
|
||||
//document.getElementById('log').insertAdjacentHTML('beforeend', consoleLineText);
|
||||
else if(data.includes('[INFO]')) {
|
||||
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-info\">" + data + "</span><br>");
|
||||
}
|
||||
else {
|
||||
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-log\">" + data + "</span><br>");
|
||||
}
|
||||
window.scrollTo(0, document.querySelector("#log-container").scrollHeight)
|
||||
})
|
||||
window.api.send("toMain", "ImAlive!")
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script>
|
||||
rewireLoggingToElement(
|
||||
() => document.getElementById("log"),
|
||||
() => document.getElementById("log-container"), true);
|
||||
|
||||
function rewireLoggingToElement(eleLocator, eleOverflowLocator, autoScroll) {
|
||||
fixLoggingFunc('log');
|
||||
fixLoggingFunc('debug');
|
||||
fixLoggingFunc('warn');
|
||||
fixLoggingFunc('error');
|
||||
fixLoggingFunc('info');
|
||||
|
||||
function fixLoggingFunc(name) {
|
||||
console['old' + name] = console[name];
|
||||
console[name] = function(...arguments) {
|
||||
//const output = produceOutput(name, arguments);
|
||||
output = window.api.receive('fromMain', (message, arguments) => {
|
||||
produceOutput(message, arguments)
|
||||
})
|
||||
const eleLog = eleLocator();
|
||||
|
||||
if (autoScroll) {
|
||||
const eleContainerLog = eleOverflowLocator();
|
||||
const isScrolledToBottom = eleContainerLog.scrollHeight - eleContainerLog.clientHeight <= eleContainerLog.scrollTop + 1;
|
||||
eleLog.innerHTML += output + "<br>";
|
||||
if (isScrolledToBottom) {
|
||||
eleContainerLog.scrollTop = eleContainerLog.scrollHeight - eleContainerLog.clientHeight;
|
||||
}
|
||||
} else {
|
||||
eleLog.innerHTML += output + "<br>";
|
||||
}
|
||||
|
||||
console['old' + name].apply(undefined, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function produceOutput(name, args) {
|
||||
return args.reduce((output, arg) => {
|
||||
return output +
|
||||
"<span class=\"log-" + (typeof arg) + " log-" + name + "\">" +
|
||||
(typeof arg === "object" && (JSON || {}).stringify ? JSON.stringify(arg) : arg) +
|
||||
"</span> ";
|
||||
}, '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* setInterval(() => {
|
||||
const method = (['log', 'debug', 'warn', 'error', 'info'][Math.floor(Math.random() * 5)]);
|
||||
console[method](method, 'logging something...');
|
||||
}, 200); */
|
||||
</script> -->
|
||||
</body>
|
||||
</html>
|
||||
+115
-51
@@ -1,55 +1,50 @@
|
||||
const {app, Menu, BrowserWindow, ipcMain} = require('electron')
|
||||
const {app, Menu, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
// To check for update on Github repo
|
||||
const {autoUpdater} = require("electron-updater")
|
||||
const { windowsStore } = require('process')
|
||||
|
||||
// Enable non contribution mode (test)
|
||||
process.env.SA_MODE = 'gitDisable'
|
||||
process.env.PACKAGED_PATH = app.getAppPath()
|
||||
process.env.DATA_PATH = app.getPath('documents')
|
||||
|
||||
const WINDOW_WIDTH = null
|
||||
const WINDOW_HEIGHT = null
|
||||
const WINDOW_WIDTH = 1280
|
||||
const WINDOW_HEIGHT = 768
|
||||
|
||||
let mainWindow, consoleWindow, platform
|
||||
|
||||
var app_ready = false
|
||||
var server_ready = false
|
||||
|
||||
const port = 34248 // Default HTTP port
|
||||
|
||||
run()
|
||||
|
||||
//var platform = null
|
||||
|
||||
function run() {
|
||||
const { fork } = require('child_process')
|
||||
platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc'], env: process.env})
|
||||
|
||||
//var consoleOutput = ""
|
||||
|
||||
platform.on('message', _ => {
|
||||
open()
|
||||
openMain()
|
||||
openConsoleWindow()
|
||||
})
|
||||
}
|
||||
|
||||
ipcMain.on("toMain", (event, args) => {
|
||||
platform.stdout.setEncoding('utf8')
|
||||
platform.stdout.on('data', (data) => {
|
||||
//data = data.toString()
|
||||
//consoleOutput += data
|
||||
consoleWindow.webContents.send("fromMain", data);
|
||||
})
|
||||
if (args === "ImAlive!" && consoleWindow) {
|
||||
platform.stdout.setEncoding('utf8')
|
||||
platform.stdout.on('data', (data) => {
|
||||
if(consoleWindow != null) {
|
||||
consoleWindow.webContents.send("fromMain", data);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function open () {
|
||||
function openMain () {
|
||||
let bw_options = {
|
||||
width: WINDOW_WIDTH ? WINDOW_WIDTH : 1280,
|
||||
height: WINDOW_HEIGHT ? WINDOW_HEIGHT : 768,
|
||||
width: WINDOW_WIDTH,
|
||||
height: WINDOW_HEIGHT,
|
||||
resizable: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: false, // is default value after Electron v5
|
||||
@@ -62,33 +57,55 @@ function open () {
|
||||
bw_options
|
||||
)
|
||||
|
||||
//mainWindow.setResizable(true)
|
||||
|
||||
createMainMenus()
|
||||
|
||||
mainWindow.loadURL("http://localhost:" + port)
|
||||
|
||||
// w.webContents.openDevTools()
|
||||
mainWindow.on('close', function (e) {
|
||||
if (consoleWindow.isVisible()) {
|
||||
e.preventDefault()
|
||||
mainWindow.hide()
|
||||
} else {
|
||||
let choice = dialog.showMessageBoxSync(
|
||||
mainWindow,
|
||||
{
|
||||
type: 'question',
|
||||
buttons: ['Yes', 'No'],
|
||||
title: 'Confirm',
|
||||
message: 'Do you really want to close Superalgos?'
|
||||
}
|
||||
)
|
||||
// 0 for Yes
|
||||
if (choice === 0) {
|
||||
mainWindow = null
|
||||
app.exit()
|
||||
}
|
||||
// 1 for No
|
||||
if (choice === 1) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.on('closed', function () {
|
||||
mainWindow = null
|
||||
mainWindow.on('activate', function () {
|
||||
mainWindow.show()
|
||||
})
|
||||
}
|
||||
|
||||
function openConsoleWindow() {
|
||||
createConsoleMenus()
|
||||
if(consoleWindow) {
|
||||
consoleWindow.focus()
|
||||
return
|
||||
}
|
||||
|
||||
newWindow =
|
||||
consoleWindow = new BrowserWindow({
|
||||
resizable: true,
|
||||
title: 'Platform Logs',
|
||||
minimizable: false,
|
||||
fullscreenable: false,
|
||||
width: 1024,
|
||||
fullscreenable: true,
|
||||
show: false,
|
||||
width: WINDOW_WIDTH,
|
||||
webPreferences: {
|
||||
devTools: true,
|
||||
nodeIntegration: false, // is default value after Electron v5
|
||||
contextIsolation: true, // protect against prototype pollution
|
||||
enableRemoteModule: false, // turn off remote
|
||||
@@ -99,25 +116,42 @@ function openConsoleWindow() {
|
||||
consoleWindow.setBackgroundColor('#000000')
|
||||
consoleWindow.loadFile('./console.html')
|
||||
|
||||
/* consoleWindow.on('ready'), _ => {
|
||||
platform.stdout.setEncoding('utf8')
|
||||
platform.stdout.on('data', (data) => {
|
||||
//data = data.toString()
|
||||
//consoleOutput += data
|
||||
consoleWindow.webContents.send("fromMain", data);
|
||||
})
|
||||
} */
|
||||
|
||||
consoleWindow.on('closed', function() {
|
||||
consoleWindow = null
|
||||
consoleWindow.on('close', function (e) {
|
||||
if (mainWindow.isVisible()) {
|
||||
e.preventDefault()
|
||||
createMainMenus()
|
||||
consoleWindow.hide()
|
||||
} else {
|
||||
let choice = dialog.showMessageBoxSync(
|
||||
mainWindow,
|
||||
{
|
||||
type: 'question',
|
||||
buttons: ['Yes', 'No'],
|
||||
title: 'Confirm',
|
||||
message: 'Do you really want to close Superalgos?'
|
||||
}
|
||||
)
|
||||
// 0 for Yes
|
||||
if (choice === 0) {
|
||||
consoleWindow = null
|
||||
app.exit()
|
||||
}
|
||||
// 1 for No
|
||||
if (choice === 1) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
consoleWindow.on('show', function () {
|
||||
createConsoleMenus()
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', function () {
|
||||
app_ready = true
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
createMainMenus()
|
||||
if (server_ready) open()
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
@@ -128,8 +162,16 @@ app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
|
||||
function createMainMenus () {
|
||||
const template = [
|
||||
function createMainMenus() {
|
||||
function logsActive() {
|
||||
if(consoleWindow) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const mainTemplate = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
@@ -176,18 +218,32 @@ function createMainMenus () {
|
||||
},
|
||||
{
|
||||
label: 'Logs',
|
||||
enabled: logsActive(),
|
||||
click () {
|
||||
openConsoleWindow()
|
||||
if(consoleWindow) {
|
||||
consoleWindow.show()
|
||||
} else {
|
||||
openConsoleWindow()
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
const mainMenu = Menu.buildFromTemplate(mainTemplate)
|
||||
Menu.setApplicationMenu(mainMenu)
|
||||
}
|
||||
|
||||
function createConsoleMenus () {
|
||||
const template = [
|
||||
|
||||
function uiActive() {
|
||||
if(mainWindow.isVisible()) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const consoleTemplate = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
@@ -222,9 +278,17 @@ function createConsoleMenus () {
|
||||
{type: 'separator'},
|
||||
{role: 'togglefullscreen'}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Show UI',
|
||||
id: 'ui',
|
||||
enabled: uiActive(),
|
||||
click () {
|
||||
mainWindow.show()
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
const consoleMenu = Menu.buildFromTemplate(consoleTemplate)
|
||||
Menu.setApplicationMenu(consoleMenu)
|
||||
}
|
||||
Reference in new issue
Block a user