Files
P42_UI/app/models/KeyframesModel.js
T
2025-10-26 20:03:19 +00:00

41 lines
1.2 KiB
JavaScript

class KeyframesModel extends WindozModel {
constructor() {
super()
this.ressource = '/keyframes'
}
async create(kfData, prevKFId) {
let endpoint = {...app.config.api[this.ressource].create}
return (
this.request(endpoint.uri, endpoint.method, kfData)
)
}
async rename(kfData, prevKFId) {
let endpoint = {...app.config.api[this.ressource].create}
return (
this.request(endpoint.uri, endpoint.method, kfData)
)
}
async save(kfId, data) {
const kfData = Object.keys(data).map(aid => {
const { position, speed, ...storeValues} = data[aid].values
return({
aid: aid,
storeValues: storeValues,
gpsValues: { position: data[aid].values.position, speed: data[aid].values.speed }
})
})
let endpoint = {...app.config.api[this.ressource].saveAgents}
endpoint.uri = endpoint.uri.replace('{kfId}', kfId)
return (
this.request(endpoint.uri, endpoint.method, kfData)
)
}
}
app.registerClass('KeyframesModel', KeyframesModel);