logs in console, caching in getAgentProps, console createAgent independent of GUI

This commit is contained in:
STEINNI
2025-12-06 18:53:23 +00:00
parent 1143c52c11
commit c1d0a16cf3
26 changed files with 18025 additions and 100 deletions
+23 -8
View File
@@ -3,6 +3,7 @@ class AgentsModel extends WindozModel {
constructor() {
super()
this.ressource = '/agents'
this.agentProps = {}
}
async getTypes(family) {
@@ -23,14 +24,28 @@ class AgentsModel extends WindozModel {
)
}
async getProperties(id) {
let endpoint = {...app.config.api[this.ressource].getProperties}
endpoint.uri = endpoint.uri.replace('{id}', id)
return (
this.request(endpoint.uri, endpoint.method)
.then( async serverData => serverData.payload.agentProperties)
)
}
async getProperties(id, force=false) {
if((!(id in this.agentProps)) || force){
let endpoint = {...app.config.api[this.ressource].getProperties}
endpoint.uri = endpoint.uri.replace('{id}', id)
return (
this.request(endpoint.uri, endpoint.method)
.then( async serverData => {
this.agentProps[id] = serverData.payload.agentProperties.atp_props
return(serverData.payload.agentProperties.atp_props)
})
)
} else {
return(this.agentProps[id])
}
}
async getDefaultProps(id){
const aprops = await this.getProperties(id)
const defaults={ position: { x:0, y:0, z:0 }, speed: { x:0, y:0, z:0 }}
for(const p in aprops) defaults[p] = aprops[p].default
return(defaults)
}
}
app.registerClass('AgentsModel', AgentsModel);