improve profile view

main
lza_menace 3 years ago
parent e52bc08cb4
commit 245ebb6c06

@ -21,40 +21,67 @@
<p>Tipped WOW: <strong><span id="tippedWOW">?</span></strong></p> <p>Tipped WOW: <strong><span id="tippedWOW">?</span></strong></p>
<h3>From Local Database</h3> <h3>From Local Database</h3>
<p> {# Handle #}
Handle:
{% if is_user %} {% if is_user %}
<input id="handleInput" type="text" placeholder="{{ user.handle }}" value="{{ user.handle }}"></input> <div class="field">
<a onclick="publishHandleAVAX()" class="publishAVAX">Publish AVAX</a> <label class="label">Handle</label>
<div class="control columns">
<div class="column is-two-thirds">
<input id="handleInput" class="input" type="text" placeholder="{{ user.handle }}" value="{{ user.handle }}">
<p class="help">The username/handle you want to be referenced by.</p>
</div>
<div class="column">
<a id="publishHandle" onclick="publishHandle()" class="publishAVAX button">Publish AVAX</a>
</div>
</div>
</div>
{% else %} {% else %}
<strong>{{ user.handle }}</strong> <p><strong>Handle:</strong> {{ user.handle }}</p>
{% endif %} {% endif %}
</p>
<p> {# Wownero Address #}
Wownero Address:
{% if is_user %} {% if is_user %}
<input id="wowneroAddressInput" type="text" placeholder="{{ user.wownero_address or '' }}" value="{{ user.wownero_address or '' }}"></input> <div class="field">
<a onclick="publishWowneroAddress()" class="publishAVAX">Publish AVAX</a> <label class="label">Wownero Address</label>
<div class="control columns">
<div class="column is-two-thirds">
<input id="wowneroAddressInput" class="input" type="text" placeholder="{{ user.wownero_address or '' }}" value="{{ user.wownero_address or '' }}">
<p class="help">The Wownero wallet address you want to receive tips on.</p>
</div>
<div class="column">
<a id="publishWowneroAddress" onclick="publishWowneroAddress()" class="publishAVAX button">Publish AVAX</a>
</div>
</div>
</div>
{% else %} {% else %}
<strong><span class="wrap">{{ user.wownero_address }}</span></strong> <p><strong>Wownero Address:</strong> <span class="wrap">{{ user.wownero_address or '?' }}</span></p>
{% endif %} {% endif %}
</p>
<p> {# Metadata IPFS Hash #}
Metadata IPFS Hash:
{% if is_user %} {% if is_user %}
<input id="metadataIPFSHashInput" type="text" placeholder="{{ user.ipfs_hash or '' }}" value="{{ user.ipfs_hash or '' }}"></input> <div class="field">
<a onclick="publishMetadataIPFSHash()" class="publishAVAX">Publish AVAX</a> <label class="label">Metadata IPFS Hash</label>
<div class="control columns">
<div class="column is-two-thirds">
<input id="metadataIPFSHashInput" class="input" type="text" placeholder="{{ user.ipfs_hash or '' }}" value="{{ user.ipfs_hash or '' }}">
<p class="help">The IPFS hash of your profile metadata.</p>
</div>
<div class="column">
<a id="publishMetadataIPFSHash" onclick="publishMetadataIPFSHash()" class="publishAVAX button">Publish AVAX</a>
</div>
</div>
</div>
{% else %} {% else %}
<strong>{{ user.ipfs_hash }}</strong> <p><strong>Metadata IPFS Hash:</strong> {{ user.ipfs_hash or '' }}</p>
{% endif %} {% endif %}
</p>
<p>Register Date: <strong>{{ user.register_date }}</strong></p> <p><strong>Register Date: </strong> {{ user.register_date }} ({{ user.register_date | humanize }})</p>
<p>Last Login Date: <strong>{{ user.last_login_date }}</strong></p> <p><strong>Last Login Date: </strong> {{ user.last_login_date }} ({{ user.last_login_date | humanize }})</p>
<p>Moderator: <strong>{{ user.is_moderator() }}</strong></p> <p><strong>Moderator: </strong> {{ user.is_moderator() }}</p>
<p>Verified: <strong>{{ user.verified }}</strong></p> <p><strong>Verified: </strong> {{ user.verified }}</p>
<p>Memes Posted: <strong>{{ user.memes | length }}</strong></p> <p><strong>Memes Posted: </strong> {{ user.memes | length }}</p>
{% if user.bio %} {% if user.bio %}
<p>Bio: {{ user.bio }}</p> <p><strong>Bio: </strong> {{ user.bio }}</p>
{% endif %} {% endif %}
{% if user.website %} {% if user.website %}
<p>Website: <a href="{{ user.website_url }}" target="_blank">{{ user.website_url }}</a></p> <p>Website: <a href="{{ user.website_url }}" target="_blank">{{ user.website_url }}</a></p>
@ -105,23 +132,26 @@
if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle}; if (userProfile.userHandle){document.getElementById('userHandle').innerHTML = userProfile.userHandle};
if (userProfile.wowneroAddress){document.getElementById('wowneroAddress').innerHTML = userProfile.wowneroAddress}; if (userProfile.wowneroAddress){document.getElementById('wowneroAddress').innerHTML = userProfile.wowneroAddress};
if (userProfile.metadataIPFSHash){document.getElementById('metadataIPFSHash').innerHTML = userProfile.metadataIPFSHash}; if (userProfile.metadataIPFSHash){document.getElementById('metadataIPFSHash').innerHTML = userProfile.metadataIPFSHash};
if (userProfile.tippedAVAX){document.getElementById('tippedAVAX').innerHTML = userProfile.tippedAVAX}; if (userProfile.tippedAVAX){document.getElementById('tippedAVAX').innerHTML = w3.utils.fromWei(userProfile.tippedAVAX)};
document.getElementById('tippedWOWX').innerHTML = 0; if (userProfile.tippedWOWX){document.getElementById('tippedWOWX').innerHTML = w3.utils.fromWei(userProfile.tippedWOWX)};
return return
} }
async function publishHandleAVAX() { async function publishHandle() {
document.getElementById('publishHandle').classList.add('is-loading');
const handle = document.getElementById('handleInput').value; const handle = document.getElementById('handleInput').value;
if (handle == "") { if (handle == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
document.getElementById('publishHandle').classList.remove('is-loading');
return false;
} }
await addAvalancheNetwork(); await addAvalancheNetwork();
try {
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserHandle(handle).estimateGas(function(err, gas){
return gas; return gas;
}); });
try {
notif(`Publishing user handle "${handle}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); notif(`Publishing user handle "${handle}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
let res = await contract.methods.setUserHandle(handle).send({ let res = await contract.methods.setUserHandle(handle).send({
from: walletAddress, from: walletAddress,
@ -133,21 +163,25 @@
window.location.href = ""; window.location.href = "";
} catch(e) { } catch(e) {
notif(e.message, 'warning'); notif(e.message, 'warning');
document.getElementById('publishHandle').classList.remove('is-loading');
} }
} }
async function publishWowneroAddress() { async function publishWowneroAddress() {
document.getElementById('publishWowneroAddress').classList.add('is-loading');
const address = document.getElementById('wowneroAddressInput').value; const address = document.getElementById('wowneroAddressInput').value;
if (address == "") { if (address == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
document.getElementById('publishWowneroAddress').classList.remove('is-loading');
return false;
} }
await addAvalancheNetwork(); await addAvalancheNetwork();
try {
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserWowneroAddress(address).estimateGas(function(err, gas){
return gas; return gas;
}); });
try {
notif(`Publishing Wownero address "${address.slice(0, 6)}...${address.slice(-6)}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info'); notif(`Publishing Wownero address "${address.slice(0, 6)}...${address.slice(-6)}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
let res = await contract.methods.setUserWowneroAddress(address).send({ let res = await contract.methods.setUserWowneroAddress(address).send({
from: walletAddress, from: walletAddress,
@ -159,22 +193,26 @@
window.location.href = ""; window.location.href = "";
} catch(e) { } catch(e) {
notif(e.message, 'warning'); notif(e.message, 'warning');
document.getElementById('publishWowneroAddress').classList.remove('is-loading');
} }
} }
async function publishMetadataIPFSHash() { async function publishMetadataIPFSHash() {
document.getElementById('publishMetadataIPFSHash').classList.add('is-loading');
const _hash = document.getElementById('metadataIPFSHashInput').value; const _hash = document.getElementById('metadataIPFSHashInput').value;
if (_hash == "") { if (_hash == "") {
notif('Cannot publish an empty value.', 'warning'); notif('Cannot publish an empty value.', 'warning');
document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading');
return false;
} }
await addAvalancheNetwork(); await addAvalancheNetwork();
try {
const walletAddress = await getMetamaskAccount(); const walletAddress = await getMetamaskAccount();
const gasPrice = await w3.eth.getGasPrice(); const gasPrice = await w3.eth.getGasPrice();
const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){ const gasLimit = await contract.methods.setUserMetadata(_hash).estimateGas(function(err, gas){
return gas; return gas;
}); });
try { notif(`Publishing user profile metadata IPFS hash "${_hash}" to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
notif(`Publishing user profile metadata IPFS hash ${_hash} to the Avalanche blockchain for address ${walletAddress.slice(0, 6)}...${walletAddress.slice(-6)}.`, 'info');
let res = await contract.methods.setUserMetadata(_hash).send({ let res = await contract.methods.setUserMetadata(_hash).send({
from: walletAddress, from: walletAddress,
value: 0, value: 0,
@ -185,6 +223,7 @@
window.location.href = ""; window.location.href = "";
} catch(e) { } catch(e) {
notif(e.message, 'warning'); notif(e.message, 'warning');
document.getElementById('publishMetadataIPFSHash').classList.remove('is-loading');
} }
} }
@ -193,8 +232,5 @@
}); });
</script> </script>
<style>
input { width: 30%; }
</style>
</body> </body>
</html> </html>

Loading…
Cancel
Save