1+ <script setup lang="ts">
2+ import { useEvents } from ' @/composables/events'
3+ import { usePrettyDates } from ' @/composables/usePrettyDate'
4+ import { onUnmounted } from ' vue'
5+ import { useRoute } from ' vue-router'
6+
7+ const { fetch } = useEvents ()
8+ const { events, close } = fetch (' job' )
9+ const { format, duration } = usePrettyDates ()
10+ const route = useRoute ()
11+
12+ let data: JobExecution | null
13+
14+ onUnmounted (() => {
15+ close ()
16+ })
17+
18+ function eventData(event : ServiceEvent | null ): JobExecution | null {
19+ if (! event ) {
20+ return null
21+ }
22+ return <JobExecution >event .data
23+ }
24+ </script >
25+
26+ <template >
27+ <div class =" card" >
28+ <div class =" card-body" >
29+ <div class =" card-title text-center" >Recent Jobs</div >
30+ <table class =" table dataTable events" data-testid =" requests" >
31+ <thead >
32+ <tr >
33+ <th scope =" col" class =" text-left" style =" width : 30px ;" ></th >
34+ <th scope =" col" class =" text-left" >Name</th >
35+ <th scope =" col" class =" text-left" >Schedule</th >
36+ <th scope =" col" class =" text-center" style =" width :15% " >Time</th >
37+ <th scope =" col" class =" text-center" style =" width : 10% " >Duration</th >
38+ </tr >
39+ </thead >
40+ <tbody >
41+ <template v-for =" (event , index ) of events " >
42+ <tr data-bs-toggle =" collapse" :data-bs-target =" '#event_'+index" aria-expanded =" false" :set =" data = eventData(event)" >
43+ <td ><i class =" bi bi-chevron-right" ></i ><i class =" bi bi-chevron-down" ></i ></td >
44+ <td >{{ data!.tags.name }}</td >
45+ <td >{{ data!.schedule }}</td >
46+ <td class =" text-center" >{{ format(event.time) }}</td >
47+ <td class =" text-center" >{{ duration(data!.duration) }}</td >
48+ </tr >
49+ <tr class =" collapse-row" :set =" data = eventData(event)" >
50+ <td colspan =" 5" v-if =" data" >
51+ <div class =" collapse" :id =" 'event_'+index" style =" padding : 2rem ;" >
52+ <h5 >Logs</h5 >
53+ <div class =" mb-3" >
54+ <ul class =" list-group" >
55+ <li v-for =" log in data.logs" class =" list-group-item" >
56+ <span class =" text-body log" >
57+ <i class =" bi bi-exclamation-triangle-fill text-warning" v-if =" log.level == 'warn'" ></i >
58+ <i class =" bi bi-x-circle-fill text-danger" v-else-if =" log.level == 'error'" ></i >
59+ <i class =" bi bi-bug-fill text-info" v-else-if =" log.level == 'debug'" ></i >
60+ <i class =" bi bi-chat-dots text-primary" v-else ></i >
61+ {{ log.message }}
62+ </span >
63+ </li >
64+ </ul >
65+ <p v-if =" !data.logs || data.logs.length == 0" >This event handler did not produce any logs. You can use <code >console.log()</code > or <code >console.error()</code > in your script to output information.</p >
66+ </div >
67+ <div class =" alert alert-danger" role =" alert" v-if =" data.error" >
68+ <h5 class =" alert-heading" >Error</h5 >
69+ <p >{{ data.error.message }}</p >
70+ </div >
71+ <h5 >Tags</h5 >
72+ <table class =" table dataTable" >
73+ <thead >
74+ <tr >
75+ <th scope =" col" class =" text-left" >Name</th >
76+ <th scope =" col" class =" text-left w-75" >Value</th >
77+ </tr >
78+ </thead >
79+ <tbody >
80+ <template v-for =" (value , key ) of data .tags " >
81+ <tr >
82+ <td >{{ key }}</td >
83+ <td >
84+ <router-link v-if =" key === 'file' && data.tags.fileKey" :to =" { name: 'config', params: { id: data.tags.fileKey }, query: { refresh: route.query.refresh }}" >
85+ {{ value }}
86+ </router-link >
87+ <span v-else >{{ value }}</span >
88+ </td >
89+ </tr >
90+ </template >
91+ </tbody >
92+ </table >
93+ </div >
94+ </td >
95+ </tr >
96+ </template >
97+ </tbody >
98+ </table >
99+ </div >
100+ </div >
101+ </template >
102+
103+ <style scoped>
104+ .events tbody td {
105+ border-bottom-width : 0 ;
106+ padding-bottom : 1px ;
107+ margin-bottom : 0 ;
108+ }
109+ .events tbody tr .collapse-row td {
110+ border-bottom-width : 2px ;
111+ border-top-width : 0 ;
112+ background-color : var (--color-background-soft );
113+ }
114+ .collapse {
115+ padding : 2rem ;
116+ }
117+
118+ tr [aria-expanded = true ] .bi-chevron-right {
119+ display :none ;
120+ }
121+ tr [aria-expanded = false ] .bi-chevron-down {
122+ display :none ;
123+ }
124+ </style >
0 commit comments