From 4cde86c1139556da79c7c6ef806e2cdd90016e18 Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Mon, 8 Aug 2022 16:34:30 +0200 Subject: [PATCH] - Refused User - Report User - Unblock User - refresh tables when an action (setFriends and setGroups) occurred. - fix duplicate call of loadsite --- config/webpack.config.dev.js | 7 +++ src/common/shared_vuejs.ts | 3 ++ src/components/CGridTableRec/CGridTableRec.ts | 11 +++++ src/components/CMyGroup/CMyGroup.vue | 14 +++++- src/components/CMyUser/CMyUser.vue | 14 ++++-- src/model/UserStore.ts | 2 + src/rootgen/admin/userPanel/userPanel.ts | 4 ++ src/rootgen/admin/userPanel/userPanel.vue | 5 +++ src/statics/lang/it.js | 7 ++- src/store/Modules/tools.ts | 21 ++++++++- src/store/NotifStore.ts | 11 +++-- src/store/UserStore.ts | 15 ++++++- src/store/globalStore.ts | 2 +- src/views/user/mygroup/mygroup.ts | 8 ++++ src/views/user/mygroup/mygroup.vue | 45 ++++++++++++++++++- 15 files changed, 155 insertions(+), 14 deletions(-) diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 4a6bc7c1..26793621 100755 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -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, diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index f60962a3..36b4f1e7 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -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, diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index 51a287b0..9ee36e89 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -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() })*/ diff --git a/src/components/CMyGroup/CMyGroup.vue b/src/components/CMyGroup/CMyGroup.vue index 08936de9..b582148c 100755 --- a/src/components/CMyGroup/CMyGroup.vue +++ b/src/components/CMyGroup/CMyGroup.vue @@ -42,12 +42,15 @@ - + {{ $t('groups.ask_group') }} - + + + {{ $t('groups.refuse_ask_group') }} + {{ $t('groups.cancel_ask_group') }} @@ -85,6 +88,10 @@ + + {{ $t('groups.refuse_ask_group') }} + {{ $t('groups.cancel_ask_group') }} @@ -104,6 +111,9 @@ + + {{ $t('groups.refuse_ask_group') }} + {{ $t('groups.cancel_ask_group') }} diff --git a/src/components/CMyUser/CMyUser.vue b/src/components/CMyUser/CMyUser.vue index 074bf3dc..83fbbfc7 100755 --- a/src/components/CMyUser/CMyUser.vue +++ b/src/components/CMyUser/CMyUser.vue @@ -72,13 +72,21 @@ + + + + + + {{ $t('groups.refuse_ask_group') }} + - {{ $t('groups.refuse_ask_group_short') }} + {{ $t('groups.cancel_ask_group_short') }} @@ -86,10 +94,10 @@ - + - + diff --git a/src/model/UserStore.ts b/src/model/UserStore.ts index ccedcf45..dec6ac3d 100755 --- a/src/model/UserStore.ts +++ b/src/model/UserStore.ts @@ -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 } diff --git a/src/rootgen/admin/userPanel/userPanel.ts b/src/rootgen/admin/userPanel/userPanel.ts index f75b022c..1d909c64 100755 --- a/src/rootgen/admin/userPanel/userPanel.ts +++ b/src/rootgen/admin/userPanel/userPanel.ts @@ -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, } } }) diff --git a/src/rootgen/admin/userPanel/userPanel.vue b/src/rootgen/admin/userPanel/userPanel.vue index 5fd64d2c..40b06849 100755 --- a/src/rootgen/admin/userPanel/userPanel.vue +++ b/src/rootgen/admin/userPanel/userPanel.vue @@ -104,6 +104,11 @@ da: {{ myuser.username_who_report }}
in Data: {{ tools.getstrshortDateTime(myuser.date_report) }} + + + +
+
diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index 4fa634d9..dd6690e5 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -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', diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 6643ca15..a38d4976 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -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 }] } }) diff --git a/src/store/NotifStore.ts b/src/store/NotifStore.ts index fa677b98..dc6f2ec7 100755 --- a/src/store/NotifStore.ts +++ b/src/store/NotifStore.ts @@ -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) { diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index 850bdd38..8ef041ef 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -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')) diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index 97d1ab8c..89f45e43 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -724,7 +724,7 @@ export const useGlobalStore = defineStore('GlobalStore', { }, async loadAfterLogin() { - // console.log('loadAfterLogin') + console.log('loadAfterLogin') this.clearDataAfterLoginOnlyIfActiveConnection() let isok = false diff --git a/src/views/user/mygroup/mygroup.ts b/src/views/user/mygroup/mygroup.ts index 87ed7020..c1e26f2c 100755 --- a/src/views/user/mygroup/mygroup.ts +++ b/src/views/user/mygroup/mygroup.ts @@ -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, diff --git a/src/views/user/mygroup/mygroup.vue b/src/views/user/mygroup/mygroup.vue index 42dfdccf..6784531f 100755 --- a/src/views/user/mygroup/mygroup.vue +++ b/src/views/user/mygroup/mygroup.vue @@ -26,9 +26,20 @@ {{ mygrp.groupname }} + + {{ $t('db.youarerefusedgroup') }}
+
+ + +
+ @@ -227,6 +239,37 @@ :visufind="costanti.REQ_ADD_USER_TO_GROUP" > + + + + + +