@@ -42,6 +42,37 @@ export class LogsTable {
4242 this . from = ( this . currentPage - 1 ) * this . limit + 1 ;
4343 this . to = this . currentPage * this . limit ;
4444 }
45+ dataFormatter ( id , item ) {
46+ {
47+ if ( id . click . clickable === false ) {
48+ if ( item [ id . alias ] . length > 25 === true ) {
49+ return item [ id . alias ] . slice ( 0 , 25 ) + '...' ;
50+ } else {
51+ if ( / \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } \. \d { 3 } Z / . test ( item [ id . alias ] ) ) {
52+ return new Date ( item [ id . alias ] ) . toString ( ) . split ( '(' ) [ 0 ]
53+ } else {
54+ if ( id . alias === 'timeTaken' ) {
55+ return `${ item [ id . alias ] } ms` ;
56+ } else {
57+ return item [ id . alias ] ;
58+ }
59+ }
60+ }
61+ } else {
62+ if ( id . alias === 'queryResult' ) {
63+ return (
64+ < a target = "_blank" href = { id . click . url + item [ id . alias ] } class = "flex items-center py-1 px-4 text-base font-normal text-gray-900 rounded-lg bg-gray-200" >
65+ < img class = "h-4" src = { id . click . icon } alt = "icon" />
66+ < span class = "px-2 " > View</ span >
67+ </ a >
68+ ) } else if ( id . alias === 'email' ) {
69+ return ( < a href = { id . click . url + item [ 'ownerId' ] } >
70+ < span class = "px-2 " > { item [ id . alias ] } </ span >
71+ </ a > )
72+ }
73+ }
74+ }
75+ }
4576
4677 render ( ) {
4778 const trList = [ ] ;
@@ -103,22 +134,8 @@ export class LogsTable {
103134 this . tableBody . map ( ( item : any ) => (
104135 < tr class = "hover:bg-gray-100 transition" >
105136 { this . tableHeader . map ( ( id : any ) => (
106- // <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{item[id.alias]}</td>
107137 < td text-overflow :ellipsis title = { item [ id . alias ] } max-width = "50px" class = "px-6 py-3 whitespace-nowrap text-sm text-gray-900" >
108- { ! id . click . clickable ? (
109- item [ id . alias ] . length > 25 ? (
110- item [ id . alias ] . slice ( 0 , 25 ) + '...'
111- ) : / \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } \. \d { 3 } Z / . test ( item [ id . alias ] ) ? (
112- item [ id . alias ] . slice ( 0 , 16 ) . split ( 'T' ) [ 0 ] + ' at ' + item [ id . alias ] . slice ( 11 , 19 )
113- ) : (
114- item [ id . alias ]
115- )
116- ) : (
117- < a target = "_blank" href = { id . click . url + item [ id . alias ] } class = "flex items-center py-1 px-4 text-base font-normal text-gray-900 rounded-lg bg-gray-200" >
118- < img class = "h-4" src = { id . click . icon } alt = "icon" />
119- < span class = "px-2 " > View</ span >
120- </ a >
121- ) }
138+ { this . dataFormatter ( id , item ) }
122139 </ td >
123140 ) ) }
124141 </ tr >
@@ -139,47 +156,41 @@ export class LogsTable {
139156 ) }
140157 </ table >
141158 </ div >
142- < div style = { { maxWidth : '75rem' } } class = "bg-gray-100 sticky bottom-0" >
143- < div class = "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" >
144- < div class = "flex justify-between items-center" >
145- { /* pagination description */ }
146- < p >
147- Showing < strong > { this . from } </ strong > to < strong > { this . to <= Number ( this . dataLength ) ? this . to : this . dataLength } </ strong > of{ ' ' }
148- < strong > { this . dataLength } </ strong > results
149- </ p >
159+ < div style = { { maxWidth : '75rem' } } class = "bg-gray-100 sticky bottom-0" >
160+ < div class = "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" >
161+ < div class = "flex justify-between items-center" >
162+ { /* pagination description */ }
163+ < p >
164+ Showing < strong > { this . from } </ strong > to < strong > { this . to <= Number ( this . dataLength ) ? this . to : this . dataLength } </ strong > of < strong > { this . dataLength } </ strong > { ' ' }
165+ results
166+ </ p >
150167
151- { /* rows per page */ }
152- < div class = "space-x-3" >
153- < span > Rows per page</ span >
154- < select
155- onChange = { e => this . rowsHandler ( e ) }
156- class = "form-select px-3 py-1.5 border-none text-inherit font-inherit text-gray-700 bg-transparent bg-clip-padding bg-no-repeat rounded transition ease-in-out focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none"
157- >
158- { this . rows . map ( row => (
159- < option value = { `${ row } ` } > { row } </ option >
160- ) ) }
161- </ select >
162- </ div >
168+ { /* rows per page */ }
169+ < div class = "space-x-3" >
170+ < span > Rows per page</ span >
171+ < select
172+ onChange = { e => this . rowsHandler ( e ) }
173+ class = "form-select px-3 py-1.5 border-none text-inherit font-inherit text-gray-700 bg-transparent bg-clip-padding bg-no-repeat rounded transition ease-in-out focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none"
174+ >
175+ { this . rows . map ( row => (
176+ < option value = { `${ row } ` } > { row } </ option >
177+ ) ) }
178+ </ select >
179+ </ div >
163180
164- { /* pagination navigation menu */ }
165- < nav class = "flex gap-4 items-center" >
166- < plain-button color = "gray-500" type = "text" clickHandler = { ( ) => this . prev ( ) } disabledHandler = { this . currentPage === 1 } addClass = "disabled:opacity-50" >
167- prev
168- </ plain-button >
169- < plain-button
170- color = "gray-500"
171- type = "text"
172- clickHandler = { ( ) => this . next ( ) }
173- disabledHandler = { parseInt ( this . dataLength ) <= this . to }
174- addClass = "disabled:opacity-50"
175- >
176- next
177- </ plain-button >
178- </ nav >
179- </ div >
180- </ div >
181- { this . isLoading && < td class = "text-gray-500" > </ td > }
181+ { /* pagination navigation menu */ }
182+ < nav class = "flex gap-4 items-center" >
183+ < plain-button color = "gray-500" type = "text" clickHandler = { ( ) => this . prev ( ) } disabledHandler = { this . currentPage === 1 } addClass = "disabled:opacity-50" >
184+ prev
185+ </ plain-button >
186+ < plain-button color = "gray-500" type = "text" clickHandler = { ( ) => this . next ( ) } disabledHandler = { parseInt ( this . dataLength ) <= this . to } addClass = "disabled:opacity-50" >
187+ next
188+ </ plain-button >
189+ </ nav >
182190 </ div >
191+ </ div >
192+ { this . isLoading && < td class = "text-gray-500" > </ td > }
193+ </ div >
183194 </ div >
184195 ) ;
185196 }
0 commit comments