- Refused User

- Report User
- Unblock User
- refresh tables when an action (setFriends and setGroups) occurred.
- fix duplicate call of loadsite
This commit is contained in:
paoloar77
2022-08-08 16:34:30 +02:00
parent ce20daed6d
commit 4cde86c113
15 changed files with 155 additions and 14 deletions

View File

@@ -55,6 +55,13 @@ const webpackDevConfig = {
new webpack.NamedModulesPlugin(),
],
devServer: {
/*
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
*/
contentBase: path.join(__dirname, 'dist'),
port: 5000,
historyApiFallback: true,

View File

@@ -16,6 +16,7 @@ export const shared_consts = {
},
QUERYTYPE_MYGROUP: 1,
QUERYTYPE_REFUSED_USER_GRP: 2,
ALL_SAW_AND_ACCEPTED: 3,
@@ -55,6 +56,7 @@ export const shared_consts = {
REFUSE_REQ_FRIEND: 145,
CANCEL_REQ_FRIEND: 146,
BLOCK_USER: 155,
UNBLOCK_USER: 156,
REPORT_USER: 158,
FIND_PEOPLE: 166,
},
@@ -889,6 +891,7 @@ export const shared_consts = {
ID_FRIENDS_REFUSED: 4,
ID_FRIENDS_ACCEPTED_MY_REQUEST: 8,
ID_FRIENDS_REPORTED: 16,
ID_FRIENDS_UNBLOCKED: 32,
TYPEDIR_GROUPS: 4,
ID_GROUP_NEW_REC: 1,

View File

@@ -841,6 +841,17 @@ export default defineComponent({
refresh()
})
watch(() => userStore.updateTables, (newval, oldval) => {
if (newval && (myvertical.value === costanti.VISUTABLE_USER_TABGROUP ||
myvertical.value === costanti.VISUTABLE_SCHEDA_GROUP ||
myvertical.value === costanti.VISUTABLE_SCHEDA_USER ||
(props.showType === costanti.SHOW_USERINFO))) {
refresh()
userStore.updateTables = false
}
})
/*watch(() => myfilterand.value, (newval, oldval) => {
refresh()
})*/

View File

@@ -42,12 +42,15 @@
<q-item-label>
<q-btn rounded :icon="userStore.IsMyGroupByGroupname(grp.groupname) ? `fas fa-ellipsis-h` : `fas fa-user`">
<q-menu>
<q-list v-if="(!userStore.IsMyGroupByGroupname(grp.groupname) && !userStore.IsAskedGroupByGroupname(grp.groupname))" style="min-width: 200px">
<q-list v-if="(!userStore.IsMyGroupByGroupname(grp.groupname) && !userStore.IsAskedGroupByGroupname(grp.groupname) && !userStore.IsRefusedGroupByGroupname(grp.groupname))" style="min-width: 200px">
<q-item clickable v-close-popup @click="tools.setCmd($q, shared_consts.GROUPSCMD.REQGROUP, myusername(), true, grp.groupname)">
<q-item-section>{{ $t('groups.ask_group') }}</q-item-section>
</q-item>
</q-list>
<q-list v-else-if="(!userStore.IsMyGroupByGroupname(grp.groupname) && userStore.IsAskedGroupByGroupname(grp.groupname))" style="min-width: 200px">
<q-list v-else-if="(!userStore.IsMyGroupByGroupname(grp.groupname) && userStore.IsAskedGroupByGroupname(grp.groupname) && !userStore.IsRefusedGroupByGroupname(grp.groupname))" style="min-width: 200px">
<q-item clickable v-close-popup @click="tools.setCmd($q, shared_consts.GROUPSCMD.REQGROUP, myusername(), false, grp.groupname)">
<q-item-section>{{ $t('groups.refuse_ask_group') }}</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="tools.setCmd($q, shared_consts.GROUPSCMD.REQGROUP, myusername(), false, grp.groupname)">
<q-item-section>{{ $t('groups.cancel_ask_group') }}</q-item-section>
</q-item>
@@ -85,6 +88,10 @@
<q-btn rounded icon="fas fa-ellipsis-h">
<q-menu>
<q-list style="min-width: 150px">
<q-item clickable icon="fas fa-user-minus" v-close-popup
@click="tools.setCmd($q, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, myusername(), '', grp.groupname)">
<q-item-section>{{ $t('groups.refuse_ask_group') }}</q-item-section>
</q-item>
<q-item clickable icon="fas fa-user-minus" v-close-popup
@click="tools.setCmd($q, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, myusername(), '', grp.groupname)">
<q-item-section>{{ $t('groups.cancel_ask_group') }}</q-item-section>
@@ -104,6 +111,9 @@
</q-item>
</q-list>
<q-list v-else-if="(!userStore.IsMyGroupByGroupname(grp.groupname) && userStore.IsAskedGroupByGroupname(grp.groupname))" style="min-width: 200px">
<q-item clickable v-close-popup @click="tools.setCmd($q, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, myusername(), false, grp.groupname)">
<q-item-section>{{ $t('groups.refuse_ask_group') }}</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="tools.setCmd($q, shared_consts.GROUPSCMD.REQGROUP, myusername(), false, grp.groupname)">
<q-item-section>{{ $t('groups.cancel_ask_group') }}</q-item-section>
</q-item>

View File

@@ -72,13 +72,21 @@
</q-item>
</q-list>
<q-list style="min-width: 200px">
<q-item clickable v-close-popup
@click="tools.refuseReqGroup($q, contact.username, groupname)">
<q-item-section avatar>
<q-icon color="negative" name="fas fa-user-minus"/>
</q-item-section>
<q-item-section>{{ $t('groups.refuse_ask_group') }}</q-item-section>
</q-item>
<q-item clickable v-close-popup
@click="tools.cancelReqGroups($q, contact.username, groupname)">
<q-item-section avatar>
<q-icon color="negative" name="fas fa-user-minus"/>
</q-item-section>
<q-item-section>{{ $t('groups.refuse_ask_group_short') }}</q-item-section>
<q-item-section>{{ $t('groups.cancel_ask_group_short') }}</q-item-section>
</q-item>
</q-list>
</q-menu>
@@ -86,10 +94,10 @@
</q-item-label>
</q-item-section>
<q-item-section side v-else-if="visu === costanti.REQ_REMOVE_USER_TO_GROUP">
<q-item-label>
<q-item-label v-if="contact.username !== userStore.my.username">
<q-btn rounded icon="fas fa-ellipsis-h">
<q-menu>
<q-list v-if="true" style="min-width: 150px">
<q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="tools.removeFromMyGroups($q, contact.username, groupname)">
<q-item-section avatar>
<q-icon color="negative" name="fas fa-user-minus"/>

View File

@@ -95,6 +95,7 @@ export interface IUserProfile {
// in memory
asked_friends: any[]
asked_groups: any[]
refused_groups: any[]
list_usersgroup?: IFriends[]
}
@@ -179,4 +180,5 @@ export interface IUserState {
usersList?: IUserFields[]
countusers?: number
lastparamquery?: any
updateTables?: boolean
}

View File

@@ -17,6 +17,7 @@ import { useNotifStore } from '@store/NotifStore'
import { INotif } from 'model'
import { IUserFields } from '@model/UserStore'
import { useI18n } from '@/boot/i18n'
import MixinUsers from '@/mixins/mixin-users'
export default defineComponent({
name: 'userPanel',
@@ -57,6 +58,8 @@ export default defineComponent({
const userStore = useUserStore()
const notifStore = useNotifStore()
const { getMyUsername } = MixinUsers()
async function mounted() {
//
search.value = tools.getCookie(tools.COOK_SEARCH + 'searchpanel')
@@ -141,6 +144,7 @@ export default defineComponent({
listnotif,
listnotiftype,
listnotifid,
getMyUsername,
}
}
})

View File

@@ -104,6 +104,11 @@
da: {{ myuser.username_who_report }}<br>
in Data: {{ tools.getstrshortDateTime(myuser.date_report) }} </em>
</q-banner>
<q-btn color="green" :label="`Sblocca ` + myuser.username" @click="tools.unblockUser($q, getMyUsername(), myuser.username)"></q-btn>
</div>
<div v-else>
<q-btn color="red" :label="`Segnala Utente ` + myuser.username" @click="tools.reportUser($q, getMyUsername(), myuser.username)"></q-btn>
</div>

View File

@@ -200,7 +200,8 @@ const msg_it = {
domanda_removegroup: 'Rimuovere dal Gruppo {username} ?',
removedfriend: 'Rimosso dalla lista di Amici',
removedgroup: 'Rimosso dal Gruppo',
refusedgroup: 'Rifiutato richiesta di entrare nel Gruppo',
refusedgroup: 'Rifiutato a {username} la richiesta di entrare nel Gruppo',
youarerefusedgroup: 'Ti è stato rifiutata la richiesta di entrare in questo Gruppo (per info chiedi all\'amministratore del gruppo)',
deletedgroup: 'Gruppo Eliminato',
domanda_addtofriend: 'Aggiungere agli amici {username}?',
domanda_addtogroup: 'Aggiungi {username} al gruppo {groupname}?',
@@ -214,6 +215,7 @@ const msg_it = {
askedtogroup: 'Chiesto l\'invito al Gruppo {groupname}',
domanda_revoke_friend: 'Revocare la richiesta di Amicizia a {username}?',
domanda_revoke_group: 'Revocare la richiesta al gruppo {groupname}?',
domanda_refuse_group: 'Rifiutare la richiesta di {username} per entrare nel gruppo {groupname}?',
revoketofriend: 'Revocato la richiesta di Amicizia a {username}',
revoketogroup: 'Revocato la richiesta d\'invito al gruppo {groupname}',
domanda_cancel_req_friend: 'Annullare la richiesta di Amicizia a {username}?',
@@ -223,10 +225,12 @@ const msg_it = {
domanda_rejectedtrust: 'Rifiutare la Fiducia a {username}?',
rejected: 'Rifiutato la Fiducia',
domanda_blockuser: 'Bloccare {username}?',
domanda_unblockuser: 'Sbloccare {username}?',
domanda_reportuser: 'Segnalare l\'utente {username}?',
domanda_blockgroup: 'Bloccare il gruppo {groupname}?',
reporteduser: 'Utente Segnalato',
blockedfriend: 'Utente Bloccato',
unblockedfriend: 'Utente Sbloccato',
domanda: 'Domanda',
},
components: {
@@ -1017,6 +1021,7 @@ const msg_it = {
remove_from_mygroups: 'Rimuovi dal Gruppo',
block_group: 'Blocca Gruppo',
cancel_ask_group: 'Annulla la richiesta',
refuse_ask_group: 'Rifiuta la richiesta (con avviso)',
cancel_ask_group_short: 'Annulla richiesta',
refuse_ask_group_short: 'Rifiuta la richiesta',
pwd: 'Password per accedere',

View File

@@ -4672,6 +4672,22 @@ export const tools = {
})
},
unblockUser($q: any, username: string, usernameDest: string) {
const userStore = useUserStore()
$q.dialog({
message: t('db.domanda_unblockuser', { username: usernameDest }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
}).onOk(() => {
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.UNBLOCK_USER, null).then((res: any) => {
if (res) {
tools.showPositiveNotif($q, t('db.unblockedfriend'))
}
})
})
},
reportUser($q: any, username: string, usernameDest: string) { // Segnala Profilo
const userStore = useUserStore()
$q.dialog({
@@ -4740,7 +4756,7 @@ export const tools = {
const userStore = useUserStore()
const notifStore = useNotifStore()
$q.dialog({
message: t('db.domanda_revoke_group', { groupname: groupnameDest }),
message: t('db.domanda_refuse_group', { username, groupname: groupnameDest }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
@@ -4750,7 +4766,7 @@ export const tools = {
if (res) {
notifStore.updateNotification = true
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
tools.showPositiveNotif($q, t('db.refusedgroup'))
tools.showPositiveNotif($q, t('db.refusedgroup', { username }))
}
})
})
@@ -5526,6 +5542,7 @@ export const tools = {
userStore.my.profile.list_usersgroup = ris.listUsersGroup ? ris.listUsersGroup : []
userStore.groups = ris.listgroups ? ris.listgroups : []
userStore.my.profile.asked_groups = ris.listSentRequestGroups ? ris.listSentRequestGroups : []
userStore.my.profile.refused_groups = ris.listRefusedGroups ? ris.listRefusedGroups : []
return [{ userId: userStore.my._id }]
}
})

View File

@@ -60,9 +60,14 @@ export const useNotifStore = defineStore('NotifStore', {
// just to give more context for this demo.
const countNow = this.getnumNotifUnread()
// @ts-ignore
await navigator.setAppBadge(countNow)
.catch((error: any) => { /* ... */ });
try {
// @ts-ignore
await navigator.setAppBadge(countNow)
.catch((error: any) => { /* ... */
});
}catch (e) {
}
},
setAllRead(username: string) {

View File

@@ -56,6 +56,7 @@ export const DefaultUser: IUserFields = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
refused_groups: [],
notifs: [],
notif_idCities: [],
notif_provinces: [],
@@ -107,6 +108,7 @@ export const DefaultProfile: IUserProfile = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
refused_groups: [],
notifs: [],
notif_idCities: [],
notif_provinces: [],
@@ -137,6 +139,7 @@ export const useUserStore = defineStore('UserStore', {
usersList: [],
countusers: 0,
lastparamquery: {},
updateTables: false,
}),
getters: {
@@ -220,6 +223,13 @@ export const useUserStore = defineStore('UserStore', {
return false
},
IsRefusedGroupByGroupname(groupname: string): boolean {
if (this.my.profile.refused_groups)
return this.my.profile.refused_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
@@ -538,6 +548,7 @@ export const useUserStore = defineStore('UserStore', {
this.my.profile.manage_mygroups = []
this.my.profile.asked_friends = []
this.my.profile.asked_groups = []
this.my.profile.refused_groups = []
}
this.isAdmin = tools.isBitActive(this.my.perm, shared_consts.Permissions.Admin.value)
@@ -765,7 +776,7 @@ export const useUserStore = defineStore('UserStore', {
this.updateLocalStorage(myuser)
globalStore.loadSite()
// globalStore.loadSite()
}
}
@@ -1108,6 +1119,7 @@ export const useUserStore = defineStore('UserStore', {
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) => {
this.updateTables = true
return res.data
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))
@@ -1119,6 +1131,7 @@ 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) => {
this.updateTables = true
return res.data
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))

View File

@@ -724,7 +724,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
},
async loadAfterLogin() {
// console.log('loadAfterLogin')
console.log('loadAfterLogin')
this.clearDataAfterLoginOnlyIfActiveConnection()
let isok = false

View File

@@ -168,6 +168,13 @@ export default defineComponent({
}
}
function extraparams_refused() {
return {
querytype: shared_consts.QUERYTYPE_REFUSED_USER_GRP,
myid: mygrp.value ? mygrp.value._id : '',
}
}
function numUsers() {
return users_in_group.value ? users_in_group.value.length : 0
}
@@ -206,6 +213,7 @@ export default defineComponent({
colmyUserGroup,
extraparams,
extraparams_rich,
extraparams_refused,
tab,
tabgrp,
numUsers,

View File

@@ -26,9 +26,20 @@
{{ mygrp.groupname }}
</div>
<q-banner
v-if="userStore.IsRefusedGroupByGroupname(mygrp.groupname)"
rounded
class="bg-red text-white"
style="text-align: center;"
>
<em style="font-weight: bold">{{ $t('db.youarerefusedgroup') }}</em><br>
</q-banner>
<div>
<q-btn
v-if="!userStore.IsMyGroupByGroupname(mygrp.groupname) && !userStore.IsAskedGroupByGroupname(mygrp.groupname)"
v-if="!userStore.IsMyGroupByGroupname(mygrp.groupname) && !userStore.IsAskedGroupByGroupname(mygrp.groupname) && !userStore.IsRefusedGroupByGroupname(mygrp.groupname)"
icon="fas fa-user-plus"
color="primary" :label="$t('groups.ask_group')"
@click="tools.setRequestGroup($q, userStore.my.username, mygrp.groupname, true)"
@@ -84,6 +95,7 @@
<q-tab v-if="userStore.IsMyGroupByGroupname(mygrp.groupname) || tools.iAmAdminGroup(groupname)"
label="Iscritti" name="membri" icon="fas fa-users"></q-tab>
<q-tab v-if="tools.iAmAdminGroup(groupname)" label="Richieste" name="rich" icon="fas fa-user-plus"></q-tab>
<q-tab v-if="tools.iAmAdminGroup(groupname)" label="Rifiutati" name="refused" icon="fas fa-user-minus"></q-tab>
</q-tabs>
<q-tab-panels v-model="tabgrp" animated>
@@ -227,6 +239,37 @@
:visufind="costanti.REQ_ADD_USER_TO_GROUP"
>
</CGridTableRec>
</q-tab-panel>
<q-tab-panel name="refused">
<CGridTableRec
prop_mytable="mygroups"
prop_mytitle=""
:prop_mycolumns="colmyUserPeople"
prop_colkey="_id"
col_title=""
:vertical="costanti.VISUTABLE_USER_TABGROUP"
nodataLabel="Nessun utente Rifiutato"
:prop_search="false"
hint="Username da trovare"
:finder="false"
:choose_visutype="false"
:finder_noNull="false"
:options="shared_consts.OPTIONS_SEARCH_USER_ALL_WORDS"
:butt_modif_new="false"
noresultLabel="Username non trovato"
:arrfilters="arrfilterand"
:filtercustom="filtercustom_rich"
:prop_searchList="searchList"
:showType="costanti.SHOW_USERINFO"
keyMain=""
:showCol="false"
:extraparams="extraparams_refused()"
:extrafield="groupname"
:visufind="costanti.REQ_ADD_USER_TO_GROUP"
>
</CGridTableRec>
</q-tab-panel>
</q-tab-panels>