-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
791c195
commit 6df1bef
Showing
21 changed files
with
1,859 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ import ImportActivity from "./Researcher/ActivityList/ImportActivity" | |
import PreventPage from "./PreventPage" | ||
import { sensorEventUpdate } from "./BottomMenu" | ||
import TwoFA from "./TwoFA" | ||
import demo_db from "../demo_db.json" | ||
import self_help_db from "../self_help_db.json" | ||
|
||
function ErrorFallback({ error }) { | ||
const [trace, setTrace] = useState([]) | ||
|
@@ -129,6 +131,11 @@ function AppRouter({ ...props }) { | |
const serverAddressFro2FA = ["api-staging.lamp.digital", "api.lamp.digital"] | ||
|
||
useEffect(() => { | ||
if (localStorage.getItem("demo_mode") === "try_it") { | ||
LAMP.initializeDemoDB(demo_db) | ||
} else if (localStorage.getItem("demo_mode") === "self_help") { | ||
LAMP.initializeDemoDB(self_help_db) | ||
} | ||
let query = window.location.hash.split("?") | ||
if (!!query && query.length > 1) { | ||
let src = Object.fromEntries(new URLSearchParams(query[1]))["src"] | ||
|
@@ -276,7 +283,9 @@ function AppRouter({ ...props }) { | |
}, [state]) | ||
|
||
let reset = async (identity?: any) => { | ||
Service.deleteUserDB() | ||
if (identity?.id != "[email protected]") { | ||
Service.deleteUserDB() | ||
} | ||
Service.deleteDB() | ||
if (typeof identity === "undefined" && LAMP.Auth._type === "participant") { | ||
await sensorEventUpdate(null, (state.identity as any)?.id ?? null, null) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next" | |
import LAMP from "lamp-core" | ||
import { useSnackbar } from "notistack" | ||
import { sensorEventUpdate } from "./BottomMenu" | ||
import { Service } from "./DBService/DBService" | ||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
backdrop: { | ||
|
@@ -47,9 +48,7 @@ const demoActivities = { | |
"lamp.symbol_digit_substitution": "symbol_digit_substitution", | ||
"lamp.gyroscope": "gyroscope", | ||
"lamp.dcog": "d-cog", | ||
"lamp.funny_memory": "funnymemory", | ||
"lamp.trails_b": "dottouch", | ||
"lamp.voice_survey": "speech", | ||
"lamp.simple_memory": "funnymemory", | ||
} | ||
|
||
export default function EmbeddedActivity({ participant, activity, name, onComplete, noBack, tab, ...props }) { | ||
|
@@ -129,6 +128,11 @@ export default function EmbeddedActivity({ participant, activity, name, onComple | |
data["timestamp"] = activityTimestamp | ||
data["duration"] = new Date().getTime() - activityTimestamp | ||
setData(data) | ||
if (LAMP.Auth._auth.id === "[email protected]") { | ||
setTimeout(() => { | ||
Service.addUserDBRow("activityEvents", data) | ||
}, 500) | ||
} | ||
setEmbeddedActivity(undefined) | ||
setSettings(null) | ||
} else { | ||
|
@@ -198,6 +202,13 @@ export default function EmbeddedActivity({ participant, activity, name, onComple | |
const exist = localStorage.getItem("first-time-" + (participant?.id ?? participant) + "-" + currentActivity?.id) | ||
try { | ||
setSaved(false) | ||
console.log({ | ||
...settings, | ||
activity: currentActivity, | ||
configuration: { language: i18n.language }, | ||
autoCorrect: !(exist === "true"), | ||
noBack: noBack, | ||
}) | ||
setSettings({ | ||
...settings, | ||
activity: currentActivity, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,6 +330,7 @@ import zhLocale from "date-fns/locale/zh-CN" | |
import esLocale from "date-fns/locale/es" | ||
import enLocale from "date-fns/locale/en-US" | ||
import hiLocale from "date-fns/locale/hi" | ||
import { getSelfHelpAllActivityEvents } from "./Participant" | ||
|
||
const userLanguages = ["en-US", "es-ES", "hi-IN", "de-DE", "da-DK", "fr-FR", "ko-KR", "it-IT", "zh-CN"] | ||
|
||
|
@@ -470,7 +471,10 @@ export default function Feed({ | |
date.setSeconds(0) | ||
let startTime = date.getTime() | ||
let endTime = startTime + 86400000 | ||
let activityEvents = await LAMP.ActivityEvent.allByParticipant(participant.id, null, startTime, endTime, null, true) | ||
let activityEvents = | ||
LAMP.Auth._auth.id === "[email protected]" | ||
? await getSelfHelpAllActivityEvents(startTime, endTime) | ||
: await LAMP.ActivityEvent.allByParticipant(participant.id, null, startTime, endTime, null, true) | ||
return activityEvents | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.