Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/health-dashboard.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import{d as ee,l as ae,o as n,c as u,a as h,b as i,w as p,E as R,u as t,t as r,N as w,i as T,e as g,f as C,_ as le,g as te,h as re,j as c,F as D,r as M,M as $,k as A,m as ne,n as se,p as ie,q as ue,s as oe,R as W,v as d,x as U,y as O,z as ce,A as he,B as de,D as ve,C as _,G as I,H as me,I as j,J as ye,K as be,L as G,O as pe,P as ge,Q as _e,S as ke,T as fe,U as Ke,V as we,W as Ce}from"./style-Dzc4b7jM.chunk.mjs";const De=["aria-busy"],Me=["aria-label"],$e={key:1,class:"health-dashboard__message"},Ae={key:2,class:"health-dashboard__summary"},Ie={key:1,class:"health-dashboard__value"},Se={class:"health-dashboard__value"},Ve={class:"health-dashboard__value"},Be={class:"health-dashboard__bmi-value health-dashboard__value"},xe={key:0,class:"health-dashboard__message"},ze=ee({__name:"HealthDashboardWidget",setup(S){const k=new Date,V=ae(k),o=d(null),y=d([]),f=d([]),K=d([]),B=d(!0),x=d(!1),b=d(0),z=d(!1),H=d(!1),q=U(()=>O(o.value,ce).flatMap(l=>{const a=y.value.filter(s=>s.metricKey===l);if(a.length===0)return[];const e=he(l)?a.reduce((s,m)=>s+(m.numericValue??0),0)/a.length:null;return[{metricKey:l,count:a.length,average:e}]})),N=U(()=>O(o.value,de).flatMap(l=>{const a=f.value.filter(s=>s.metricKey===l);if(a.length===0)return[];if(o.value?.metrics[l]?.aggregation==="sum")return[{metricKey:l,total:a.reduce((s,m)=>s+(m.numericValue??0),0)}];const e=a.sort((s,m)=>new Date(m.recordedAt).getTime()-new Date(s.recordedAt).getTime())[0];return[{metricKey:l,measurement:e}]})),L=U(()=>O(o.value,ve).flatMap(l=>{const a=K.value.find(e=>e.metricKey===l);return a===void 0?[]:[{metricKey:l,value:a}]}));function E(l){return o.value?.metrics[l]?.displayUnit??Ke(l)[0]}function v(l){return l.toLocaleString(void 0,{maximumFractionDigits:2})}function J(l){const a=E(l.metricKey);return l.values!==null?`${v(_("blood_pressure",l.values.systolic,a))} / ${v(_("blood_pressure",l.values.diastolic,a))} ${I(a)}`:`${v(_(l.metricKey,l.numericValue??0,a))} ${I(a)}`}function Q(l,a){const e=E(l);return`${v(_(l,a,e))} ${I(e)}`}function X(l,a){const e=E(l),s=v(_(l,a.numericValue,e));return me(l)?`${s} ${I(e)}`:s}function Y(l){y.value=[...l.createdEntries,...y.value],f.value=[...l.createdMeasurements,...f.value];for(const a of l.updatedDailyValues)K.value=[...K.value.filter(e=>e.metricKey!==a.metricKey),a]}function P(l,a){Y(l),j(a==="check-in"?r("health","Check-in saved."):r("health","Check-out saved."))}async function F(l,a){b.value++;try{const e=await ye({metricKey:l,numericValue:null,optionValue:a,context:"manual",source:"web",recordedAt:new Date().toISOString(),note:null});y.value=[e,...y.value],j(r("health","{entry} recorded.",{entry:be(l,a)}))}catch{G(r("health","Entry could not be recorded."))}finally{b.value--}}async function Z(){B.value=!0,x.value=!1;try{const l=pe(k),[a,e,s,m]=await Promise.all([ge(),_e({...l,limit:200}),ke(V),fe(l.from,l.to)]);o.value=a,y.value=e,K.value=s,f.value=m}catch{x.value=!0,G(r("health","Health summary could not be loaded."))}finally{B.value=!1}}return Z(),(l,a)=>(n(),u("section",{"aria-busy":b.value>0,class:"health-dashboard"},[h("div",{"aria-label":t(r)("health","Health actions"),class:"health-dashboard__actions",role:"group"},[i(t(w),{"aria-label":t(r)("health","Check-in"),title:t(r)("health","Check-in"),variant:"primary",onClick:a[0]||(a[0]=e=>z.value=!0)},{icon:p(()=>[i(R,{symbol:"🌅",size:"button"})]),_:1},8,["aria-label","title"]),i(t(w),{"aria-label":t(r)("health","Check-out"),title:t(r)("health","Check-out"),variant:"primary",onClick:a[1]||(a[1]=e=>H.value=!0)},{icon:p(()=>[i(R,{symbol:"🌃",size:"button"})]),_:1},8,["aria-label","title"]),t(T)(o.value,"hydration")?(n(),g(t(w),{key:0,"aria-label":t(r)("health","Record small glass of water"),disabled:b.value>0,title:t(r)("health","Record water"),variant:"secondary",onClick:a[2]||(a[2]=e=>F("hydration","small_glass"))},{icon:p(()=>[i(R,{symbol:"🥛",size:"button"})]),_:1},8,["aria-label","disabled","title"])):C("",!0),t(T)(o.value,"hydration")?(n(),g(le,{key:1,disabled:b.value>0,onSelect:a[3]||(a[3]=e=>F("hydration",e))},null,8,["disabled"])):C("",!0),t(T)(o.value,"break")?(n(),g(te,{key:2,disabled:b.value>0,onSelect:a[4]||(a[4]=e=>F("break",e))},null,8,["disabled"])):C("",!0)],8,Me),B.value?(n(),g(t(re),{key:0,name:t(r)("health","Loading Health summary"),size:28},null,8,["name"])):x.value?(n(),u("p",$e,c(t(r)("health","The summary is temporarily unavailable.")),1)):(n(),u("div",Ae,[(n(!0),u(D,null,M(q.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),e.average!==null?(n(),g(t(se),{key:0,"aria-label":t(r)("health","{metric} average: {value} out of 5",{metric:t(A)(e.metricKey),value:v(e.average)}),color:t(ne)(e.metricKey).color,size:8,value:e.average*20},null,8,["aria-label","color","value"])):(n(),u("span",Ie,c(t(r)("health","{count}×",{count:e.count})),1))]))),128)),(n(!0),u(D,null,M(N.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),h("span",Se,c("total"in e?Q(e.metricKey,e.total):J(e.measurement)),1)]))),128)),(n(!0),u(D,null,M(L.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),h("span",Ve,c(X(e.metricKey,e.value)),1)]))),128)),(n(!0),u(D,null,M(L.value.filter(e=>e.value.bmi!==null),e=>(n(),u("div",{key:`${e.metricKey}-bmi`,class:"health-dashboard__row"},[i($,{"metric-key":"weight"}),h("span",null,c(t(r)("health","BMI")),1),h("span",Be,[h("span",null,c(v(e.value.bmi??0)),1),i(t(oe),{"popup-role":"dialog"},{trigger:p(()=>[i(t(w),{"aria-label":t(r)("health","About the BMI calculation"),title:t(r)("health","About the BMI calculation"),variant:"tertiary"},{icon:p(()=>[i(t(ie),{path:t(ue).information},null,8,["path"])]),_:1},8,["aria-label","title"])]),default:p(()=>[h("p",null,c(t(r)("health","Adult BMI is calculated as weight in kilograms divided by height in metres squared. It is shown as a descriptive value only.")),1)]),_:1})])]))),128)),q.value.length+N.value.length+L.value.length===0?(n(),u("p",xe,c(t(r)("health","Record a value to see today’s Health summary here.")),1)):C("",!0)])),i(W,{open:z.value,"onUpdate:open":a[5]||(a[5]=e=>z.value=e),context:"check-in",configuration:o.value,date:t(V),onSaved:a[6]||(a[6]=e=>P(e,"check-in"))},null,8,["open","configuration","date"]),i(W,{open:H.value,"onUpdate:open":a[7]||(a[7]=e=>H.value=e),context:"check-out",configuration:o.value,date:t(V),onSaved:a[8]||(a[8]=e=>P(e,"check-out"))},null,8,["open","configuration","date"])],8,De))}}),He=we(ze,[["__scopeId","data-v-d38c59cd"]]);function Le(){const S=window.OCA?.Dashboard;S!==void 0&&S.register("health",k=>{Ce(He).mount(k)})}document.addEventListener("DOMContentLoaded",Le);
import{d as ee,l as ae,o as n,c as u,a as h,b as i,w as p,E as R,u as t,t as r,N as w,i as T,e as g,f as C,_ as le,g as te,h as re,j as c,F as D,r as M,M as $,k as A,m as ne,n as se,p as ie,q as ue,s as oe,R as W,v as d,x as U,y as O,z as ce,A as he,B as de,D as ve,C as _,G as I,H as me,I as j,J as ye,K as be,L as G,O as pe,P as ge,Q as _e,S as ke,T as fe,U as Ke,V as we,W as Ce}from"./style-DjXOpZBy.chunk.mjs";const De=["aria-busy"],Me=["aria-label"],$e={key:1,class:"health-dashboard__message"},Ae={key:2,class:"health-dashboard__summary"},Ie={key:1,class:"health-dashboard__value"},Se={class:"health-dashboard__value"},Ve={class:"health-dashboard__value"},Be={class:"health-dashboard__bmi-value health-dashboard__value"},xe={key:0,class:"health-dashboard__message"},ze=ee({__name:"HealthDashboardWidget",setup(S){const k=new Date,V=ae(k),o=d(null),y=d([]),f=d([]),K=d([]),B=d(!0),x=d(!1),b=d(0),z=d(!1),H=d(!1),q=U(()=>O(o.value,ce).flatMap(l=>{const a=y.value.filter(s=>s.metricKey===l);if(a.length===0)return[];const e=he(l)?a.reduce((s,m)=>s+(m.numericValue??0),0)/a.length:null;return[{metricKey:l,count:a.length,average:e}]})),N=U(()=>O(o.value,de).flatMap(l=>{const a=f.value.filter(s=>s.metricKey===l);if(a.length===0)return[];if(o.value?.metrics[l]?.aggregation==="sum")return[{metricKey:l,total:a.reduce((s,m)=>s+(m.numericValue??0),0)}];const e=a.sort((s,m)=>new Date(m.recordedAt).getTime()-new Date(s.recordedAt).getTime())[0];return[{metricKey:l,measurement:e}]})),L=U(()=>O(o.value,ve).flatMap(l=>{const a=K.value.find(e=>e.metricKey===l);return a===void 0?[]:[{metricKey:l,value:a}]}));function E(l){return o.value?.metrics[l]?.displayUnit??Ke(l)[0]}function v(l){return l.toLocaleString(void 0,{maximumFractionDigits:2})}function J(l){const a=E(l.metricKey);return l.values!==null?`${v(_("blood_pressure",l.values.systolic,a))} / ${v(_("blood_pressure",l.values.diastolic,a))} ${I(a)}`:`${v(_(l.metricKey,l.numericValue??0,a))} ${I(a)}`}function Q(l,a){const e=E(l);return`${v(_(l,a,e))} ${I(e)}`}function X(l,a){const e=E(l),s=v(_(l,a.numericValue,e));return me(l)?`${s} ${I(e)}`:s}function Y(l){y.value=[...l.createdEntries,...y.value],f.value=[...l.createdMeasurements,...f.value];for(const a of l.updatedDailyValues)K.value=[...K.value.filter(e=>e.metricKey!==a.metricKey),a]}function P(l,a){Y(l),j(a==="check-in"?r("health","Check-in saved."):r("health","Check-out saved."))}async function F(l,a){b.value++;try{const e=await ye({metricKey:l,numericValue:null,optionValue:a,context:"manual",source:"web",recordedAt:new Date().toISOString(),note:null});y.value=[e,...y.value],j(r("health","{entry} recorded.",{entry:be(l,a)}))}catch{G(r("health","Entry could not be recorded."))}finally{b.value--}}async function Z(){B.value=!0,x.value=!1;try{const l=pe(k),[a,e,s,m]=await Promise.all([ge(),_e({...l,limit:200}),ke(V),fe(l.from,l.to)]);o.value=a,y.value=e,K.value=s,f.value=m}catch{x.value=!0,G(r("health","Health summary could not be loaded."))}finally{B.value=!1}}return Z(),(l,a)=>(n(),u("section",{"aria-busy":b.value>0,class:"health-dashboard"},[h("div",{"aria-label":t(r)("health","Health actions"),class:"health-dashboard__actions",role:"group"},[i(t(w),{"aria-label":t(r)("health","Check-in"),title:t(r)("health","Check-in"),variant:"primary",onClick:a[0]||(a[0]=e=>z.value=!0)},{icon:p(()=>[i(R,{symbol:"🌅",size:"button"})]),_:1},8,["aria-label","title"]),i(t(w),{"aria-label":t(r)("health","Check-out"),title:t(r)("health","Check-out"),variant:"primary",onClick:a[1]||(a[1]=e=>H.value=!0)},{icon:p(()=>[i(R,{symbol:"🌃",size:"button"})]),_:1},8,["aria-label","title"]),t(T)(o.value,"hydration")?(n(),g(t(w),{key:0,"aria-label":t(r)("health","Record small glass of water"),disabled:b.value>0,title:t(r)("health","Record water"),variant:"secondary",onClick:a[2]||(a[2]=e=>F("hydration","small_glass"))},{icon:p(()=>[i(R,{symbol:"🥛",size:"button"})]),_:1},8,["aria-label","disabled","title"])):C("",!0),t(T)(o.value,"hydration")?(n(),g(le,{key:1,disabled:b.value>0,onSelect:a[3]||(a[3]=e=>F("hydration",e))},null,8,["disabled"])):C("",!0),t(T)(o.value,"break")?(n(),g(te,{key:2,disabled:b.value>0,onSelect:a[4]||(a[4]=e=>F("break",e))},null,8,["disabled"])):C("",!0)],8,Me),B.value?(n(),g(t(re),{key:0,name:t(r)("health","Loading Health summary"),size:28},null,8,["name"])):x.value?(n(),u("p",$e,c(t(r)("health","The summary is temporarily unavailable.")),1)):(n(),u("div",Ae,[(n(!0),u(D,null,M(q.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),e.average!==null?(n(),g(t(se),{key:0,"aria-label":t(r)("health","{metric} average: {value} out of 5",{metric:t(A)(e.metricKey),value:v(e.average)}),color:t(ne)(e.metricKey).color,size:8,value:e.average*20},null,8,["aria-label","color","value"])):(n(),u("span",Ie,c(t(r)("health","{count}×",{count:e.count})),1))]))),128)),(n(!0),u(D,null,M(N.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),h("span",Se,c("total"in e?Q(e.metricKey,e.total):J(e.measurement)),1)]))),128)),(n(!0),u(D,null,M(L.value,e=>(n(),u("div",{key:e.metricKey,class:"health-dashboard__row"},[i($,{"metric-key":e.metricKey},null,8,["metric-key"]),h("span",null,c(t(A)(e.metricKey)),1),h("span",Ve,c(X(e.metricKey,e.value)),1)]))),128)),(n(!0),u(D,null,M(L.value.filter(e=>e.value.bmi!==null),e=>(n(),u("div",{key:`${e.metricKey}-bmi`,class:"health-dashboard__row"},[i($,{"metric-key":"weight"}),h("span",null,c(t(r)("health","BMI")),1),h("span",Be,[h("span",null,c(v(e.value.bmi??0)),1),i(t(oe),{"popup-role":"dialog"},{trigger:p(()=>[i(t(w),{"aria-label":t(r)("health","About the BMI calculation"),title:t(r)("health","About the BMI calculation"),variant:"tertiary"},{icon:p(()=>[i(t(ie),{path:t(ue).information},null,8,["path"])]),_:1},8,["aria-label","title"])]),default:p(()=>[h("p",null,c(t(r)("health","Adult BMI is calculated as weight in kilograms divided by height in metres squared. It is shown as a descriptive value only.")),1)]),_:1})])]))),128)),q.value.length+N.value.length+L.value.length===0?(n(),u("p",xe,c(t(r)("health","Record a value to see today’s Health summary here.")),1)):C("",!0)])),i(W,{open:z.value,"onUpdate:open":a[5]||(a[5]=e=>z.value=e),context:"check-in",configuration:o.value,date:t(V),onSaved:a[6]||(a[6]=e=>P(e,"check-in"))},null,8,["open","configuration","date"]),i(W,{open:H.value,"onUpdate:open":a[7]||(a[7]=e=>H.value=e),context:"check-out",configuration:o.value,date:t(V),onSaved:a[8]||(a[8]=e=>P(e,"check-out"))},null,8,["open","configuration","date"])],8,De))}}),He=we(ze,[["__scopeId","data-v-d38c59cd"]]);function Le(){const S=window.OCA?.Dashboard;S!==void 0&&S.register("health",k=>{Ce(He).mount(k)})}document.addEventListener("DOMContentLoaded",Le);
//# sourceMappingURL=health-dashboard.mjs.map
6 changes: 3 additions & 3 deletions js/health-main.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/health-main.mjs.license
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This file is generated from multiple sources. Included packages:
- version: 5.1.3
- license: MIT
- vite
- version: 7.3.6
- version: 7.3.7
- license: MIT
- vue-router
- version: 5.3.1
Expand Down
Loading
Loading