mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 09:45:52 +00:00
Added start core function from nodemanagement
This commit is contained in:
parent
1697adeafe
commit
6123f5eb36
@ -999,7 +999,9 @@
|
||||
"nchange31": "Stop Node",
|
||||
"nchange32": "Successfully Sent Stop Request!",
|
||||
"nchange33": "Restart Node",
|
||||
"nchange34": "Successfully Sent Restart Request!"
|
||||
"nchange34": "Successfully Sent Restart Request!",
|
||||
"nchange35": "Start Node",
|
||||
"nchange36": "Successfully Started Node!"
|
||||
},
|
||||
"transpage": {
|
||||
"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() {
|
||||
let winLoader = new BrowserWindow({
|
||||
width: 500,
|
||||
@ -1085,6 +1149,9 @@ if (!isLock) {
|
||||
check.show()
|
||||
autoUpdater.checkForUpdatesAndNotify()
|
||||
})
|
||||
ipcMain.on('start-core-electron', (event) => {
|
||||
checkOsPlatform()
|
||||
})
|
||||
ipcMain.on('show-my-menu', (event) => {
|
||||
let homePageOptions = Menu.buildFromTemplate([
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ const { contextBridge, ipcRenderer, webFrame } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setStartCore: () => ipcRenderer.send('set-start-core'),
|
||||
startCore: () => ipcRenderer.send('start-core-electron'),
|
||||
checkForUpdate: () => ipcRenderer.send('check-for-update'),
|
||||
showMyMenu: () => ipcRenderer.send('show-my-menu'),
|
||||
focusApp: () => ipcRenderer.send('focus-app'),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { css, html, LitElement } from 'lit'
|
||||
import { render } from 'lit/html.js'
|
||||
import { Epml } from '../../../epml.js'
|
||||
import {css, html, LitElement} from 'lit'
|
||||
import {render} from 'lit/html.js'
|
||||
import {Epml} from '../../../epml.js'
|
||||
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 '@material/mwc-icon'
|
||||
import '@material/mwc-textfield'
|
||||
@ -11,7 +11,7 @@ import '@material/mwc-dialog'
|
||||
import '@vaadin/grid'
|
||||
|
||||
registerTranslateConfig({
|
||||
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
||||
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
||||
})
|
||||
|
||||
const parentEpml = new Epml({ type: "WINDOW", source: window.parent })
|
||||
@ -77,6 +77,10 @@ class NodeManagement extends LitElement {
|
||||
--mdc-theme-primary: #F44336;
|
||||
}
|
||||
|
||||
.green {
|
||||
--mdc-theme-primary: #198754;
|
||||
}
|
||||
|
||||
.red-button {
|
||||
--mdc-theme-primary: red;
|
||||
--mdc-theme-on-primary: white;
|
||||
@ -146,13 +150,13 @@ class NodeManagement extends LitElement {
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
return html`
|
||||
<div id="node-management-page">
|
||||
<div class="node-card">
|
||||
<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;" 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>
|
||||
${this.renderStartStopButton()}
|
||||
<span class="sblack"><br>${translate("nodepage.nchange2")} ${this.upTime}</span>
|
||||
<br><br>
|
||||
<div id="minting">
|
||||
@ -167,12 +171,12 @@ class NodeManagement extends LitElement {
|
||||
<vaadin-grid-column auto-width header="${translate("nodepage.nchange9")}" path="mintingAccount"></vaadin-grid-column>
|
||||
<vaadin-grid-column auto-width header="${translate("nodepage.nchange10")}" path="recipientAccount"></vaadin-grid-column>
|
||||
<vaadin-grid-column width="12em" header="${translate("nodepage.nchange11")}" .renderer=${(root, column, data) => {
|
||||
render(html`
|
||||
render(html`
|
||||
<mwc-button class="red" ?disabled=${this.removeMintingAccountLoading} @click=${() => this.removeMintingAccount(data.item.publicKey)}>
|
||||
<mwc-icon>create</mwc-icon> ${translate("nodepage.nchange12")}
|
||||
</mwc-button>
|
||||
`, root)
|
||||
}}></vaadin-grid-column>
|
||||
}}></vaadin-grid-column>
|
||||
</vaadin-grid>
|
||||
${this.isEmptyArray(this.mintingAccounts) ? html`<span style="color: var(--black);">${translate("nodepage.nchange13")}</span>` : ""}
|
||||
</div><br>
|
||||
@ -190,7 +194,7 @@ class NodeManagement extends LitElement {
|
||||
<vaadin-grid-column header="${translate("nodepage.nchange20")}" path="version"></vaadin-grid-column>
|
||||
<vaadin-grid-column header="${translate("nodepage.nchange21")}" path="age"></vaadin-grid-column>
|
||||
<vaadin-grid-column width="12em" header="${translate("nodepage.nchange22")}" .renderer=${(root, column, data) => {
|
||||
render(html`
|
||||
render(html`
|
||||
<mwc-button class="red" @click=${() => this.removePeer(data.item.address, data.index)}>
|
||||
<mwc-icon>delete</mwc-icon> ${translate("nodepage.nchange12")}
|
||||
</mwc-button>
|
||||
@ -198,7 +202,7 @@ class NodeManagement extends LitElement {
|
||||
${translate("nodepage.nchange23")}
|
||||
</mwc-button>
|
||||
`, root)
|
||||
}}></vaadin-grid-column>
|
||||
}}></vaadin-grid-column>
|
||||
</vaadin-grid>
|
||||
${this.isEmptyArray(this.peers) ? html`<span style="color: var(--black);">${translate("nodepage.nchange24")}</span>` : ""}
|
||||
</div><br>
|
||||
@ -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() {
|
||||
parentEpml
|
||||
.request("apiCall", {
|
||||
@ -409,7 +434,7 @@ class NodeManagement extends LitElement {
|
||||
method: "GET"
|
||||
})
|
||||
.then((res) => {
|
||||
let snackString = get("nodepage.nchange32")
|
||||
let snackString = get("nodepage.nchange32")
|
||||
parentEpml.request('showSnackBar', `${snackString}`)
|
||||
})
|
||||
}
|
||||
@ -421,24 +446,21 @@ class NodeManagement extends LitElement {
|
||||
method: "GET"
|
||||
})
|
||||
.then((res) => {
|
||||
let snackString = get("nodepage.nchange34")
|
||||
let snackString = get("nodepage.nchange34")
|
||||
parentEpml.request('showSnackBar', `${snackString}`)
|
||||
})
|
||||
}
|
||||
|
||||
bootstrap() {
|
||||
parentEpml
|
||||
.request("apiCall", {
|
||||
url: `/admin/bootstrap/?apiKey=${this.getApiKey()}`,
|
||||
method: "GET"
|
||||
})
|
||||
.then((res) => {
|
||||
if (res === true) {
|
||||
let snackString = get("tour.tour22")
|
||||
parentEpml.request('showSnackBar', `${snackString}`)
|
||||
}
|
||||
|
||||
})
|
||||
parentEpml.request("apiCall", {
|
||||
url: `/admin/bootstrap/?apiKey=${this.getApiKey()}`,
|
||||
method: "GET"
|
||||
}).then((res) => {
|
||||
if (res === true) {
|
||||
let snackString = get("tour.tour22")
|
||||
parentEpml.request('showSnackBar', `${snackString}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async addPeer() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user