-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decent progress on 2nd day of development. Got several classes and ca…
…ncer model class with static methods to produce data. Next step is to switch focus to the actual interface
- Loading branch information
1 parent
96499cc
commit e85592e
Showing
19 changed files
with
287 additions
and
219 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:8080", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
"emulators": { | ||
"firestore": { | ||
"port": 8080 | ||
"port": 5000 | ||
}, | ||
|
||
"ui": { | ||
|
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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
API endpoint: http://localhost:8080 | ||
API endpoint: http://localhost:5000 | ||
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run: | ||
|
||
export FIRESTORE_EMULATOR_HOST=localhost:8080 | ||
export FIRESTORE_EMULATOR_HOST=localhost:5000 | ||
|
||
Dev App Server is now running. | ||
|
||
Nov 30, 2020 1:39:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
Dec 02, 2020 3:38:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
Nov 30, 2020 1:39:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
Dec 02, 2020 3:38:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected HTTP/2 connection. | ||
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
Dec 02, 2020 3:38:39 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
Dec 02, 2020 3:38:55 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
Dec 02, 2020 3:38:55 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead | ||
INFO: Detected non-HTTP/2 connection. | ||
*** shutting down gRPC server since JVM is shutting down | ||
*** server shut down |
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 |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import PracticeInterface from './PracticeInterface/PracticeInterface'; | ||
import data from './cancers_template.json'; | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import { DBQueryer } from './DBQueryer/DBQueryer'; | ||
import { CancerModel } from './models'; | ||
|
||
const App = () => { | ||
return <PracticeInterface data={ data } /> | ||
const [cancers, setCancers] = useState([]); | ||
|
||
const output = (bundle) => { | ||
if (!Array.isArray(bundle)) { | ||
return; | ||
} | ||
return bundle.map( (items, i) => { | ||
return ( | ||
<ul> | ||
<li key={ i }>{ items.name }</li> | ||
{ output(items.getContents()) } | ||
</ul> | ||
); | ||
}); | ||
} | ||
|
||
useEffect( () => { | ||
if (cancers.length === 0) { | ||
DBQueryer.getAll("cancers") | ||
.then( (dbCancers) => { | ||
CancerModel.load(dbCancers); | ||
setCancers(CancerModel.getCancersFull()); | ||
}); | ||
} | ||
}); | ||
|
||
return cancers.length > 0 && ( | ||
<> | ||
{ output(cancers) } | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Revealing module design pattern | ||
|
||
import { dbInstance } from '../helpers/dbinstance'; | ||
|
||
const DBQueryer = ( () => { | ||
const db = dbInstance.getDB(); | ||
const collections = {}; | ||
|
||
const getAllFromDB = async (name) => { | ||
const querySnapshot = await db.collection(name).get(); | ||
return querySnapshot.docs.map( (doc) => doc.data() ); | ||
} | ||
|
||
const getAllInCollection = async (name) => { | ||
if (!collections.hasOwnProperty(name)) { | ||
const result = await getAllFromDB(name); | ||
collections[name] = result; | ||
} | ||
return collections[name]; | ||
} | ||
|
||
return { | ||
getAll: getAllInCollection | ||
} | ||
|
||
})(); | ||
|
||
export { DBQueryer }; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { screen, render } from '@testing-library/react' | ||
import { Regimen, RiskStrat, Cancer } from '../models'; | ||
import App from '../App'; | ||
|
||
beforeEach( () => { | ||
render(<App />); | ||
}); | ||
|
||
it('should show a list of cancers', async () => { | ||
expect( await screen.findByRole('list')).toBeInTheDocument(); | ||
}); | ||
|
||
const getRegimens = () => { | ||
return [ | ||
new Regimen('Regimen 1'), | ||
new Regimen('Regimen 2'), | ||
new Regimen('Regimen 3') | ||
]; | ||
} | ||
|
||
const getRiskStrats = () => { | ||
return [ | ||
new RiskStrat('Risk strat 1'), | ||
new RiskStrat('Risk strat 2'), | ||
new RiskStrat('Risk strat 3') | ||
]; | ||
} | ||
|
||
const getCancers = () => { | ||
return [ | ||
new Cancer('Cancer 1'), | ||
new Cancer('Cancer 2'), | ||
new Cancer('Cancer 3') | ||
]; | ||
} |
Oops, something went wrong.