From 5c671eb0d3bcecf5b205170cf65eb6280081aeb2 Mon Sep 17 00:00:00 2001 From: Gabriel Pastori <58153955+gabrielpastori1@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:52:52 -0300 Subject: [PATCH] group controller --- src/components/instance/message/MyGroups.vue | 21 +- src/components/modal/ConnectPhone.vue | 22 +- src/components/modal/GroupModal.vue | 218 +++++++++++++++++++ src/services/instanceGroupController.js | 32 ++- src/views/Home.vue | 1 - 5 files changed, 290 insertions(+), 4 deletions(-) create mode 100644 src/components/modal/GroupModal.vue diff --git a/src/components/instance/message/MyGroups.vue b/src/components/instance/message/MyGroups.vue index ef22df9..2328268 100644 --- a/src/components/instance/message/MyGroups.vue +++ b/src/components/instance/message/MyGroups.vue @@ -45,6 +45,12 @@ value: 'creation', align: 'center', }, + { + title: '', + value: 'action', + align: 'center', + sortable: false, + }, ]" :items="groups" :no-data-text="loading ? '' : 'Nenhum grupo encontrado'" @@ -75,13 +81,22 @@ - + + + + diff --git a/src/components/modal/ConnectPhone.vue b/src/components/modal/ConnectPhone.vue index da593dc..831e398 100644 --- a/src/components/modal/ConnectPhone.vue +++ b/src/components/modal/ConnectPhone.vue @@ -25,6 +25,19 @@ mdi-qrcode-remove + + mdi-refresh + Atualizar + {{ Array.isArray(error) ? error.join(", ") : error }} @@ -54,6 +67,7 @@ export default { success: false, timeout: null, + disabledRefresh: false, AppStore: useAppStore(), }), @@ -62,6 +76,7 @@ export default { try { this.loading = true; this.error = false; + clearTimeout(this.timeout); const response = await instanceController.connect( this.instance.instance.instanceName @@ -72,9 +87,14 @@ export default { this.dialog = false; this.AppStore.reconnect(); return; - } else throw new Error("Não foi possível carregar o QR Code, se o erro persistir, reinicie a API e tente novamente."); + } else + throw new Error( + "Não foi possível carregar o QR Code, se o erro persistir, reinicie a API e tente novamente." + ); this.timeout = setTimeout(this.loadQr, 40000); + this.disabledRefresh = true; + setTimeout(() => (this.disabledRefresh = false), 5000); } catch (e) { this.error = e.message?.message || e.message || e; } finally { diff --git a/src/components/modal/GroupModal.vue b/src/components/modal/GroupModal.vue new file mode 100644 index 0000000..33773ee --- /dev/null +++ b/src/components/modal/GroupModal.vue @@ -0,0 +1,218 @@ + + + diff --git a/src/services/instanceGroupController.js b/src/services/instanceGroupController.js index 1755960..b9dab14 100644 --- a/src/services/instanceGroupController.js +++ b/src/services/instanceGroupController.js @@ -14,6 +14,36 @@ const getAll = async (instanceName) => { }); } +const getById = async (instanceName, groupId) => { + return await http + .get(`/group/findGroupInfos/:instance/?groupJid=${groupId}`, { + params: { instance: instanceName } + }) + .then((r) => r.data) + .catch((error) => { + throw error.response?.data || error.response || error; + }); +} + + +const updateParticipant = async (instanceName, groupId, action, participants) => { + return await http + .put(`/group/updateParticipant/:instance/?groupJid=${groupId}`, { + action, + participants // Array of participants phone numbers + }, { + params: { instance: instanceName } + }) + .then((r) => r.data) + .catch((error) => { + throw error.response?.data || error.response || error; + }); +} + + + export default { - getAll: getAll + getAll: getAll, + getById: getById, + updateParticipant: updateParticipant } \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index e69ec85..a5ca4c0 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -171,7 +171,6 @@ export default { watch: {}, computed: { loading() { - debugger; return this.loadingInner || this.AppStore.connecting; },