11import React from 'react' ;
22
33import { explode } from '../../libs/strings'
4+ import shortid from 'shortid' ;
45
56interface Props {
67 modelsData : any ,
78}
89
910export default function ApiActionEvents ( props : Props ) {
1011 const { modelsData } = props
12+ const { modelsSummary, modelsTimeline } = modelsData
1113
1214 return (
1315 < >
14- { ! Object . keys ( modelsData ) . length && (
16+ { ! Object . keys ( modelsSummary ) . length && (
1517 < div className = 'text-center text-sm text-slate-500' >
1618 No Models Data
1719 </ div >
1820 ) }
19- { Object . keys ( modelsData ) . length != 0 && (
21+ { Object . keys ( modelsSummary ) . length != 0 && (
2022 < >
21- < h3 className = 'title' > Models</ h3 >
22- < p >
23- < small className = 'text-slate-500' > Events are in the order of occurances</ small >
24- </ p >
23+ < h3 className = 'title' > Model events Summary</ h3 >
2524 < div className = 'divider' > </ div >
26- { Object . keys ( modelsData ) . map ( ( model , index ) => {
25+ { Object . keys ( modelsSummary ) . map ( ( model ) => {
2726 return (
28- < table className = 'table table-compact table-fixed table-zebra w-full mb-10' key = { index } >
27+ < table className = 'table table-compact table-fixed table-zebra w-full mb-10' key = { shortid . generate ( ) } >
2928 < tbody >
30- { Object . keys ( modelsData [ model ] ) . map ( ( event , idx ) => {
29+ { Object . keys ( modelsSummary [ model ] ) . map ( ( event , idx ) => {
3130 return (
32- < tr key = { idx } >
31+ < tr key = { shortid . generate ( ) } >
3332 { idx == 0 && (
34- < td rowSpan = { Object . keys ( modelsData [ model ] ) . length } >
33+ < td rowSpan = { Object . keys ( modelsSummary [ model ] ) . length } >
3534 < span className = 'font-bold text-slate-500' > Model</ span >
3635 < br />
3736 < div className = '' dangerouslySetInnerHTML = { { __html : explode ( model . split ( '\\' ) [ model . split ( '\\' ) . length - 1 ] , 30 , "<br/>" ) } } />
3837 </ td >
3938 ) }
4039 < td className = 'capitalize' > { event } </ td >
4140 < td >
42- < span className = 'font-bold' > { modelsData [ model ] [ event ] } </ span >
41+ < span className = 'font-bold' > { modelsSummary [ model ] [ event ] } </ span >
4342 < span className = 'text-slate-400 pl-1' >
44- Time{ modelsData [ model ] [ event ] > 1 ? 's' : '' }
43+ Time{ modelsSummary [ model ] [ event ] > 1 ? 's' : '' }
4544 </ span >
4645 </ td >
4746 </ tr >
@@ -53,6 +52,40 @@ export default function ApiActionEvents(props: Props) {
5352 } ) }
5453 </ >
5554 ) }
55+
56+ { Object . keys ( modelsTimeline ) . length != 0 && (
57+ < >
58+ < h3 className = 'title' > Model Events Timeline</ h3 >
59+ < small className = 'text-slate-500' > Events are in the order of occurrences</ small >
60+ < div className = 'divider' > </ div >
61+ < div className = "flex flex-col md:grid grid-cols-12" >
62+ { Object . keys ( modelsTimeline ) . map ( ( index ) => {
63+ return (
64+ < div className = "flex md:contents" key = { shortid . generate ( ) } >
65+ < div className = "col-start-2 col-end-4 mr-10 md:mx-auto relative" >
66+ < div className = "h-full w-3 flex items-center justify-center" >
67+ < div className = { `h-full w-1 bg-${ modelsTimeline [ index ] . event } pointer-events-none` } > </ div >
68+ </ div >
69+ < div className = { `w-3 h-3 absolute top-1/2 rounded-full bg-${ modelsTimeline [ index ] . event } shadow text-center` } >
70+ < i className = "fas fa-check-circle text-white" > </ i >
71+ </ div >
72+ </ div >
73+ < div className = "col-start-4 col-end-12 rounded-md my-3 mr-auto w-full break-all" >
74+ < h3 className = "mb-1" >
75+ < div className = '' dangerouslySetInnerHTML = { { __html : explode ( modelsTimeline [ index ] . model . split ( '\\' ) [ modelsTimeline [ index ] . model . split ( '\\' ) . length - 1 ] , 30 , "<br/>" ) } } />
76+ </ h3 >
77+ < p className = "title text-justify w-full" >
78+ < span className = { `badge badge-${ modelsTimeline [ index ] . event } rounded-sm` } >
79+ { modelsTimeline [ index ] . event }
80+ </ span >
81+ </ p >
82+ </ div >
83+ </ div >
84+ )
85+ } ) }
86+ </ div >
87+ </ >
88+ ) }
5689 </ >
5790 )
5891}
0 commit comments