This commit is contained in:
paoloar77
2022-02-03 00:33:05 +01:00
parent d7480fd489
commit 124cb5cc64
96 changed files with 1944 additions and 2611 deletions

View File

@@ -9,6 +9,10 @@ export const costanti = {
CONFIG_ID_SHOW_TYPE_TODOS: '3',
SHOW_USERINFO: 1,
SHOW_GROUPINFO: 5,
VISUTABLE_SCHEDA_USER: -1,
VISUTABLE_SCHEDA_GROUP: -3,
DIR_UPLOAD: 'upload/', // upload/
@@ -20,7 +24,17 @@ export const costanti = {
ASK_SENT_FRIENDS: 6,
FIND_PEOPLE: 10,
GROUPS: 11,
GRP_REJECTED: 14,
REQ_GROUP: 15,
ASK_SENT_GROUP: 16,
FIND_GROUP: 20,
MY_GROUPS: 21,
CREATE_GROUP: 30,
FILTER_TUTTI: -100,
TABLES_ARRAY: ['mygroups'],
TABLES_USERNAME_DATE: ['friends', 'friendsandme'],
FuncDialog: {
CANCEL_BOOKING: 1,

View File

@@ -368,6 +368,18 @@ export const colTablePhones = [
AddCol({ name: 'flag', label_trans: 'city.flag' }),
]
export const colTableUsersGeneric = [
AddCol({ name: 'username', label_trans: 'reg.username_short' }),
AddCol({ name: 'date', label_trans: 'reg.date', fieldtype: costanti.FieldType.onlydate,
showWhen: costanti.showWhen.InPage + costanti.showWhen.InView_OnlyifExist }),
]
export const colTableMyGroup = [
AddCol({ name: 'groupname', label_trans: 'reg.groupname' }),
AddCol({ name: 'date', label_trans: 'reg.date', fieldtype: costanti.FieldType.onlydate,
showWhen: costanti.showWhen.InPage + costanti.showWhen.InView_OnlyifExist }),
]
export const colSkills = [
// AddCol({ name: '_id', label_trans: 'index', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'descr', label_trans: 'store.description' }),
@@ -408,11 +420,54 @@ export const colmyUserPeople = [
AddCol({ name: 'name', label_trans: 'reg.name' }),
AddCol({
name: 'profile.img', field: 'profile', subfield: 'img', label_trans: 'reg.img', sortable: false,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
}),
// AddCol({ name: 'sospeso', label_trans: 'reg.sospeso', fieldtype: costanti.FieldType.boolean }),
// AddCol({ name: 'deleted', label_trans: 'reg.deleted', fieldtype: costanti.FieldType.boolean }),
]
export const colmyUserGroup = [
// AddCol({ name: '_id', label_trans: 'reg.id' }),
AddCol({ name: 'groupname', label_trans: 'reg.groupname', required: true }),
AddCol({ name: 'title', label_trans: 'reg.name', required: true }),
AddCol({
name: 'idSector',
label_trans: 'sectors.name',
fieldtype: costanti.FieldType.select,
required: true,
jointable: 'sectors',
visible: true,
icon: 'category',
}),
AddCol({ name: 'descr', label_trans: 'proj.longdescr', required: true }),
AddCol({ name: 'visibility', label_trans: 'bot.visibility', fieldtype: costanti.FieldType.select, jointable: 'visibilGroup', required: true }),
AddCol({
name: 'admins',
label_trans: 'groups.admins',
fieldtype: costanti.FieldType.multiselect,
jointable: 'friendsandme',
}),
AddCol({
name: 'photos',
label_trans: 'skill.photos',
fieldtype: costanti.FieldType.listimages,
jointable: '',
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
}),
AddCol({
name: 'idCity',
label_trans: 'skill.city',
fieldtype: costanti.FieldType.multiselect_by_server,
jointable: 'cities',
tablesel: 'cities',
noshowlabel: true,
icon: 'fas fa-map-marker-alt',
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
}),
AddCol({ name: 'date_created', label_trans: 'reg.date_created', fieldtype: costanti.FieldType.onlydate,
showWhen: costanti.showWhen.InPage + costanti.showWhen.InView_OnlyifExist }),
]
export const colmySkills = [
@@ -807,6 +862,11 @@ const colTablePermission = [
AddCol(DuplicateRec),
]
const colTableGeneric = [
AddCol({ name: 'value', label_trans: 'others.value' }),
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
]
const colTableOperator = [
AddCol({ name: 'username', label_trans: 'reg.username_short' }),
AddCol({ name: 'name', label_trans: 'reg.name' }),
@@ -1502,6 +1562,7 @@ export const fieldsTable = {
}),
AddCol({
name: 'profile.img', field: 'profile', subfield: 'img', label_trans: 'reg.img', sortable: false,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
}),
AddCol({ name: 'date_reg', label_trans: 'reg.date_reg', fieldtype: costanti.FieldType.date }),
AddCol({ name: 'lasttimeonline', label_trans: 'reg.lasttimeonline', fieldtype: costanti.FieldType.date }),
@@ -1765,13 +1826,21 @@ export const fieldsTable = {
},
{
value: 'visibility',
label: 'Visibilità',
label: 'Visibilità Permessi',
columns: colTablePermission,
colkey: 'value',
collabel: 'label',
colicon: 'icon',
noshow: true,
},
{
value: 'visibilGroup',
label: 'Visibilità',
columns: colTableGeneric,
colkey: 'value',
collabel: 'label',
noshow: true,
},
{
value: 'lang',
label: 'Lingua',
@@ -1893,6 +1962,27 @@ export const fieldsTable = {
collabel: 'value',
remote: true,
},
{
value: 'friends',
label: 'Amici',
columns: colTableUsersGeneric,
colkey: 'username',
collabel: 'username',
},
{
value: 'friendsandme',
label: 'Amici',
columns: colTableUsersGeneric,
colkey: 'username',
collabel: 'username',
},
{
value: 'mygroups',
label: 'Gruppi',
columns: colTableMyGroup,
colkey: 'groupname',
collabel: 'groupname',
},
],
}

View File

@@ -3,7 +3,7 @@ import {
IColGridTable,
IColl,
ICollaborations, IDataToSet,
IEvents, IFriends,
IEvents, IFriends, IMyGroup,
IListRoutes,
IParamDialog,
IPathFile,
@@ -56,6 +56,7 @@ export const tools = {
COOK_SEARCH: 'SEARCH_',
FRIENDS_SEARCH: 'FR_SE',
GROUP_SEARCH: 'GR_SE',
getprefCountries: ['it', 'es', 'us'],
@@ -4422,6 +4423,26 @@ export const tools = {
})
})
},
addToMyGroups($q: any, username: string, groupnameDest: string) {
const userStore = useUserStore()
$q.dialog({
message: t('db.domanda_addtogroup', { username, groupname: groupnameDest }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
}).onOk(() => {
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.SETGROUP, null)
.then((res: any) => {
if (res) {
userStore.my.profile.groups = [...userStore.my.profile.groups, res]
tools.showPositiveNotif($q, t('db.addedgroup'))
}
})
})
},
setRequestFriendship($q: any, username: string, usernameDest: string, value: boolean) {
const userStore = useUserStore()
@@ -4464,6 +4485,48 @@ export const tools = {
})
})
},
setRequestGroup($q: any, username: string, groupnameDest: string, value: boolean) {
const userStore = useUserStore()
let msg = ''
if (value) {
msg = t('db.domanda_ask_group', { groupname: groupnameDest })
} else {
msg = t('db.domanda_revoke_group', { groupname: groupnameDest })
}
$q.dialog({
message: msg,
ok: {
label: t('dialog.yes'),
push: true
},
cancel: {
label: t('dialog.cancel')
},
title: t('db.domanda')
}).onOk(() => {
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REQGROUP, value)
.then((res: any) => {
if (res) {
if (value) {
// ADD to req Friends
userStore.my.profile.asked_groups.push(res)
tools.showPositiveNotif($q, t('db.askedtogroup', { groupname: groupnameDest }))
} else {
// REMOVE to req Friends
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
tools.showPositiveNotif($q, t('db.revoketogroup', { groupname: groupnameDest }))
}
} else {
tools.showNegativeNotif($q, t('db.recfailed'))
}
})
})
},
cancelReqFriends($q: any, username: string, usernameDest: string) {
const userStore = useUserStore()
$q.dialog({
@@ -4480,6 +4543,23 @@ export const tools = {
}
})
})
},
cancelReqGroups($q: any, username: string, groupnameDest: string) {
const userStore = useUserStore()
$q.dialog({
message: t('db.domanda_cancel_req_group', { groupname: groupnameDest }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
}).onOk(() => {
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, null).then((res) => {
if (res) {
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
tools.showPositiveNotif($q, t('db.cancel_req_group'))
}
})
})
},
CSVToArray(strData: any, strDelimiter: string) {
// Check to see if the delimiter is defined. If not,

View File

@@ -58,6 +58,8 @@ export const func_tools = {
export const toolsext = {
TABUSER: 'users',
TABFRIENDS: 'friends',
TABMYGROUPS: 'mygroups',
TABNAVI: 'navi',
TABLISTAINGRESSO: 'listaingressos',
TABGRADUATORIA: 'graduatorias',
@@ -65,10 +67,10 @@ export const toolsext = {
TABNEWSLETTER: 'newstosent',
TABGALLERY: 'gallery',
TABMAILINGLIST: 'mailinglist',
TABGROUPS: 'groups',
TABMYPAGE: 'mypage',
TABMYBOT: 'mybots',
TABCALZOOM: 'calzoom',
TABGROUPS: 'groups',
TABTEMPLEMAIL: 'templemail',
TABOPZEMAIL: 'opzemail',
TABSHAREWITHUS: 'sharewithus',

View File

@@ -23,6 +23,7 @@ import { Router } from 'vue-router'
import { useProjectStore } from '@store/Projects'
import { shared_consts } from '@/common/shared_vuejs'
import { costanti } from '@costanti'
import { IMyGroup } from '@model/UserStore'
export const DefaultUser: IUserFields = {
_id: '',
@@ -49,7 +50,9 @@ export const DefaultUser: IUserFields = {
myshares: [],
friends: [],
req_friends: [],
groups: [],
asked_friends: [],
asked_groups: [],
},
cart: {
userId: '',
@@ -91,12 +94,15 @@ export const DefaultProfile: IUserProfile = {
myshares: [],
friends: [],
req_friends: [],
groups: [],
asked_friends: [],
asked_groups: [],
}
export const useUserStore = defineStore('UserStore', {
state: () => ({
my: { ...DefaultUser },
groups: [],
lang: process.env.LANG_DEFAULT ? process.env.LANG_DEFAULT : 'it',
repeatPassword: '',
categorySel: 'personal',
@@ -170,6 +176,13 @@ export const useUserStore = defineStore('UserStore', {
return false
},
IsMyGroupByGroupname(groupname: string): boolean {
if (this.my.profile.friends)
return this.my.profile.groups.findIndex((rec) => rec.groupname === groupname) >= 0
else
return false
},
IsAskedFriendByUsername(username: string): boolean {
if (this.my.profile.asked_friends)
return this.my.profile.asked_friends.findIndex((rec) => rec.username === username) >= 0
@@ -177,6 +190,13 @@ export const useUserStore = defineStore('UserStore', {
return false
},
IsAskedGroupByGroupname(groupname: string): boolean {
if (this.my.profile.asked_groups)
return this.my.profile.asked_groups.findIndex((rec: IMyGroup) => rec.groupname === groupname) >= 0
else
return false
},
getUserByUsername(username: string): IUserFields | null {
// Check if is this User!
if (this.my.username === username) return this.my
@@ -210,6 +230,16 @@ export const useUserStore = defineStore('UserStore', {
return 'images/noimg.png'
},
getImgByGroup(group: IMyGroup): string {
try {
//++Todo: Sistemare!
return costanti.DIR_UPLOAD + 'groups/' + group.groupname + '/' + group.photos[0].directory
} catch (e) {
}
return 'images/noimg.png'
},
getRefLink(username: string): string {
if (username === '')
username = this.my.username
@@ -446,6 +476,7 @@ export const useUserStore = defineStore('UserStore', {
// Memory
this.my.profile.asked_friends = []
this.my.profile.asked_groups = []
}
this.isAdmin = tools.isBitActive(this.my.perm, shared_consts.Permissions.Admin.value)
@@ -825,7 +856,7 @@ export const useUserStore = defineStore('UserStore', {
verified_by_aportador,
made_gift,
perm,
profile: { img, teleg_id, myshares: [], friends: [], req_friends: [], asked_friends: [] },
profile: { img, teleg_id, myshares: [], friends: [], req_friends: [], asked_friends: [], groups: [], asked_groups: [] },
})
isLogged = true
@@ -857,6 +888,20 @@ export const useUserStore = defineStore('UserStore', {
},
async loadGroup(groupname: string) {
const data = {
groupname
}
return Api.SendReq('/mygroup/load', 'POST', data)
.then((res) => {
return res.data
}).catch((error) => {
return {}
})
},
async loadSkill(idSkill: string) {
const data = {
idSkill
@@ -881,6 +926,16 @@ export const useUserStore = defineStore('UserStore', {
},
async loadGroups(username: string) {
return Api.SendReq('/users/groups', 'POST', null)
.then((res) => {
return res.data
}).catch((error) => {
return {}
})
},
async setFriendsCmd($q: any, t: any, usernameOrig: string, usernameDest: string, cmd: number, value: any) {
return Api.SendReq('/users/friends/cmd', 'POST', { usernameOrig, usernameDest, cmd, value })
.then((res) => {
@@ -892,6 +947,17 @@ export const useUserStore = defineStore('UserStore', {
},
async setGroupsCmd($q: any, t: any, usernameOrig: string, groupnameDest: string, cmd: number, value: any) {
return Api.SendReq('/users/groups/cmd', 'POST', { usernameOrig, groupnameDest, cmd, value })
.then((res) => {
return res.data
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))
return {}
})
},
async importToServerCmd($q: any, t: any, cmd: number, data: any) {
return Api.SendReq('/admin/import', 'POST', { cmd, data })
.then((res) => {

View File

@@ -219,6 +219,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
return calendarStore.bookedevent
else if (table === 'users')
return userStore.usersList
else if (table === 'friends')
return userStore.my.profile.friends
else if (table === 'friendsandme')
return [{username: userStore.my.username }, ...userStore.my.profile.friends]
else if (table === 'mygroups')
return userStore.groups
else if (table === 'sendmsgs')
return messageStore.last_msgs
else if (table === 'settings')
@@ -1356,12 +1362,22 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (table === 'metodo_pagamento') return tools.SelectMetodiPagamento
if (table === 'bottype') return shared_consts.BotType
if (table === 'visibility') return shared_consts.Visibility
if (table === 'visibilGroup') return shared_consts.VisibilGroup
if (table === 'lang') return shared_consts.Lang
if (table === 'regions') return shared_consts.Regions
if (table === 'provinces') return shared_consts.Provinces
let myarr = this.getListByTable(table)
if (costanti.TABLES_ARRAY.includes(table)) {
const newarr = []
for (const value of myarr) {
newarr.push({value, label:value})
}
myarr = newarr
}
if (addall)
myarr = [costanti.FILTER_TUTTI, ...myarr]