103 lines
2.9 KiB
JavaScript
103 lines
2.9 KiB
JavaScript
class ProjectFundingModel extends EICModel {
|
|
|
|
currentProject = null;
|
|
projects = [];
|
|
|
|
constructor(privileges) {
|
|
super('/icmp', privileges);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {*} node
|
|
*/
|
|
getProjects(phase) {
|
|
|
|
this.projects = [];
|
|
|
|
let payload = {}
|
|
//if(phase) payload.phase = phase
|
|
|
|
/*
|
|
this.projects = [
|
|
{
|
|
number: '987654321',
|
|
acronym: 'MAXIBROUZOUF',
|
|
status: '...'
|
|
},
|
|
{
|
|
number: '965432187',
|
|
acronym: 'Total Pepet 2000',
|
|
status: '...'
|
|
}
|
|
];
|
|
|
|
return Promise.resolve(this.projects);
|
|
*/
|
|
let endpoint = this.getApiEndpoint('list');
|
|
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, payload)
|
|
.then( async serverData => {
|
|
this.projects = this.sanitizeProjects(serverData.payload);
|
|
return this.projects;
|
|
})
|
|
)
|
|
}
|
|
|
|
sanitizeProjects(data) { return data; }
|
|
|
|
getProject(number) {
|
|
//if(!this.hasPrivilege('getProject')) return( new Promise((resolve, reject) => reject()))
|
|
|
|
this.currentProject = null;
|
|
|
|
let endpoint = this.getApiEndpoint('getProject');
|
|
endpoint.uri = endpoint.uri.replace('{projectId}', number);
|
|
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method)
|
|
.then( async serverData => {
|
|
this.currentProject = this.sanitizeProject(serverData.payload);
|
|
return this.currentProject;
|
|
})
|
|
)
|
|
}
|
|
|
|
sanitizeProject(data) { return data; }
|
|
|
|
getProjectNode(number, node, nodeId) {
|
|
//if(!this.hasPrivilege('update')) return( new Promise((resolve, reject) => reject()))
|
|
|
|
let endpoint = this.getApiEndpoint('getProjectNode');
|
|
endpoint.uri = endpoint.uri.replace('{projectId}', number);
|
|
endpoint.uri = endpoint.uri.replace('{node}', node);
|
|
endpoint.uri = endpoint.uri.replace('{nodeId}', nodeId);
|
|
console.log(endpoint)
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method)
|
|
.then( async serverData => {
|
|
return serverData.payload;
|
|
})
|
|
)
|
|
}
|
|
|
|
updateProjectNode(number, node, nodeId, payload) {
|
|
//if(!this.hasPrivilege('update')) return( new Promise((resolve, reject) => reject()))
|
|
|
|
let endpoint = this.getApiEndpoint('saveProjectNode');
|
|
endpoint.uri = endpoint.uri.replace('{projectId}', number);
|
|
endpoint.uri = endpoint.uri.replace('{node}', node);
|
|
endpoint.uri = endpoint.uri.replace('{nodeId}', nodeId);
|
|
|
|
return (
|
|
this.request(endpoint.uri, endpoint.method, payload)
|
|
.then( async serverData => {
|
|
return serverData.payload;
|
|
})
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
app.registerClass('ProjectFundingModel', ProjectFundingModel); |