Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor style updates, fixing the "combined" steps provider #112

Merged
merged 5 commits into from
Sep 18, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/components/container/DailyDataChart/DailyDataChart.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.mdhui-daily-data-chart .mdhui-daily-data-tooltip {
padding: 8px;
background: var(--mdhui-background-color-0);
border-radius: 5px;
border-radius: var(--mdhui-card-border-radius);
box-shadow: var(--mdhui-box-shadow-1);
animation: fadein 1s;
-moz-animation: fadein 1s;
Expand Down
16 changes: 16 additions & 0 deletions src/components/container/DailyDataChart/DailyDataChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ export const stepsBarChart = {
render: render
};


export const stepsLiveBarChart = {
args: {
title: "Steps",
options: {

},
intervalType: "Week",
weekStartsOn: "6DaysAgo",
dailyDataType: DailyDataType.Steps,
valueFormatter: (value: number) => Number(value.toFixed(0)).toLocaleString(),
chartType: "Bar"
},
render: render
};

export const stepsAreaChart = {
args: {
title: "Steps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
padding: 4px;
font-size: 12px;
background: var(--mdhui-background-color-0);
border-radius: 5px;
border-radius: var(--mdhui-card-border-radius);
box-shadow: var(--mdhui-box-shadow-0);
animation: fadein 1s;
-moz-animation: fadein 1s;
Expand Down
2 changes: 1 addition & 1 deletion src/components/presentational/Button/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
line-height: 17px;
color: #FFF;
border: none;
border-radius: 5px;
border-radius: var(--mdhui-card-border-radius);
cursor: pointer;
font-weight: bold;
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion src/components/presentational/Card/Card.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.mdhui-card {
border-radius: 5px;
border-radius: var(--mdhui-card-border-radius);
margin: 16px;
background: var(--mdhui-background-color-0);
box-shadow: var(--mdhui-box-shadow-0);
Expand Down
51 changes: 32 additions & 19 deletions src/helpers/daily-data-providers/combined-steps.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import { add } from "date-fns";
import { appleHealthStepsDataProvider, fitbitStepsDataProvider, garminStepsDataProvider } from ".";
import getDayKey from "../get-day-key";
import MyDataHelps from "@careevolution/mydatahelps-js";

export default function (startDate: Date, endDate: Date) {
var fitbitSteps = fitbitStepsDataProvider(startDate, endDate);
var appleSteps = appleHealthStepsDataProvider(startDate, endDate);
var garminSteps = garminStepsDataProvider(startDate, endDate);
let providers: Promise<{ [key: string]: number }>[] = [];

return Promise.all([fitbitSteps, appleSteps, garminSteps]).then((values) => {
var data: { [key: string]: number } = {};
while (startDate < endDate) {
var dayKey = getDayKey(startDate);
var steps: number | null = null;
if (values[0][dayKey]) {
steps = values[0][dayKey];
}
return MyDataHelps.getDataCollectionSettings().then((settings) => {
if (settings.fitbitEnabled) {
providers.push(fitbitStepsDataProvider(startDate, endDate));
}
if (settings.garminEnabled) {
providers.push(garminStepsDataProvider(startDate, endDate));
}
if (settings.queryableDeviceDataTypes.find(s => s.namespace == "AppleHealth" && s.type == "HourlySteps")) {
providers.push(appleHealthStepsDataProvider(startDate, endDate));
}

if (values[1][dayKey] && (steps == null || values[1][dayKey] > steps)) {
steps = values[1][dayKey];
}
if (steps) {
data[dayKey] = steps;
}
startDate = add(startDate, { days: 1 });
if (!providers.length) {
return {};
}
return data;

return Promise.all(providers).then((values) => {
var data: { [key: string]: number } = {};
while (startDate < endDate) {
var dayKey = getDayKey(startDate);
var steps: number | null = null;
values.forEach((value) => {
if (value[dayKey] || steps == null || steps < value[dayKey]) {
steps = value[dayKey];
}
});
if (steps) {
data[dayKey] = steps;
}
startDate = add(startDate, { days: 1 });
}
return data;
});
});
}
4 changes: 3 additions & 1 deletion src/helpers/daily-data-providers/query-all-device-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MyDataHelps, { DeviceDataPoint, DeviceDataPointQuery, Guid, } from '@careevolution/mydatahelps-js';
import MyDataHelps, { DeviceDataPoint, DeviceDataPointQuery, Guid, } from '@careevolution/mydatahelps-js';

export default function queryAllDeviceData(parameters: DeviceDataPointQuery) {
var allDeviceDataPoints: DeviceDataPoint[] = [];
Expand All @@ -14,6 +14,8 @@ export default function queryAllDeviceData(parameters: DeviceDataPointQuery) {
} else {
return allDeviceDataPoints;
}
}).catch(function (error) {
return allDeviceDataPoints;
});
}
return queryPage();
Expand Down
13 changes: 9 additions & 4 deletions src/helpers/globalCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export const core = css`
--mdhui-color-warning: #FF671D;
--mdhui-color-danger: #eb5546;
--mdhui-fadein-animation: fadein 1s;

--mdhui-card-border-radius: 12px;
--mdhui-font-family: ui-rounded, -apple-system, Helvetica, Arial, sans-serif;
--mdhui-modal-overlay-color: rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion) {
Expand Down Expand Up @@ -59,13 +63,14 @@ export const lightColorScheme = css`
--mdhui-text-color-3: #999;
--mdhui-text-color-4: #bbb;

--mdhui-box-shadow-color-0: #ddd;
--mdhui-box-shadow-color-0: rgba(0, 0, 0, 0.05);
--mdhui-box-shadow-color-1: #aaa;

--mdhui-box-shadow-0: 0px 9px 9px 0px var(--mdhui-box-shadow-color-0);
--mdhui-box-shadow-0: 0px 4px 4px 0px var(--mdhui-box-shadow-color-0);
--mdhui-box-shadow-1: 0px 0px 5px 0px var(--mdhui-box-shadow-color-1);

--mdhui-overlay-gradient:linear-gradient(to left, rgba(255, 255, 255, 0) 0%, rgba(255, 244, 240, 0.2) 100%);

}
`

Expand Down Expand Up @@ -113,9 +118,9 @@ html {
body {
padding: 0;
margin: 0;
font-family: ui-rounded, -apple-system, Helvetica, Arial, sans-serif;
font-family: var(--mdhui-font-family);
background: var(--mdhui-background-color-1);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.2em;
line-height: 1.2;
}`;