mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-16 23:02:13 +11:00
purged some unneeded files and update for v3? logs
This commit is contained in:
parent
8b3e3da71c
commit
2c62a9a40b
5 changed files with 30 additions and 3185 deletions
66
index.js
66
index.js
|
|
@ -149,16 +149,15 @@ fastify.get(
|
|||
console.log(balance);
|
||||
console.log("start " + Date.now());
|
||||
|
||||
let logsent = await got(`${api}/api/v2/user/log`, {
|
||||
let log = await got(`${api}/api/v2/user/log`, {
|
||||
headers: {
|
||||
Authorization: auth,
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
logsent = JSON.parse(logsent.body);
|
||||
console.log(logsent);
|
||||
let logrec = logsent;
|
||||
let graphlog = logsent;
|
||||
log = JSON.parse(log.body);
|
||||
console.log(log);
|
||||
let graphlog = log;
|
||||
if (graphlog != null) {
|
||||
graphlog = graphlog.reverse();
|
||||
}
|
||||
|
|
@ -166,13 +165,8 @@ fastify.get(
|
|||
let currentbal = balance;
|
||||
if (graphlog) {
|
||||
for (i = graphlog.length - 1; i > -1; i--) {
|
||||
if (graphlog[i].from == req.session.get("user")) {
|
||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||
} else {
|
||||
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
graphlog = undefined;
|
||||
|
|
@ -182,43 +176,31 @@ fastify.get(
|
|||
", [" + parseInt(graphlog.length) + "," + balance + "]" + graphdata;
|
||||
graphdata = '["transaction", "balance"]' + graphdata;
|
||||
}
|
||||
if (logsent == null) {
|
||||
logsent = undefined;
|
||||
} else {
|
||||
logsent = await logsent.filter(
|
||||
({ from }) => from === req.session.get("user")
|
||||
);
|
||||
}
|
||||
if (logrec == null) {
|
||||
logrec = undefined;
|
||||
} else {
|
||||
logrec = await logrec.filter(({ to }) => to === req.session.get("user"));
|
||||
}
|
||||
if (logsent) {
|
||||
for (i in logrec) {
|
||||
logrec[i].time = new Date(logrec[i].time);
|
||||
let transactionlog = []
|
||||
for(i = 0; i < log.length; i++){
|
||||
if(log[i].amount > 0){
|
||||
let absol = Math.abs(log[i].amount)
|
||||
console.log(absol)
|
||||
let date = Date(log[i].time)
|
||||
console.log(date)
|
||||
transactionlog.push(`You sent ${log[i].counterparty} ${absol} at ${date}`);
|
||||
|
||||
} else {
|
||||
|
||||
transactionlog.push(`${log[i].counterparty} sent you ${log[i].amount} at ${log[i].time}`);
|
||||
|
||||
}
|
||||
}
|
||||
if (logrec) {
|
||||
for (i in logsent) {
|
||||
logsent[i].time = new Date(logsent[i].time);
|
||||
}
|
||||
}
|
||||
if (logrec != null) {
|
||||
logrec.reverse();
|
||||
}
|
||||
if (logsent != null) {
|
||||
logsent.reverse();
|
||||
}
|
||||
console.log(logrec);
|
||||
console.log(logsent);
|
||||
|
||||
console.log(transactionlog)
|
||||
let maxgraph = balance + 1000;
|
||||
console.log(graphdata)
|
||||
console.log("begin render " + Date.now());
|
||||
|
||||
res.view("bankf", {
|
||||
transactionlog: transactionlog,
|
||||
maxgraph: maxgraph,
|
||||
graphdata: graphdata,
|
||||
logrec: logrec,
|
||||
logsent: logsent,
|
||||
user: req.session.get("user"),
|
||||
balance: balance,
|
||||
admin: req.session.get("admin"),
|
||||
|
|
@ -241,7 +223,7 @@ fastify.post(
|
|||
let result;
|
||||
let auth = req.session.get("b64");
|
||||
try {
|
||||
result = await got.post(`${api}user/transfer`, {
|
||||
result = await got.post(`${api}/api/v1/user/transfer`, {
|
||||
headers: {
|
||||
Authorization: auth,
|
||||
Accept: "application/json",
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
# ccashfrontend
|
||||
This is a Front End for EntireTwix's CCcash API, it allows regular users to access the banks features and do what they like without having to know code or http requests.
|
||||
|
||||
## Deployment
|
||||
To begin you must have set up CCash API server which you can find here [Github](https://github.com/EntireTwix/CCash) He is much better at documentation than i, but his is also harder to set up so good luck.
|
||||
|
||||
From here is will assume you have set up the api server, know its URL and what protocol it is using
|
||||
|
||||
if deploying to a serverless application make sure you set the environmental variables first. these are as follows
|
||||
* BANKAPIURL=your api url including http/s and the trailing slash NOT BANKF
|
||||
* SECURE=true if you have ssl on your front end host
|
||||
* SETUP=true when you have set the above this just gets rid of the setup page that will show if it equals false or the .env file is not found
|
||||
* PORT=Optional will default to 3000 if not set
|
||||
|
||||
if you are deploying on a vps then
|
||||
1. git clone repository
|
||||
2. run npm install
|
||||
3. Set environmental variables (they are no longer set through the webpage) hint: make a .env file in the root and fill in environmental variables as above
|
||||
4. run with your favourite node webserver if you dont know any use [pm2](https://pm2.keymetrics.io/)
|
||||
5. restart the application and badda bim badda boom you done
|
||||
|
||||
If you want to properly deploy it put it behind a reverse proxy too so you can have virtual hosts and all that shizzaz
|
||||
but im not going to outline that because that is more advanced, and will require a lot of explaining, google `how to reverse proxy a nodejs app` if you want to know more
|
||||
|
||||
|
||||
## Credits
|
||||
https://github.com/LukeeeeBennett/ccash-client-js - API (started using his api because it makes my code cleaner though as of writing this it needs a few changes to work but should be fixed within 24ish hours ive made a pull request)
|
||||
|
|
@ -35,28 +35,17 @@ block content
|
|||
|
||||
ul#transactions.nav.nav-tabs.card-header-tabs(role='tablist')
|
||||
li.nav-item
|
||||
a.nav-link.active.text-black(href='#sent', role='tab', aria-controls='sent', aria-selected='true') Sent
|
||||
li.nav-item
|
||||
a.nav-link.text-black(href='#received', role='tab', aria-controls='recieved', aria-selected='false') Recieved
|
||||
a.nav-link.active.text-black(href='#transaction-list', role='tab', aria-controls='sent', aria-selected='true') Transaction List
|
||||
li.nav-item
|
||||
a.nav-link.text-black(href='#balhistory', role='tab', aria-controls='balhistory', aria-selected='false') Balance History
|
||||
.tab-content.mt-3
|
||||
#sent.tab-pane.active(role='tabpanel')
|
||||
#transaction-list.tab-pane.active(role='tabpanel')
|
||||
.logs
|
||||
if logsent
|
||||
each log in logsent
|
||||
hr
|
||||
p Date: #{log.time}
|
||||
p You sent #{log.to} $#{log.amount}
|
||||
hr
|
||||
#received.tab-pane(role='tabpanel', aria-labelledby='recieved-tab')
|
||||
.logs
|
||||
if logrec
|
||||
each log in logrec
|
||||
hr
|
||||
p Date: #{log.time}
|
||||
p #{log.from} sent you $#{log.amount}
|
||||
if transactionlog
|
||||
each i in transactionlog
|
||||
hr
|
||||
p #{i}
|
||||
|
||||
#balhistory.tab-pane(role='tabpanel', aria-labelledby='balhistory-tab')
|
||||
#chart_div(style="width:100%; height 100%")
|
||||
|
||||
|
|
|
|||
3060
views/package-lock.json
generated
3060
views/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"ccash-client-js": "^1.6.3",
|
||||
"connect-flash": "^0.1.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-messages": "^1.0.1",
|
||||
"express-session": "^1.17.1",
|
||||
"express-validator": "5.3.1",
|
||||
"got": "^11.8.2",
|
||||
"https": "^1.0.0",
|
||||
"memorystore": "*",
|
||||
"mongoose": "^5.12.5",
|
||||
"path": "^0.12.7",
|
||||
"pug": "^3.0.2",
|
||||
"url": "^0.11.0",
|
||||
"validator": "^13.5.2"
|
||||
},
|
||||
"name": "ccashfrontend",
|
||||
"description": "",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Expand-sys/ccashfrontend.git"
|
||||
},
|
||||
"author": "Expand",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Expand-sys/ccashfrontend/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Expand-sys/ccashfrontend#readme",
|
||||
"engines": {
|
||||
"node": "16.x"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue