-
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.
Merge pull request #28 from Cambio-Project/mtl-stimuli
Add MTL Stimuli creation and application to analyses
- Loading branch information
Showing
19 changed files
with
1,311 additions
and
393 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Command} from "~/server/models/command.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
|
||
let commands: any = [] | ||
|
||
try { | ||
commands = await Command.find({}) | ||
} catch (e) { | ||
console.log("Error finding commands") | ||
} | ||
|
||
return commands | ||
}); |
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,14 @@ | ||
import {Listener} from "~/server/models/listener.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
|
||
let listeners: any = [] | ||
|
||
try { | ||
listeners = await Listener.find({}) | ||
} catch (e) { | ||
console.log("Error finding events") | ||
} | ||
|
||
return listeners | ||
}); |
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,21 @@ | ||
import {Command} from "~/server/models/command.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
// read the request body | ||
const body = await readBody(event); | ||
const requestBody = JSON.parse(body); | ||
|
||
try { | ||
// extract the ID of the item to be updated | ||
const commandId = requestBody._id; | ||
// remove _id from the update data | ||
delete requestBody._id; | ||
|
||
// update the event | ||
const updatedCommand = await Command.updateOne({_id: commandId}, requestBody); | ||
|
||
} catch (e) { | ||
console.log("Error updating command:", e); | ||
return {"done": false}; | ||
} | ||
}); |
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,21 @@ | ||
import {Listener} from "~/server/models/listener.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
// read the request body | ||
const body = await readBody(event); | ||
const requestBody = JSON.parse(body); | ||
|
||
try { | ||
// extract the ID of the item to be updated | ||
const listenerId = requestBody._id; | ||
// remove _id from the update data | ||
delete requestBody._id; | ||
|
||
// update the event | ||
const updatedListener = await Listener.updateOne({_id: listenerId}, requestBody); | ||
|
||
} catch (e) { | ||
console.log("Error updating listener:", e); | ||
return {"done": false}; | ||
} | ||
}); |
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,19 @@ | ||
import {Command} from "~/server/models/command.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
// Read the request body | ||
const body = await readBody(event); | ||
const requestBody = JSON.parse(body); | ||
|
||
try { | ||
// extract the ID of the item to be deleted | ||
const commandId = requestBody._id; | ||
|
||
// find and delete the event by its ID | ||
const deletedCommand = await Command.deleteOne({ _id: commandId }); | ||
|
||
} catch (e) { | ||
console.log("Error deleting command:", e); | ||
return { "done": false }; | ||
} | ||
}); |
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,19 @@ | ||
import {Listener} from "~/server/models/listener.model"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
// Read the request body | ||
const body = await readBody(event); | ||
const requestBody = JSON.parse(body); | ||
|
||
try { | ||
// extract the ID of the item to be deleted | ||
const listenerId = requestBody._id; | ||
|
||
// find and delete the event by its ID | ||
const deletedListener = await Listener.deleteOne({ _id: listenerId }); | ||
|
||
} catch (e) { | ||
console.log("Error deleting event:", e); | ||
return { "done": false }; | ||
} | ||
}); |
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,19 @@ | ||
import {Command} from "~/server/models/command.model"; | ||
import * as crypto from "crypto"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
let body = await readBody(event) | ||
body = JSON.parse(body) | ||
|
||
body["_id"] = crypto.randomUUID() | ||
|
||
try { | ||
await Command.create(body) | ||
} catch (e) { | ||
console.log("Error creating command") | ||
} | ||
|
||
return { | ||
"done": true | ||
}; | ||
}); |
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,19 @@ | ||
import {Listener} from "~/server/models/listener.model"; | ||
import * as crypto from "crypto"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
let body = await readBody(event); | ||
body = JSON.parse(body) | ||
|
||
body["_id"] = crypto.randomUUID() | ||
|
||
try { | ||
await Listener.create(body) | ||
} catch (e) { | ||
console.log("Error creating listener") | ||
} | ||
|
||
return { | ||
"done": true | ||
}; | ||
}); |
Oops, something went wrong.