Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3205 from modoboa/feature/postfix_autoreply
Postfix autoreply merged back to core repo
- Loading branch information
Showing
98 changed files
with
40,585 additions
and
25,867 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<template> | ||
<v-card v-if="!token" flat> | ||
<v-card-text> | ||
{{ $gettext('Your API token has not been generated yet.') }} | ||
</v-card-text> | ||
<v-card-actions> | ||
<v-btn | ||
color="success" | ||
variant="flat" | ||
:loading="loading" | ||
@click="generateKey" | ||
> | ||
{{ $gettext('Generate') }} | ||
</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
<v-card v-else flat> | ||
<v-card-text> | ||
<label class="m-label"> | ||
{{ $gettext('Your API token is:') }} | ||
</label> | ||
<code class="ml-5 mr-5"> | ||
{{ token }} | ||
</code> | ||
<v-btn | ||
icon="mdi-clipboard-plus" | ||
density="compact" | ||
:title="$gettext('Copy token to clipboard')" | ||
variant="text" | ||
@click="copyToClipboard()" | ||
> | ||
</v-btn> | ||
<v-btn | ||
icon="mdi-delete" | ||
density="compact" | ||
color="error" | ||
variant="text" | ||
:title="$gettext('Delete token')" | ||
@click="openDeletionDialog" | ||
> | ||
</v-btn> | ||
</v-card-text> | ||
</v-card> | ||
<v-alert type="info" variant="tonal" border="start" class="mt-4"> | ||
{{ $gettext('A documentation of the API is available') }} | ||
<a :href="apiDocUrl" target="_blank">{{ $gettext('here') }}</a | ||
>. | ||
</v-alert> | ||
<ConfirmDialog ref="confirm" @agree="deleteToken" /> | ||
</template> | ||
|
||
<script setup> | ||
import accountApi from '@/api/account' | ||
import { useBusStore } from '@/stores' | ||
import ConfirmDialog from '@/components/tools/ConfirmDialog.vue' | ||
import { ref, computed, inject, onMounted } from 'vue' | ||
import { useGettext } from 'vue3-gettext' | ||
const { $gettext } = useGettext() | ||
const busStore = useBusStore() | ||
const $config = inject('$config') | ||
const apiDocUrl = computed(() => $config.API_DOC_URL) | ||
const loading = ref(false) | ||
const token = ref(null) | ||
const confirm = ref() | ||
function copyToClipboard() { | ||
navigator.clipboard.writeText(token.value) | ||
busStore.displayNotification({ | ||
msg: $gettext('API token copied to your clipboard'), | ||
type: 'success', | ||
}) | ||
} | ||
function generateKey() { | ||
loading.value = true | ||
accountApi | ||
.createAPIToken() | ||
.then((resp) => { | ||
token.value = resp.data.token | ||
busStore.displayNotification({ | ||
msg: $gettext('API token created'), | ||
type: 'success', | ||
}) | ||
}) | ||
.finally(() => (loading.value = false)) | ||
} | ||
function openDeletionDialog() { | ||
confirm.value.open( | ||
$gettext('Warning'), | ||
$gettext('You are about to delete your API access token'), | ||
{ | ||
color: 'error', | ||
cancelLabel: $gettext('Cancel'), | ||
agreeLabel: $gettext('Proceed'), | ||
} | ||
) | ||
} | ||
async function deleteToken() { | ||
await accountApi.deleteAPIToken() | ||
busStore.displayNotification({ | ||
msg: $gettext('API token deleted'), | ||
type: 'success', | ||
}) | ||
token.value = null | ||
} | ||
onMounted(() => { | ||
accountApi.getAPIToken().then((resp) => { | ||
token.value = resp.data.token | ||
}) | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<template> | ||
<v-card flat> | ||
<v-card-text> | ||
<v-form ref="formRef" @submit.prevent="submit"> | ||
<v-checkbox | ||
v-model="form.enabled" | ||
:label="$gettext('Enabled')" | ||
color="primary" | ||
hide-details | ||
class="mb-4" | ||
/> | ||
<label class="m-label">{{ $gettext('Subject') }}</label> | ||
<v-text-field | ||
v-model="form.subject" | ||
variant="outlined" | ||
density="compact" | ||
:rules="[rules.required]" | ||
/> | ||
<div class="mb-4"> | ||
<label class="m-label">{{ $gettext('Content') }}</label> | ||
<v-textarea | ||
v-model="form.content" | ||
:hint="$gettext('The content of your answer. You can use the following variables, which will be automatically replaced by the appropriate value: %(name)s, %(fromdate)s, %(untildate)s')" | ||
persistent-hint | ||
variant="outlined" | ||
rows="3" | ||
density="compact" | ||
:rules="[rules.required]" | ||
/> | ||
</div> | ||
<div class="mb-4"> | ||
<label class="m-label">{{ $gettext('From') }}</label> | ||
<v-text-field | ||
v-model="form.fromdate" | ||
:hint="$gettext('Activate your auto reply from this date')" | ||
variant="outlined" | ||
persistent-hint | ||
type="datetime-local" | ||
density="compact" | ||
/> | ||
</div> | ||
<div class="mb-4"> | ||
<label class="m-label">{{ $gettext('Until') }}</label> | ||
<v-text-field | ||
v-model="form.untildate" | ||
:hint="$gettext('Activate your auto reply until this date')" | ||
variant="outlined" | ||
persistent-hint | ||
type="datetime-local" | ||
density="compact" | ||
/> | ||
</div> | ||
<v-btn color="success" type="submit" :loading="loading"> | ||
{{ $gettext('Update auto-reply') }} | ||
</v-btn> | ||
</v-form> | ||
</v-card-text> | ||
</v-card> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { useBusStore } from '@/stores' | ||
import { useGettext } from 'vue3-gettext' | ||
import accountApi from '@/api/account' | ||
import rules from '@/plugins/rules' | ||
const busStore = useBusStore() | ||
const { $gettext } = useGettext() | ||
const form = ref({}) | ||
const formRef = ref() | ||
const loading = ref(false) | ||
async function submit() { | ||
const { valid } = await formRef.value.validate() | ||
if (!valid) { | ||
return | ||
} | ||
loading.value = true | ||
accountApi.setARMessage(form.value).then(() => { | ||
busStore.displayNotification({ msg: $gettext('Auto-reply message updated') }) | ||
loading.value = false | ||
}).catch(() => { | ||
loading.value = false | ||
}) | ||
} | ||
accountApi.getARMessage().then(resp => { | ||
form.value = resp.data | ||
if (form.value.fromdate) { | ||
form.value.fromdate = form.value.fromdate.slice(0, -4) | ||
} | ||
if (form.value.untildate) { | ||
form.value.untildate = form.value.untildate.slice(0, -4) | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.