diff --git a/index.js b/index.js index 708b568..0f22138 100644 --- a/index.js +++ b/index.js @@ -238,7 +238,7 @@ fastify.post( req.session.set("errors", ""); req.session.set("successes", ""); let result; - //result = await client.sendFunds(a_name, senderpass, name, amount); + let auth = req.session.get("b64"); try { result = await got.post(`${api}/user/transfer`, { headers: { @@ -247,12 +247,11 @@ fastify.post( }, json: { name: name, - amount: amount, + amount: parseInt(amount), }, }); } catch (e) { - req.session.set("errors", `${e.response.body}`); - console.log(e.response.body); + req.session.set("errors", `${e}`); } if (result) { req.session.set("successes", "Transfer successful"); diff --git a/public/css/style.css b/public/css/style.css index 37ca9a2..56c3afc 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -82,10 +82,6 @@ p { .text-white { color: white; } -.form-check-input { - margin-left: 0; - padding: inherit; -} input[type="radio"]:checked ~ .reveal-if-active, input[type="checkbox"]:checked ~ .reveal-if-active { @@ -123,7 +119,6 @@ $w: Min(10em, 100%); } .logo { align-content: center; - width: 115px; padding: 5px; border-radius: 10px; border-color: rgba(113, 63, 230, 1); @@ -136,3 +131,6 @@ $w: Min(10em, 100%); rgba(38, 9, 108, 1) 100% ); } +#navbars { + flex-grow: 0; +} diff --git a/routes/admin.js b/routes/admin.js index ae2d9dd..a938cb9 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -199,7 +199,7 @@ module.exports = function (fastify, opts, done) { }, json: { name: name, - new_pass: new_pass, + pass: new_pass, }, }); } catch (e) { diff --git a/views/bankf.pug b/views/bankf.pug index 75bed4b..be072fb 100644 --- a/views/bankf.pug +++ b/views/bankf.pug @@ -60,38 +60,52 @@ block content #balhistory.tab-pane(role='tabpanel', aria-labelledby='balhistory-tab') #chart_div(style="width:100%; height 100%") - script(type='text/javascript' src='https://www.gstatic.com/charts/loader.js') - script(type='text/javascript'). - - google.charts.load('current', {'packages':['corechart', 'line']}); - google.charts.setOnLoadCallback(drawChart); - function drawChart() { - var data = google.visualization.arrayToDataTable([!{graphdata}]); + script(type='text/javascript' src='https://www.gstatic.com/charts/loader.js') + script(type='text/javascript'). + + google.charts.load('current', {'packages':['corechart', 'line']}); + google.charts.setOnLoadCallback(drawChart); + function drawChart() { + var data = google.visualization.arrayToDataTable([!{graphdata}]); - var options = { - title: 'Balance', - hAxis: { - title: 'Transaction', - textPosition: 'out', - }, - vAxis: { - title: 'Balance', - format: 'currency', - textPosition: 'out', - }, - trendlines: { - 0: {type: 'exponential', color: '#333', opacity: .5}, - 1: {type: 'linear', color: '#111', opacity: .3} - }, - width: 670, - height: 350, - }; - - var chart = new google.visualization.LineChart(document.getElementById('chart_div')); - - chart.draw(data, options); - window.onload = resize; - window.onresize = resize; - } + var options = { + title: 'Balance', + hAxis: { + title: 'Transaction', + textPosition: 'out', + }, + vAxis: { + title: 'Balance', + format: 'currency', + textPosition: 'out', + }, + trendlines: { + 0: {type: 'exponential', color: '#333', opacity: .5}, + 1: {type: 'linear', color: '#111', opacity: .3} + }, + width: 680, + height: 350, + }; + function resize () { + var chart = new google.visualization.LineChart(document.getElementById('chart_div')); + chart.draw(data, options); + } + window.onload = resize; + window.onresize = resize; + + } + script(type='text/javascript'). + function resize () { + var chart = new google.visualization.LineChart(document.getElementById('chart_div')); + chart.draw(data, options); + } + var nav = document.querySelector('.nav-link'); + nav.addEventListener('click', function(e) { + // Event delegation - make sure it was one of the tab nav items that was clicked + if (e.target) { + resize(); + // Call the redraw function for the charts + } + }); br diff --git a/views/layout.pug b/views/layout.pug index 514d46c..0b6ac08 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -2,7 +2,7 @@ doctype html html head title CCashBank - link(rel="stylesheet", href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css", integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z", crossorigin="anonymous") + link(rel="stylesheet", href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css", integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3", crossorigin="anonymous") link(rel="preconnect" href="https://fonts.gstatic.com") link(href="https://fonts.googleapis.com/css2?family=Lato&family=Montserrat&display=swap" rel="stylesheet") if random @@ -27,24 +27,24 @@ html button.navbar-toggler(type='button', data-toggle='collapse', data-target='#navbars', aria-controls='navbars', aria-expanded='false', aria-label='Toggle navigation') span.navbar-toggler-icon #navbars.collapse.navbar-collapse - - ul.navbar-nav.mr-right.text-white - if user == undefined - li.nav-item - a.nav-link(href='/login').text-white Login - li.nav-item - a.nav-link(href='/register').text-white Register - - if user - li.nav-item - a.nav-link(href='/logout').text-white Log out - li.nav-item - a.nav-link(href='/BankF').text-white Bank - li.nav-item - a.nav-link(href='/settings').text-white Settings - if admin == 204 + .d-flex + ul.navbar-nav.text-white + if user == undefined li.nav-item - a.nav-link(href='/admin').text-white Admin + a.nav-link(href='/login').text-white Login + li.nav-item + a.nav-link(href='/register').text-white Register + + if user + li.nav-item + a.nav-link(href='/logout').text-white Log out + li.nav-item + a.nav-link(href='/BankF').text-white Bank + li.nav-item + a.nav-link(href='/settings').text-white Settings + if admin == 204 + li.nav-item + a.nav-link(href='/admin').text-white Admin .container .container(style="min-height: 3vh") if errors @@ -60,4 +60,5 @@ html script(src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous") script(src='/js/main.js') - script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js", integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV", crossorigin="anonymous") + script(src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js", integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13", crossorigin="anonymous") + script(src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js", integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p", crossorigin="anonymous") diff --git a/views/setup.pug b/views/setup.pug index ccd77fe..7017f92 100644 --- a/views/setup.pug +++ b/views/setup.pug @@ -6,12 +6,13 @@ block content h1 Welcome to CCashBank Front End SETUP .card form(method='POST', action='/setup') - #form-group - label BANKAPIURL: - input.form-control(name='url', type='url') - label SSL enabled on front end? leave unchecked if unsure: - input.form-control(name='secure', type='checkbox') + label BANKAPIURL: + input.form-control(name='url', type='url') + label SSL enabled on front end? leave unchecked if unsure: + .form-check + input.form-check-input(name='secure', type='checkbox') br + input.btn.btn-primary(type='submit',value='Submit') br br