Files
P42_UI/app/models/projects/icmp/ICMPProjectModel.js
T
2025-08-27 07:03:09 +00:00

58 lines
1.6 KiB
JavaScript

/**
*
*/
class ICMPProjectModel extends EICModel {
current = null;
constructor(privileges) { super('/icmp', privileges); }
get(number) {
if(!this.hasPrivilege('read')) return( new Promise((resolve, reject) => reject()))
this.current = null;
let endpoint = this.getApiEndpoint('getProject');
endpoint.uri = endpoint.uri.replace('{projectId}', number);
return (
this.request(endpoint.uri, endpoint.method)
.then( async serverData => {
this.current = this.sanitize(serverData.payload);
return this.current;
})
)
}
sanitize(data) { return data; }
documents(number) {
if(!this.hasPrivilege('read')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('getProjectDocuments');
endpoint.uri = endpoint.uri.replace('{projectId}', number);
return (
this.request(endpoint.uri, endpoint.method)
.then( async serverData => {
return serverData.payload;
})
)
}
contributors(number) {
if(!this.hasPrivilege('read')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('getProjectContributors');
endpoint.uri = endpoint.uri.replace('{projectId}', number);
return (
this.request(endpoint.uri, endpoint.method)
.then( async serverData => {
return serverData.payload;
})
)
}
}
app.registerClass('ICMPProjectModel', ICMPProjectModel);