Merge pull request #243 from Philreact/feature/node-bootstrap-button
add bootstrap button to node and added new request
This commit is contained in:
commit
581257163e
@ -1274,7 +1274,7 @@
|
|||||||
"tour16": "Checklist",
|
"tour16": "Checklist",
|
||||||
"tour17": "Please start the Core to access the Qortal blockchain.",
|
"tour17": "Please start the Core to access the Qortal blockchain.",
|
||||||
"tour18": "Refresh (bootstrap)",
|
"tour18": "Refresh (bootstrap)",
|
||||||
"tour19": "Currently syncing... you must be fully synchronized to use Qortal",
|
"tour19": "Currently syncing... you must be fully synchronized to use Qortal.",
|
||||||
"tour20": "blocks behind. Would you like to refresh (bootstrap) to speed up the syncing process?",
|
"tour20": "blocks behind. Would you like to refresh (bootstrap) to speed up the syncing process?",
|
||||||
"tour21": "blocks remaining.",
|
"tour21": "blocks remaining.",
|
||||||
"tour22": "Refresh (bootstrap) requested. Please wait."
|
"tour22": "Refresh (bootstrap) requested. Please wait."
|
||||||
|
@ -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'
|
||||||
@ -11,7 +11,7 @@ import '@material/mwc-dialog'
|
|||||||
import '@vaadin/grid'
|
import '@vaadin/grid'
|
||||||
|
|
||||||
registerTranslateConfig({
|
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 })
|
const parentEpml = new Epml({ type: "WINDOW", source: window.parent })
|
||||||
@ -146,10 +146,11 @@ class NodeManagement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<div id="node-management-page">
|
<div id="node-management-page">
|
||||||
<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;" class="red" ?hidden="${(this.upTime === "offline")}" @click=${() => this.stopNode()}><mwc-icon>dangerous</mwc-icon> ${translate("nodepage.nchange31")}</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>
|
||||||
<span class="sblack"><br>${translate("nodepage.nchange2")} ${this.upTime}</span>
|
<span class="sblack"><br>${translate("nodepage.nchange2")} ${this.upTime}</span>
|
||||||
@ -166,12 +167,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.nchange9")}" path="mintingAccount"></vaadin-grid-column>
|
||||||
<vaadin-grid-column auto-width header="${translate("nodepage.nchange10")}" path="recipientAccount"></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) => {
|
<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-button class="red" ?disabled=${this.removeMintingAccountLoading} @click=${() => this.removeMintingAccount(data.item.publicKey)}>
|
||||||
<mwc-icon>create</mwc-icon> ${translate("nodepage.nchange12")}
|
<mwc-icon>create</mwc-icon> ${translate("nodepage.nchange12")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
`, root)
|
`, root)
|
||||||
}}></vaadin-grid-column>
|
}}></vaadin-grid-column>
|
||||||
</vaadin-grid>
|
</vaadin-grid>
|
||||||
${this.isEmptyArray(this.mintingAccounts) ? html`<span style="color: var(--black);">${translate("nodepage.nchange13")}</span>` : ""}
|
${this.isEmptyArray(this.mintingAccounts) ? html`<span style="color: var(--black);">${translate("nodepage.nchange13")}</span>` : ""}
|
||||||
</div><br>
|
</div><br>
|
||||||
@ -189,7 +190,7 @@ class NodeManagement extends LitElement {
|
|||||||
<vaadin-grid-column header="${translate("nodepage.nchange20")}" path="version"></vaadin-grid-column>
|
<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 header="${translate("nodepage.nchange21")}" path="age"></vaadin-grid-column>
|
||||||
<vaadin-grid-column width="12em" header="${translate("nodepage.nchange22")}" .renderer=${(root, column, data) => {
|
<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-button class="red" @click=${() => this.removePeer(data.item.address, data.index)}>
|
||||||
<mwc-icon>delete</mwc-icon> ${translate("nodepage.nchange12")}
|
<mwc-icon>delete</mwc-icon> ${translate("nodepage.nchange12")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
@ -197,7 +198,7 @@ class NodeManagement extends LitElement {
|
|||||||
${translate("nodepage.nchange23")}
|
${translate("nodepage.nchange23")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
`, root)
|
`, root)
|
||||||
}}></vaadin-grid-column>
|
}}></vaadin-grid-column>
|
||||||
</vaadin-grid>
|
</vaadin-grid>
|
||||||
${this.isEmptyArray(this.peers) ? html`<span style="color: var(--black);">${translate("nodepage.nchange24")}</span>` : ""}
|
${this.isEmptyArray(this.peers) ? html`<span style="color: var(--black);">${translate("nodepage.nchange24")}</span>` : ""}
|
||||||
</div><br>
|
</div><br>
|
||||||
@ -408,7 +409,7 @@ class NodeManagement extends LitElement {
|
|||||||
method: "GET"
|
method: "GET"
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
let snackString = get("nodepage.nchange32")
|
let snackString = get("nodepage.nchange32")
|
||||||
parentEpml.request('showSnackBar', `${snackString}`)
|
parentEpml.request('showSnackBar', `${snackString}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -420,21 +421,34 @@ class NodeManagement extends LitElement {
|
|||||||
method: "GET"
|
method: "GET"
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
let snackString = get("nodepage.nchange34")
|
let snackString = get("nodepage.nchange34")
|
||||||
parentEpml.request('showSnackBar', `${snackString}`)
|
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}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async addPeer() {
|
async addPeer() {
|
||||||
this.addPeerLoading = true
|
this.addPeerLoading = true
|
||||||
const addPeerAddress = this.shadowRoot.getElementById('addPeerAddress').value
|
const addPeerAddress = this.shadowRoot.getElementById('addPeerAddress').value
|
||||||
console.log("ADDRESS", addPeerAddress)
|
|
||||||
await parentEpml.request("apiCall", {
|
await parentEpml.request("apiCall", {
|
||||||
url: `/peers?apiKey=${this.getApiKey()}`,
|
url: `/peers?apiKey=${this.getApiKey()}`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: addPeerAddress
|
body: addPeerAddress
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log("RES", res)
|
|
||||||
if (res === true) {
|
if (res === true) {
|
||||||
let trueString = get("walletpage.wchange52")
|
let trueString = get("walletpage.wchange52")
|
||||||
parentEpml.request('showSnackBar', `${trueString}`)
|
parentEpml.request('showSnackBar', `${trueString}`)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {css, html, LitElement} from 'lit'
|
import { css, html, LitElement } from 'lit'
|
||||||
import {Epml} from '../../../../epml'
|
import { Epml } from '../../../../epml'
|
||||||
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 ShortUniqueId from 'short-unique-id';
|
import ShortUniqueId from 'short-unique-id';
|
||||||
import FileSaver from 'file-saver'
|
import FileSaver from 'file-saver'
|
||||||
import * as actions from '../../components/qdn-action-types'
|
import * as actions from '../../components/qdn-action-types'
|
||||||
@ -10,10 +10,10 @@ import '@material/mwc-icon'
|
|||||||
import '@material/mwc-checkbox'
|
import '@material/mwc-checkbox'
|
||||||
import WebWorker from 'web-worker:./computePowWorkerFile.src.js'
|
import WebWorker from 'web-worker:./computePowWorkerFile.src.js'
|
||||||
import WebWorkerChat from 'web-worker:./computePowWorker.src.js'
|
import WebWorkerChat from 'web-worker:./computePowWorker.src.js'
|
||||||
import {publishData} from '../../../utils/publish-image.js'
|
import { publishData } from '../../../utils/publish-image.js'
|
||||||
import {Loader} from '../../../utils/loader.js';
|
import { Loader } from '../../../utils/loader.js';
|
||||||
import {QORT_DECIMALS} from '../../../../../crypto/api/constants'
|
import { QORT_DECIMALS } from '../../../../../crypto/api/constants'
|
||||||
import {mimeToExtensionMap} from '../../components/qdn-action-constants';
|
import { mimeToExtensionMap } from '../../components/qdn-action-constants';
|
||||||
import {
|
import {
|
||||||
base64ToUint8Array,
|
base64ToUint8Array,
|
||||||
decryptDeprecatedSingle,
|
decryptDeprecatedSingle,
|
||||||
@ -51,7 +51,7 @@ class WebBrowser extends LitElement {
|
|||||||
dogeFeePerByte: { type: Number },
|
dogeFeePerByte: { type: Number },
|
||||||
dgbFeePerByte: { type: Number },
|
dgbFeePerByte: { type: Number },
|
||||||
rvnFeePerByte: { type: Number },
|
rvnFeePerByte: { type: Number },
|
||||||
arrrWalletAddress: { type: String }
|
arrrWalletAddress: { type: String }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,39 +323,39 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
async linkOpenNewTab(link) {
|
async linkOpenNewTab(link) {
|
||||||
|
|
||||||
const value = link
|
const value = link
|
||||||
let newQuery = value
|
let newQuery = value
|
||||||
if (newQuery.endsWith('/')) {
|
if (newQuery.endsWith('/')) {
|
||||||
newQuery = newQuery.slice(0, -1)
|
newQuery = newQuery.slice(0, -1)
|
||||||
}
|
}
|
||||||
const res = await this.extractComponents(newQuery)
|
const res = await this.extractComponents(newQuery)
|
||||||
if (!res) return
|
if (!res) return
|
||||||
const { service, name, identifier, path } = res
|
const { service, name, identifier, path } = res
|
||||||
let query = `?service=${service}`
|
let query = `?service=${service}`
|
||||||
if (name) {
|
if (name) {
|
||||||
query = query + `&name=${name}`
|
query = query + `&name=${name}`
|
||||||
}
|
}
|
||||||
if (identifier) {
|
if (identifier) {
|
||||||
query = query + `&identifier=${identifier}`
|
query = query + `&identifier=${identifier}`
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
query = query + `&path=${path}`
|
query = query + `&path=${path}`
|
||||||
}
|
}
|
||||||
|
|
||||||
window.parent.reduxStore.dispatch(window.parent.reduxAction.setNewTab({
|
window.parent.reduxStore.dispatch(window.parent.reduxAction.setNewTab({
|
||||||
url: `qdn/browser/index.html${query}`,
|
url: `qdn/browser/index.html${query}`,
|
||||||
id: this.uid.rnd(),
|
id: this.uid.rnd(),
|
||||||
myPlugObj: {
|
myPlugObj: {
|
||||||
"url": service === 'WEBSITE' ? "websites" : "qapps",
|
"url": service === 'WEBSITE' ? "websites" : "qapps",
|
||||||
"domain": "core",
|
"domain": "core",
|
||||||
"page": `qdn/browser/index.html${query}`,
|
"page": `qdn/browser/index.html${query}`,
|
||||||
"title": name,
|
"title": name,
|
||||||
"icon": service === 'WEBSITE' ? 'vaadin:desktop' : 'vaadin:external-browser',
|
"icon": service === 'WEBSITE' ? 'vaadin:desktop' : 'vaadin:external-browser',
|
||||||
"mwcicon": service === 'WEBSITE' ? 'desktop_mac' : 'open_in_browser',
|
"mwcicon": service === 'WEBSITE' ? 'desktop_mac' : 'open_in_browser',
|
||||||
"menus": [],
|
"menus": [],
|
||||||
"parent": false
|
"parent": false
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ class WebBrowser extends LitElement {
|
|||||||
return joinFee
|
return joinFee
|
||||||
}
|
}
|
||||||
|
|
||||||
async getArbitraryFee (){
|
async getArbitraryFee() {
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now()
|
||||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
@ -714,11 +714,11 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const makeTransactionRequest = async (lastRef) => {
|
const makeTransactionRequest = async (lastRef) => {
|
||||||
let votedialog3 = get("transactions.votedialog3")
|
let votedialog3 = get("transactions.votedialog3")
|
||||||
let votedialog4 = get("transactions.votedialog4")
|
let votedialog4 = get("transactions.votedialog4")
|
||||||
let votedialog5 = get("transactions.votedialog5")
|
let votedialog5 = get("transactions.votedialog5")
|
||||||
let votedialog6 = get("transactions.votedialog6")
|
let votedialog6 = get("transactions.votedialog6")
|
||||||
let feeDialog = get("walletpage.wchange12")
|
let feeDialog = get("walletpage.wchange12")
|
||||||
|
|
||||||
let myTxnrequest = await parentEpml.request('transaction', {
|
let myTxnrequest = await parentEpml.request('transaction', {
|
||||||
type: 8,
|
type: 8,
|
||||||
@ -836,6 +836,45 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case actions.ENCRYPT_DATA: {
|
||||||
|
try {
|
||||||
|
let dataSentBack = {}
|
||||||
|
let data64 = data.data64
|
||||||
|
let publicKeys = data.publicKeys || []
|
||||||
|
if (data.file) {
|
||||||
|
data64 = await fileToBase64(data.file)
|
||||||
|
}
|
||||||
|
if (!data64) {
|
||||||
|
|
||||||
|
dataSentBack['error'] = "Please include data to encrypt"
|
||||||
|
response = JSON.stringify(dataSentBack)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
const encryptDataResponse = encryptDataGroup({
|
||||||
|
data64, publicKeys: publicKeys
|
||||||
|
})
|
||||||
|
if (encryptDataResponse) {
|
||||||
|
data64 = encryptDataResponse
|
||||||
|
response = JSON.stringify(encryptDataResponse)
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
dataSentBack['error'] = "Unable to encrypt"
|
||||||
|
response = JSON.stringify(dataSentBack)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
const data = {}
|
||||||
|
const errorMsg = error.message || "Error in encrypting data"
|
||||||
|
data['error'] = errorMsg
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case actions.DECRYPT_DATA: {
|
case actions.DECRYPT_DATA: {
|
||||||
|
|
||||||
const { encryptedData, publicKey } = data
|
const { encryptedData, publicKey } = data
|
||||||
@ -1100,7 +1139,7 @@ class WebBrowser extends LitElement {
|
|||||||
try {
|
try {
|
||||||
let list = JSON.parse(localStorage.getItem('friends-my-friend-list') || "[]")
|
let list = JSON.parse(localStorage.getItem('friends-my-friend-list') || "[]")
|
||||||
|
|
||||||
list = list.map((friend)=> friend.name || "")
|
list = list.map((friend) => friend.name || "")
|
||||||
response = JSON.stringify(list)
|
response = JSON.stringify(list)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const data = {}
|
const data = {}
|
||||||
@ -1388,13 +1427,13 @@ class WebBrowser extends LitElement {
|
|||||||
try {
|
try {
|
||||||
const requiredFields = ['service', 'name']
|
const requiredFields = ['service', 'name']
|
||||||
const missingFields = []
|
const missingFields = []
|
||||||
|
|
||||||
requiredFields.forEach((field) => {
|
requiredFields.forEach((field) => {
|
||||||
if (!resource[field]) {
|
if (!resource[field]) {
|
||||||
missingFields.push(field)
|
missingFields.push(field)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
const missingFieldsString = missingFields.join(', ')
|
const missingFieldsString = missingFields.join(', ')
|
||||||
const errorMsg = `Missing fields: ${missingFieldsString}`
|
const errorMsg = `Missing fields: ${missingFieldsString}`
|
||||||
@ -1404,7 +1443,7 @@ class WebBrowser extends LitElement {
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resource.file && !resource.data64) {
|
if (!resource.file && !resource.data64) {
|
||||||
const errorMsg = 'No data or file was submitted'
|
const errorMsg = 'No data or file was submitted'
|
||||||
failedPublishesIdentifiers.push({
|
failedPublishesIdentifiers.push({
|
||||||
@ -1413,7 +1452,7 @@ class WebBrowser extends LitElement {
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const service = resource.service
|
const service = resource.service
|
||||||
const name = resource.name
|
const name = resource.name
|
||||||
let identifier = resource.identifier
|
let identifier = resource.identifier
|
||||||
@ -1430,7 +1469,7 @@ class WebBrowser extends LitElement {
|
|||||||
if (resource.identifier == null) {
|
if (resource.identifier == null) {
|
||||||
identifier = 'default'
|
identifier = 'default'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.encrypt && service.endsWith("_PRIVATE")) {
|
if (!data.encrypt && service.endsWith("_PRIVATE")) {
|
||||||
const errorMsg = "Only encrypted data can go into private services"
|
const errorMsg = "Only encrypted data can go into private services"
|
||||||
failedPublishesIdentifiers.push({
|
failedPublishesIdentifiers.push({
|
||||||
@ -1442,36 +1481,36 @@ class WebBrowser extends LitElement {
|
|||||||
if (data.file) {
|
if (data.file) {
|
||||||
data64 = await fileToBase64(data.file)
|
data64 = await fileToBase64(data.file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (data.encrypt) {
|
if (data.encrypt) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const encryptDataResponse = encryptDataGroup({
|
const encryptDataResponse = encryptDataGroup({
|
||||||
data64, publicKeys: data.publicKeys
|
data64, publicKeys: data.publicKeys
|
||||||
})
|
})
|
||||||
if (encryptDataResponse) {
|
if (encryptDataResponse) {
|
||||||
data64 = encryptDataResponse
|
data64 = encryptDataResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMsg = error.message || 'Upload failed due to failed encryption'
|
const errorMsg = error.message || 'Upload failed due to failed encryption'
|
||||||
failedPublishesIdentifiers.push({
|
failedPublishesIdentifiers.push({
|
||||||
reason: errorMsg,
|
reason: errorMsg,
|
||||||
identifier: resource.identifier
|
identifier: resource.identifier
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (resource.file && !data.encrypt) {
|
if (resource.file && !data.encrypt) {
|
||||||
data64 = await fileToBase64(resource.file)
|
data64 = await fileToBase64(resource.file)
|
||||||
}
|
}
|
||||||
|
|
||||||
const worker = new WebWorker()
|
const worker = new WebWorker()
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await publishData({
|
await publishData({
|
||||||
registeredName: encodeURIComponent(name),
|
registeredName: encodeURIComponent(name),
|
||||||
file: data64,
|
file: data64,
|
||||||
service: service,
|
service: service,
|
||||||
@ -1494,9 +1533,9 @@ class WebBrowser extends LitElement {
|
|||||||
withFee: res2.userData.isWithFee === true ? true : false,
|
withFee: res2.userData.isWithFee === true ? true : false,
|
||||||
feeAmount: feeAmount
|
feeAmount: feeAmount
|
||||||
})
|
})
|
||||||
|
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
await new Promise((res)=> {
|
await new Promise((res) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
res()
|
res()
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -1510,7 +1549,7 @@ class WebBrowser extends LitElement {
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
failedPublishesIdentifiers.push({
|
failedPublishesIdentifiers.push({
|
||||||
reason: "Unknown error",
|
reason: "Unknown error",
|
||||||
@ -1518,27 +1557,27 @@ class WebBrowser extends LitElement {
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.loader.hide()
|
this.loader.hide()
|
||||||
if(failedPublishesIdentifiers.length > 0){
|
if (failedPublishesIdentifiers.length > 0) {
|
||||||
response = failedPublishesIdentifiers
|
response = failedPublishesIdentifiers
|
||||||
const obj = {}
|
const obj = {}
|
||||||
const errorMsg = {
|
const errorMsg = {
|
||||||
unsuccessfulPublishes: failedPublishesIdentifiers
|
unsuccessfulPublishes: failedPublishesIdentifiers
|
||||||
}
|
}
|
||||||
obj['error'] = errorMsg
|
obj['error'] = errorMsg
|
||||||
response = JSON.stringify(obj)
|
response = JSON.stringify(obj)
|
||||||
this.loader.hide()
|
this.loader.hide()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response = true
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
response = true
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.VOTE_ON_POLL: {
|
case actions.VOTE_ON_POLL: {
|
||||||
@ -1642,7 +1681,7 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case actions.OPEN_NEW_TAB: {
|
case actions.OPEN_NEW_TAB: {
|
||||||
if(!data.qortalLink){
|
if (!data.qortalLink) {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
const errorMsg = 'Please enter a qortal link - qortal://...'
|
const errorMsg = 'Please enter a qortal link - qortal://...'
|
||||||
obj['error'] = errorMsg
|
obj['error'] = errorMsg
|
||||||
@ -1674,10 +1713,10 @@ class WebBrowser extends LitElement {
|
|||||||
name: this.name
|
name: this.name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (res.action === 'accept'){
|
if (res.action === 'accept') {
|
||||||
this.addAppToNotificationList(this.name)
|
this.addAppToNotificationList(this.name)
|
||||||
response = true
|
response = true
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
response = false
|
response = false
|
||||||
break
|
break
|
||||||
@ -1694,33 +1733,33 @@ class WebBrowser extends LitElement {
|
|||||||
try {
|
try {
|
||||||
const id = `appNotificationList-${this.selectedAddress.address}`
|
const id = `appNotificationList-${this.selectedAddress.address}`
|
||||||
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
||||||
if(!checkData || !checkData[this.name]) throw new Error('App not on permission list')
|
if (!checkData || !checkData[this.name]) throw new Error('App not on permission list')
|
||||||
const appInfo = checkData[this.name]
|
const appInfo = checkData[this.name]
|
||||||
const lastNotification = appInfo.lastNotification
|
const lastNotification = appInfo.lastNotification
|
||||||
const interval = appInfo.interval
|
const interval = appInfo.interval
|
||||||
if (lastNotification && interval) {
|
if (lastNotification && interval) {
|
||||||
const timeDifference = Date.now() - lastNotification
|
const timeDifference = Date.now() - lastNotification
|
||||||
|
|
||||||
if (timeDifference > interval) {
|
if (timeDifference > interval) {
|
||||||
|
parentEpml.request('showNotification', {
|
||||||
|
title, type: "qapp-local-notification", sound: '', url, options: { body: message, icon, badge: icon }
|
||||||
|
})
|
||||||
|
response = true
|
||||||
|
this.updateLastNotification(id, this.name)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
throw new Error(`invalid data`)
|
||||||
|
}
|
||||||
|
} else if (!lastNotification) {
|
||||||
parentEpml.request('showNotification', {
|
parentEpml.request('showNotification', {
|
||||||
title, type: "qapp-local-notification", sound: '', url, options: { body: message, icon, badge: icon }
|
title, type: "qapp-local-notification", sound: '', url, options: { body: message, icon, badge: icon }
|
||||||
})
|
})
|
||||||
response = true
|
response = true
|
||||||
this.updateLastNotification(id, this.name)
|
this.updateLastNotification(id)
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`invalid data`)
|
throw new Error(`invalid data`)
|
||||||
}
|
}
|
||||||
} else if(!lastNotification){
|
|
||||||
parentEpml.request('showNotification', {
|
|
||||||
title, type: "qapp-local-notification", sound: '', url, options: { body: message, icon, badge: icon }
|
|
||||||
})
|
|
||||||
response = true
|
|
||||||
this.updateLastNotification(id)
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
throw new Error(`invalid data`)
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
@ -2261,7 +2300,7 @@ class WebBrowser extends LitElement {
|
|||||||
function handleResponseEvent(event) {
|
function handleResponseEvent(event) {
|
||||||
// Handle the data from the event, if any
|
// Handle the data from the event, if any
|
||||||
const responseData = event.detail;
|
const responseData = event.detail;
|
||||||
if(responseData && responseData.uniqueId !== uniqueId) return
|
if (responseData && responseData.uniqueId !== uniqueId) return
|
||||||
// Clean up by removing the event listener once we've received the response
|
// Clean up by removing the event listener once we've received the response
|
||||||
window.removeEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
window.removeEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
||||||
|
|
||||||
@ -2275,8 +2314,8 @@ class WebBrowser extends LitElement {
|
|||||||
// Set up an event listener to wait for the response
|
// Set up an event listener to wait for the response
|
||||||
window.addEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
window.addEventListener('qortal-request-set-profile-data-response', handleResponseEvent);
|
||||||
});
|
});
|
||||||
if(!res.response) throw new Error('Failed to set property')
|
if (!res.response) throw new Error('Failed to set property')
|
||||||
response = JSON.stringify(res.response);
|
response = JSON.stringify(res.response);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
@ -2310,10 +2349,10 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const customEvent = new CustomEvent('open-visiting-profile', {
|
const customEvent = new CustomEvent('open-visiting-profile', {
|
||||||
detail: data.name
|
detail: data.name
|
||||||
});
|
});
|
||||||
window.parent.dispatchEvent(customEvent);
|
window.parent.dispatchEvent(customEvent);
|
||||||
response = JSON.stringify(true);
|
response = JSON.stringify(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
@ -2345,19 +2384,19 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
const res3 = await showModalAndWait(
|
const res3 = await showModalAndWait(
|
||||||
actions.GET_USER_WALLET
|
actions.GET_USER_WALLET
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res3.action === 'accept') {
|
if (res3.action === 'accept') {
|
||||||
let coin = data.coin;
|
let coin = data.coin;
|
||||||
let userWallet = {};
|
let userWallet = {};
|
||||||
let arrrAddress = "";
|
let arrrAddress = "";
|
||||||
if (coin === "ARRR") {
|
if (coin === "ARRR") {
|
||||||
arrrAddress = await parentEpml.request('apiCall', {
|
arrrAddress = await parentEpml.request('apiCall', {
|
||||||
url: `/crosschain/arrr/walletaddress?apiKey=${this.getApiKey()}`,
|
url: `/crosschain/arrr/walletaddress?apiKey=${this.getApiKey()}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: `${window.parent.reduxStore.getState().app.selectedAddress.arrrWallet.seed58}`
|
body: `${window.parent.reduxStore.getState().app.selectedAddress.arrrWallet.seed58}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
switch (coin) {
|
switch (coin) {
|
||||||
case 'QORT':
|
case 'QORT':
|
||||||
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address
|
||||||
@ -2486,7 +2525,7 @@ class WebBrowser extends LitElement {
|
|||||||
})
|
})
|
||||||
if (isNaN(Number(res))) {
|
if (isNaN(Number(res))) {
|
||||||
const data = {}
|
const data = {}
|
||||||
const errorMsg = get("browserpage.bchange21")
|
const errorMsg = get("browserpage.bchange21")
|
||||||
data['error'] = errorMsg
|
data['error'] = errorMsg
|
||||||
response = JSON.stringify(data)
|
response = JSON.stringify(data)
|
||||||
return
|
return
|
||||||
@ -3478,7 +3517,7 @@ class WebBrowser extends LitElement {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Unhandled message: ' + JSON.stringify(data))
|
console.log('Unhandled message: ' + JSON.stringify(data))
|
||||||
return
|
return
|
||||||
@ -3577,44 +3616,44 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addAppToNotificationList(appName) {
|
addAppToNotificationList(appName) {
|
||||||
if(!appName) throw new Error('unknown app name')
|
if (!appName) throw new Error('unknown app name')
|
||||||
const id = `appNotificationList-${this.selectedAddress.address}`
|
const id = `appNotificationList-${this.selectedAddress.address}`
|
||||||
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
||||||
|
|
||||||
if (!checkData) {
|
if (!checkData) {
|
||||||
const newData = {
|
const newData = {
|
||||||
[appName]: {
|
[appName]: {
|
||||||
interval: 900000, // 15mins in milliseconds
|
interval: 900000, // 15mins in milliseconds
|
||||||
lastNotification: null,
|
lastNotification: null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
localStorage.setItem(id, JSON.stringify(newData))
|
localStorage.setItem(id, JSON.stringify(newData))
|
||||||
} else {
|
} else {
|
||||||
const copyData = { ...checkData }
|
const copyData = { ...checkData }
|
||||||
copyData[appName] = {
|
copyData[appName] = {
|
||||||
interval: 900000, // 15mins in milliseconds
|
interval: 900000, // 15mins in milliseconds
|
||||||
lastNotification: null,
|
lastNotification: null,
|
||||||
}
|
}
|
||||||
localStorage.setItem(id, JSON.stringify(copyData))
|
localStorage.setItem(id, JSON.stringify(copyData))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLastNotification(id, appName) {
|
updateLastNotification(id, appName) {
|
||||||
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null
|
||||||
|
|
||||||
if (checkData) {
|
if (checkData) {
|
||||||
const copyData = { ...checkData }
|
const copyData = { ...checkData }
|
||||||
if (copyData[appName]) {
|
if (copyData[appName]) {
|
||||||
copyData[appName].lastNotification = Date.now() // Make sure to use Date.now(), not date.now()
|
copyData[appName].lastNotification = Date.now() // Make sure to use Date.now(), not date.now()
|
||||||
} else {
|
} else {
|
||||||
copyData[appName] = {
|
copyData[appName] = {
|
||||||
interval: 900000, // 15mins in milliseconds
|
interval: 900000, // 15mins in milliseconds
|
||||||
lastNotification: Date.now(),
|
lastNotification: Date.now(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
localStorage.setItem(id, JSON.stringify(copyData))
|
||||||
localStorage.setItem(id, JSON.stringify(copyData))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderFollowUnfollowButton() {
|
renderFollowUnfollowButton() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user