mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.0 KiB
116 lines
3.0 KiB
3 years ago
|
<template>
|
||
|
<div>
|
||
|
<v-card-title>
|
||
3 years ago
|
<span class="text-capitalize mr-1">{{ meta.title }}</span> : Webhooks
|
||
3 years ago
|
<v-spacer />
|
||
2 years ago
|
<v-btn tooltip="Save" class="primary nc-btn-create-webhook" @click.prevent="$emit('add')"> Create Webhook </v-btn>
|
||
3 years ago
|
</v-card-title>
|
||
|
|
||
3 years ago
|
<v-divider />
|
||
|
|
||
2 years ago
|
<div v-if="hooks" class="pa-6">
|
||
|
<template v-if="hooks.length">
|
||
|
<v-card
|
||
|
v-for="(hook, i) in hooks"
|
||
|
:key="hook.id"
|
||
|
max-width="500px"
|
||
|
class="mx-auto elevation-0 backgroundColor nc-hook mb-4"
|
||
|
@click="$emit('edit', hook)"
|
||
|
>
|
||
3 years ago
|
<div class="d-flex">
|
||
2 years ago
|
<v-icon class="ml-4"> mdi-hook </v-icon>
|
||
3 years ago
|
<div class="pa-4 flex-grow-1">
|
||
|
<div class="d-flex">
|
||
|
<h4 class="nc-text mb-2">
|
||
|
{{ hook.title }}
|
||
|
</h4>
|
||
|
|
||
|
<v-spacer />
|
||
|
<!--Notify Via-->
|
||
2 years ago
|
<span class="caption textColor1--text mt-1"
|
||
|
>{{ $t('labels.notifyVia') }} : {{ hook.notification && hook.notification.type }}
|
||
3 years ago
|
</span>
|
||
|
</div>
|
||
|
<div class="d-flex">
|
||
|
<!--Title-->
|
||
2 years ago
|
<span class="caption textColor1--text text-uppercase"> {{ hook.event }} {{ hook.operation }}</span>
|
||
3 years ago
|
</div>
|
||
3 years ago
|
</div>
|
||
2 years ago
|
<v-icon class="nc-hook-delete-icon" small @click.stop="deleteHook(hook, i)"> mdi-delete-outline </v-icon>
|
||
3 years ago
|
</div>
|
||
3 years ago
|
</v-card>
|
||
|
</template>
|
||
|
<div v-else class="pa-4 backgroundColor caption textColor--text text--lighten-3">
|
||
|
Webhooks list is empty, create new webhook by clicking 'Create webhook' button.
|
||
|
</div>
|
||
3 years ago
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { calculateDiff } from '~/helpers';
|
||
3 years ago
|
|
||
3 years ago
|
export default {
|
||
|
name: 'WebhookList',
|
||
|
props: { meta: Object },
|
||
|
data: () => ({
|
||
2 years ago
|
hooks: null,
|
||
|
loading: false,
|
||
3 years ago
|
}),
|
||
|
mounted() {
|
||
2 years ago
|
this.loadHooksList();
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
calculateDiff,
|
||
3 years ago
|
async loadHooksList() {
|
||
2 years ago
|
this.key++;
|
||
|
this.loading = true;
|
||
3 years ago
|
|
||
2 years ago
|
const hooks = await this.$api.dbTableWebhook.list(this.meta.id);
|
||
3 years ago
|
|
||
2 years ago
|
this.hooks = hooks.list.map(h => {
|
||
|
h.notification = h.notification && JSON.parse(h.notification);
|
||
|
return h;
|
||
|
});
|
||
|
this.loading = false;
|
||
3 years ago
|
},
|
||
|
async deleteHook(item, i) {
|
||
|
try {
|
||
|
if (item.id) {
|
||
2 years ago
|
await this.$api.dbTableWebhook.delete(item.id);
|
||
|
this.hooks.splice(i, 1);
|
||
3 years ago
|
} else {
|
||
2 years ago
|
this.hooks.splice(i, 1);
|
||
3 years ago
|
}
|
||
2 years ago
|
this.$toast.success('Hook deleted successfully').goAway(3000);
|
||
3 years ago
|
if (!this.hooks.length) {
|
||
2 years ago
|
this.hook = null;
|
||
3 years ago
|
}
|
||
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
this.$e('a:webhook:delete');
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<style scoped lang="scss">
|
||
|
.nc-hook {
|
||
|
position: relative;
|
||
3 years ago
|
|
||
3 years ago
|
.nc-hook-delete-icon {
|
||
|
position: absolute;
|
||
|
opacity: 0;
|
||
2 years ago
|
transition: 0.3s opacity;
|
||
3 years ago
|
right: 16px;
|
||
2 years ago
|
bottom: 16px;
|
||
3 years ago
|
}
|
||
|
|
||
|
&:hover .nc-hook-delete-icon {
|
||
|
opacity: 1;
|
||
|
}
|
||
|
}
|
||
3 years ago
|
</style>
|