unclean SPARC

This commit is contained in:
STEINNI
2025-08-27 07:03:09 +00:00
commit f308460931
430 changed files with 54426 additions and 0 deletions
+110
View File
@@ -0,0 +1,110 @@
class BypassUsersModel extends EICPluralModel {
constructor(privileges) {
super('users', privileges);
this.singletonClass = class {
itemData = {
uuid: null,
firstname: null,
lastname: null,
role: null
}
}
}
getUid(uid) {
return(this.collection.find(x=>(x.uid == uid)));
}
create(payload) {
if(!this.hasPrivilege('create')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('create');
return ( this.request(endpoint.uri, endpoint.method, payload) );
}
revoke(uid) {
if(!this.hasPrivilege('revoke')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('revoke');
let uri = endpoint.uri.replace('{id}', uid);
return this.request(uri, endpoint.method, null);
}
search(hint) {
// This is publicly avail, don't check until ML understand what anonymous means
// if(!this.hasPrivilege('search')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('search');
let uri = endpoint.uri.replace('{id}', hint);
return (
this.request(uri, endpoint.method, {'hint': hint })
.then( async serverData => {
let users = serverData.payload.map(x=> { // Cleanup keys starting with https://
for(let k in x){
if(k.substring(0,4)=='http') { x[k.substring(k.lastIndexOf('/')+1)]=x[k]; delete(x[k]);}
} return(x);
} )
return(users);
})
)
}
sanitize(item) {
//TODO what if several BP_ roles...
item.BProle = item.roles.filter(r => (r.substring(0,3)=='BP_'))[0];
let trackTree = null;
if(item.track) {
trackTree = app.meta.getItem('accelerator-tracks',item.track);
item.track = { id: item.track, label: trackTree.label };
} else {
item.track = { id: null, label: '(n/a)' };
}
if((item.domain) && (trackTree)){
item.domain = { id: item.domain, label: app.meta.getItemRecurse(trackTree, item.domain).label };
} else {
item.domain = { id: null, label: '(n/a)' };
}
return item;
}
list(filters) {
if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('list');
return (
this.request(endpoint.uri, endpoint.method, filters)
.then( async serverData => {
const payload = serverData.payload;
this.fill(payload);
})
)
}
// Not sure why / when / where they think I'll need it, but it exists (and takes 2.5 seconds to get 5 strings)
// If someday the response-time is decent, and if we have the delegationRules the payload...maybe...
getRoles() {
if(!this.hasPrivilege('getRoles')) return( new Promise((resolve, reject) => reject()))
let endpoint = app.config.api.roles.list;
return (
this.request(endpoint.uri, endpoint.method, {})
.then( async serverData => {
this.existingRoles = serverData.payload;
})
)
}
fill(serverData) {
if(serverData && serverData.length) {
this.collection = [];
for(let singletonData of serverData) this.collection.push(this.sanitize(singletonData));
}
}
}
app.registerClass('BypassUsersModel', BypassUsersModel);
+85
View File
@@ -0,0 +1,85 @@
class applicantModel extends EICModel {
constructor(privileges) {
super('applicant', privileges);
}
getOrganisations() {
let responsePayload = [
{
pic: 12345678,
legalname: 'NightShift.be SNC'
}
];
return (
new Promise((resolve) => {
setTimeout(() => {
resolve(responsePayload);
}, 300);
})
)
}
getOrganisationSummary(pic) {
let responsePayload = {
pic: 12345678,
legalname: 'NightShift.be SNC',
proposals: [
{
id: 14373,
proposalNumber: '190129445',
acronym: 'patchd',
status: 'draft',
type: 'short',
accessRequests: 2,
version: 'legacy1.0'
},
{
id: 99999,
proposalNumber: '999123456',
acronym: 'fastinfra',
status: 'draft',
type: 'short',
accessRequests: 2,
version: '2023'
}
],
coachings: [],
members: [
{
uid: 'fallimi',
firstname: 'Michael',
lastname: 'Fallise',
function: 'Chief Executive Officer',
status: 'active'
},
{
uid: 'steinni',
firstname: 'Nicolas',
lastname: 'Stein',
function: 'Chief Technical Officer',
status: 'active'
},
{
uid: 'schwemi',
firstname: 'Michael',
lastname: 'Schweda',
function: 'Marketing manager',
status: 'pending'
}
],
calendar: []
};
return (
new Promise((resolve) => {
setTimeout(() => {
resolve(responsePayload);
}, 300);
})
)
}
}
app.registerClass('applicantModel', applicantModel);
+120
View File
@@ -0,0 +1,120 @@
class onboardingUserModel extends EICPluralModel {
constructor(privileges) {
super('/organisations', privileges);
this.singletonClass = class {
itemData = {
uuid: null,
firstname: null,
lastname: null,
role: null,
organisations: []
}
}
}
readOrganisation(pic) {
if(!this.hasPrivilege('read')) return( new Promise((resolve, reject) => reject()));
let endpoint = this.getApiEndpoint('read');
let uri = endpoint.uri.replace('{pic}',pic)
return (
this.request(uri, endpoint.method)
.then( async serverData => {
this.loadData(serverData.payload)
return(serverData.payload)
})
)
}
searchOrganisation(pic) {
// This is publicly avail, don't check until ML understand what anonymous means
// if(!this.hasPrivilege('search')) return( new Promise((resolve, reject) => reject()))
let endpoint = this.getApiEndpoint('search');
let uri = endpoint.uri
return (
this.request(uri, endpoint.method, {'search': pic })
.then( async serverData => {
this.loadData(serverData.payload)
return(serverData.payload)
})
)
}
registerOrganisationAccess(orgData) {
if(!this.hasPrivilege('apply')) return( new Promise((resolve, reject) => reject()));
let endpoint = this.getApiEndpoint('apply')
let uri = endpoint.uri.replace('{pic}',orgData.pic).replace('{uid}', app.User.identity.uuid);
return (
this.request(uri, endpoint.method, {
status: 'pending',
organisationLink: '/applicant/{pic}'.replace('{pic}',orgData.pic)
})
.then( async serverData => {
return(serverData.payload)
})
)
}
requestOrganisationAccess(orgData) {
if(!this.hasPrivilege('apply')) return( new Promise((resolve, reject) => reject()));
let endpoint = this.getApiEndpoint('apply')
let uri = endpoint.uri.replace('{pic}',orgData.pic).replace('{uid}', app.User.identity.uuid);
return (
this.request(uri, endpoint.method, {
status: 'pending',
organisationLink: '/applicant/{pic}'.replace('{pic}',orgData.pic)
})
.then( async serverData => {
return(serverData.payload)
})
)
}
// MFA: needed here ? handled thru dashboard
// Nike: Yes, good place, for rel2
acceptRegistrationAccess(uid, pic) {
if(!this.hasPrivilege('grant')) return( new Promise((resolve, reject) => reject()));
let endpoint = this.getApiEndpoint('grant').replace('{pic}',pic).replace('{uid}', app.User.identity.uuid);
let uri = endpoint.uri
return (
this.request(uri, endpoint.method, {
status: 'pending',
organisationLink: '/applicant/{pic}'.replace('{pic}',pic)
} )
.then( async serverData => {
return(serverData.payload)
})
)
}
// MFA: needed here ? handled thru dashboard
// Nike: Yes, good place, for rel2
denyRegistrationAccess(uid, pic) {
if(!this.hasPrivilege('revoke')) return( new Promise((resolve, reject) => reject()));
let endpoint = this.getApiEndpoint('revoke').replace('{pic}',pic).replace('{uid}', app.User.identity.uuid);
let uri = endpoint.uri
return (
this.request(uri, endpoint.method, {
status: 'pending',
organisationLink: '/applicant/{pic}'.replace('{pic}',pic)
} )
.then( async serverData => {
return(serverData.payload)
})
)
}
}
app.registerClass('onboardingUserModel', onboardingUserModel);