unclean SPARC
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
class SoeModel extends EICModel {
|
||||
|
||||
latestProject = null;
|
||||
|
||||
constructor(privileges) {
|
||||
super('/soe', privileges);
|
||||
}
|
||||
|
||||
list() {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('list');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
members() {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('members');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
fundings(companyId, projectId) {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('project');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
this.latestProject = serverData.payload;
|
||||
return this.latestProject;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
getFeedback(id) {
|
||||
return this.latestProject ? this.latestProject.fundings.find(item => item.id == id) : null;
|
||||
}
|
||||
|
||||
item(companyId, projectId, fundingId) {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('read');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
create(companyId, projectId, payload) {
|
||||
if(!this.hasPrivilege('create')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('create');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
update(companyId, projectId, fundingId, payload) {
|
||||
if(!this.hasPrivilege('update')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('update');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
delete(companyId, projectId, fundingId) {
|
||||
if(!this.hasPrivilege('delete')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('delete');
|
||||
endpoint.uri = endpoint.uri.replace('{pic}', companyId);
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', projectId);
|
||||
endpoint.uri = endpoint.uri.replace('{fundingId}', fundingId);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('SoeModel', SoeModel);
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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);
|
||||
@@ -0,0 +1,83 @@
|
||||
class ICMPProjectNodeModel extends EICModel {
|
||||
|
||||
currentProject = null;
|
||||
|
||||
constructor(privileges) { super('/icmp', privileges); }
|
||||
|
||||
get(number, node, nodeId) {
|
||||
if(!this.hasPrivilege('read')) 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);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
process(action, number, node, nodeId, payload) {
|
||||
switch (action) {
|
||||
case 'saving':
|
||||
if(!this.hasPrivilege('update')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
case 'submitting':
|
||||
if(!this.hasPrivilege('submit')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
case 'validating':
|
||||
if(!this.hasPrivilege('validate')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
case 'aborting':
|
||||
if(!this.hasPrivilege('cancel')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
case 'reviewing':
|
||||
if(!this.hasPrivilege('sendforreview')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
payload.status = action;
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
comment(action, number, node, nodeId, payload) {
|
||||
switch (action) {
|
||||
case 'rejecting':
|
||||
if(!this.hasPrivilege('reject')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
case 'reviewing':
|
||||
if(!this.hasPrivilege('review')) return( new Promise((resolve, reject) => reject()))
|
||||
break;
|
||||
}
|
||||
|
||||
let endpoint = this.getApiEndpoint('saveProjectNodeComments');
|
||||
endpoint.uri = endpoint.uri.replace('{projectId}', number);
|
||||
endpoint.uri = endpoint.uri.replace('{node}', node);
|
||||
endpoint.uri = endpoint.uri.replace('{nodeId}', nodeId);
|
||||
|
||||
payload.status = action;
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('ICMPProjectNodeModel', ICMPProjectNodeModel);
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ICMPProjectsModel extends EICModel {
|
||||
|
||||
list = [];
|
||||
|
||||
constructor(privileges) { super('/icmp', privileges); }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} node
|
||||
*/
|
||||
get(phase) {
|
||||
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
this.list = [];
|
||||
let payload = {}
|
||||
let endpoint = this.getApiEndpoint('list');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, payload)
|
||||
.then( async serverData => {
|
||||
this.list = this.sanitize(serverData.payload);
|
||||
return this.list;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
sanitize(data) { return data; }
|
||||
}
|
||||
|
||||
app.registerClass('ICMPProjectsModel', ICMPProjectsModel);
|
||||
@@ -0,0 +1,103 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user