Skip to content

Commit

Permalink
Merge pull request #94 from jspsych/test
Browse files Browse the repository at this point in the history
Release multi-region support
  • Loading branch information
jodeleeuw authored Mar 12, 2024
2 parents ac3896a + d200393 commit 58d76a4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/firebase-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
cache: "npm"
- uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' # Replace with the name of your GitHub Actions secret
credentials_json: '${{ secrets.GOOGLE_TEST_CREDENTIALS }}' # Replace with the name of your GitHub Actions secret
- name: Install firebase tools
run: npm install -g [email protected]
- name: Enable firebase webframeworks
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/firebase-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: ["main"]

env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
#FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
NEXT_PUBLIC_FIREBASE_CONFIG: ${{ secrets.FIREBASE_PRODUCTION_CONFIG }}


Expand All @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -28,6 +28,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_PRODUCTION_CREDENTIALS }}'
- name: Install firebase tools
run: npm install -g [email protected]
- name: Enable firebase webframeworks
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
### Live Server
# DataPipe

https://pipe.jspsych.org

### Development
Send your experiment data directly to the OSF, for free.

```
npm install -g firebase-tools
npm install
npm run emulators
```
https://pipe.jspsych.org

The local site will be available at localhost:5000.
18 changes: 9 additions & 9 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"logs": "firebase functions:log"
},
"engines": {
"node": "16"
"node": "20"
},
"main": "index.js",
"type": "module",
Expand All @@ -18,7 +18,7 @@
"csv-string": "^4.1.1",
"express": "^4.18.2",
"firebase-admin": "^11.9.0",
"firebase-functions": "^4.4.0",
"firebase-functions": "^4.8.0",
"is-base64": "^1.1.0",
"joi": "^17.7.0",
"node-fetch": "^3.2.10"
Expand Down
46 changes: 31 additions & 15 deletions pages/admin/new.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { customAlphabet } from "nanoid";
import AuthCheck from "../../components/AuthCheck";
import {
doc,
getDoc,
writeBatch,
arrayUnion,
} from "firebase/firestore";
import { doc, getDoc, writeBatch, arrayUnion } from "firebase/firestore";
import { db, auth } from "../../lib/firebase";
import { useContext, useState } from "react";
import { UserContext } from "../../lib/context";
Expand All @@ -26,6 +21,7 @@ import {
FormHelperText,
VStack,
Text,
Select,
} from "@chakra-ui/react";

export default function NewExperimentPage({}) {
Expand All @@ -42,7 +38,7 @@ function NewExperimentForm() {
const [osfError, setOsfError] = useState(false);
const [titleError, setTitleError] = useState(false);
const [dataComponentError, setDataComponentError] = useState(false);

const [data, loading, error] = useDocumentData(doc(db, "users", user.uid));

return (
Expand All @@ -53,8 +49,10 @@ function NewExperimentForm() {
<Heading>Create a New Experiment</Heading>
<FormControl id="title" isInvalid={titleError}>
<FormLabel>Title</FormLabel>
<Input type="text" onChange={()=>setTitleError(false)} />
<FormErrorMessage color={"red"}>This field is required</FormErrorMessage>
<Input type="text" onChange={() => setTitleError(false)} />
<FormErrorMessage color={"red"}>
This field is required
</FormErrorMessage>
</FormControl>
<FormControl id="osf-repo" isInvalid={osfError}>
<FormLabel>Existing OSF Project</FormLabel>
Expand All @@ -70,9 +68,26 @@ function NewExperimentForm() {
</FormControl>
<FormControl id="osf-component-name" isInvalid={dataComponentError}>
<FormLabel>New OSF Data Component Name</FormLabel>
<Input type="text" onChange={()=>setDataComponentError(false)}/>
<FormErrorMessage color={"red"}>This field is required</FormErrorMessage>
<FormHelperText color="gray">DataPipe will create a new component with this name in the OSF project and store all data in it.</FormHelperText>
<Input type="text" onChange={() => setDataComponentError(false)} />
<FormErrorMessage color={"red"}>
This field is required
</FormErrorMessage>
<FormHelperText color="gray">
DataPipe will create a new component with this name in the OSF
project and store all data in it.
</FormHelperText>
</FormControl>
<FormControl id="osf-component-region">
<FormLabel>Storage Location</FormLabel>
<Select defaultValue="us" sx={{'> option': {background: 'black', color: 'white'}}}>
<option value="us">United States</option>
<option value="de-1">Germany - Frankfurt</option>
<option value="au-1">Australia - Sydney</option>
<option value="ca-1">Canada - Montreal</option>
</Select>
<FormHelperText color="gray">
Choose the region where the data will be stored.
</FormHelperText>
</FormControl>
<Button
onClick={() =>
Expand Down Expand Up @@ -120,6 +135,7 @@ async function handleCreateExperiment(
const user = auth.currentUser;
const title = document.querySelector("#title").value;
let osfRepo = document.querySelector("#osf-repo").value;
const region = document.querySelector("#osf-component-region").value;
const osfComponentName = document.querySelector("#osf-component-name").value;
const nConditions = 1;
const useValidation = true;
Expand All @@ -128,13 +144,13 @@ async function handleCreateExperiment(
const useSessionLimit = false;
const maxSessions = 1;

if(title.length === 0) {
if (title.length === 0) {
setTitleError(true);
setIsSubmitting(false);
return;
}

if(osfComponentName.length === 0) {
if (osfComponentName.length === 0) {
setDataComponentError(true);
setIsSubmitting(false);
return;
Expand All @@ -160,7 +176,7 @@ async function handleCreateExperiment(
}

const osfResult = await fetch(
`https://api.osf.io/v2/nodes/${osfRepo}/children/`,
`https://api.osf.io/v2/nodes/${osfRepo}/children/?region=${region}`,
{
method: "POST",
headers: {
Expand Down

0 comments on commit 58d76a4

Please sign in to comment.