This commit is contained in:
sairaj mote 2020-09-10 19:54:34 +05:30
parent 8e263559aa
commit 180bcd67c5
4 changed files with 424 additions and 314 deletions

View File

@ -697,19 +697,19 @@ form {
transform: scale(0.95); transform: scale(0.95);
} }
.options-tab .option:nth-of-type(1) .icon { .options-tab .option:nth-of-type(1) .icon {
background: #D32F2F; background: linear-gradient(135deg, #D32F2F 50%, #B71C1C 50%);
} }
.options-tab .option:nth-of-type(2) .icon { .options-tab .option:nth-of-type(2) .icon {
background: #7B1FA2; background: linear-gradient(135deg, #7B1FA2 50%, #4A148C 50%);
} }
.options-tab .option:nth-of-type(3) .icon { .options-tab .option:nth-of-type(3) .icon {
background: #303F9F; background: linear-gradient(135deg, #1976D2 50%, #0D47A1 50%);
} }
.options-tab .option:nth-of-type(4) .icon { .options-tab .option:nth-of-type(4) .icon {
background: #1976D2; background: linear-gradient(135deg, #388E3C 50%, #1B5E20 50%);
} }
.options-tab .option:nth-of-type(5) .icon { .options-tab .option:nth-of-type(5) .icon {
background: #388E3C; background: linear-gradient(135deg, #F57C00 50%, #E65100 50%);
} }
.notification-dot::after { .notification-dot::after {
@ -744,7 +744,8 @@ sm-tab-header {
} }
sm-tab::part(tab) { sm-tab::part(tab) {
padding: 0.8rem 0; padding: 0.8rem 0.4rem;
text-transform: uppercase;
} }
sm-panel { sm-panel {
@ -1100,6 +1101,11 @@ sm-panel {
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
} }
.user-panel {
position: sticky;
top: 1.5rem;
}
} }
@media only screen and (min-width: 1920px) { @media only screen and (min-width: 1920px) {
body { body {

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -689,7 +689,6 @@ form {
position: relative; position: relative;
padding: 1.5rem; padding: 1.5rem;
border-radius: 0.6rem; border-radius: 0.6rem;
//background: linear-gradient(160deg, #ffffff10 50%, #00000040 80%), linear-gradient(-120deg, #ffffff10 50%, #00000040 10%), midnightblue;
background: radial-gradient(circle at top left, #EF6C00 20%, #C51162 30%, #4A148C 40%, #251f44); background: radial-gradient(circle at top left, #EF6C00 20%, #C51162 30%, #4A148C 40%, #251f44);
box-shadow: 0 0.1rem 0.1rem #00000020, 0 2rem 1rem -1rem #00000040; box-shadow: 0 0.1rem 0.1rem #00000020, 0 2rem 1rem -1rem #00000040;
color: rgba(var(--foreground-color), 1); color: rgba(var(--foreground-color), 1);
@ -757,31 +756,31 @@ form {
&:nth-of-type(1) { &:nth-of-type(1) {
.icon { .icon {
background: #D32F2F; background: linear-gradient(135deg, #D32F2F 50%, #B71C1C 50%);
} }
} }
&:nth-of-type(2) { &:nth-of-type(2) {
.icon { .icon {
background: #7B1FA2; background: linear-gradient(135deg, #7B1FA2 50%, #4A148C 50%);
} }
} }
&:nth-of-type(3) { &:nth-of-type(3) {
.icon { .icon {
background: #303F9F; background: linear-gradient(135deg, #1976D2 50%, #0D47A1 50%);
} }
} }
&:nth-of-type(4) { &:nth-of-type(4) {
.icon { .icon {
background: #1976D2; background: linear-gradient(135deg, #388E3C 50%, #1B5E20 50%);
} }
} }
&:nth-of-type(5) { &:nth-of-type(5) {
.icon { .icon {
background: #388E3C; background: linear-gradient(135deg, #F57C00 50%, #E65100 50%);
} }
} }
} }
@ -820,7 +819,8 @@ sm-tab-header {
border-bottom: solid 1px rgba(var(--text-color), 0.2); border-bottom: solid 1px rgba(var(--text-color), 0.2);
} }
sm-tab::part(tab){ sm-tab::part(tab){
padding: 0.8rem 0; padding: 0.8rem 0.4rem;
text-transform: uppercase;
} }
sm-panel{ sm-panel{
width: 100%; width: 100%;
@ -1234,6 +1234,10 @@ sm-panel{
flex-direction: column; flex-direction: column;
} }
} }
.user-panel{
position: sticky;
top: 1.5rem;
}
} }
@media only screen and (min-width: 1920px) { @media only screen and (min-width: 1920px) {

View File

@ -437,6 +437,10 @@
<div class="balance"> <div class="balance">
<h5>Rupee</h5> <h5>Rupee</h5>
<h3 class="token-balance">0</h3> <h3 class="token-balance">0</h3>
</div>
<div class="balance">
<h5>Unconfirmed Rupee</h5>
<h3 class="uncnf-token-balance">0</h3>
</div> </div>
<div class="balance"> <div class="balance">
<h5>FLO</h5> <h5>FLO</h5>
@ -660,6 +664,10 @@
<h5>Rupee</h5> <h5>Rupee</h5>
<h3 class="token-balance">0</h3> <h3 class="token-balance">0</h3>
</div> </div>
<div class="balance">
<h5>Unconfirmed Rupee</h5>
<h3 class="uncnf-token-balance">0</h3>
</div>
<div class="balance"> <div class="balance">
<h5>FLO</h5> <h5>FLO</h5>
<h3 class="flo-balance">0</h3> <h3 class="flo-balance">0</h3>
@ -1506,7 +1514,7 @@
submitBtn = parent.querySelector("button[type='submit']"); submitBtn = parent.querySelector("button[type='submit']");
if (!submitBtn) return; if (!submitBtn) return;
if (formElement.hasAttribute('floId')) { if (formElement.hasAttribute('floId')) {
if (floCrypto.validateAddr(formElement.value)) { if (floCrypto.validateAddr(formElement.value.trim())) {
submitBtn.disabled = false; submitBtn.disabled = false;
} else { } else {
submitBtn.disabled = true; submitBtn.disabled = true;
@ -11122,12 +11130,18 @@
return false; return false;
} }
} }
function delay(t, v) {
return new Promise(function(resolve) {
setTimeout(resolve.bind(null, v), t);
});
}
</script> </script>
<script> <script>
const token_app = { const token_app = {
master_configurations: {}, master_configurations: {},
//masterFLOAddress: 'FD5hK9ryBogJ5AcSvCy1tW5as8jRTkMLky',
actions: {}, actions: {},
blocked_flo_ids: [], blocked_flo_ids: [],
}; };
@ -11135,33 +11149,29 @@
token_app.actions = { token_app.actions = {
parse_flo_comments: async function () { parse_flo_comments: async function () {
const num=3;
text = `masterFLOAddress=FD5hK9ryBogJ5AcSvCy1tW5as8jRTkMLky text = `masterFLOAddress=FD5hK9ryBogJ5AcSvCy1tW5as8jRTkMLky
#!#CURRENCY=INR #!#CURRENCY=INR
#!#TYPE_DEPOSITS=CASH_DEPOSITS_TEST2 #!#TYPE_DEPOSITS=CASH_DEPOSITS_TEST${num}
#!#TYPE_WITHDRAWS=CASH_WITHDRAWS_TEST2 #!#TYPE_WITHDRAWS=CASH_WITHDRAWS_TEST${num}
#!#TYPE_MSGES=USER_MESSAGES_TEST2 #!#TYPE_MSGES=USER_MESSAGES_TEST${num}
#!#TYPE_PROCESSED_DEPOSITS=PROCESSED_DEPOSITS_TEST2 #!#TYPE_PROCESSED_DEPOSITS=PROCESSED_DEPOSITS_TEST${num}
#!#TYPE_PROCESSED_WITHDRAWS=PROCESSED_WITHDRAWS_TEST2 #!#TYPE_PROCESSED_WITHDRAWS=PROCESSED_WITHDRAWS_TEST${num}
#!#TYPE_FILE_DEPOSITS_COMPLAINT=DEPOSITS_COMPLAINT_TEST2 #!#TYPE_FILE_DEPOSITS_COMPLAINT=DEPOSITS_COMPLAINT_TEST${num}
#!#TYPE_PROCESSED_DEPOSITS_COMPLAINT=PROCESSED_DEPOSITS_COMPLAINT_TEST2 #!#TYPE_PROCESSED_DEPOSITS_COMPLAINT=PROCESSED_DEPOSITS_COMPLAINT_TEST${num}
#!#TYPE_FILE_WITHDRAWS_COMPLAINT=WITHDRAWS_COMPLAINT_TEST2 #!#TYPE_FILE_WITHDRAWS_COMPLAINT=WITHDRAWS_COMPLAINT_TEST${num}
#!#TYPE_PROCESSED_WITHDRAWS_COMPLAINT=PROCESSED_WITHDRAWS_COMPLAINT_TEST2 #!#TYPE_PROCESSED_WITHDRAWS_COMPLAINT=PROCESSED_WITHDRAWS_COMPLAINT_TEST${num}
#!#TYPE_PAY_THROUGH_CASHIER=PAY_THRU_CASHIER_TEST2 #!#TYPE_PAY_THROUGH_CASHIER=PAY_THRU_CASHIER_TEST${num}
#!#TYPE_FILE_PAY_THROUGH_CASHIER_COMPLAINT=PAY_THRU_CASHIER_COMPLAINT_TEST2 #!#TYPE_FILE_PAY_THROUGH_CASHIER_COMPLAINT=PAY_THRU_CASHIER_COMPLAINT_TEST${num}
#!#TYPE_PROCESSED_PAY_THROUGH_CASHIER=PROCESSED_PAY_THROUGH_CASHIER_TEST2 #!#TYPE_PROCESSED_PAY_THROUGH_CASHIER=PROCESSED_PAY_THROUGH_CASHIER_TEST${num}
#!#TYPE_PROCESSED_PAY_THROUGH_CASHIER_COMPLAINT=PROCESSED_PAY_THROUGH_CASHIER_COMPLAINT_TEST2 #!#TYPE_PROCESSED_PAY_THROUGH_CASHIER_COMPLAINT=PROCESSED_PAY_THROUGH_CASHIER_COMPLAINT_TEST${num}
#!#TYPE_REQUEST_PAYMENT_DECLINED=REQUEST_PAYMENT_DECLINED_TEST2 #!#TYPE_REQUEST_PAYMENT=REQUEST_PAYMENT_TEST${num}
#!#TYPE_REQUEST_PAYMENT_APPROVED=REQUEST_PAYMENT_APPROVED_TEST2 #!#TYPE_REQUEST_PAYMENT_DECLINED=REQUEST_PAYMENT_DECLINED_TEST${num}
#!#TYPE_REQUEST_PAYMENT_APPROVED=REQUEST_PAYMENT_APPROVED_TEST${num}
#!#vendors=FGtPEBu2NFFYkqFrA9NDBJJLpVhyuPubDj, #!#vendors=FGtPEBu2NFFYkqFrA9NDBJJLpVhyuPubDj,
#!#helplineFloId=F9MAyvT5b9aSfsuukAungrbt1L5fgmJmuK #!#helplineFloId=F9MAyvT5b9aSfsuukAungrbt1L5fgmJmuK
#!#cashiers= #!#cashiers=
{ {
"FByrY4vc1NRfbkqAqABtUyhhNzMZsKUjqr": {
"upi_id": "7004780931@upi"
},
"FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd": {
"upi_id": "7744023898@paytm"
},
"FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX": { "FCja6sLv58e3RMy41T5AmWyvXEWesqBCkX": {
"upi_id": "8507742774@ybl" "upi_id": "8507742774@ybl"
}, },
@ -11181,9 +11191,6 @@
"upi_id": "krishraj1012-2@okicici" "upi_id": "krishraj1012-2@okicici"
} }
}` }`
/*
*/
text = removeWhiteSpaces(text); text = removeWhiteSpaces(text);
return text; return text;
const master_data = await ajaxGet( const master_data = await ajaxGet(
@ -11443,6 +11450,9 @@
floCloudAPI.resetObjectData(token_app, floGlobals.application, { floCloudAPI.resetObjectData(token_app, floGlobals.application, {
receiverID: floGlobals.adminID receiverID: floGlobals.adminID
}); });
floGlobals.appObjects["unconfirmed_rupee_deposits"] = {};
floCloudAPI.resetObjectData("unconfirmed_rupee_deposits");
} }
async function show_deposit_request() { async function show_deposit_request() {
@ -11470,7 +11480,7 @@
let cash_deposits = await compactIDB.readAllData('deposits_flo_txids'); let cash_deposits = await compactIDB.readAllData('deposits_flo_txids');
let cash_deposits_upi_txid_list = Object.values(cash_deposits).map(m => m.upi_txid); let cash_deposits_upi_txid_list = Object.values(cash_deposits).map(m => m.user_upi_txid);
const general_msg = floDapps.getNextGeneralData(token_app.master_configurations.TYPE_DEPOSITS, "0"); const general_msg = floDapps.getNextGeneralData(token_app.master_configurations.TYPE_DEPOSITS, "0");
@ -11558,15 +11568,40 @@
notify(`Transfer unsuccessfull.`); notify(`Transfer unsuccessfull.`);
return false; return false;
} }
// TODO: check https://ranchimallflo.duckdns.org/api/v1.0/getTransactionDetails/${flo_txid}
// and then continue
const input_data = { const input_data = {
receiver_flo_id, receiver_flo_id,
flo_txid, flo_txid,
user_upi_txid, user_upi_txid,
"tokens_transferred": amount_of_tokens_to_transfer,
"datetime": +new Date() "datetime": +new Date()
} }
// TODO: check https://ranchimallflo.duckdns.org/api/v1.0/getTransactionDetails/${flo_txid}
// and then continue
let n=1;
(async function validateDepositTxidInBlockchain() {
notify('Txid '+flo_txid+' validation in process. Please do not close the app until directed.');
await delay(60000);
let validate_txid = await ajaxGet(`https://ranchimallflo.duckdns.org/api/v1.0/getTransactionDetails/${flo_txid}`);
if(typeof validate_txid=="object" && validate_txid.result=="ok") {
// tx registered. Do nothing
} else if(n<=5) {
validateDepositTxidInBlockchain();
n++;
} else {
floGlobals.appObjects["unconfirmed_rupee_deposits"][flo_txid] = input_data;
let receiverID = floGlobals.adminID;
floCloudAPI.updateObjectData("unconfirmed_rupee_deposits", { receiverID });
notify('Txid '+flo_txid+' added in Unconfirmed Rupee Deposits.', 'error');
}
})();
compactIDB.addData('deposits_flo_txids', input_data, "flo_txid"); compactIDB.addData('deposits_flo_txids', input_data, "flo_txid");
// Add data into personal ledger as well // Add data into personal ledger as well
@ -11640,6 +11675,7 @@
notify(error, 'error') notify(error, 'error')
} }
} }
async function transferTokensManually() { async function transferTokensManually() {
try { try {
const send_tokens_btn = document.getElementById('send_tokens_btn'); const send_tokens_btn = document.getElementById('send_tokens_btn');
@ -11686,7 +11722,7 @@
hidePopup() hidePopup()
return false; return false;
} else { } else {
notify(`Transaction successful: ${flo_txid}.`, 'success', '', true); notify(`Transaction successful: <span class="breakable">${flo_txid}</span>.`, 'success', '', true);
if (payingRequested) { if (payingRequested) {
payment_request_status(currentPaymentRequest.requestId, 'APPROVED') payment_request_status(currentPaymentRequest.requestId, 'APPROVED')
showPayRequests() showPayRequests()
@ -11711,19 +11747,22 @@
const get_user_rupee_balance = await ajaxGet( const get_user_rupee_balance = await ajaxGet(
'https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=' + 'https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=' +
myFloID) myFloID)
const get_user_flo_balance = await ajaxGet(` const get_user_unconfirmed_rupee_balance = await get_unconfirmed_balance(myFloID);
https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?floAddress=${myFloID}`)
const get_user_flo_balance = await floBlockchainAPI.getBalance(myFloID)
console.log(get_user_flo_balance) console.log(get_user_flo_balance)
if (typeof get_user_rupee_balance === "object" && get_user_rupee_balance.balance >= 0) { if (typeof get_user_rupee_balance === "object" && get_user_rupee_balance.balance >= 0) {
if (get_user_rupee_balance.balance === null) if (get_user_rupee_balance.balance === null)
get_user_rupee_balance.balance = 0; get_user_rupee_balance.balance = 0;
document.querySelectorAll('.token-balance').forEach(bal => bal.textContent = get_user_rupee_balance.balance); document.querySelectorAll('.token-balance').forEach(bal => bal.textContent = get_user_rupee_balance.balance);
} }
/*if (typeof get_user_flo_balance === "object" && get_user_flo_balance.balance >= 0) { if(typeof get_user_unconfirmed_rupee_balance=="number" && !isNaN(get_user_unconfirmed_rupee_balance)) {
if (get_user_flo_balance.balance === null) document.querySelectorAll('.uncnf-token-balance').forEach(elem => elem.textContent = get_user_unconfirmed_rupee_balance);
get_user_flo_balance.balance = 0; }
document.getElementById('flo_balance').textContent = get_user_flo_balance.balance; if (typeof get_user_flo_balance !== "number" || isNaN(get_user_flo_balance)) {
}*/ get_user_flo_balance = 0;
}
document.querySelectorAll('.flo-balance').forEach(elem => elem.textContent = get_user_flo_balance);
} }
if (refreshButton) { if (refreshButton) {
notify('Balance Updated') notify('Balance Updated')
@ -11845,6 +11884,32 @@
throw new Error(error) throw new Error(error)
} }
} }
async function accounting(date='') {
try {
await floCloudAPI.requestGeneralData(token_app.master_configurations
.TYPE_PROCESSED_DEPOSITS, {
receiverID: myFloID
});
const cash_deposits = floDapps.getNextGeneralData(token_app.master_configurations
.TYPE_PROCESSED_DEPOSITS, "0");
let total = 0;
for(t in cash_deposits) {
let data = cash_deposits[t].message;
if(typeof date !=='number'
|| (new Date(data.datetime*1000).getDate() !== new Date(date).getDate())) continue;
let tokens_transferred = Number(data.tokens_transferred);
if(isNaN(tokens_transferred)) tokens_transferred=0;
total += tokens_transferred;
}
console.log(total);
} catch(e) {
console.log(e);
}
}
</script> </script>
<!-- User functions --> <!-- User functions -->
@ -12176,8 +12241,8 @@
console.log(approved_reqs_list); console.log(approved_reqs_list);
console.log(declined_reqs_list); console.log(declined_reqs_list);
let processed_payments_requests = approved_reqs_list.map(m => m.message).concat(declined_reqs_list let processed_payments_requests = approved_reqs_list.map(m => m.message.pay_req_id).concat(declined_reqs_list
.map(m => m.message)); .map(m => m.message.pay_req_id));
let pendingPaymentRequestContainer = document.getElementById("pending_payment_request_container"), let pendingPaymentRequestContainer = document.getElementById("pending_payment_request_container"),
approvedPaymentRequestContainer = document.getElementById("approved_payment_request_container"), approvedPaymentRequestContainer = document.getElementById("approved_payment_request_container"),
@ -12196,6 +12261,7 @@
pay_req_id pay_req_id
} = m.message; } = m.message;
if (processed_payments_requests.includes(pay_req_id || m.message)) continue; if (processed_payments_requests.includes(pay_req_id || m.message)) continue;
console.log(sender_flo_id, amount, datetime, pay_req_id);
if (typeof sender_flo_id !== "string") continue; if (typeof sender_flo_id !== "string") continue;
frag.append(render.paymentRequest(datetime, sender_flo_id, amount, pay_req_id, true)) frag.append(render.paymentRequest(datetime, sender_flo_id, amount, pay_req_id, true))
} }
@ -12231,10 +12297,10 @@
} }
} }
function payment_request_status(req_id = '', status = '') { function payment_request_status(req = '', status = '') {
try { try {
if (req_id.lenght < 1) return false; if (typeof req !== 'object') return false;
if (status === 'DECLINED') { if (status === 'DECLINED') {
status = token_app.master_configurations.TYPE_REQUEST_PAYMENT_DECLINED; status = token_app.master_configurations.TYPE_REQUEST_PAYMENT_DECLINED;
@ -12242,11 +12308,11 @@
status = token_app.master_configurations.TYPE_REQUEST_PAYMENT_APPROVED; status = token_app.master_configurations.TYPE_REQUEST_PAYMENT_APPROVED;
} else return; } else return;
floCloudAPI.sendGeneralData(req_id, status, { floCloudAPI.sendGeneralData(req, status, {
receiverID: myFloID receiverID: myFloID
}); });
console.info(req_id + ' added to declined requests list.'); console.log(req);
return true; return true;
@ -12254,6 +12320,40 @@
console.log(e); console.log(e);
} }
} }
async function get_unconfirmed_balance(flo_id='') {
try {
let api = `https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressTransactions?floAddress=${flo_id}`;
let token_balance = await ajaxGet(`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=${flo_id}`);
token_balance = token_balance.balance;
let tokens_transfers_tx_list = await ajaxGet(api);
tokens_transfers_tx_list = Object.keys(tokens_transfers_tx_list.transactions);
let receiverID = floGlobals.adminID;
let senderIDs = Object.keys(token_app.master_configurations.cashiers);
await floCloudAPI.requestObjectData("unconfirmed_rupee_deposits", { receiverID, senderIDs });
let unconfirmed_tx_list = Object.keys(floGlobals.appObjects["unconfirmed_rupee_deposits"]);
//console.log(unconfirmed_tx_list);
//console.log(tokens_transfers_tx_list);
//console.log(token_balance);
let unconfirmed_balance=0;
for(ut of unconfirmed_tx_list) {
if(tokens_transfers_tx_list.includes(ut)) {
// remove this item from unconfirmed_tx_list
if(delete floGlobals.appObjects["unconfirmed_rupee_deposits"][ut])
floCloudAPI.updateObjectData("unconfirmed_rupee_deposits", { receiverID });
} else {
unconfirmed_balance += Number(floGlobals.appObjects["unconfirmed_rupee_deposits"][ut]["tokens_transferred"])
}
}
console.log(token_balance, unconfirmed_balance);
return unconfirmed_balance;
} catch(error) {
notify('Failed to get rupee balance.', 'error')
throw new Error(error);
}
}
</script> </script>
<!-- Helpline --> <!-- Helpline -->