mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-17 15:12:14 +11:00
almost done, need twix to patch some things in api
This commit is contained in:
parent
7bf74a55b1
commit
76b36d5740
1 changed files with 10 additions and 13 deletions
23
index.js
23
index.js
|
|
@ -6,7 +6,6 @@ const bodyParser = require("body-parser");
|
||||||
const expressValidator = require("express-validator");
|
const expressValidator = require("express-validator");
|
||||||
const flash = require("connect-flash");
|
const flash = require("connect-flash");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
|
|
||||||
const { ensureAuthenticated } = require("./config/auth.js");
|
const { ensureAuthenticated } = require("./config/auth.js");
|
||||||
const app = express();
|
const app = express();
|
||||||
const MemoryStore = require("memorystore")(session);
|
const MemoryStore = require("memorystore")(session);
|
||||||
|
|
@ -19,6 +18,7 @@ const { CCashClient } = require("ccash-client-js");
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const { postUser } = require("./helpers/functions.js");
|
const { postUser } = require("./helpers/functions.js");
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
const client = new CCashClient(process.env.BANKAPIURL);
|
||||||
|
|
||||||
app.set("views", path.join(__dirname, "views"));
|
app.set("views", path.join(__dirname, "views"));
|
||||||
app.set("view engine", "pug");
|
app.set("view engine", "pug");
|
||||||
app.use(flash());
|
app.use(flash());
|
||||||
|
|
@ -190,6 +190,7 @@ app.get("/BankF", ensureAuthenticated, async function (req, res) {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
console.log(balance);
|
||||||
let logsent;
|
let logsent;
|
||||||
console.log("start " + Date.now());
|
console.log("start " + Date.now());
|
||||||
try {
|
try {
|
||||||
|
|
@ -198,36 +199,32 @@ app.get("/BankF", ensureAuthenticated, async function (req, res) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
console.log(logsent);
|
|
||||||
console.log("query finished " + Date.now());
|
|
||||||
let logrec = logsent;
|
let logrec = logsent;
|
||||||
let graphlog = logsent;
|
let graphlog = logsent;
|
||||||
console.log(graphlog);
|
if (graphlog != null) {
|
||||||
if (graphlog != 0 && graphlog != null) {
|
|
||||||
graphlog = graphlog.reverse();
|
graphlog = graphlog.reverse();
|
||||||
}
|
}
|
||||||
let graphdata = "";
|
let graphdata = "";
|
||||||
let currentbal = balance;
|
let currentbal = balance;
|
||||||
if (graphlog != 0 && graphlog != null) {
|
if (graphlog) {
|
||||||
graphdata =
|
for (i = graphlog.length - 1; i > -1; i--) {
|
||||||
graphdata + ", [" + parseInt(graphlog.length) + "," + balance + "]";
|
|
||||||
for (i = 0; i < graphlog.length; i++) {
|
|
||||||
if (graphlog[i].from == req.session.user) {
|
if (graphlog[i].from == req.session.user) {
|
||||||
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||||
} else {
|
} else {
|
||||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(balance);
|
|
||||||
console.log(JSON.stringify(graphdata));
|
|
||||||
} else {
|
} else {
|
||||||
graphlog = undefined;
|
graphlog = undefined;
|
||||||
}
|
}
|
||||||
if (graphdata != "") {
|
if (graphdata != "") {
|
||||||
|
graphdata =
|
||||||
|
", [" + parseInt(graphlog.length) + "," + balance + "]" + graphdata;
|
||||||
graphdata = '["transaction", "balance"]' + graphdata;
|
graphdata = '["transaction", "balance"]' + graphdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(balance);
|
console.log(balance);
|
||||||
console.log(JSON.stringify(graphdata));
|
console.log(JSON.stringify(graphdata));
|
||||||
if (logsent == null) {
|
if (logsent == null) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue