Errors.vue
3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
<div>
<h1 class="mb-8 font-bold text-3xl">
<inertia-link class="text-indigo-400 hover:text-indigo-600" :href="route('tokens')">Tokens</inertia-link>
<span class="text-indigo-400 font-medium">/</span>
<inertia-link class="text-indigo-400 hover:text-indigo-600" :href="route('token.edit', token.id)">{{token.login}}</inertia-link>
<span class="text-indigo-400 font-medium">/</span>
Errors
</h1>
<div class="mb-6 flex justify-between items-center">
<search-filter class="w-full max-w-md mr-4" @reset="reset">
<label class="block text-gray-700">Service:</label>
<select v-model="form.service" class="mt-1 w-full form-select">
<option hidden :value="null" />
<option v-for="service in services" :value="service">{{ service }}</option>
</select>
<label class="block text-gray-700 mt-2">Method:</label>
<select v-model="form.method" class="mt-1 w-full form-select">
<option hidden :value="null" />
<option v-for="method in methods" :value="method">{{ method }}</option>
</select>
</search-filter>
<button class="text-red-600 hover:underline mb-4"
tabindex="-1"
type="button"
@click="errorsDestroy"
>
Delete errors
</button>
</div>
<div class="bg-white rounded-md shadow overflow-x-auto">
<table class="w-full whitespace-nowrap">
<tr class="text-left font-bold">
<th class="px-6 pt-6 pb-4">Create</th>
<th class="px-6 pt-6 pb-4">Service</th>
<th class="px-6 pt-6 pb-4">Method</th>
<th class="px-6 pt-6 pb-4">Errors</th>
<th class="px-6 pt-6 pb-4">Params</th>
</tr>
<tr v-for="error in rows.data" :key="error.id" class="">
<td class="border-t px-6 pt-6 pb-4">
{{ error.created_at }}
</td>
<td class="border-t px-6 pt-6 pb-4">
{{ error.service }}
</td>
<td class="border-t px-6 pt-6 pb-4">
{{ error.method }}
</td>
<td class="border-t px-6 pt-6 pb-4">
<pre v-html="objectFormatting(error.errors)"/>
</td>
<td class="border-t px-6 pt-6 pb-4">
<details>
<summary>Params</summary>
<pre v-html="objectFormatting(error.params)"/>
</details>
</td>
</tr>
<tr v-if="rows.data.length === 0">
<td class="border-t px-6 py-4" colspan="6">No errors found.</td>
</tr>
</table>
</div>
<pagination class="mt-6" :links="rows.links" />
</div>
</template>
<script>
import Icon from '@/Shared/Icon'
import pickBy from 'lodash/pickBy'
import Layout from '@/Shared/Layout'
import throttle from 'lodash/throttle'
import mapValues from 'lodash/mapValues'
import Pagination from '@/Shared/Pagination'
import SearchFilter from '@/Shared/SearchFilter'
export default {
metaInfo: { title: 'Token' },
components: {
Icon,
Pagination,
SearchFilter,
},
layout: Layout,
props: {
token: Object,
rows: Object,
filters: Object,
services: Object,
methods: Object,
},
data() {
return {
form: {
service: this.filters.service,
method: this.filters.method,
},
}
},
watch: {
form: {
handler: throttle(function() {
this.$inertia.get(this.route('token.errors', this.token.id), pickBy(this.form))
}, 150),
deep: true,
},
},
methods: {
objectFormatting(object) {
return JSON.stringify(object, null, ' ').replace(/\n/gi,'<br/>')
},
errorsDestroy() {
if (confirm('Are you sure you want to delete this errors?')) {
this.$inertia.delete(this.route('token.errors.destroy', this.token.id))
}
},
reset() {
this.form = mapValues(this.form, () => null)
},
},
}
</script>