diff options
author | Zach Berwaldt <zberwaldt@tutamail.com> | 2024-03-21 11:23:42 -0400 |
---|---|---|
committer | Zach Berwaldt <zberwaldt@tutamail.com> | 2024-03-21 11:23:42 -0400 |
commit | fd6f6f169f9ff9a1247228fb34dc9654a9584915 (patch) | |
tree | 4241792d4b41bc025807cab001a18a2d355e7ea3 | |
parent | 655aeaac60c7dec09276f469904752c7dc58c8c5 (diff) |
fix bugs, redo layout, reorg.
-rw-r--r-- | api/go.mod | 8 | ||||
-rw-r--r-- | api/go.sum | 17 | ||||
-rw-r--r-- | api/internal/controllers/auth.go | 2 | ||||
-rw-r--r-- | api/internal/database/database.go | 2 | ||||
-rw-r--r-- | db/sql/views.sql | 6 | ||||
-rw-r--r-- | fe/src/App.svelte | 2 | ||||
-rw-r--r-- | fe/src/app.css | 53 | ||||
-rw-r--r-- | fe/src/lib/Card.svelte | 5 | ||||
-rw-r--r-- | fe/src/lib/Column.svelte | 8 | ||||
-rw-r--r-- | fe/src/lib/DataView.svelte | 8 | ||||
-rw-r--r-- | fe/src/lib/Layout.svelte | 51 | ||||
-rw-r--r-- | fe/src/lib/Table.svelte | 10 | ||||
-rw-r--r-- | fe/src/lib/forms/AddForm.svelte | 25 | ||||
-rw-r--r-- | fe/src/lib/forms/LoginForm.svelte (renamed from fe/src/lib/LoginForm.svelte) | 6 | ||||
-rw-r--r-- | fe/src/lib/forms/PreferencesForm.svelte (renamed from fe/src/lib/PreferencesForm.svelte) | 10 | ||||
-rw-r--r-- | fe/src/lib/forms/index.ts | 10 | ||||
-rw-r--r-- | fe/src/types.ts | 2 |
17 files changed, 127 insertions, 98 deletions
@@ -4,8 +4,8 @@ go 1.18 | |||
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | github.com/gin-gonic/gin v1.9.1 | 6 | github.com/gin-gonic/gin v1.9.1 |
7 | github.com/glebarez/go-sqlite v1.22.0 | ||
7 | github.com/google/uuid v1.6.0 | 8 | github.com/google/uuid v1.6.0 |
8 | github.com/mattn/go-sqlite3 v1.14.22 | ||
9 | github.com/spf13/viper v1.18.2 | 9 | github.com/spf13/viper v1.18.2 |
10 | github.com/stretchr/testify v1.8.4 | 10 | github.com/stretchr/testify v1.8.4 |
11 | golang.org/x/crypto v0.19.0 | 11 | golang.org/x/crypto v0.19.0 |
@@ -16,6 +16,7 @@ require ( | |||
16 | github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect | 16 | github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect |
17 | github.com/chenzhuoyu/iasm v0.9.1 // indirect | 17 | github.com/chenzhuoyu/iasm v0.9.1 // indirect |
18 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | 18 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect |
19 | github.com/dustin/go-humanize v1.0.1 // indirect | ||
19 | github.com/fsnotify/fsnotify v1.7.0 // indirect | 20 | github.com/fsnotify/fsnotify v1.7.0 // indirect |
20 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect | 21 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect |
21 | github.com/gin-contrib/sse v0.1.0 // indirect | 22 | github.com/gin-contrib/sse v0.1.0 // indirect |
@@ -34,6 +35,7 @@ require ( | |||
34 | github.com/modern-go/reflect2 v1.0.2 // indirect | 35 | github.com/modern-go/reflect2 v1.0.2 // indirect |
35 | github.com/pelletier/go-toml/v2 v2.1.1 // indirect | 36 | github.com/pelletier/go-toml/v2 v2.1.1 // indirect |
36 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | 37 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect |
38 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||
37 | github.com/sagikazarmark/locafero v0.4.0 // indirect | 39 | github.com/sagikazarmark/locafero v0.4.0 // indirect |
38 | github.com/sagikazarmark/slog-shim v0.1.0 // indirect | 40 | github.com/sagikazarmark/slog-shim v0.1.0 // indirect |
39 | github.com/sourcegraph/conc v0.3.0 // indirect | 41 | github.com/sourcegraph/conc v0.3.0 // indirect |
@@ -53,4 +55,8 @@ require ( | |||
53 | google.golang.org/protobuf v1.32.0 // indirect | 55 | google.golang.org/protobuf v1.32.0 // indirect |
54 | gopkg.in/ini.v1 v1.67.0 // indirect | 56 | gopkg.in/ini.v1 v1.67.0 // indirect |
55 | gopkg.in/yaml.v3 v3.0.1 // indirect | 57 | gopkg.in/yaml.v3 v3.0.1 // indirect |
58 | modernc.org/libc v1.37.6 // indirect | ||
59 | modernc.org/mathutil v1.6.0 // indirect | ||
60 | modernc.org/memory v1.7.2 // indirect | ||
61 | modernc.org/sqlite v1.28.0 // indirect | ||
56 | ) | 62 | ) |
@@ -13,6 +13,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs | |||
13 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 13 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
14 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= | 14 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= |
15 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 15 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
16 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | ||
17 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | ||
16 | github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= | 18 | github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= |
17 | github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= | 19 | github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= |
18 | github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= | 20 | github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= |
@@ -22,6 +24,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE | |||
22 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= | 24 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= |
23 | github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= | 25 | github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= |
24 | github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= | 26 | github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= |
27 | github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= | ||
28 | github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= | ||
25 | github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= | 29 | github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= |
26 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= | 30 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= |
27 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= | 31 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= |
@@ -33,6 +37,7 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= | |||
33 | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= | 37 | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= |
34 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | 38 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |
35 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | 39 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
40 | github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= | ||
36 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | 41 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= |
37 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 42 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
38 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= | 43 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= |
@@ -51,8 +56,6 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V | |||
51 | github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= | 56 | github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= |
52 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= | 57 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
53 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= | 58 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
54 | github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= | ||
55 | github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= | ||
56 | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= | 59 | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= |
57 | github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= | 60 | github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= |
58 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | 61 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
@@ -65,6 +68,8 @@ github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdU | |||
65 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | 68 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
66 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= | 69 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= |
67 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | 70 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
71 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= | ||
72 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | ||
68 | github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= | 73 | github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= |
69 | github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= | 74 | github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= |
70 | github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= | 75 | github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= |
@@ -124,5 +129,13 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= | |||
124 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | 129 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
125 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | 130 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
126 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | 131 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
132 | modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw= | ||
133 | modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= | ||
134 | modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= | ||
135 | modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= | ||
136 | modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= | ||
137 | modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= | ||
138 | modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= | ||
139 | modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= | ||
127 | nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= | 140 | nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= |
128 | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= | 141 | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= |
diff --git a/api/internal/controllers/auth.go b/api/internal/controllers/auth.go index b06c6ef..2599550 100644 --- a/api/internal/controllers/auth.go +++ b/api/internal/controllers/auth.go | |||
@@ -12,7 +12,7 @@ import ( | |||
12 | 12 | ||
13 | "water/api/internal/database" | 13 | "water/api/internal/database" |
14 | 14 | ||
15 | _ "github.com/mattn/go-sqlite3" | 15 | _ "github.com/glebarez/go-sqlite" |
16 | "golang.org/x/crypto/bcrypt" | 16 | "golang.org/x/crypto/bcrypt" |
17 | ) | 17 | ) |
18 | 18 | ||
diff --git a/api/internal/database/database.go b/api/internal/database/database.go index 1bfb789..8a54e4a 100644 --- a/api/internal/database/database.go +++ b/api/internal/database/database.go | |||
@@ -6,7 +6,7 @@ import ( | |||
6 | "path/filepath" | 6 | "path/filepath" |
7 | "water/api/internal/config" | 7 | "water/api/internal/config" |
8 | 8 | ||
9 | _ "github.com/mattn/go-sqlite3" | 9 | _ "github.com/glebarez/go-sqlite" |
10 | ) | 10 | ) |
11 | 11 | ||
12 | func EstablishDBConnection() (*sql.DB, error) { | 12 | func EstablishDBConnection() (*sql.DB, error) { |
diff --git a/db/sql/views.sql b/db/sql/views.sql index c56286d..3ca2cf9 100644 --- a/db/sql/views.sql +++ b/db/sql/views.sql | |||
@@ -4,7 +4,7 @@ CREATE VIEW IF NOT EXISTS aggregated_stats AS | |||
4 | CREATE VIEW IF NOT EXISTS `DailyUserStatistics` AS | 4 | CREATE VIEW IF NOT EXISTS `DailyUserStatistics` AS |
5 | SELECT users.name, IFNULL(SUM(statistics.quantity), 0) as total, preferences.color as color | 5 | SELECT users.name, IFNULL(SUM(statistics.quantity), 0) as total, preferences.color as color |
6 | FROM users | 6 | FROM users |
7 | LEFT JOIN statistics ON users.id = statistics.user_id AND DATE(statistics.date) = DATE('now', '-1 day') | 7 | LEFT JOIN statistics ON users.id = statistics.user_id AND DATE(statistics.date) = DATE('now') |
8 | LEFT JOIN preferences ON users.id = preferences.user_id | 8 | LEFT JOIN preferences ON users.id = preferences.user_id |
9 | GROUP BY users.name; | 9 | GROUP BY users.name; |
10 | 10 | ||
@@ -12,11 +12,11 @@ GROUP BY users.name; | |||
12 | CREATE VIEW IF NOT EXISTS `WeeklyStatisticsView` AS | 12 | CREATE VIEW IF NOT EXISTS `WeeklyStatisticsView` AS |
13 | WITH DateSequence(Dates) AS | 13 | WITH DateSequence(Dates) AS |
14 | ( | 14 | ( |
15 | SELECT Date(CURRENT_DATE, '-7 day') | 15 | SELECT Date(CURRENT_DATE, '-6 day') |
16 | UNION ALL | 16 | UNION ALL |
17 | SELECT Date(Dates, '+1 day') | 17 | SELECT Date(Dates, '+1 day') |
18 | FROM DateSequence | 18 | FROM DateSequence |
19 | WHERE Date(Dates, '+1 day') < Date(CURRENT_DATE) | 19 | WHERE Date(Dates, '+1 day') <= Date(CURRENT_DATE) |
20 | ) | 20 | ) |
21 | SELECT DateSequence.Dates as 'date', | 21 | SELECT DateSequence.Dates as 'date', |
22 | IFNULL(SUM(statistics.quantity), 0) AS 'total' | 22 | IFNULL(SUM(statistics.quantity), 0) AS 'total' |
diff --git a/fe/src/App.svelte b/fe/src/App.svelte index 25d53dc..11eb217 100644 --- a/fe/src/App.svelte +++ b/fe/src/App.svelte | |||
@@ -1,6 +1,6 @@ | |||
1 | <script lang="ts"> | 1 | <script lang="ts"> |
2 | import Layout from "./lib/Layout.svelte"; | 2 | import Layout from "./lib/Layout.svelte"; |
3 | import LoginForm from "./lib/LoginForm.svelte"; | 3 | import { LoginForm } from './lib/forms'; |
4 | import DataView from "./lib/DataView.svelte"; | 4 | import DataView from "./lib/DataView.svelte"; |
5 | import { authenticated } from "./stores/auth"; | 5 | import { authenticated } from "./stores/auth"; |
6 | </script> | 6 | </script> |
diff --git a/fe/src/app.css b/fe/src/app.css index c24c713..be7d15c 100644 --- a/fe/src/app.css +++ b/fe/src/app.css | |||
@@ -5,48 +5,34 @@ | |||
5 | 5 | ||
6 | color-scheme: light dark; | 6 | color-scheme: light dark; |
7 | color: rgba(255, 255, 255, 0.87); | 7 | color: rgba(255, 255, 255, 0.87); |
8 | background-color: #242424; | 8 | background-color: var(--background); |
9 | width: 100vw; | ||
9 | 10 | ||
10 | font-synthesis: none; | 11 | font-synthesis: none; |
11 | text-rendering: optimizeLegibility; | 12 | text-rendering: optimizeLegibility; |
12 | -webkit-font-smoothing: antialiased; | 13 | -webkit-font-smoothing: antialiased; |
13 | -moz-osx-font-smoothing: grayscale; | 14 | -moz-osx-font-smoothing: grayscale; |
14 | 15 | ||
15 | --submit: #28a745; | 16 | --background: #242424; |
16 | } | 17 | } |
17 | 18 | ||
18 | a { | 19 | @media (min-width: 916px) { |
19 | font-weight: 500; | 20 | :root { |
20 | color: #646cff; | 21 | width: unset; |
21 | text-decoration: inherit; | 22 | } |
22 | } | ||
23 | 23 | ||
24 | a:hover { | 24 | #content div.column:first-child { |
25 | color: #535bf2; | 25 | flex-direction: row; |
26 | height: 300px; | ||
27 | } | ||
26 | } | 28 | } |
27 | 29 | ||
28 | body { | 30 | body { |
29 | margin: 0; | 31 | margin: 0; |
30 | display: flex; | 32 | padding: 0 2em 2em; |
31 | place-items: center; | ||
32 | min-width: 320px; | ||
33 | min-height: 100vh; | ||
34 | } | 33 | } |
35 | 34 | ||
36 | h1 { | ||
37 | font-size: 3.2em; | ||
38 | line-height: 1.1; | ||
39 | } | ||
40 | 35 | ||
41 | .card { | ||
42 | padding: 2em; | ||
43 | } | ||
44 | |||
45 | #app { | ||
46 | flex-grow: 2; | ||
47 | max-width: 1280px; | ||
48 | margin: 0 auto; | ||
49 | } | ||
50 | 36 | ||
51 | button { | 37 | button { |
52 | border-radius: 8px; | 38 | border-radius: 8px; |
@@ -56,6 +42,7 @@ button { | |||
56 | font-weight: 500; | 42 | font-weight: 500; |
57 | font-family: inherit; | 43 | font-family: inherit; |
58 | background-color: #1a1a1a; | 44 | background-color: #1a1a1a; |
45 | color: inherit; | ||
59 | cursor: pointer; | 46 | cursor: pointer; |
60 | transition: border-color 0.25s; | 47 | transition: border-color 0.25s; |
61 | } | 48 | } |
@@ -64,10 +51,6 @@ button:hover { | |||
64 | border-color: #646cff; | 51 | border-color: #646cff; |
65 | } | 52 | } |
66 | 53 | ||
67 | button:focus, | ||
68 | button:focus-visible { | ||
69 | outline: 4px auto -webkit-focus-ring-color; | ||
70 | } | ||
71 | 54 | ||
72 | @media (prefers-color-scheme: light) { | 55 | @media (prefers-color-scheme: light) { |
73 | :root { | 56 | :root { |
@@ -84,12 +67,6 @@ button:focus-visible { | |||
84 | } | 67 | } |
85 | } | 68 | } |
86 | 69 | ||
87 | @media (prefers-color-scheme: dark) { | ||
88 | :root { | ||
89 | color: #000; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | .form { | 70 | .form { |
94 | display: flex; | 71 | display: flex; |
95 | flex-direction: column; | 72 | flex-direction: column; |
@@ -118,3 +95,7 @@ button:focus-visible { | |||
118 | background: var(--submit); | 95 | background: var(--submit); |
119 | color: #fff; | 96 | color: #fff; |
120 | } | 97 | } |
98 | |||
99 | dialog { | ||
100 | top: 8em; | ||
101 | } | ||
diff --git a/fe/src/lib/Card.svelte b/fe/src/lib/Card.svelte index cd1e02c..0f29279 100644 --- a/fe/src/lib/Card.svelte +++ b/fe/src/lib/Card.svelte | |||
@@ -11,13 +11,12 @@ | |||
11 | 11 | ||
12 | <style> | 12 | <style> |
13 | .card { | 13 | .card { |
14 | background: #fff; | ||
15 | display: flex; | 14 | display: flex; |
16 | flex-direction: column; | 15 | flex-direction: column; |
17 | align-items: flex-start; | 16 | align-items: flex-start; |
18 | border: solid 2px #00000066; | 17 | border: solid 2px #00000066; |
19 | border-radius: 0.25em; | 18 | border-radius: 0.25em; |
20 | height: var(--height, fit-content); | 19 | height: var(--height, inherit); |
21 | overflow-y: var(--overflow, initial); | 20 | flex-grow: 2; |
22 | } | 21 | } |
23 | </style> | 22 | </style> |
diff --git a/fe/src/lib/Column.svelte b/fe/src/lib/Column.svelte index f036073..6902edf 100644 --- a/fe/src/lib/Column.svelte +++ b/fe/src/lib/Column.svelte | |||
@@ -7,7 +7,13 @@ | |||
7 | display: flex; | 7 | display: flex; |
8 | flex-direction: column; | 8 | flex-direction: column; |
9 | height: 100%; | 9 | height: 100%; |
10 | gap: var(--gap, 32px); | 10 | gap: var(--gap, 2em); |
11 | width: var(--width, initial); | 11 | width: var(--width, initial); |
12 | } | 12 | } |
13 | |||
14 | @media (min-width: 916px) { | ||
15 | .column { | ||
16 | flex-direction: column; | ||
17 | } | ||
18 | } | ||
13 | </style> \ No newline at end of file | 19 | </style> \ No newline at end of file |
diff --git a/fe/src/lib/DataView.svelte b/fe/src/lib/DataView.svelte index ffc2fe8..1496239 100644 --- a/fe/src/lib/DataView.svelte +++ b/fe/src/lib/DataView.svelte | |||
@@ -205,12 +205,11 @@ | |||
205 | }); | 205 | }); |
206 | </script> | 206 | </script> |
207 | 207 | ||
208 | <Column --width="500px"> | 208 | <Column> |
209 | <Card --height="300px"> | 209 | <Card> |
210 | <!--<Chart />--> | ||
211 | <canvas bind:this={barCanvasRef} /> | 210 | <canvas bind:this={barCanvasRef} /> |
212 | </Card> | 211 | </Card> |
213 | <Card --height="300px"> | 212 | <Card> |
214 | <canvas bind:this={lineCanvasRef} /> | 213 | <canvas bind:this={lineCanvasRef} /> |
215 | </Card> | 214 | </Card> |
216 | </Column> | 215 | </Column> |
@@ -225,4 +224,3 @@ | |||
225 | {/await} | 224 | {/await} |
226 | </Card> | 225 | </Card> |
227 | </Column> | 226 | </Column> |
228 | <!-- <Chart /> --> | ||
diff --git a/fe/src/lib/Layout.svelte b/fe/src/lib/Layout.svelte index 2728dd3..26630d2 100644 --- a/fe/src/lib/Layout.svelte +++ b/fe/src/lib/Layout.svelte | |||
@@ -1,6 +1,6 @@ | |||
1 | <script> | 1 | <script> |
2 | import { authenticated, token, user, preferences } from "../stores/auth"; | 2 | import { authenticated, token, user, preferences } from "../stores/auth"; |
3 | import PreferencesForm from "./PreferencesForm.svelte"; | 3 | import { PreferencesForm, AddForm } from "./forms"; |
4 | import { addFormOpen } from "../stores/forms"; | 4 | import { addFormOpen } from "../stores/forms"; |
5 | 5 | ||
6 | const logout = () => { | 6 | const logout = () => { |
@@ -30,9 +30,18 @@ | |||
30 | <h1>Water</h1> | 30 | <h1>Water</h1> |
31 | </div> | 31 | </div> |
32 | <div> | 32 | <div> |
33 | <button on:click={showAddDialog}>Log Water</button> | 33 | <button on:click={showAddDialog}> |
34 | <button on:click={showPreferencesDialog}>Preference</button> | 34 | <span class="btn-icon">âž•</span> |
35 | <button on:click={logout}>Logout</button> | 35 | <span class="btn-content">Log Water</span> |
36 | </button> | ||
37 | <button on:click={showPreferencesDialog}> | ||
38 | <span class="btn-icon">âš™</span> | ||
39 | <span class="btn-content">Preference</span> | ||
40 | </button> | ||
41 | <button on:click={logout}> | ||
42 | <span class="btn-icon">🔒</span> | ||
43 | <span class="btn-content">Logout</span> | ||
44 | </button> | ||
36 | </div> | 45 | </div> |
37 | </nav> | 46 | </nav> |
38 | <PreferencesForm open={preferenceFormOpen} on:close={closePreferenceDialog} /> | 47 | <PreferencesForm open={preferenceFormOpen} on:close={closePreferenceDialog} /> |
@@ -43,17 +52,30 @@ | |||
43 | </div> | 52 | </div> |
44 | 53 | ||
45 | <style> | 54 | <style> |
46 | .layout { | ||
47 | height: 100vh; | ||
48 | } | ||
49 | |||
50 | nav { | 55 | nav { |
51 | display: flex; | 56 | display: flex; |
52 | flex-direction: row; | 57 | flex-direction: row; |
53 | align-items: center; | 58 | align-items: center; |
54 | justify-content: space-between; | 59 | justify-content: space-between; |
55 | height: 64px; | 60 | height: 64px; |
56 | padding: 0 2em; | 61 | padding: 1em 0; |
62 | } | ||
63 | |||
64 | nav div button { | ||
65 | margin: 0 .5em; | ||
66 | } | ||
67 | |||
68 | nav div button:first-child { | ||
69 | margin-left: 0; | ||
70 | } | ||
71 | |||
72 | nav div button:last-child { | ||
73 | margin-right: 0; | ||
74 | } | ||
75 | |||
76 | |||
77 | nav .btn-content { | ||
78 | display: none; | ||
57 | } | 79 | } |
58 | 80 | ||
59 | nav div { | 81 | nav div { |
@@ -66,9 +88,16 @@ | |||
66 | 88 | ||
67 | #content { | 89 | #content { |
68 | display: flex; | 90 | display: flex; |
69 | flex-direction: row; | 91 | flex-direction: column; |
70 | justify-content: center; | 92 | justify-content: center; |
71 | gap: 2em; | 93 | gap: 2em; |
72 | margin-top: 4em; | 94 | margin-top: 1em; |
95 | } | ||
96 | |||
97 | @media (min-width: 916px) { | ||
98 | nav .btn-content { | ||
99 | display: inline; | ||
100 | margin-left: 1em; | ||
101 | } | ||
73 | } | 102 | } |
74 | </style> | 103 | </style> |
diff --git a/fe/src/lib/Table.svelte b/fe/src/lib/Table.svelte index 621157e..3ce3331 100644 --- a/fe/src/lib/Table.svelte +++ b/fe/src/lib/Table.svelte | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | export let sortBy: string = 'date'; | 8 | export let sortBy: string = 'date'; |
9 | 9 | ||
10 | type SortComparator = (a, b) => number | 10 | type SortComparator = (a:any , b:any) => number |
11 | 11 | ||
12 | function getDataKeys(data: any[]): string[] { | 12 | function getDataKeys(data: any[]): string[] { |
13 | if (!data || data.length === 0) return []; | 13 | if (!data || data.length === 0) return []; |
@@ -20,7 +20,7 @@ | |||
20 | return Object.entries(row).filter((r) => !omit.includes(r[0])); | 20 | return Object.entries(row).filter((r) => !omit.includes(r[0])); |
21 | } | 21 | } |
22 | 22 | ||
23 | function sort(arr: Array<Record<string, any>>, fn: SortComparator = (a , b) => new Date(b[sortBy]) - new Date(a[sortBy])) { | 23 | function sort(arr: Array<Record<string, any>>, fn: SortComparator = (a , b) => Date.parse(b[sortBy]) - Date.parse(a[sortBy])) { |
24 | return arr.sort(fn) | 24 | return arr.sort(fn) |
25 | } | 25 | } |
26 | 26 | ||
@@ -92,10 +92,7 @@ | |||
92 | border: solid 1px black; | 92 | border: solid 1px black; |
93 | border-collapse: collapse; | 93 | border-collapse: collapse; |
94 | overflow-y: hidden; | 94 | overflow-y: hidden; |
95 | } | 95 | width: calc(100% - 16px); |
96 | |||
97 | th { | ||
98 | text-transform: capitalize; | ||
99 | } | 96 | } |
100 | 97 | ||
101 | thead tr { | 98 | thead tr { |
@@ -108,6 +105,7 @@ | |||
108 | 105 | ||
109 | th, | 106 | th, |
110 | td { | 107 | td { |
108 | text-transform: capitalize; | ||
111 | padding: 1em; | 109 | padding: 1em; |
112 | border: 1px solid rgba(0, 0, 0, 1); | 110 | border: 1px solid rgba(0, 0, 0, 1); |
113 | } | 111 | } |
diff --git a/fe/src/lib/forms/AddForm.svelte b/fe/src/lib/forms/AddForm.svelte index f85cce6..bbc8356 100644 --- a/fe/src/lib/forms/AddForm.svelte +++ b/fe/src/lib/forms/AddForm.svelte | |||
@@ -11,21 +11,10 @@ | |||
11 | const statistic: Statistic = newStatistic(); | 11 | const statistic: Statistic = newStatistic(); |
12 | 12 | ||
13 | function newStatistic(): Statistic { | 13 | function newStatistic(): Statistic { |
14 | let now = new Date(), | 14 | let date = new Date().toString(); |
15 | month, | ||
16 | day, | ||
17 | year; | ||
18 | |||
19 | month = `${now.getMonth() + 1}`; | ||
20 | day = `${now.getDate()}`; | ||
21 | year = now.getFullYear(); | ||
22 | if (month.length < 2) month = "0" + month; | ||
23 | if (day.length < 2) day = "0" + day; | ||
24 | |||
25 | const date = [year, month, day].join("-"); | ||
26 | 15 | ||
27 | return { | 16 | return { |
28 | user_id: $user!.uuid, | 17 | user_id: $user!.id, |
29 | date, | 18 | date, |
30 | quantity: 1 | 19 | quantity: 1 |
31 | }; | 20 | }; |
@@ -37,7 +26,7 @@ | |||
37 | 26 | ||
38 | async function handleSubmitStat() | 27 | async function handleSubmitStat() |
39 | { | 28 | { |
40 | const { date, quantity } = statistic; | 29 | const { user_id, date, quantity } = statistic; |
41 | await fetch(apiURL("stats"), { | 30 | await fetch(apiURL("stats"), { |
42 | method: "POST", | 31 | method: "POST", |
43 | headers: { | 32 | headers: { |
@@ -45,7 +34,7 @@ | |||
45 | }, | 34 | }, |
46 | body: JSON.stringify({ | 35 | body: JSON.stringify({ |
47 | date: new Date(date), | 36 | date: new Date(date), |
48 | user_id: 2, | 37 | user_id, |
49 | quantity | 38 | quantity |
50 | }) | 39 | }) |
51 | }); | 40 | }); |
@@ -54,12 +43,12 @@ | |||
54 | 43 | ||
55 | </script> | 44 | </script> |
56 | 45 | ||
57 | <dialog {open} on:submit={handleSubmitStat}> | 46 | <dialog id="addForm" {open} on:submit={handleSubmitStat}> |
58 | <h2>Add Water</h2> | 47 | <h2>Add Water</h2> |
59 | <form method="dialog"> | 48 | <form method="dialog"> |
60 | <div class="form input group"> | 49 | <div class="form input group"> |
61 | <label for="date">Date:</label> | 50 | <label for="date">Date:</label> |
62 | <input bind:value={statistic.date} id="date" name="date" type="date" /> | 51 | <input bind:value={statistic.date} id="date" name="date" type="datetime-local" /> |
63 | </div> | 52 | </div> |
64 | <div class="form input group"> | 53 | <div class="form input group"> |
65 | <label for="quantity">Quantity:</label> | 54 | <label for="quantity">Quantity:</label> |
@@ -75,4 +64,4 @@ | |||
75 | <button on:click={closeDialog}>Cancel</button> | 64 | <button on:click={closeDialog}>Cancel</button> |
76 | <button type="submit">Submit</button> | 65 | <button type="submit">Submit</button> |
77 | </form> | 66 | </form> |
78 | </dialog> \ No newline at end of file | 67 | </dialog> |
diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/forms/LoginForm.svelte index cf5febf..88d4479 100644 --- a/fe/src/lib/LoginForm.svelte +++ b/fe/src/lib/forms/LoginForm.svelte | |||
@@ -1,7 +1,7 @@ | |||
1 | <script lang="ts"> | 1 | <script lang="ts"> |
2 | import { token, user, preferences } from "../stores/auth"; | 2 | import { token, user, preferences } from "../../stores/auth"; |
3 | import Card from "./Card.svelte"; | 3 | import Card from "../Card.svelte"; |
4 | import { apiURL } from "../utils"; | 4 | import { apiURL } from "../../utils"; |
5 | 5 | ||
6 | let credentials: CredentialObject = { | 6 | let credentials: CredentialObject = { |
7 | username: "", | 7 | username: "", |
diff --git a/fe/src/lib/PreferencesForm.svelte b/fe/src/lib/forms/PreferencesForm.svelte index 74b8a63..79663d1 100644 --- a/fe/src/lib/PreferencesForm.svelte +++ b/fe/src/lib/forms/PreferencesForm.svelte | |||
@@ -1,8 +1,8 @@ | |||
1 | <script lang="ts"> | 1 | <script lang="ts"> |
2 | import { user, preferences, token } from "../stores/auth"; | 2 | import { user, preferences, token } from "../../stores/auth"; |
3 | import { createEventDispatcher, onDestroy, onMount } from "svelte"; | 3 | import { createEventDispatcher, onDestroy, onMount } from "svelte"; |
4 | import type { User } from "../types"; | 4 | import type { User } from "../../types"; |
5 | import { apiURL } from "../utils"; | 5 | import { apiURL } from "../../utils"; |
6 | 6 | ||
7 | export let open: boolean; | 7 | export let open: boolean; |
8 | 8 | ||
@@ -107,7 +107,7 @@ | |||
107 | </dialog> | 107 | </dialog> |
108 | 108 | ||
109 | <style> | 109 | <style> |
110 | dialog { | 110 | /* dialog { |
111 | background: white; | 111 | background: white; |
112 | color: black; | 112 | color: black; |
113 | } | 113 | } |
@@ -115,5 +115,5 @@ | |||
115 | input[type="color"] { | 115 | input[type="color"] { |
116 | width: 4em; | 116 | width: 4em; |
117 | height: 4em; | 117 | height: 4em; |
118 | } | 118 | } */ |
119 | </style> | 119 | </style> |
diff --git a/fe/src/lib/forms/index.ts b/fe/src/lib/forms/index.ts new file mode 100644 index 0000000..ac4e63b --- /dev/null +++ b/fe/src/lib/forms/index.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import AddForm from "./AddForm.svelte"; | ||
2 | import LoginForm from "./LoginForm.svelte"; | ||
3 | import PreferencesForm from "./PreferencesForm.svelte"; | ||
4 | |||
5 | |||
6 | export { | ||
7 | AddForm, | ||
8 | LoginForm, | ||
9 | PreferencesForm | ||
10 | }; \ No newline at end of file | ||
diff --git a/fe/src/types.ts b/fe/src/types.ts index c8f2f00..e06e789 100644 --- a/fe/src/types.ts +++ b/fe/src/types.ts | |||
@@ -19,7 +19,7 @@ export interface User { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | export interface Statistic { | 21 | export interface Statistic { |
22 | user_id: string; | 22 | user_id: number; |
23 | date: string; | 23 | date: string; |
24 | quantity: number; | 24 | quantity: number; |
25 | } | 25 | } |