This commit is contained in:
j3d1 2024-07-13 17:28:38 +02:00
parent 9f288fec82
commit 1c99604e73
3 changed files with 40 additions and 7 deletions

View file

@ -73,7 +73,7 @@
import TimelineMail from "@/components/TimelineMail.vue"; import TimelineMail from "@/components/TimelineMail.vue";
import TimelineComment from "@/components/TimelineComment.vue"; import TimelineComment from "@/components/TimelineComment.vue";
import TimelineStateChange from "@/components/TimelineStateChange.vue"; import TimelineStateChange from "@/components/TimelineStateChange.vue";
import {mapGetters} from "vuex"; import {mapActions, mapGetters} from "vuex";
import TimelineAssignment from "@/components/TimelineAssignment.vue"; import TimelineAssignment from "@/components/TimelineAssignment.vue";
import TimelineRelatedItem from "@/components/TimelineRelatedItem.vue"; import TimelineRelatedItem from "@/components/TimelineRelatedItem.vue";
import TimelineShippingVoucher from "@/components/TimelineShippingVoucher.vue"; import TimelineShippingVoucher from "@/components/TimelineShippingVoucher.vue";

View file

@ -48,6 +48,7 @@ const store = createStore({
states: 0, states: 0,
messageTemplates: 0, messageTemplates: 0,
shippingVouchers: 0, shippingVouchers: 0,
userNotificationChannels: 0,
}, },
persistent_loaded: false, persistent_loaded: false,
shared_loaded: false, shared_loaded: false,
@ -262,6 +263,10 @@ const store = createStore({
state.shippingVouchers = codes; state.shippingVouchers = codes;
state.fetchedData = {...state.fetchedData, shippingVouchers: Date.now()}; state.fetchedData = {...state.fetchedData, shippingVouchers: Date.now()};
}, },
setUserNotificationChannels(state, channels) {
state.userNotificationChannels = channels;
state.fetchedData = {...state.fetchedData, userNotificationChannels: Date.now()};
},
}, },
actions: { actions: {
async login({commit}, {username, password, remember}) { async login({commit}, {username, password, remember}) {
@ -544,9 +549,10 @@ const store = createStore({
}, },
async fetchUserNotificationChannels({commit, state}) { async fetchUserNotificationChannels({commit, state}) {
if (!state.user.token) return; if (!state.user.token) return;
if (state.fetchedData.userNotificationChannels > Date.now() - 1000 * 60 * 60 * 24) return;
const {data, success} = await http.get('/2/user_notification_channels/', state.user.token); const {data, success} = await http.get('/2/user_notification_channels/', state.user.token);
if (data && success) { if (data && success) {
state.userNotificationChannels = data; commit('setUserNotificationChannels', data);
} }
}, },
}, },

View file

@ -1,9 +1,36 @@
<template> <template>
<ul> <div>
<li v-for="channel in userNotificationChannels" :key="channel.id"> <Table :items="userNotificationChannels.map(channel => ({...channel, username: channel.user.username || {}}))"
{{ channel.id }} - {{ channel.channel_type }} - {{ channel.channel_target }} - {{ channel.event_filter }} - {{ channel.active }} - {{ channel.created }} - {{ channel.user }} :columns="['id', 'username', 'channel_type', 'channel_target', 'event_filter', /*'active', 'created'*/]">
</li> <template #actions="{ item }">
</ul> <div class="btn-group">
<button class="btn btn-danger" @click.stop="">
<font-awesome-icon icon="trash"/>
delete
</button>
</div>
</template>
</Table>
<div class="card bg-dark">
<div class="card-body">
<div class="input-group">
<select class="form-control">
<option value="1">user</option>
<option value="2">admin</option>
</select>
<select class="form-control">
<option value="email">Email</option>
<option value="telegram">Telegram</option>
</select>
<input type="text" class="form-control" placeholder="channel_target">
<input type="text" class="form-control" value="*">
<div class="input-group-append">
<button class="btn btn-primary">Add</button>
</div>
</div>
</div>
</div>
</div>
</template> </template>
<script> <script>