keyframes
This commit is contained in:
+29
-4
@@ -1,8 +1,9 @@
|
||||
import { authGuard } from '../authGuard.js'
|
||||
|
||||
export const mappings = [
|
||||
{ method: 'get', url:'/agent-types', handler: 'getAgentTypes', middlewares: [authGuard]},
|
||||
{ method: 'get', url:'/agent-types/:family', handler: 'getAgentTypes', middlewares: [authGuard]},
|
||||
{ method: 'get', url:'/agent-sprites/:group', handler: 'getAgentSprites', middlewares: [authGuard]},
|
||||
{ method: 'get', url:'/agent/:id', handler: 'getAgentProps', middlewares: [authGuard]},
|
||||
]
|
||||
|
||||
export const methods = {
|
||||
@@ -24,9 +25,9 @@ export const methods = {
|
||||
})
|
||||
},
|
||||
|
||||
async getAgentSprites(req, res) {
|
||||
async getAgentSprites(req, res) { //TODO implement group & family filtering
|
||||
const results = await this.db.execute(`
|
||||
SELECT *
|
||||
SELECT atp_id, atp_name, asp_3d
|
||||
FROM p42SIM.agent_types
|
||||
LEFT JOIN p42GUI.agents_sprites on asp_atp_id = atp_id
|
||||
WHERE asp_group = ?`, [req.params.group])
|
||||
@@ -35,7 +36,31 @@ export const methods = {
|
||||
fullObj[row.atp_name] = row.asp_3d
|
||||
}
|
||||
this.ok(req, res, {
|
||||
agentSprites: fullObj
|
||||
agentSprites: results
|
||||
})
|
||||
},
|
||||
|
||||
async getAgentProps(req, res) {
|
||||
let results
|
||||
if(req.params.id){
|
||||
results = await this.db.execute(`
|
||||
SELECT *
|
||||
FROM p42SIM.agent_types
|
||||
WHERE atp_id = ?
|
||||
`, [req.params.id])
|
||||
|
||||
} else {
|
||||
this.err(req, res, `Invalid request`, `Missing Agent ID`, 401)
|
||||
return
|
||||
}
|
||||
|
||||
if(results.length==0){
|
||||
this.err(req, res, `Agent not found !`, `Unknown Agent ID (${req.params.id})`, 401)
|
||||
return
|
||||
}
|
||||
|
||||
this.ok(req, res, {
|
||||
agentProperties : results[0]
|
||||
})
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user