agents defs from DB

This commit is contained in:
STEINNI
2025-10-12 19:45:18 +00:00
parent f62a7176d4
commit a38d2da3e4
11 changed files with 64 additions and 1014 deletions
-24
View File
@@ -32,30 +32,6 @@ class EICModel extends Model {
this.setPrivileges(resource, privileges);
}
/**
*
* @param {*} action
* @param {*} resource
* @returns {object}
*/
getApiEndpoint(action, resource=null) {
resource = resource || this.resource;
for(let ApiBizObj of Object.keys(app.config.api)) {
//If called without real ids
if(ApiBizObj==resource) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
//If called with real ids
let re = new RegExp('^'+ApiBizObj.replace(/\//g,'\\/').replace(/\{\w+\}/gi,'([0-9a-zA-Z]+)')+'$', 'm')
if(resource.match(re)) {
if(app.config.api[ApiBizObj].hasOwnProperty(action)) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
else console.error(`No API endpoint for action "${action}" on resource "${resource}"`)
}
}
console.error(`No API service for resource:${resource}`)
return({ "method":null, "uri": null });
}
setPrivileges(resource, privileges) {
this.resource = resource;
this.privileges = privileges || [];
+15 -2
View File
@@ -34,7 +34,20 @@ class myUser extends app.LoadedClasses.User {
* @returns {Array<string>}
*/
getRoles() { return(app.User.roles); }
/**
*
* @returns {Promise<Array>}
*/
fetchServices() {
return(fetch('/app/assets/json/global/services.json?'+crypto.randomUUID(), {
method: 'GET'
})
.then(response => response.text())
.then(response => JSON.parse(response))
.then(response => app.config.api = response.payload)
)
}
/**
*
@@ -103,6 +116,7 @@ class myUser extends app.LoadedClasses.User {
})
this.model = new MyUserModleModel()
this.loadPreferences()
this.fetchServices()
}, 'myUser')
}
@@ -191,7 +205,6 @@ class myUser extends app.LoadedClasses.User {
loadPreferences() {
this.model.getPreferences().then(settings => {
console.log("Prefs received from bus:", settings)
this.preferences = settings.value || {}
})
}