mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-14 19:25:50 +00:00
added separate components
This commit is contained in:
parent
5b28b0779e
commit
3b2b017a8b
@ -2,6 +2,7 @@ import { LitElement, html } from 'lit';
|
|||||||
import { Epml } from '../../../epml.js';
|
import { Epml } from '../../../epml.js';
|
||||||
import '../components/ButtonIconCopy.js';
|
import '../components/ButtonIconCopy.js';
|
||||||
import { use, translate, registerTranslateConfig } from 'lit-translate';
|
import { use, translate, registerTranslateConfig } from 'lit-translate';
|
||||||
|
import { blocksNeed } from './utils/blocks-needed.js';
|
||||||
|
|
||||||
registerTranslateConfig({
|
registerTranslateConfig({
|
||||||
loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()),
|
loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()),
|
||||||
@ -11,18 +12,16 @@ import '@polymer/paper-spinner/paper-spinner-lite.js';
|
|||||||
import '@material/mwc-button';
|
import '@material/mwc-button';
|
||||||
import '@material/mwc-textfield';
|
import '@material/mwc-textfield';
|
||||||
import '@vaadin/button';
|
import '@vaadin/button';
|
||||||
import { _blocksNeed } from './utils/blocks-needed.js';
|
|
||||||
import { pageStyles } from './become-minter-css.js';
|
import { pageStyles } from './become-minter-css.js';
|
||||||
import './components/not-sponsored';
|
import './components/not-sponsored';
|
||||||
|
import './components/yes-sponsored';
|
||||||
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
|
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent });
|
||||||
|
|
||||||
class BecomeMinter extends LitElement {
|
class BecomeMinter extends LitElement {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
theme: { type: String, reflect: true },
|
theme: { type: String, reflect: true },
|
||||||
isLoadingSponsorshipKeySubmit: { type: Boolean },
|
|
||||||
sponsorshipKeyValue: { type: String },
|
sponsorshipKeyValue: { type: String },
|
||||||
addMintingAccountMessage: { type: String },
|
|
||||||
|
|
||||||
nodeInfo: { type: Object },
|
nodeInfo: { type: Object },
|
||||||
isPageLoading: { type: Boolean },
|
isPageLoading: { type: Boolean },
|
||||||
@ -38,9 +37,7 @@ class BecomeMinter extends LitElement {
|
|||||||
this.theme = localStorage.getItem('qortalTheme')
|
this.theme = localStorage.getItem('qortalTheme')
|
||||||
? localStorage.getItem('qortalTheme')
|
? localStorage.getItem('qortalTheme')
|
||||||
: 'light';
|
: 'light';
|
||||||
this.isLoadingSponsorshipKeySubmit = false;
|
|
||||||
this.sponsorshipKeyValue = '';
|
this.sponsorshipKeyValue = '';
|
||||||
this.addMintingAccountMessage = '';
|
|
||||||
this.isPageLoading = true;
|
this.isPageLoading = true;
|
||||||
this.nodeInfo = {};
|
this.nodeInfo = {};
|
||||||
this.addressInfo = {};
|
this.addressInfo = {};
|
||||||
@ -95,7 +92,7 @@ class BecomeMinter extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async firstUpdated() {
|
async firstUpdated() {
|
||||||
console.log({ change: 6 });
|
console.log({ change: 11 });
|
||||||
|
|
||||||
this.changeLanguage();
|
this.changeLanguage();
|
||||||
this.getNodeInfo();
|
this.getNodeInfo();
|
||||||
@ -107,61 +104,6 @@ class BecomeMinter extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMintingAccounts() {
|
|
||||||
parentEpml
|
|
||||||
.request('apiCall', {
|
|
||||||
url: `/admin/mintingaccounts`,
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
setTimeout(() => (this.mintingAccounts = res), 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getApiKey() {
|
|
||||||
const myNode =
|
|
||||||
window.parent.reduxStore.getState().app.nodeConfig.knownNodes[
|
|
||||||
window.parent.reduxStore.getState().app.nodeConfig.node
|
|
||||||
];
|
|
||||||
let apiKey = myNode.apiKey;
|
|
||||||
return apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
this.updateMintingAccounts();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getRewardShareRelationship(recipientAddress) {
|
async getRewardShareRelationship(recipientAddress) {
|
||||||
let myRewardShareArray = await parentEpml.request('apiCall', {
|
let myRewardShareArray = await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
@ -173,7 +115,7 @@ class BecomeMinter extends LitElement {
|
|||||||
|
|
||||||
_levelUpBlocks() {
|
_levelUpBlocks() {
|
||||||
let countBlocksString = (
|
let countBlocksString = (
|
||||||
_blocksNeed(0) -
|
blocksNeed(0) -
|
||||||
(this.addressInfo?.blocksMinted +
|
(this.addressInfo?.blocksMinted +
|
||||||
this.addressInfo?.blocksMintedAdjustment)
|
this.addressInfo?.blocksMintedAdjustment)
|
||||||
).toString();
|
).toString();
|
||||||
@ -198,154 +140,15 @@ class BecomeMinter extends LitElement {
|
|||||||
${this.isPageLoading ? html` <p>Loading....</p> ` : ''}
|
${this.isPageLoading ? html` <p>Loading....</p> ` : ''}
|
||||||
${isAlreadySponsored
|
${isAlreadySponsored
|
||||||
? ''
|
? ''
|
||||||
: html`
|
: html` <not-sponsored></not-sponsored> `}
|
||||||
<not-sponsored></not-sponsored>
|
|
||||||
<!-- <div class="inner-container">
|
|
||||||
<div class="sub-main">
|
|
||||||
<h2 class="level-black">
|
|
||||||
${translate('becomeMinterPage.bchange2')}
|
|
||||||
</h2>
|
|
||||||
<p class="description">
|
|
||||||
${translate('becomeMinterPage.bchange3')}
|
|
||||||
</p>
|
|
||||||
<h2 class="level-black">
|
|
||||||
${translate('becomeMinterPage.bchange4')}
|
|
||||||
</h2>
|
|
||||||
<p class="description">
|
|
||||||
${translate('becomeMinterPage.bchange5')}
|
|
||||||
</p>
|
|
||||||
<p class="description">
|
|
||||||
${translate('becomeMinterPage.bchange6')}
|
|
||||||
</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
|
|
||||||
?disabled="${this.isLoadingSponsorshipKeySubmit}"
|
|
||||||
@click="${this.addMintingAccount}"
|
|
||||||
>
|
|
||||||
${this.isLoadingSponsorshipKeySubmit === false
|
|
||||||
? html`${translate(
|
|
||||||
'becomeMinterPage.bchange9'
|
|
||||||
)}`
|
|
||||||
: html`<paper-spinner-lite
|
|
||||||
active
|
|
||||||
></paper-spinner-lite>`}
|
|
||||||
</vaadin-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
`}
|
|
||||||
${!isAlreadySponsored
|
${!isAlreadySponsored
|
||||||
? ''
|
? ''
|
||||||
: html`
|
: html`
|
||||||
<div class="inner-container">
|
<yes-sponsored
|
||||||
<div class="column column-center">
|
.rewardSharePublicKey=${this
|
||||||
<div class="column column-center">
|
.rewardSharePublicKey}
|
||||||
<span class="level-black"
|
.addressInfo=${this.addressInfo}
|
||||||
>${translate(
|
></yes-sponsored>
|
||||||
'becomeMinterPage.bchange10'
|
|
||||||
)}</span
|
|
||||||
>
|
|
||||||
<hr
|
|
||||||
style="width: 50%; color: #eee; border-radius: 80%; margin-bottom: 2rem;"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<div class="row row-center gap">
|
|
||||||
<div class="content-box">
|
|
||||||
<span class="title"
|
|
||||||
>${translate(
|
|
||||||
'becomeMinterPage.bchange11'
|
|
||||||
)}</span
|
|
||||||
>
|
|
||||||
<hr
|
|
||||||
style="color: #eee; border-radius: 90%; margin-bottom: 1rem;"
|
|
||||||
/>
|
|
||||||
<h4>
|
|
||||||
${translate(
|
|
||||||
'becomeMinterPage.bchange12'
|
|
||||||
)}
|
|
||||||
</h4>
|
|
||||||
</div>
|
|
||||||
<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(
|
|
||||||
'becomeMinterPage.bchange14'
|
|
||||||
)}
|
|
||||||
</h4>
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user