unclean SPARC
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
class MarklogicModel extends EICModel {
|
||||
|
||||
entityTypes = [
|
||||
{
|
||||
ref: '',
|
||||
label: '(entity)',
|
||||
icon: '',
|
||||
filters: [ ]
|
||||
},
|
||||
{
|
||||
ref: 'person',
|
||||
label: 'Person',
|
||||
icon: '',
|
||||
filters: [ 'id', 'euLogin', 'email' ]
|
||||
},
|
||||
{
|
||||
ref: 'application',
|
||||
label: 'App',
|
||||
icon: '',
|
||||
filters: [ ]
|
||||
},
|
||||
{
|
||||
ref: 'evaluation',
|
||||
label: 'SP Evaluation',
|
||||
icon: '',
|
||||
filters: [ ]
|
||||
},
|
||||
{
|
||||
ref: 'organisation',
|
||||
label: 'Organisation',
|
||||
icon: '',
|
||||
filters: [ 'id', 'pic' ]
|
||||
}
|
||||
]
|
||||
|
||||
payload = {
|
||||
entities: [],
|
||||
relations: []
|
||||
};
|
||||
|
||||
constructor(privileges) {
|
||||
|
||||
super('explorer', privileges);
|
||||
|
||||
}
|
||||
|
||||
getType(type) { return this.entityTypes.find(item => item.ref == type) || this.entityTypes.find(item => item.ref == ''); }
|
||||
|
||||
filters() {
|
||||
//if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('filters');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
search(filters) {
|
||||
//if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('search');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, filters)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('MarklogicModel', MarklogicModel);
|
||||
|
||||
/* Leftovers
|
||||
|
||||
addPerson() {
|
||||
let fnames = ['Mike', 'Marc', 'Nico', 'John', 'Jack', 'Sam', 'Steve', 'Mary', 'July']
|
||||
let lnames = ['Myers', 'Vandenbroek', 'Dumoulin', 'Smith', 'Yamaha', 'Roland', 'Jones', 'Flintstone', 'Moog']
|
||||
|
||||
let fname = fnames[Math.floor(Math.random() * fnames.length)]
|
||||
let lname = lnames[Math.floor(Math.random() * lnames.length)]
|
||||
let item = {
|
||||
id: crypto.randomUUID().substring(0,8),
|
||||
label: fname + ' ' + lname,
|
||||
type: 'person',
|
||||
userProfile: {
|
||||
euLogin: lname.substring(0,5).toLowerCase() + fname.substring(0,2).toLowerCase(),
|
||||
roles: [
|
||||
{
|
||||
role: [
|
||||
{
|
||||
referenceItemKey: {
|
||||
key: "dK1kTbD_kSAS64tAxGB4LoQ",
|
||||
_value: "ByPass Project Officer"
|
||||
}
|
||||
},
|
||||
{
|
||||
referenceItemKey: {
|
||||
key: "dlcsLwB2vQMOPEXN5D8PUQg",
|
||||
_value: "EIC Developer"
|
||||
}
|
||||
},
|
||||
{
|
||||
referenceItemKey: {
|
||||
key: "d3XJP_8OETQyb4Qqmip2ypw",
|
||||
_value: "EIC_Admin"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
information: {
|
||||
gender: {
|
||||
referenceItemKey: {
|
||||
key: "dKQGjloGhSbGlOKIiABV8eQ",
|
||||
_value: "M"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
firstName: fname,
|
||||
lastName: lname
|
||||
},
|
||||
contacts: {
|
||||
email: fname + '.' + lname + '@someemail.com',
|
||||
phone: '+324' + Math.random().toString().slice(2,8)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
this.payload.entities.push(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
addOrg() {
|
||||
let fnames = ['co', 'glass', 'alu', 'art', 'steel', 'eco', 'son', 'digit', 'net', 'tech', 'bio', 'nano', 'tron']
|
||||
let lnames = ['sprl', 'ltd', 'inc.', 'gmbh', 'intl.', 'sa']
|
||||
|
||||
let name = fnames[Math.floor(Math.random() * fnames.length)] + fnames[Math.floor(Math.random() * fnames.length)] + ' ' + lnames[Math.floor(Math.random() * lnames.length)]
|
||||
|
||||
let item = {
|
||||
id: crypto.randomUUID().substring(0,8),
|
||||
label: name,
|
||||
type: 'organisation',
|
||||
information: {
|
||||
pic: '8' + Math.random().toString().slice(2,8),
|
||||
legalName: name
|
||||
},
|
||||
statusHistory: [
|
||||
{
|
||||
status: {
|
||||
value: "created",
|
||||
dateTime: "2023-07-18T15:27:06.397381Z",
|
||||
changedByKey: "d4rP8zgrURMiAAv-StY9YKQ"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.payload.entities.push(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
addLink(org, person) {
|
||||
if(!this.payload.relations.find(
|
||||
item => (item.source == org.id && item.target == person.id) || (item.target == org.id && item.source == person.id))) {
|
||||
let relation = {
|
||||
source: org.id,
|
||||
target: person.id
|
||||
}
|
||||
|
||||
this.payload.relations.push(relation)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,176 @@
|
||||
class PlatformModel extends EICBusModel {
|
||||
|
||||
getUsers() {
|
||||
return(
|
||||
this.busWssGwRequest('GETACTIVEUSERS')
|
||||
.then(
|
||||
list => {
|
||||
if(!list) list = []
|
||||
list.sort((a,b) => {
|
||||
if(a.family_name<b.family_name) return(-1)
|
||||
else if(a.family_name>b.family_name) return(1)
|
||||
else if(a.given_name<b.given_name) return(-1)
|
||||
else return(1)
|
||||
})
|
||||
return(list)
|
||||
},
|
||||
() => [] // Empty list on connection timeout
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
getPlatformStatus() {
|
||||
return(
|
||||
this.busWssGwRequest('GETPLATFORMMODE', {}).then(data=>{
|
||||
if(!data) return(null)
|
||||
if(data.platformRestrictions) data.platformRestrictions.allowedUUIDs = data.platformRestrictions.allowedUUIDs || []
|
||||
data.blockedUUIDs = data.blockedUUIDs || []
|
||||
return(data)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
setPlatformStatus(status){
|
||||
app.MessageBus.requestWssGwAction('SETPLATFORMMODE', status)
|
||||
}
|
||||
|
||||
async getDaemonsStatus(){
|
||||
let daemons = {
|
||||
wssGateway:false,
|
||||
httpGateway:false,
|
||||
midas:false
|
||||
}
|
||||
for(let daemon of Object.keys(daemons)){
|
||||
let result = null
|
||||
if(daemon == 'wssGateway'){ //for him, ask direct in wss
|
||||
result = await app.MessageBus.requestWssGwAction('TIME',{}, 200)
|
||||
} else { //all the others we talk via bus
|
||||
try{
|
||||
result = await this.busActionRequest(`infraNotifs:${daemon}`, 'TIME', {}, 200)
|
||||
} catch(err) {
|
||||
console.warn(`Daemon ${daemon} timed out on TIME request ! `)
|
||||
}
|
||||
|
||||
}
|
||||
daemons[daemon] = (result !== null) ? result[`${daemon}Time`] : false
|
||||
}
|
||||
return(daemons)
|
||||
}
|
||||
|
||||
async ban(uid) {
|
||||
let status = await this.getPlatformStatus()
|
||||
if(!status.blockedUUIDs.includes(uid)) status.blockedUUIDs.push(uid)
|
||||
this.setPlatformStatus(status)
|
||||
this.kick(uid)
|
||||
}
|
||||
|
||||
async unban(uid) {
|
||||
let status = await this.getPlatformStatus()
|
||||
let idx = status.blockedUUIDs.indexOf(uid)
|
||||
if(idx>-1) status.blockedUUIDs.splice(idx,1)
|
||||
this.setPlatformStatus(status)
|
||||
}
|
||||
|
||||
async stopPlatform(data){
|
||||
let status = await this.getPlatformStatus()
|
||||
if(status.XX_platformRestrictions) delete(status.XX_platformRestrictions)
|
||||
status.platformRestrictions = {
|
||||
"allowedRoles": data.allowedRoles,
|
||||
"allowedUUIDs": data.allowedUUIDs,
|
||||
}
|
||||
this.setPlatformStatus(status)
|
||||
}
|
||||
|
||||
async startPlatform(data){
|
||||
let status = await this.getPlatformStatus()
|
||||
this.setPlatformStatus({
|
||||
"blockedUUIDs":status.blockedUUIDs
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
growlOne(uid, growlData) {
|
||||
let userNotifChan = app.config.messageBus.userNotifChan.replace(/\{uid\}/g, uid)
|
||||
growlData.growlMessage = growlData.growlMessage.replace(/\n/g,'<br>')
|
||||
this.busEvent(userNotifChan, 'growl', growlData)
|
||||
}
|
||||
|
||||
growlGlobal(growlData) {
|
||||
growlData.growlMessage = growlData.growlMessage.replace(/\n/g,'<br>')
|
||||
this.busEvent('system:notifs', 'growl', growlData)
|
||||
}
|
||||
|
||||
kick(uid) {
|
||||
let userNotifChan = app.config.messageBus.userNotifChan.replace(/\{uid\}/g, uid)
|
||||
this.busEvent(userNotifChan, 'kick')
|
||||
return(
|
||||
this.busWssGwRequest('KILLSESSION', {
|
||||
uids: [ uid ],
|
||||
notRoles : ['EIC_admin', 'EIC_Dev' ],
|
||||
ttl: 0
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
kickAll() {
|
||||
this.busEvent('system:notifs', 'kick')
|
||||
return(
|
||||
this.busWssGwRequest('KILLSESSION', {
|
||||
uids: null,
|
||||
notRoles : ['EIC_admin', 'EIC_Dev' ],
|
||||
ttl: 0
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
refreshWssGwRights(){
|
||||
return(
|
||||
this.busWssGwRequest('RELOADACCESSRIGHTS', {})
|
||||
)
|
||||
}
|
||||
|
||||
viewWssGwRights(){
|
||||
return(
|
||||
this.busWssGwRequest('GETACCESSRIGHTS', {})
|
||||
)
|
||||
}
|
||||
|
||||
refreshHttpGwRights(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:httpGateway', 'RELOADACCESSRIGHTS', {})
|
||||
)
|
||||
}
|
||||
|
||||
viewHttpGwRights(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:httpGateway', 'GETACCESSRIGHTS', {})
|
||||
)
|
||||
}
|
||||
|
||||
refreshMidasConfig(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:midas', 'RELOADCONFIG', {})
|
||||
)
|
||||
}
|
||||
|
||||
viewMidasConfig(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:midas', 'GETCONFIG', {})
|
||||
)
|
||||
}
|
||||
|
||||
refreshMidasPlugins(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:midas', 'RELOADPLUGINS', {})
|
||||
)
|
||||
}
|
||||
|
||||
viewMidasPlugins(){
|
||||
return(
|
||||
this.busActionRequest('infraNotifs:midas', 'LISTPLUGINS', {})
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('PlatformModel', PlatformModel);
|
||||
@@ -0,0 +1,87 @@
|
||||
class SupportModel extends EICModel {
|
||||
|
||||
constructor(privileges) {
|
||||
super('/zammad/tickets', privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
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 => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
get(id) {
|
||||
// if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('get');
|
||||
endpoint.uri = endpoint.uri.replace('{id}', id);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
create(ticket) {
|
||||
//if(!this.hasPrivilege('create')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('create');
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, ticket)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
update(id, content) {
|
||||
//if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('update');
|
||||
endpoint.uri = endpoint.uri.replace('{id}', id);
|
||||
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method, content)
|
||||
.then( async serverData => {
|
||||
return serverData.payload;
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
download(ticketId, articleId, attachmentId) {
|
||||
// if(!this.hasPrivilege('list')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('download');
|
||||
endpoint.uri = endpoint.uri.replace('{ticid}', ticketId);
|
||||
endpoint.uri = endpoint.uri.replace('{artid}', articleId);
|
||||
endpoint.uri = endpoint.uri.replace('{attid}', attachmentId);
|
||||
|
||||
window.open(endpoint.uri, '_blank');
|
||||
}
|
||||
}
|
||||
app.registerClass('SupportModel', SupportModel);
|
||||
Reference in New Issue
Block a user