From ab330b0be56e63bd180c9290675fd6ae8234cf9b Mon Sep 17 00:00:00 2001 From: ally <3210jr@gmail.com> Date: Sun, 15 May 2022 18:13:40 +0300 Subject: [PATCH 1/6] update tests --- .gitignore | 2 +- app/realm.ts | 62 +++++++++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 13 ++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/realm.ts create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 4d63ad3..d3c6447 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ node_modules dist -realm.ts +realms.ts notes.txt .env .vscode diff --git a/app/realm.ts b/app/realm.ts new file mode 100644 index 0000000..009c40d --- /dev/null +++ b/app/realm.ts @@ -0,0 +1,62 @@ +import * as Realm from "realm-web"; + +const id = "xxxx"; +const DB = "xxxx"; +const DB_NAME = "xxxx"; + +export const app = new Realm.App({ id }); +export default Realm; + +// Authenticate all users as anonymous by default +export const ensureLoggedIn = async (app) => { + console.log("called", app.currentUser); + if (app.currentUser === null) { + const res = await loginAnonymous(); + return res; + } + return app.currentUser; +}; + +// IFFE to await login for everyone +(async function () { + await ensureLoggedIn(app); +})(); + +// console.log("REALM: ", Realm, app); + +const mongodb = app.currentUser?.mongoClient(DB); +export const modelsDb = mongodb?.db(DB_NAME)?.collection("models"); +export const conditionsDb = mongodb?.db(DB_NAME)?.collection("conditions"); + +export const commentsDb = mongodb?.db(DB_NAME)?.collection("comments"); +export const datasetsDb = mongodb?.db(DB_NAME)?.collection("datasets"); + +export const userDataDb = mongodb?.db(DB_NAME)?.collection("user-data"); + +export const invitationsDb = mongodb?.db(DB_NAME)?.collection("invitations"); + +export async function loginAnonymous() { + if (app.currentUser !== null) { + return; + } + console.log("Creating anon user"); + // Create an anonymous credential + const credentials = Realm.Credentials.anonymous(); + try { + // Authenticate the user + const user = await app.logIn(credentials); + return user; + } catch (err) { + console.error("Failed to log in", err); + } +} + +// app.currennottUser.isLoggedIn +// app.currentUser.profile +// app.currentUser.isLoggedIn +// app.currentUser.id +// app.currentUser.profile.email + +// modelsDb.findOne({_id: "61ee74703dcfba9bb366f494"}) + +// modelsDb.updateOne({ _id: "" }, {$set: { ...conditionModel }}) diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..7f5e38d --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,13 @@ +// const webpack = require("webpack"); +// module.exports = (env) => { +// console.log(env); //{NODE_ENV:"dev"} +// return { +// /*original parameters in starter*/ +// plugins: [ +// new webpack.DefinePlugin({ +// "process.env": JSON.stringify({ NODE_ENV: "production", ...env }), +// }), +// ], +// entry: "./src/client/index.imba", +// }; +// }; From 552600092af06b66045a7ff76fe29a75a99881fb Mon Sep 17 00:00:00 2001 From: ally <3210jr@gmail.com> Date: Tue, 17 May 2022 15:06:54 +0300 Subject: [PATCH 2/6] improve vignette creation process --- .gitignore | 3 +- app/components/@ui/input.imba | 5 +- app/components/assessment-interact.imba | 134 ++++---- app/data/allergies.ts | 28 ++ app/data/medications.ts | 400 ++++++++++++++++++++++++ app/data/riskFactors.ts | 6 + app/data/symptoms.ts | 27 +- app/realm.ts | 62 ---- app/screens/vignette-creator.imba | 177 ++++++----- readme.md | 56 +++- 10 files changed, 684 insertions(+), 214 deletions(-) create mode 100644 app/data/allergies.ts create mode 100644 app/data/medications.ts delete mode 100644 app/realm.ts diff --git a/.gitignore b/.gitignore index d3c6447..2504914 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ node_modules dist -realms.ts +realm.ts notes.txt .env .vscode @@ -10,3 +10,4 @@ notes.txt .vercel playwright-report +app/realm.ts diff --git a/app/components/@ui/input.imba b/app/components/@ui/input.imba index ea808e7..0712242 100644 --- a/app/components/@ui/input.imba +++ b/app/components/@ui/input.imba @@ -138,7 +138,8 @@ tag chekbox-input prop id prop label prop onChange - prop value + prop data + prop value\string bool = no @@ -147,7 +148,7 @@ tag chekbox-input