Merge pull request #2712 from NAmorim/develop

[Distribution] Add menu for profile creation/update
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-11-23 12:46:15 -04:00
commit 3749f9fc85
3 files changed
+52 -6

No files matched your search

+9
View File
@@ -42,6 +42,15 @@
try {
drawSplashText()
loadSuperalgos()
window.api.receive('fromMaster', (data) => {
if(data.newUser){
UI.projects.foundations.spaces.designSpace.workspace.replaceWorkspaceByLoadingOne(data.newUser[0], data.newUser[1])
}else if(data.submit){
UI.projects.governance.spaces.reportsSpace.commandInterface.command = data.submit[0]
UI.projects.governance.spaces.reportsSpace.commandInterface.detectCommands()
//const element = document.getElementsByClassName("governance-filter-input")[0]
}
})
} catch (err) {
console.log("[ERROR] UI can not be started. Please check that WebServer is running.", err);
}
+41 -4
View File
@@ -40,7 +40,6 @@ ipcMain.on("toMain", (event, args) => {
}
})
function openMain () {
let bw_options = {
width: WINDOW_WIDTH,
@@ -50,6 +49,7 @@ function openMain () {
nodeIntegration: false, // is default value after Electron v5
contextIsolation: true, // protect against prototype pollution
enableRemoteModule: false, // turn off remote
preload: path.join(__dirname, "preload.js") // use a preload script
}
}
@@ -90,6 +90,10 @@ function openMain () {
mainWindow.on('activate', function () {
mainWindow.show()
})
mainWindow.on('focus', function () {
createMainMenus()
})
}
function openConsoleWindow() {
@@ -116,7 +120,6 @@ function openConsoleWindow() {
consoleWindow.setBackgroundColor('#000000')
consoleWindow.loadFile('./console.html')
consoleWindow.on('close', function (e) {
if (mainWindow.isVisible()) {
e.preventDefault()
@@ -144,13 +147,13 @@ function openConsoleWindow() {
}
})
consoleWindow.on('show', function () {
consoleWindow.on('focus', function () {
createConsoleMenus()
})
}
app.on('ready', function () {
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.checkForUpdatesAndNotify()
createMainMenus()
})
@@ -226,6 +229,40 @@ function createMainMenus() {
openConsoleWindow()
}
}
},
{
label: 'Profile',
submenu: [
{
label: 'New/Update',
click: async() => {
data = {newUser: ["Governance", "Plugin → Token-Distribution-Superalgos"]}
mainWindow.webContents.send("fromMaster", data)
data
//mainWindow.loadURL('http://localhost:34248/LoadPlugin/Governance/Workspaces/Token-Distribution-Superalgos.json')
}
},
{
label: 'Save',
click: async() => {
let modifiers = []
modifiers.push('shift')
modifiers.push('control')
mainWindow.webContents.sendInputEvent({type: 'keyDown', modifiers, keyCode: "s"})
mainWindow.webContents.sendInputEvent({type: 'char', modifiers, keyCode: "s"})
mainWindow.webContents.sendInputEvent({type: 'keyUp', modifiers, keyCode: "s"})
}
},
{
label: 'Submit',
click: async() => {
data = {submit: ["gov.userProfile"]}
mainWindow.webContents.send("fromMaster", data)
mainWindow.webContents.sendInputEvent({type: 'keyDown', modifiers, keyCode: "Enter"})
mainWindow.webContents.sendInputEvent({type: 'keyUp', modifiers, keyCode: "Enter"})
}
}
]
}
]
+2 -2
View File
@@ -9,13 +9,13 @@ contextBridge.exposeInMainWorld(
"api", {
send: (channel, data) => {
// whitelist channels
let validChannels = ["toMain"];
let validChannels = ["toMain", "toMaster"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
let validChannels = ["fromMain"];
let validChannels = ["fromMain", "fromMaster"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));