Skip to content

Commit

Permalink
Merge pull request #5 from wkarts/uno-clairton-pr
Browse files Browse the repository at this point in the history
feat: addition of individual parameter manipulation for the WhatsApp Unoapi Provider
  • Loading branch information
clairton authored Jul 29, 2024
2 parents 45ee68a + 94b44ce commit 9e1bde9
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 17 deletions.
60 changes: 60 additions & 0 deletions app/javascript/dashboard/i18n/locale/en/inboxMgmt.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,66 @@
"PLACEHOLDER": "Check to ignore groups messages.",
"ERROR": "Check to ignore groups messages."
},
"GENERATE_API_KEY": {
"LABEL": "Generate API Key",
"PLACEHOLDER": "Generate API Key",
"ERROR": "Generate API Key"
},
"REJECT_CALLS": {
"LABEL": "Reject call",
"PLACEHOLDER": "Reject call.",
"ERROR": "Reject call."
},
"MESSAGE_CALLS_WEBHOOK": {
"LABEL": "Message on reject call",
"PLACEHOLDER": "Message on reject call.",
"ERROR": "Message on reject call."
},
"IGNORE_BROADCAST_STATUSES": {
"LABEL": "Ignore broadcast statuses",
"PLACEHOLDER": "Select to ignore broadcast statuses.",
"ERROR": "Select to ignore broadcast statuses."
},
"IGNORE_BROADCAST_MESSAGES": {
"LABEL": "Ignore broadcast messages",
"PLACEHOLDER": "Select to ignore broadcast messages.",
"ERROR": "Select to ignore broadcast messages."
},
"IGNORE_OWN_MESSAGES": {
"LABEL": "Ignore own messages",
"PLACEHOLDER": "Select to ignore own messages.",
"ERROR": "Select to ignore own messages."
},
"IGNORE_YOURSELF_MESSAGES": {
"LABEL": "Ignore your messages",
"PLACEHOLDER": "Select to ignore your messages.",
"ERROR": "Select to ignore your messages."
},
"SEND_CONNECTION_STATUS": {
"LABEL": "Show connection status",
"PLACEHOLDER": "Select to show connection status.",
"ERROR": "Select to show connection status."
},
"NOTIFY_FAILED_MESSAGES": {
"LABEL": "Notify failed messages",
"PLACEHOLDER": "Select to notify failed messages.",
"ERROR": "Select to notify failed messages."
},
"COMPOSING_MESSAGE": {
"LABEL": "Compose message",
"PLACEHOLDER": "Select to compose message.",
"ERROR": "Select to compose message."
},
"SEND_REACTION_AS_REPLY": {
"LABEL": "Show reaction as reply",
"PLACEHOLDER": "Select to show reaction as reply.",
"ERROR": "Select to show reaction as reply."
},
"SEND_PROFILE_PICTURE": {
"LABEL": "Show profile picture",
"PLACEHOLDER": "Select to show profile picture.",
"ERROR": "Select to show profile picture."
},
"URL": {
"LABEL": "Unoapi URL",
"PLACEHOLDER": "Please enter an Unoapi URL or use default https://unoapi.cloud",
Expand Down
65 changes: 65 additions & 0 deletions app/javascript/dashboard/i18n/locale/pt_BR/inboxMgmt.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,71 @@
"PLACEHOLDER": "Por favor, digite um nome para caixa de entrada",
"ERROR": "Este campo é obrigatório"
},
"GENERATE_API_KEY": {
"LABEL": "Generate API Key",
"PLACEHOLDER": "Generate API Key",
"ERROR": "Generate API Key"
},
"REJECT_CALLS": {
"LABEL": "Rejeitar chamada",
"PLACEHOLDER": "Rejeitar chamada.",
"ERROR": "Rejeitar chamada."
},
"MESSAGE_CALLS_WEBHOOK": {
"LABEL": "Mensagem ao rejeitar chamada",
"PLACEHOLDER": "Mensagem ao rejeitar chamada.",
"ERROR": "Mensagem ao rejeitar chamada."
},
"IGNORE_BROADCAST_STATUSES": {
"LABEL": "Ignorar transmissão de status",
"PLACEHOLDER": "Selecione para ignorar transmissão de status.",
"ERROR": "Selecione para ignorar transmissão de status."
},
"IGNORE_BROADCAST_MESSAGES": {
"LABEL": "Ignorar mensagens de transmissão",
"PLACEHOLDER": "Selecione para ignorar mensagens de transmissão.",
"ERROR": "Selecione para ignorar mensagens de transmissão."
},
"IGNORE_OWN_MESSAGES": {
"LABEL": "Ignorar próprias mensagens",
"PLACEHOLDER": "Selecione para ignorar próprias mensagens.",
"ERROR": "Selecione para ignorar próprias mensagens."
},
"IGNORE_YOURSELF_MESSAGES": {
"LABEL": "Ignorar suas mensagens",
"PLACEHOLDER": "Selecione para ignorar suas mensagens.",
"ERROR": "Selecione para ignorar suas mensagens."
},
"SEND_CONNECTION_STATUS": {
"LABEL": "Exibir status de conexão",
"PLACEHOLDER": "Selecione para exibir status de conexão.",
"ERROR": "Selecione para exibir status de conexão."
},
"NOTIFY_FAILED_MESSAGES": {
"LABEL": "Notificar mensagens com falha",
"PLACEHOLDER": "Selecione para notificar mensagens com falha.",
"ERROR": "Selecione para notificar mensagens com falha."
},
"COMPOSING_MESSAGE": {
"LABEL": "Compor mensagem",
"PLACEHOLDER": "Selecione para compor mensagem.",
"ERROR": "Selecione para compor mensagem."
},
"SEND_REACTION_AS_REPLY": {
"LABEL": "Mostrar reação como resposta",
"PLACEHOLDER": "Selecione para mostrar reação como resposta.",
"ERROR": "Selecione para mostrar reação como resposta."
},
"SEND_PROFILE_PICTURE": {
"LABEL": "Exibir foto de perfil",
"PLACEHOLDER": "Selecione para exibir foto de perfil.",
"ERROR": "Selecione para exibir foto de perfil."
},
"URL": {
"LABEL": "Unoapi URL",
"PLACEHOLDER": "Insira um URL Unoapi",
"ERROR": "Este campo é obrigatório"
},
"PHONE_NUMBER": {
"LABEL": "Número de telefone",
"PLACEHOLDER": "Por favor, insira o número de telefone do qual a mensagem será enviada.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,32 @@
</span>
</label>
</div>


<div class="w-[65%] flex-shrink-0 flex-grow-0 max-w-[65%] config-helptext">
<label :class="{ error: $v.webhookSendNewMessages.$error }" style="display: flex; align-items: center;">
<woot-switch
v-model="webhookSendNewMessages"
:value="webhookSendNewMessages"
style="flex: 0 0 auto; margin-right: 10px;"
/>
{{ $t('INBOX_MGMT.ADD.WHATSAPP.WEBWOOK_SEND_NEW_MESSAGES.LABEL') }}
<span v-if="$v.webhookSendNewMessages.$error" class="message">
{{ $t('INBOX_MGMT.ADD.WHATSAPP.WEBWOOK_SEND_NEW_MESSAGES.ERROR') }}
</span>
</label>
</div>

<div class="w-full" style="margin-top: 20px">
<woot-submit-button
:loading="uiFlags.isCreating"
:button-text="$t('INBOX_MGMT.ADD.WHATSAPP.SUBMIT_BUTTON')"
/>
</div>
<woot-submit-button
:loading="uiFlags.isUpdating"
:button-text="$t('INBOX_MGMT.ADD.WHATSAPP.GENERATE_API_KEY.LABEL')"
@click="generateToken"
/>
</div>
</form>
</template>

Expand All @@ -136,6 +155,7 @@ export default {
ignoreGroupMessages: true,
ignoreHistoryMessages: true,
sendAgentName: true,
webhookSendNewMessages: true,
};
},
computed: {
Expand All @@ -148,9 +168,25 @@ export default {
ignoreGroupMessages: { required },
ignoreHistoryMessages: { required },
sendAgentName: { required },
webhookSendNewMessages: { required },
url: { required },
},
methods: {
generateToken() {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let token = '';
for (let i = 0; i < 64; i++) {
token += characters.charAt(Math.floor(Math.random() * characters.length));
}
if (this.apiKey) {
if (confirm('A token already exists. Do you want to replace it?')) {
this.apiKey = token;
}
} else {
this.apiKey = token;
}
},
async createChannel() {
this.$v.$touch();
if (this.$v.$invalid) {
Expand All @@ -174,6 +210,7 @@ export default {
ignore_history_messages: this.ignoreHistoryMessages,
ignore_group_messages: this.ignoreGroupMessages,
send_agent_name: this.sendAgentName,
webhook_send_new_messages: this.webhookSendNewMessages,
url: this.url,
},
},
Expand Down
Loading

0 comments on commit 9e1bde9

Please sign in to comment.