mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-14 11:15:50 +00:00
Add missing files become-minter
This commit is contained in:
parent
fa29ff4c43
commit
a66d945ed4
144
plugins/plugins/core/become-minter/not-sponsored.js
Normal file
144
plugins/plugins/core/become-minter/not-sponsored.js
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
import { html, LitElement } from 'lit'
|
||||||
|
import { Epml } from '../../../epml'
|
||||||
|
import { becomeMinterStyles } from '../components/plugins-css'
|
||||||
|
import '../components/ButtonIconCopy'
|
||||||
|
import '@material/mwc-button'
|
||||||
|
import '@material/mwc-textfield'
|
||||||
|
import '@polymer/paper-spinner/paper-spinner-lite.js'
|
||||||
|
import '@vaadin/button'
|
||||||
|
|
||||||
|
// Multi language support
|
||||||
|
import { translate } from '../../../../core/translate'
|
||||||
|
|
||||||
|
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
|
||||||
|
|
||||||
|
class NotSponsored extends LitElement {
|
||||||
|
static properties = {
|
||||||
|
atMount: { type: Function },
|
||||||
|
isLoadingSponsorshipKeySubmit: { type: Boolean },
|
||||||
|
sponsorshipKeyValue: { type: String },
|
||||||
|
addMintingAccountMessage: { type: String }
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return [becomeMinterStyles]
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.isLoadingSponsorshipKeySubmit = false
|
||||||
|
this.sponsorshipKeyValue = ''
|
||||||
|
this.addMintingAccountMessage = ''
|
||||||
|
this.atMount = () => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<div class="inner-container">
|
||||||
|
<div class="sub-main">
|
||||||
|
<h2 class="level-black">
|
||||||
|
${translate('mintingpage.mchange33')}
|
||||||
|
</h2>
|
||||||
|
<p class="description">
|
||||||
|
${translate('mintingpage.mchange34')}
|
||||||
|
</p>
|
||||||
|
<h2 class="level-black">
|
||||||
|
${translate('mintingpage.mchange35')}
|
||||||
|
</h2>
|
||||||
|
<p class="description">
|
||||||
|
${translate('mintingpage.mchange36')}
|
||||||
|
</p>
|
||||||
|
<p class="description">
|
||||||
|
${translate('mintingpage.mchange37')}
|
||||||
|
</p>
|
||||||
|
<p class="message">${this.addMintingAccountMessage}</p>
|
||||||
|
<div class="form-wrapper">
|
||||||
|
<div class="form-item form-item--input">
|
||||||
|
<mwc-textfield
|
||||||
|
?disabled="${this
|
||||||
|
.isLoadingSponsorshipKeySubmit}"
|
||||||
|
label="${translate('becomeMinterPage.bchange8')}"
|
||||||
|
id="addSponsorshipKey"
|
||||||
|
@input="${this.inputHandler}"
|
||||||
|
.value="${this.sponsorshipKeyValue || ''}"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
</mwc-textfield>
|
||||||
|
</div>
|
||||||
|
<div class="form-item form-item--button">
|
||||||
|
<vaadin-button
|
||||||
|
theme="primary"
|
||||||
|
?disabled="${this.isLoadingSponsorshipKeySubmit}"
|
||||||
|
@click="${this.addMintingAccount}"
|
||||||
|
>
|
||||||
|
${this.isLoadingSponsorshipKeySubmit === false ?
|
||||||
|
html`
|
||||||
|
${translate('puzzlepage.pchange15')}
|
||||||
|
`
|
||||||
|
: html`
|
||||||
|
<paper-spinner-lite active></paper-spinner-lite>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
</vaadin-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
renderErr1Text() {
|
||||||
|
return html`${translate('nodepage.nchange27')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
renderErr2Text() {
|
||||||
|
return html`${translate('nodepage.nchange28')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
addMintingAccount(e) {
|
||||||
|
this.isLoadingSponsorshipKeySubmit = true
|
||||||
|
this.addMintingAccountMessage = 'Loading...'
|
||||||
|
parentEpml.request('apiCall', {
|
||||||
|
url: `/admin/mintingaccounts?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'POST',
|
||||||
|
body: this.sponsorshipKeyValue
|
||||||
|
}).then((res) => {
|
||||||
|
if (res === true) {
|
||||||
|
// refetch data
|
||||||
|
this.atMount()
|
||||||
|
this.sponsorshipKeyValue = ''
|
||||||
|
this.addMintingAccountMessage = this.renderErr1Text()
|
||||||
|
this.isLoadingSponsorshipKeySubmit = false
|
||||||
|
} else {
|
||||||
|
this.sponsorshipKeyValue = ''
|
||||||
|
this.addMintingAccountMessage = this.renderErr2Text()
|
||||||
|
this.isLoadingSponsorshipKeySubmit = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
inputHandler(e) {
|
||||||
|
this.sponsorshipKeyValue = e.target.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard functions
|
||||||
|
getApiKey() {
|
||||||
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
|
return myNode.apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
isEmptyArray(arr) {
|
||||||
|
if (!arr) { return true }
|
||||||
|
return arr.length === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
round(number) {
|
||||||
|
return (Math.round(parseFloat(number) * 1e8) / 1e8).toFixed(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.customElements.define('not-sponsored', NotSponsored)
|
125
plugins/plugins/core/become-minter/yes-sponsored.js
Normal file
125
plugins/plugins/core/become-minter/yes-sponsored.js
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
import { html, LitElement } from 'lit'
|
||||||
|
import { blocksNeed } from '../../utils/functions'
|
||||||
|
import { becomeMinterStyles } from '../components/plugins-css'
|
||||||
|
import '../components/ButtonIconCopy'
|
||||||
|
import '@material/mwc-button'
|
||||||
|
import '@material/mwc-textfield'
|
||||||
|
import '@polymer/paper-spinner/paper-spinner-lite.js'
|
||||||
|
import '@vaadin/button'
|
||||||
|
|
||||||
|
// Multi language support
|
||||||
|
import { translate } from '../../../../core/translate'
|
||||||
|
|
||||||
|
class YesSponsored extends LitElement {
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
addressInfo: { type: Object },
|
||||||
|
rewardSharePublicKey: { type: String },
|
||||||
|
isMinting: {type: Boolean}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return [becomeMinterStyles]
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.addressInfo = {}
|
||||||
|
this.rewardSharePublicKey = ''
|
||||||
|
this.isMinting = false
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<div class="inner-container">
|
||||||
|
<div class="column column-center">
|
||||||
|
<div class="column column-center">
|
||||||
|
<span class="level-black">
|
||||||
|
${translate('becomeMinterPage.bchange10')}
|
||||||
|
</span>
|
||||||
|
<hr style="width: 75%; color: #eee; border-radius: 80%; margin-bottom: 2rem;">
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row row-center gap">
|
||||||
|
<div class="content-box">
|
||||||
|
<span class="title">
|
||||||
|
${translate('walletpage.wchange41')}
|
||||||
|
</span>
|
||||||
|
<hr style="color: #eee; border-radius: 90%; margin-bottom: 1rem;">
|
||||||
|
${this.isMinting ? html`
|
||||||
|
<h4>${translate('becomeMinterPage.bchange12')}</h4>
|
||||||
|
` : html`
|
||||||
|
<h4>${translate('mintingpage.mchange9')}</h4>
|
||||||
|
`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row row-center gap">
|
||||||
|
<div class="content-box">
|
||||||
|
<span class="title">
|
||||||
|
${translate('becomeMinterPage.bchange13')}
|
||||||
|
</span>
|
||||||
|
<hr style="color: #eee; border-radius: 90%; margin-bottom: 1rem;">
|
||||||
|
<h4>
|
||||||
|
${this._levelUpBlocks()}
|
||||||
|
${translate('mintingpage.mchange26')}
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row row-center gap">
|
||||||
|
<div class="content-box">
|
||||||
|
<span class="title">
|
||||||
|
${translate('becomeMinterPage.bchange15')}
|
||||||
|
</span>
|
||||||
|
<hr style="color: #eee; border-radius: 90%; margin-bottom: 1rem;">
|
||||||
|
<h4 class="no-margin">
|
||||||
|
${translate('becomeMinterPage.bchange16')}
|
||||||
|
</h4>
|
||||||
|
<div class="row row-center column-center no-wrap">
|
||||||
|
<p class="address">
|
||||||
|
${this.rewardSharePublicKey}
|
||||||
|
</p>
|
||||||
|
<button-icon-copy
|
||||||
|
title="${translate('walletpage.wchange3')}"
|
||||||
|
onSuccessMessage="${translate('walletpage.wchange4')}"
|
||||||
|
onErrorMessage="${translate('walletpage.wchange39')}"
|
||||||
|
textToCopy=${this.rewardSharePublicKey}
|
||||||
|
buttonSize="28px"
|
||||||
|
iconSize="16px"
|
||||||
|
color="var(--copybutton)"
|
||||||
|
offsetLeft="4px"
|
||||||
|
>
|
||||||
|
</button-icon-copy>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
_levelUpBlocks() {
|
||||||
|
return (blocksNeed(0) - (this.addressInfo?.blocksMinted + this.addressInfo?.blocksMintedAdjustment)).toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard functions
|
||||||
|
getApiKey() {
|
||||||
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
|
return myNode.apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
isEmptyArray(arr) {
|
||||||
|
if (!arr) { return true }
|
||||||
|
return arr.length === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
round(number) {
|
||||||
|
return (Math.round(parseFloat(number) * 1e8) / 1e8).toFixed(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.customElements.define('yes-sponsored', YesSponsored)
|
Loading…
x
Reference in New Issue
Block a user