Circuit table...
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
IColGridTable,
|
||||
IColl,
|
||||
ICollaborations, IDataToSet,
|
||||
IEvents, IFriends, IMyGroup,
|
||||
IEvents, IFriends, IMyGroup, ICircuit,
|
||||
IListRoutes,
|
||||
IParamDialog,
|
||||
IPathFile,
|
||||
@@ -36,6 +36,7 @@ import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import { useProjectStore } from '@store/Projects'
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useCalendarStore } from '@store/CalendarStore'
|
||||
import { Router } from 'vue-router'
|
||||
import { AxiosResponse, default as Axios } from 'axios'
|
||||
@@ -65,6 +66,7 @@ export const tools = {
|
||||
|
||||
FRIENDS_SEARCH: 'FR_SE',
|
||||
GROUP_SEARCH: 'GR_SE',
|
||||
CIRCUIT_SEARCH: 'CI_SE',
|
||||
|
||||
getprefCountries: ['it', 'es', 'us'],
|
||||
|
||||
@@ -5159,6 +5161,28 @@ export const tools = {
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
iAmAdminCircuit(name: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
|
||||
if (circuit.name === name) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
// console.log('ris', ris)
|
||||
if (ris && ris.admins) {
|
||||
const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username)
|
||||
risultato = !!isadmin
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
|
||||
iAmPartOfThisGroup(grp: IMyGroup) {
|
||||
@@ -5238,6 +5262,68 @@ export const tools = {
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
iAmTheCreatorOfTheCircuit(name: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
|
||||
if (circuit.name === name) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
// console.log('ris', ris)
|
||||
return (ris && ris.createdBy === userStore.my.username)
|
||||
|
||||
}
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
|
||||
isUserTheCreatorOfThCircuit(name: string, username: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
|
||||
if (circuit.name === name) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
// console.log('ris', ris)
|
||||
return (ris && ris.createdBy === username)
|
||||
|
||||
}
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
|
||||
isUserAdminCircuit(name: string, username: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
|
||||
if (circuit.name === name) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
// console.log('ris', ris)
|
||||
if (ris && ris.admins) {
|
||||
const isadmin = ris.admins.find((user: IFriends) => user.username === username)
|
||||
risultato = !!isadmin
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return risultato
|
||||
|
||||
},
|
||||
|
||||
setCmd($q: any, cmd: number, username: string, value: any, dest: string) {
|
||||
@@ -5457,6 +5543,15 @@ export const tools = {
|
||||
link_telegram: '',
|
||||
}
|
||||
},
|
||||
getdefaultnewrec_Circuit(): any {
|
||||
return {
|
||||
_id: 0,
|
||||
name: '',
|
||||
subname: '',
|
||||
img_logo: '',
|
||||
admins: [],
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getdefaultnewrec_MyBacheca(): any {
|
||||
@@ -5508,6 +5603,8 @@ export const tools = {
|
||||
return 'mygood'
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
return 'grp'
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
return 'circuit'
|
||||
}
|
||||
|
||||
return ''
|
||||
@@ -5516,6 +5613,8 @@ export const tools = {
|
||||
getFullFileName(arrimage: IImgGallery[], table: string, username: string, groupname: string) {
|
||||
if (shared_consts.TABLES_DIRECTORY_A_PARTE.includes(table)) {
|
||||
return `upload/${table}/` + groupname + '/' + arrimage[0].imagefile
|
||||
} else if (shared_consts.TABLES_DIRECTORY_SINGLE_IMG.includes(table)) {
|
||||
return `upload/${table}/` + groupname + '/' + arrimage[0].imagefile
|
||||
} else {
|
||||
if (arrimage && arrimage.length > 0) {
|
||||
return 'upload/profile/' + username + '/' + table + '/' + arrimage[0].imagefile
|
||||
@@ -5533,7 +5632,7 @@ export const tools = {
|
||||
if ((userStore.isAdmin || userStore.isManager))
|
||||
return true
|
||||
|
||||
if (tablesel === toolsext.TABMYGROUPS) {
|
||||
if (shared_consts.TABLES_WITH_ADMINS.includes(tablesel)) {
|
||||
// is Admin ?
|
||||
if (rec.admins) {
|
||||
const trovato = rec.admins.find((myuser: any) => myuser.username === userStore.my.username)
|
||||
@@ -5561,6 +5660,8 @@ export const tools = {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + rec['_id']
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
return '/grp/' + rec.groupname
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
return '/circuit/' + rec.name
|
||||
}
|
||||
|
||||
return ''
|
||||
@@ -5570,6 +5671,10 @@ export const tools = {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + grp.groupname
|
||||
},
|
||||
|
||||
getPathByCircuit(grp: any, table: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + grp.name
|
||||
},
|
||||
|
||||
getPathByTable(table: string, pagename: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + pagename
|
||||
},
|
||||
@@ -5693,6 +5798,30 @@ export const tools = {
|
||||
return []
|
||||
},
|
||||
|
||||
async loadCircuits() {
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
// Carica il profilo di quest'utente
|
||||
|
||||
await userStore.loadCircuits().then((ris) => {
|
||||
// console.log('ris', ris)
|
||||
if (ris) {
|
||||
|
||||
circuitStore.listcircuits = ris.listcircuits ? ris.listcircuits : []
|
||||
|
||||
// to Refresh Data User Accounts:
|
||||
userStore.my.profile.listUserAccounts = ris.listUserAccounts ? ris.listUserAccounts : []
|
||||
|
||||
// Others not loaded at the beginning:
|
||||
userStore.my.profile.asked_circuits = ris.listSentRequestCircuits ? ris.listSentRequestCircuits : []
|
||||
userStore.my.profile.refused_circuits = ris.listRefusedCircuits ? ris.listRefusedCircuits : []
|
||||
return [{ userId: userStore.my._id }]
|
||||
}
|
||||
})
|
||||
|
||||
return []
|
||||
},
|
||||
|
||||
async loadrecProfile() {
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
Reference in New Issue
Block a user