From e0a4d1bb1339e80775aa37efaf8cac314278f8e9 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 19 Oct 2020 21:55:02 -0500 Subject: Add navigation template and logout --- src/server.js | 4 + src/static/styles.css | 38 +++++-- src/templates.js | 7 +- src/templates/about.html | 14 +-- src/templates/expected.html | 86 ++++++++------- src/templates/goals.html | 75 ++++++------- src/templates/ledger-edit.html | 33 +++--- src/templates/ledger.html | 82 +++++++------- src/templates/navigation.html | 8 ++ src/templates/summary.html | 239 ++++++++++++++++++++--------------------- 10 files changed, 311 insertions(+), 275 deletions(-) create mode 100644 src/templates/navigation.html diff --git a/src/server.js b/src/server.js index 541f467..17d5372 100644 --- a/src/server.js +++ b/src/server.js @@ -67,6 +67,10 @@ function setUpRoutes(models, jwtFunctions, database, templates) { let body = templates["login"]({}); res.status(200).send(body) }) + server.get('/logout', (req, res) => { + res.clearCookie('authorization'); + res.redirect("/login"); + }); server.get('/login/signup', async (req, res) => { let body = templates["signup"]({}); res.status(200).send(body) diff --git a/src/static/styles.css b/src/static/styles.css index 4eedd0b..fb91d3b 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -7,11 +7,6 @@ table { max-width: 100%; } -li { - cursor: pointer; - text-decoration: underline; -} - tr:nth-child(2n+1) { background-color: lightgray; } @@ -43,17 +38,43 @@ pre { } .net-negative { - /* color: red; */ background-color: lightcoral; } .net-positive { - /* color: green; */ background-color: lightgreen } + +.summary { + display: flex; + flex-wrap: wrap; + flex-direction: row; +} .summary-panel { float:left; padding-right: 2em; } + +body { + display: flex; + flex-wrap: wrap; +} + +.navigation { + flex-grow: 1; + max-width: 100px; + border-left: 1px solid #333; + padding-left: 10px; +} + +.main { + flex-grow: 3; + max-width: 1000px; +} + +p, li { + max-width: 70ch; +} + @media only screen and (max-width: 600px) { .newItem td { display:block; @@ -69,4 +90,7 @@ pre { display: block; width: 100%; } + .navigation { + border-left: none; + } } \ No newline at end of file diff --git a/src/templates.js b/src/templates.js index 28435f8..a9e3305 100644 --- a/src/templates.js +++ b/src/templates.js @@ -7,7 +7,13 @@ function loadTemplate(templates, name, filepath){ templates[name] = handlebars.compile(templateContent); } +function loadPartial(name, filepath){ + handlebars.registerPartial(name, fs.readFileSync(filepath).toString()); +} + function setUpTemplates(){ + loadPartial("navigation", path.join(__dirname, "templates/navigation.html")) + let templates = {}; loadTemplate(templates, "about", path.join(__dirname, 'templates/about.html')) loadTemplate(templates, "login", path.join(__dirname, 'templates/login.html')) @@ -17,7 +23,6 @@ function setUpTemplates(){ loadTemplate(templates, "goals", path.join(__dirname, 'templates/goals.html')) loadTemplate(templates, "expected", path.join(__dirname, 'templates/expected.html')) loadTemplate(templates, "summary", path.join(__dirname, 'templates/summary.html')) - return templates } diff --git a/src/templates/about.html b/src/templates/about.html index 3a80b50..d4f215f 100644 --- a/src/templates/about.html +++ b/src/templates/about.html @@ -2,21 +2,14 @@ - Mark's Database - Login + About - + -
- - - - - -
-
+

About

Welcome to the alpha budget app! You've been given exclusive access to this secret trial

Here is how I use this site

@@ -30,6 +23,7 @@
  • Goals can be used to subdivide net savings into categories. It is still W.I.P.
  • + {{> navigation}} \ No newline at end of file diff --git a/src/templates/expected.html b/src/templates/expected.html index 64841a5..9554896 100644 --- a/src/templates/expected.html +++ b/src/templates/expected.html @@ -8,44 +8,54 @@ -

    {{name}}'s Budget

    -
    - - - - - -
    +
    +

    {{name}}'s Budget

    +
    + + + + + +
    -
    - - - - -
    - - - {{#each expecteds}} - - - - - - - {{/each}} -
    NameTotalPeriod
    {{this.index}}{{this.name}}{{this.total}}{{this.days}}
    - - - - - - - - - - - -
    Weekly:{{week}}
    Monthly:{{month}}
    Yearly:{{year}}
    +
    + + + + +
    + + + + + + + + {{#each expecteds}} + + + + + + + {{/each}} +
    NameTotalPeriod
    {{this.index}}{{this.name}}{{this.total}}{{this.days}}
    + + + + + + + + + + + + + +
    Weekly:{{week}}
    Monthly:{{month}}
    Yearly:{{year}}
    +
    + {{>navigation}} - + \ No newline at end of file diff --git a/src/templates/goals.html b/src/templates/goals.html index b5dbe42..e30aa62 100644 --- a/src/templates/goals.html +++ b/src/templates/goals.html @@ -8,44 +8,45 @@ -

    {{name}}'s Budget

    -
    - - - - - -
    - -
    - - - -
    -
    - Allocate funds - + + +
    +
    + Allocate funds + + + +
    + + + + + + + + {{#each goals}} - + + + + + + + {{/each}} - - - - -
    NameAmountTotalRemaining
    {{this.index}}{{this.name}}{{this.amount}}{{this.total}}{{this.remaining}}
    - - {{#each goals}} - - - - - - - - {{/each}} -
    NameAmountTotalRemaining
    {{this.index}}{{this.name}}{{this.amount}}{{this.total}}{{this.remaining}}
    + +
    + {{>navigation}} - + \ No newline at end of file diff --git a/src/templates/ledger-edit.html b/src/templates/ledger-edit.html index 2acc2c2..e939b6d 100644 --- a/src/templates/ledger-edit.html +++ b/src/templates/ledger-edit.html @@ -8,24 +8,21 @@ -

    {{name}}'s Budget

    -
    - - - - +
    +

    {{name}}'s Budget

    +
    + + + + + + +
    +
    -
    - - - - - - -
    - + {{> navigation}} - + \ No newline at end of file diff --git a/src/templates/ledger.html b/src/templates/ledger.html index 9ffdeea..e2b7625 100644 --- a/src/templates/ledger.html +++ b/src/templates/ledger.html @@ -9,49 +9,45 @@ -

    {{name}}'s Budget

    -
    - - - - - +
    +

    {{name}}'s Budget

    +
    + + + + + + +
    + + + + + + + + + + + + {{#each ledger}} + + + + + + + + + + + {{/each}} +
    WhenWhereAmountCategoryTags
    {{this.index}}{{this.when}}{{this.where}}{{this.amount}}{{this.category}}{{this.subcategory}}
    +
    -
    - - - - - - -
    - - - - - - - - - - - - {{#each ledger}} - - - - - - - - - - - {{/each}} -
    WhenWhereAmountCategoryTags
    {{this.index}}{{this.when}}{{this.where}}{{this.amount}}{{this.category}}{{this.subcategory}}
    - + {{> navigation}} - + \ No newline at end of file diff --git a/src/templates/navigation.html b/src/templates/navigation.html new file mode 100644 index 0000000..c20ccbf --- /dev/null +++ b/src/templates/navigation.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/src/templates/summary.html b/src/templates/summary.html index a998be9..2759986 100644 --- a/src/templates/summary.html +++ b/src/templates/summary.html @@ -8,128 +8,125 @@ -

    {{name}}'s Budget

    -
    - - - - - -
    - -
    -

    Weekly

    - - - - - - - - - {{#each week}} - - - - - - - - {{/each}} - Avg: - - - - - - - -
    YearWeekInOutNet
    {{this.y}}{{this.w}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{week_avg.in}}{{week_avg.out}}{{week_avg.net}}
    -
    -
    -

    Monthly

    - - - - - - - - - {{#each month}} - - - - - - - - {{/each}} - - - - - - - -
    YearMonthInOutNet
    {{this.y}}{{this.m}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{month_avg.in}}{{month_avg.out}}{{month_avg.net}}
    -
    -
    -

    Yearly

    - - - - - - - - {{#each year}} - - - - - - - {{/each}} - Avg: - - - - - - -
    YearInOutNet
    {{this.y}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{year_avg.in}}{{year_avg.out}}{{year_avg.net}}
    -
    -
    -

    Categories

    - - - - - - {{#each categories}} - - - - - {{/each}} -
    CategoryTotal
    {{this.category}}{{this.s}}
    -
    -
    -

    Sub-Categories

    - - - - - - {{#each subcategories}} - - - - - {{/each}} -
    Sub-CategoryTotal
    {{this.subcategory}}{{this.s}}
    +
    +

    {{name}}'s Budget

    +
    +
    +

    Weekly

    + + + + + + + + + {{#each week}} + + + + + + + + {{/each}} + Avg: + + + + + + + +
    YearWeekInOutNet
    {{this.y}}{{this.w}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{week_avg.in}}{{week_avg.out}}{{week_avg.net}}
    +
    +
    +

    Monthly

    + + + + + + + + + {{#each month}} + + + + + + + + {{/each}} + + + + + + + +
    YearMonthInOutNet
    {{this.y}}{{this.m}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{month_avg.in}}{{month_avg.out}}{{month_avg.net}}
    +
    +
    +

    Yearly

    + + + + + + + + {{#each year}} + + + + + + + {{/each}} + Avg: + + + + + + +
    YearInOutNet
    {{this.y}}{{this.in}}{{this.out}}{{this.net}}
    Avg:{{year_avg.in}}{{year_avg.out}}{{year_avg.net}}
    +
    +
    +

    Categories

    + + + + + + {{#each categories}} + + + + + {{/each}} +
    CategoryTotal
    {{this.category}}{{this.s}}
    +
    +
    +

    Sub-Categories

    + + + + + + {{#each subcategories}} + + + + + {{/each}} +
    Sub-CategoryTotal
    {{this.subcategory}}{{this.s}}
    +
    +
    + {{> navigation}} \ No newline at end of file -- cgit v1.2.3