mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-03-28 00:05:53 +00:00
Added start core function from nodemanagement
This commit is contained in:
parent
1697adeafe
commit
6123f5eb36
@ -999,7 +999,9 @@
|
|||||||
"nchange31": "Stop Node",
|
"nchange31": "Stop Node",
|
||||||
"nchange32": "Successfully Sent Stop Request!",
|
"nchange32": "Successfully Sent Stop Request!",
|
||||||
"nchange33": "Restart Node",
|
"nchange33": "Restart Node",
|
||||||
"nchange34": "Successfully Sent Restart Request!"
|
"nchange34": "Successfully Sent Restart Request!",
|
||||||
|
"nchange35": "Start Node",
|
||||||
|
"nchange36": "Successfully Started Node!"
|
||||||
},
|
},
|
||||||
"transpage": {
|
"transpage": {
|
||||||
"tchange1": "Transaction request",
|
"tchange1": "Transaction request",
|
||||||
|
67
electron.js
67
electron.js
@ -207,6 +207,70 @@ async function checkWin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkOsPlatform() {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
startElectronWin()
|
||||||
|
} else if (process.platform === 'linux' || process.platform === 'darwin') {
|
||||||
|
startElectronUnix()
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startElectronWin() {
|
||||||
|
if (fs.existsSync(winjar)) {
|
||||||
|
isRunning('qortal.exe', (status) => {
|
||||||
|
if (status == true) {
|
||||||
|
log.info("Core is running, perfect !")
|
||||||
|
} else {
|
||||||
|
spawn(startWinCore, { detached: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const dialogOpts = {
|
||||||
|
type: 'info',
|
||||||
|
buttons: [i18n.__("electron_translate_18"), i18n.__("electron_translate_19")],
|
||||||
|
title: i18n.__("electron_translate_20"),
|
||||||
|
message: i18n.__("electron_translate_21"),
|
||||||
|
detail: i18n.__("electron_translate_22")
|
||||||
|
}
|
||||||
|
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
||||||
|
if (returnValue.response === 0) {
|
||||||
|
downloadWindows()
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startElectronUnix() {
|
||||||
|
if (fs.existsSync(qortaljar)) {
|
||||||
|
isRunning('qortal.jar', (status) => {
|
||||||
|
if (status == true) {
|
||||||
|
log.info("Core is running, perfect !")
|
||||||
|
} else {
|
||||||
|
startQortal()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const dialogOpts = {
|
||||||
|
type: 'info',
|
||||||
|
buttons: [i18n.__("electron_translate_18"), i18n.__("electron_translate_19")],
|
||||||
|
title: i18n.__("electron_translate_20"),
|
||||||
|
message: i18n.__("electron_translate_21"),
|
||||||
|
detail: i18n.__("electron_translate_22")
|
||||||
|
}
|
||||||
|
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
||||||
|
if (returnValue.response === 0) {
|
||||||
|
downloadQortal()
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function downloadWindows() {
|
async function downloadWindows() {
|
||||||
let winLoader = new BrowserWindow({
|
let winLoader = new BrowserWindow({
|
||||||
width: 500,
|
width: 500,
|
||||||
@ -1085,6 +1149,9 @@ if (!isLock) {
|
|||||||
check.show()
|
check.show()
|
||||||
autoUpdater.checkForUpdatesAndNotify()
|
autoUpdater.checkForUpdatesAndNotify()
|
||||||
})
|
})
|
||||||
|
ipcMain.on('start-core-electron', (event) => {
|
||||||
|
checkOsPlatform()
|
||||||
|
})
|
||||||
ipcMain.on('show-my-menu', (event) => {
|
ipcMain.on('show-my-menu', (event) => {
|
||||||
let homePageOptions = Menu.buildFromTemplate([
|
let homePageOptions = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ const { contextBridge, ipcRenderer, webFrame } = require('electron')
|
|||||||
|
|
||||||
contextBridge.exposeInMainWorld('electronAPI', {
|
contextBridge.exposeInMainWorld('electronAPI', {
|
||||||
setStartCore: () => ipcRenderer.send('set-start-core'),
|
setStartCore: () => ipcRenderer.send('set-start-core'),
|
||||||
|
startCore: () => ipcRenderer.send('start-core-electron'),
|
||||||
checkForUpdate: () => ipcRenderer.send('check-for-update'),
|
checkForUpdate: () => ipcRenderer.send('check-for-update'),
|
||||||
showMyMenu: () => ipcRenderer.send('show-my-menu'),
|
showMyMenu: () => ipcRenderer.send('show-my-menu'),
|
||||||
focusApp: () => ipcRenderer.send('focus-app'),
|
focusApp: () => ipcRenderer.send('focus-app'),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { css, html, LitElement } from 'lit'
|
import {css, html, LitElement} from 'lit'
|
||||||
import { render } from 'lit/html.js'
|
import {render} from 'lit/html.js'
|
||||||
import { Epml } from '../../../epml.js'
|
import {Epml} from '../../../epml.js'
|
||||||
import isElectron from 'is-electron'
|
import isElectron from 'is-electron'
|
||||||
import { get, registerTranslateConfig, translate, use } from '../../../../core/translate/index.js'
|
import {get, registerTranslateConfig, translate, use} from '../../../../core/translate/index.js'
|
||||||
import '@polymer/paper-spinner/paper-spinner-lite.js'
|
import '@polymer/paper-spinner/paper-spinner-lite.js'
|
||||||
import '@material/mwc-icon'
|
import '@material/mwc-icon'
|
||||||
import '@material/mwc-textfield'
|
import '@material/mwc-textfield'
|
||||||
@ -77,6 +77,10 @@ class NodeManagement extends LitElement {
|
|||||||
--mdc-theme-primary: #F44336;
|
--mdc-theme-primary: #F44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.green {
|
||||||
|
--mdc-theme-primary: #198754;
|
||||||
|
}
|
||||||
|
|
||||||
.red-button {
|
.red-button {
|
||||||
--mdc-theme-primary: red;
|
--mdc-theme-primary: red;
|
||||||
--mdc-theme-on-primary: white;
|
--mdc-theme-on-primary: white;
|
||||||
@ -151,8 +155,8 @@ class NodeManagement extends LitElement {
|
|||||||
<div class="node-card">
|
<div class="node-card">
|
||||||
<h2>${translate("nodepage.nchange1")} ${this.nodeDomain}</h2>
|
<h2>${translate("nodepage.nchange1")} ${this.nodeDomain}</h2>
|
||||||
<mwc-button style="float:right;" ?hidden="${(this.upTime === "offline")}" @click=${() => this.bootstrap()}><mwc-icon>restart_alt</mwc-icon> ${translate("tour.tour18")}</mwc-button>
|
<mwc-button style="float:right;" ?hidden="${(this.upTime === "offline")}" @click=${() => this.bootstrap()}><mwc-icon>restart_alt</mwc-icon> ${translate("tour.tour18")}</mwc-button>
|
||||||
<mwc-button style="float:right;" class="red" ?hidden="${(this.upTime === "offline")}" @click=${() => this.stopNode()}><mwc-icon>dangerous</mwc-icon> ${translate("nodepage.nchange31")}</mwc-button>
|
|
||||||
<mwc-button style="float:right;" ?hidden="${(this.upTime === "offline")}" @click=${() => this.restartNode()}><mwc-icon>360</mwc-icon> ${translate("nodepage.nchange33")}</mwc-button>
|
<mwc-button style="float:right;" ?hidden="${(this.upTime === "offline")}" @click=${() => this.restartNode()}><mwc-icon>360</mwc-icon> ${translate("nodepage.nchange33")}</mwc-button>
|
||||||
|
${this.renderStartStopButton()}
|
||||||
<span class="sblack"><br>${translate("nodepage.nchange2")} ${this.upTime}</span>
|
<span class="sblack"><br>${translate("nodepage.nchange2")} ${this.upTime}</span>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div id="minting">
|
<div id="minting">
|
||||||
@ -402,6 +406,27 @@ class NodeManagement extends LitElement {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderStartStopButton() {
|
||||||
|
if (!isElectron()) {
|
||||||
|
return html`<mwc-button style="float:right;" class="red" ?hidden="${(this.upTime === "offline")}" @click=${() => this.stopNode()}><mwc-icon>dangerous</mwc-icon> ${translate("nodepage.nchange31")}</mwc-button>`
|
||||||
|
} else {
|
||||||
|
if (this.upTime === "offline") {
|
||||||
|
return html`<mwc-button style="float:right;" class="green" @click=${() => this.startNode()}><mwc-icon>play_circle</mwc-icon> ${translate("nodepage.nchange35")}</mwc-button>`
|
||||||
|
} else {
|
||||||
|
return html`<mwc-button style="float:right;" class="red" @click=${() => this.stopNode()}><mwc-icon>stop_circle</mwc-icon> ${translate("nodepage.nchange31")}</mwc-button>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
startNode() {
|
||||||
|
if (!isElectron()) {
|
||||||
|
} else {
|
||||||
|
window.parent.electronAPI.startCore()
|
||||||
|
let startString = get("nodepage.nchange36")
|
||||||
|
parentEpml.request('showSnackBar', `${startString}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stopNode() {
|
stopNode() {
|
||||||
parentEpml
|
parentEpml
|
||||||
.request("apiCall", {
|
.request("apiCall", {
|
||||||
@ -427,17 +452,14 @@ class NodeManagement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
parentEpml
|
parentEpml.request("apiCall", {
|
||||||
.request("apiCall", {
|
|
||||||
url: `/admin/bootstrap/?apiKey=${this.getApiKey()}`,
|
url: `/admin/bootstrap/?apiKey=${this.getApiKey()}`,
|
||||||
method: "GET"
|
method: "GET"
|
||||||
})
|
}).then((res) => {
|
||||||
.then((res) => {
|
|
||||||
if (res === true) {
|
if (res === true) {
|
||||||
let snackString = get("tour.tour22")
|
let snackString = get("tour.tour22")
|
||||||
parentEpml.request('showSnackBar', `${snackString}`)
|
parentEpml.request('showSnackBar', `${snackString}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user