1.0.1 Added switch to decide for each miner
Added a switch on the subadmin page to decide if the miner is part of token distribution system or not
This commit is contained in:
parent
833c0ff13f
commit
c18e0a8f56
69
index.html
69
index.html
@ -347,8 +347,8 @@
|
||||
|
||||
<h2>Approve new Users</h2>
|
||||
<p></p>
|
||||
<div id='approve-newuser-section' class="card-wrapper">
|
||||
</div>
|
||||
<ul id='approve-newuser-section' class="card-wrapper">
|
||||
</ul>
|
||||
|
||||
<h2>Release updated shares</h2>
|
||||
<p></p>
|
||||
@ -379,6 +379,12 @@
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
<template id="miner-status-entry">
|
||||
<li class='miner-status-entry-cls'>
|
||||
<div class="miner-status-entry-floid"></div>
|
||||
<sm-switch></sm-switch>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<script src="js/main_UI.js"></script>
|
||||
<script src="js/components.min.js"></script>
|
||||
@ -528,8 +534,14 @@
|
||||
break;
|
||||
}
|
||||
return clone
|
||||
}
|
||||
},
|
||||
|
||||
minerStatusInfo({ coin_address, is_admin }) {
|
||||
const clone = getRef('miner-status-entry').content.cloneNode(true).firstElementChild;
|
||||
clone.querySelector('.miner-status-entry-floid').textContent = coin_address;
|
||||
clone.querySelector('sm-switch').setAttribute('checked', is_admin);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
function update_element(id, value) {
|
||||
@ -541,11 +553,11 @@
|
||||
rates = await floExchangeAPI.getRates();
|
||||
update_element(
|
||||
"flobnb-price",
|
||||
formatAmount(parseFloat(rates['mining']))
|
||||
formatAmount(parseFloat(rates.rates['mining']))
|
||||
);
|
||||
update_element(
|
||||
"flobnb-price-userpage",
|
||||
formatAmount(parseFloat(rates['mining']))
|
||||
formatAmount(parseFloat(rates.rates['mining']))
|
||||
);
|
||||
update_element(
|
||||
"total-amount-issued",
|
||||
@ -634,7 +646,6 @@
|
||||
|
||||
let transactionsLazyLoader
|
||||
function render_user_transactions(transaction_dictionary) {
|
||||
const frag = document.createDocumentFragment();
|
||||
let arrayOfTransactions = []
|
||||
for (let vectorClock in transaction_dictionary) {
|
||||
// do something for each key in the object
|
||||
@ -658,7 +669,7 @@
|
||||
blockchain_data["balance"] = 0;
|
||||
update_element("blockchain-flobnb-balance", `${parseFloat(blockchain_data["balance"])} mining#`);
|
||||
update_element("total-flobnb-balance", `${parseFloat(blockchain_data["balance"]) + parseFloat(results[0].balance)} mining#`);
|
||||
update_element("total-flobnb-valuation", formatAmount((parseFloat(blockchain_data["balance"]) + parseFloat(results[0].balance)) * parseFloat(results[2].mining)));
|
||||
update_element("total-flobnb-valuation", formatAmount((parseFloat(blockchain_data["balance"]) + parseFloat(results[0].balance)) * parseFloat(results[2].rates.mining)));
|
||||
});
|
||||
});
|
||||
|
||||
@ -704,8 +715,8 @@
|
||||
update_overview_ui_data();
|
||||
},
|
||||
});
|
||||
|
||||
Promise.all([promise1, promise2])
|
||||
let promise3 = floCloudAPI.requestObjectData("mining_base")
|
||||
Promise.all([promise1, promise2, promise3])
|
||||
.then((r) => resolve(r))
|
||||
.catch((e) => reject(e));
|
||||
});
|
||||
@ -1140,6 +1151,41 @@
|
||||
return await user_shares_details.json()
|
||||
}
|
||||
|
||||
function render_miner_status(miner_data){
|
||||
const frag = document.createDocumentFragment();
|
||||
var miner_floIDs = Object.keys(floGlobals.appObjects.mining_base.miners)
|
||||
miner_data.forEach(element => {
|
||||
frag.append(render.minerStatusInfo(element))
|
||||
// check if part of the global object, otherwise add it
|
||||
if(!miner_floIDs.includes(element.coin_address)){
|
||||
floGlobals.appObjects.mining_base.miners[element.coin_address] = {
|
||||
'id': element.coin_id,
|
||||
'shares': 0,
|
||||
'username': element.username,
|
||||
'token_distribution_permission': element.is_admin
|
||||
}
|
||||
}
|
||||
});
|
||||
document.getElementById("approve-newuser-section").append(frag);
|
||||
}
|
||||
|
||||
function process_mining_shares(miner_shares){
|
||||
var userinfo = await fetch('https://miningapitest.duckdns.org/getUsers')
|
||||
userinfo = await userinfo.json()
|
||||
|
||||
miner_shares.forEach((share) => {
|
||||
debugger
|
||||
// floGlobals.appObjects.mining_base[userinfo['users'][]]
|
||||
});
|
||||
}
|
||||
|
||||
async function calculate_share_difference(){
|
||||
// for each line of share api's response
|
||||
var miner_shares = await fetch(`https://miningapitest.duckdns.org/getShares`)
|
||||
miner_shares = await miner_shares.json()
|
||||
process_mining_shares(miner_shares['shares'])
|
||||
}
|
||||
|
||||
async function onLoadStartUp() {
|
||||
//floDapps.addStartUpFunction('Sample', Promised Function)
|
||||
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
||||
@ -1192,7 +1238,10 @@
|
||||
console.log('user data')
|
||||
console.log(data)
|
||||
let unregistered_floids = find_unregistered_floids(data['users'])
|
||||
debugger
|
||||
render_miner_status(unregistered_floids)
|
||||
|
||||
// Write a function which will calculate the number of shares required
|
||||
var share_diff = calculate_share_difference()
|
||||
})
|
||||
.catch(error => console.error('Error:', error))
|
||||
|
||||
|
||||
4
js/components.min.js
vendored
4
js/components.min.js
vendored
@ -1173,4 +1173,6 @@ customElements.define('sm-popup', class extends HTMLElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const smSwitch=document.createElement("template");smSwitch.innerHTML='\t\n<style>\n *{\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n }\n \n :host{\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n --accent-color: #4d2588;\n --text-color: 17, 17, 17;\n --background-color: 255, 255, 255;\n }\n label{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n width: 100%;\n outline: none;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n }\n :host([disabled]) {\n cursor: not-allowed;\n opacity: 0.6;\n pointer-events: none;\n }\n .switch {\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n width: 2.4rem;\n flex-shrink: 0;\n margin-left: auto;\n padding: 0.2rem;\n cursor: pointer;\n border-radius: 2rem;\n }\n \n input {\n display: none;\n }\n \n .track {\n position: absolute;\n left: 0;\n right: 0;\n height: 1.4rem;\n -webkit-transition: background 0.3s;\n -o-transition: background 0.3s;\n transition: background 0.3s;\n background: rgba(var(--text-color), 0.4);\n -webkit-box-shadow: 0 0.1rem 0.3rem #00000040 inset;\n box-shadow: 0 0.1rem 0.3rem #00000040 inset;\n border-radius: 1rem;\n }\n \n label:active .thumb::after,\n label:focus-within .thumb::after{\n opacity: 1;\n }\n \n .thumb::after{\n content: \'\';\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n height: 2.6rem;\n width: 2.6rem;\n background: rgba(var(--text-color), 0.2);\n border-radius: 2rem;\n opacity: 0;\n -webkit-transition: opacity 0.3s;\n -o-transition: opacity 0.3s;\n transition: opacity 0.3s;\n }\n \n .thumb {\n position: relative;\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n height: 1rem;\n width: 1rem;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n border-radius: 1rem;\n -webkit-box-shadow: 0 0.1rem 0.4rem #00000060;\n box-shadow: 0 0.1rem 0.4rem #00000060;\n -webkit-transition: -webkit-transform 0.3s;\n transition: -webkit-transform 0.3s;\n -o-transition: transform 0.3s;\n transition: transform 0.3s;\n transition: transform 0.3s, -webkit-transform 0.3s;\n border: solid 0.3rem white;\n }\n \n input:checked ~ .thumb {\n -webkit-transform: translateX(100%);\n -ms-transform: translateX(100%);\n transform: translateX(100%);\n }\n \n input:checked ~ .track {\n background: var(--accent-color);\n }\n</style>\n<label tabindex="0">\n <slot name="left"></slot>\n <div part="switch" class="switch">\n <input type="checkbox">\n <div class="track"></div>\n <div class="thumb"></div>\n </div>\n <slot name="right"></slot>\n</label>',customElements.define("sm-switch",class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}).append(smSwitch.content.cloneNode(!0)),this.switch=this.shadowRoot.querySelector(".switch"),this.input=this.shadowRoot.querySelector("input"),this.isChecked=!1,this.isDisabled=!1,this.dispatch=this.dispatch.bind(this)}static get observedAttributes(){return["disabled","checked"]}get disabled(){return this.isDisabled}set disabled(n){n?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get checked(){return this.isChecked}set checked(n){n?this.setAttribute("checked",""):this.removeAttribute("checked")}reset(){}dispatch(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:this.isChecked}}))}connectedCallback(){this.addEventListener("keydown",n=>{" "!==n.key||this.isDisabled||(n.preventDefault(),this.input.click())}),this.input.addEventListener("click",n=>{this.input.checked?this.checked=!0:this.checked=!1,this.dispatch()})}attributeChangedCallback(n,t,e){t!==e&&("disabled"===n?this.hasAttribute("disabled")?this.disabled=!0:this.disabled=!1:"checked"===n&&(this.hasAttribute("checked")?(this.isChecked=!0,this.input.checked=!0):(this.isChecked=!1,this.input.checked=!1)))}});
|
||||
Loading…
Reference in New Issue
Block a user