diff --git a/buildAndUpdateProd.sh b/buildAndUpdateProd.sh deleted file mode 100755 index cc773c2..0000000 --- a/buildAndUpdateProd.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - - -# -# Push built release files to production server -# - -echo -e "\e[32m\nStarting Build. \n\e[0m" - -# Build out new release -cd client -npm run build -cd .. - -# only compress client/dist and server with node_modules -echo -e "\e[32m\nCompressing client and server code... \n\e[0m" -tar -czf release.tar.gz server node_modules client/dist staticFiles/assets - -#send compressed release to remote machine -echo -e "\e[32m\nMoving compressed release to production... \n\e[0m" -rsync -e 'ssh -p 13328' -havzC --update release.tar.gz mab@45.79.41.75:/home/mab/pi/ - -# Remove Release from local after its been uploaded -rm release.tar.gz - -#uncompress release on server -echo -e "\e[32m\nExtracting release on production... \n\e[0m" -ssh mab@45.79.41.75 -p 13328 "cd /home/mab/pi/; rm -r server node_modules client; tar -xzf *.tar.gz --overwrite; rm *.tar.gz; pm2 reload all" - -#Congratulate how awesome you are -echo -e "\e[32m\nRelease Complete! Nice Work! \n\e[0m" \ No newline at end of file diff --git a/client/.gitignore b/client/.gitignore index 078b834..9769e79 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1,26 +1,28 @@ -.DS_Store -node_modules -/dist - - -# local env files -.env.local -.env.*.local -*.pem -*.crt -*.key - -# Log files +# Logs +logs +*.log npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local # Editor directories and files +.vscode/* +!.vscode/extensions.json .idea -.vscode +.DS_Store *.suo *.ntvs* *.njsproj *.sln *.sw? + +# Local dev TLS certs (mkcert) +*.pem +certs/ diff --git a/v2client-vite-vue3/.vscode/extensions.json b/client/.vscode/extensions.json similarity index 100% rename from v2client-vite-vue3/.vscode/extensions.json rename to client/.vscode/extensions.json diff --git a/client/README.md b/client/README.md index 2dae4fc..1511959 100644 --- a/client/README.md +++ b/client/README.md @@ -1,19 +1,5 @@ -# client +# Vue 3 + Vite -## Project setup -``` -npm install -``` +This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` \ No newline at end of file diff --git a/client/src/components/Metrictracking/PillCalendarGraph.vue b/client/src/components/Metrictracking/PillCalendarGraph.vue index a18aa17..0d4c46e 100644 --- a/client/src/components/Metrictracking/PillCalendarGraph.vue +++ b/client/src/components/Metrictracking/PillCalendarGraph.vue @@ -81,6 +81,13 @@ } + .days-since { + padding: 0.75em 0.5em 0.25em 0.5em; + font-size: 0.95em; + } + .days-since-row { + padding: 0.15em 0; + } .pill-container { width: 100%; } @@ -229,36 +236,47 @@ - + + +
+
+ + Days Since {{ entry.label }} - no entries yet + Days Since {{ entry.label }} - {{ entry.days }} {{ entry.days === 1 ? 'day' : 'days' }}. +
+
@@ -269,6 +287,7 @@ // let chartData = {} export default { + inject: ['getFieldColor', 'getFieldIcon', 'getFieldLabel'], props: [ 'graph', // options associated with this graph 'userFields', // all field attributes @@ -309,6 +328,53 @@ this.setupCalendar(new Date()) }, computed: { + // "Days Since - days" for every field on this graph. + // Counts a day as recorded only if it passes the same + // showZeroValuesCheck the pills use, so the "Show/Hide Lowest Value" + // toggle moves these numbers too. + daysSince(){ + + // showZeroValuesCheck reads lowestGraphValue, which getChartData + // assigns as a side effect -- touch it so the threshold is current + // and so this recomputes whenever the chart data does. + void this.getChartData + + const dayMs = 86400000 + const midnight = (time) => { + const date = new Date(time) + date.setHours(0, 0, 0, 0) + return date.getTime() + } + const today = midnight(Date.now()) + + return (this.graph?.fieldIds || []).map(fieldId => { + + let latest = null + + Object.keys(this.cycleData || {}).forEach(dateCode => { + + const value = this.cycleData[dateCode]?.[fieldId] + if(value === undefined || value === null || value === ''){ return } + + // honour the Lowest Value toggle + if(!this.showZeroValuesCheck(value, fieldId)){ return } + + const time = this.dateCodeToTime(dateCode) + // ignore unparseable codes and anything dated ahead of today + if(time === null || time > today){ return } + + if(latest === null || time > latest){ latest = time } + }) + + return { + fieldId, + label: this.getFieldLabel(fieldId), + icon: this.getFieldIcon(fieldId), + color: this.getFieldColor(fieldId), + days: latest === null ? null : Math.round((today - latest) / dayMs), + } + }) + }, getChartData(){ let chartData = {} @@ -389,11 +455,26 @@ }, }, methods: { + // Date codes are stored unpadded as D.M.YYYY + dateCodeToTime(dateCode){ + + const parts = String(dateCode).split('.').map(Number) + if(parts.length !== 3 || parts.some(isNaN)){ return null } + + const [day, month, year] = parts + const date = new Date(year, month - 1, day) + date.setHours(0, 0, 0, 0) + + return isNaN(date.getTime()) ? null : date.getTime() + }, showZeroValuesCheck(dayValue, fieldId){ + // Optional chaining: a graph can reference a default field (BT, + // CM, ...) that was never customised, so it has no userFields + // entry and the bare lookup threw. // if graph type is boolean or there are two options - let isBooleanField = this.userFields[fieldId].type == 'boolean' - if(this.userFields[fieldId].customOptions){ + let isBooleanField = this.userFields[fieldId]?.type == 'boolean' + if(this.userFields[fieldId]?.customOptions){ let options = this.userFields[fieldId].customOptions isBooleanField = options.split(',').length == 2 @@ -411,6 +492,13 @@ } + // lowestGraphValue comes from Math.min of the charted values, so + // it is Infinity when the window holds no data -- without the + // finite guard nothing would ever clear the threshold. + if(!isFinite(this.lowestGraphValue)){ + return true + } + return this.showZeroValues || dayValue > this.lowestGraphValue }, getDayValue(fieldId, value){ diff --git a/client/src/components/NoteInputPanel.vue b/client/src/components/NoteInputPanel.vue index 1cb9210..89d162e 100644 --- a/client/src/components/NoteInputPanel.vue +++ b/client/src/components/NoteInputPanel.vue @@ -62,7 +62,7 @@