@@ -41,11 +41,6 @@ export class LogsTable {
4141 componentWillRender ( ) {
4242 this . from = ( this . currentPage - 1 ) * this . limit + 1 ;
4343 this . to = this . currentPage * this . limit ;
44- {
45- this . tableHeader . map ( ( id : any ) => {
46- console . log ( id . click . clickable ) ;
47- } ) ;
48- }
4944 }
5045
5146 render ( ) {
@@ -59,136 +54,132 @@ export class LogsTable {
5954 }
6055
6156 return (
62- < div style = { { overflowY :"auto" } } >
63- < div style = { { height :"580px" , overflow :"auto" } } >
64- < table class = "table-auto h-full min-w-full divide-y divide-gray-200 relative" >
65- { /* Table Head */ }
66- < thead class = "bg-violet-50 sticky top-0" >
67- < tr >
68- { this . tableHeader . map ( ( item : any ) => (
69- < th scope = "col" class = "px-6 py-3 text-left text-xs font-medium text-gray-500 hover:text-indigo-700 uppercase tracking-wider" >
70- { item . title }
71-
72- { item ?. filter ?. sortable && (
73- < button class = "ml-3" onClick = { ( ) => this . toggleSortMethod ( item . title ) } >
74- { sort }
75- </ button >
76- ) }
77-
78- { item ?. filter ?. searchable && (
79- < drop-down searchMethod = { ( value , field ) => this . searchMethod ( value , field ) } alias = { item . alias } clearSearch = { colName => this . clearSearch ( colName ) } >
80- { search }
81- </ drop-down >
82- ) }
83- </ th >
84- ) ) }
85- { this . isLoading && < th class = "text-gray-500 " > </ th > }
86- </ tr >
87- </ thead >
88-
89- { /* loading screen */ }
90- { this . isLoading && (
91- < tbody >
92- < tr >
93- < td colSpan = { this . tableHeader . length } rowSpan = { 10 } class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" >
94- < loader-component > </ loader-component >
95- </ td >
96- < td class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" > </ td >
97- </ tr >
98-
99- { trList }
100- </ tbody >
101- ) }
57+ < div style = { { overflowY : 'auto' } } >
58+ < div style = { { maxWidth : '72.5rem' , maxHeight : '580px' , overflow : 'auto' } } >
59+ < table class = "table-auto h-full min-w-full divide-y divide-gray-200 relative" >
60+ { /* Table Head */ }
61+ < thead class = "bg-violet-50 sticky top-0" >
62+ < tr >
63+ { this . tableHeader . map ( ( item : any ) => (
64+ < th scope = "col" class = "px-6 py-3 text-left text-xs font-medium text-gray-500 hover:text-indigo-700 uppercase tracking-wider" >
65+ { item . title }
66+
67+ { item ?. filter ?. sortable && (
68+ < button class = "ml-3" onClick = { ( ) => this . toggleSortMethod ( item . title ) } >
69+ { sort }
70+ </ button >
71+ ) }
10272
103- < tbody class = "bg-white divide-y divide-gray-200" >
104- { /* loaded body */ }
105- { this . tableBody &&
106- ! this . isLoading &&
107- ! this . isLoadingError &&
108- this . tableBody . map ( ( item : any ) => (
109- < tr class = "hover:bg-gray-100 transition" >
110- { this . tableHeader . map ( ( id : any ) => (
111- // <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{item[id.alias]}</td>
112- < td text-overflow :ellipsis max-width = "50px" class = "px-6 py-3 whitespace-nowrap text-sm text-gray-900" >
113- { ! id . click . clickable ? (
114- item [ id . alias ] . length > 25 ? (
115- item [ id . alias ] . slice ( 0 , 25 ) + '...'
116- ) : / \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } \. \d { 3 } Z / . test ( item [ id . alias ] ) ? (
117- item [ id . alias ] . slice ( 0 , 16 ) . split ( 'T' ) [ 0 ] + ' at ' + item [ id . alias ] . slice ( 11 , 19 )
118- ) : (
119- item [ id . alias ]
120- )
121- ) : (
122- < 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" >
123- < img class = "h-4" src = { id . click . icon } alt = "icon" />
124- < span class = "px-2 " > View</ span >
125- </ a >
73+ { item ?. filter ?. searchable && (
74+ < drop-down searchMethod = { ( value , field ) => this . searchMethod ( value , field ) } alias = { item . alias } clearSearch = { colName => this . clearSearch ( colName ) } >
75+ { search }
76+ </ drop-down >
12677 ) }
127- </ td >
78+ </ th >
12879 ) ) }
80+ { this . isLoading && < th class = "text-gray-500 " > </ th > }
12981 </ tr >
130- ) ) }
131- </ tbody >
132-
133- { /* error screen */ }
134- { ! this . isLoading && this . isLoadingError && (
135- < tbody >
136- < tr >
137- < td colSpan = { this . tableHeader . length } rowSpan = { 10 } class = "px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900" >
138- < p > Error Found</ p >
139- < plain-button type = "text" > retry</ plain-button >
140- </ td >
141- < td class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" > </ td >
142- </ tr >
143- { trList }
144- </ tbody >
145- ) }
146-
147- { /* Table Footer */ }
148- < tfoot class = "bg-violet-50 w-full sticky bottom-0" >
149- < tr >
150- < td colSpan = { this . tableHeader . length } class = "px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" >
151- < div class = "flex justify-between items-center" >
152- { /* pagination description */ }
153- < p >
154- Showing < strong > { this . from } </ strong > to < strong > { this . to } </ strong > of < strong > { this . dataLength } </ strong > results
155- </ p >
156-
157- { /* rows per page */ }
158- < div class = "space-x-3" >
159- < span > Rows per page</ span >
160- < select
161- onChange = { e => this . rowsHandler ( e ) }
162- 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"
163- >
164- { this . rows . map ( row => (
165- < option value = { `${ row } ` } > { row } </ option >
82+ </ thead >
83+
84+ { /* loading screen */ }
85+ { this . isLoading && (
86+ < tbody >
87+ < tr >
88+ < td colSpan = { this . tableHeader . length } rowSpan = { 10 } class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" >
89+ < loader-component > </ loader-component >
90+ </ td >
91+ < td class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" > </ td >
92+ </ tr >
93+
94+ { trList }
95+ </ tbody >
96+ ) }
97+
98+ < tbody class = "bg-white divide-y divide-gray-200" >
99+ { /* loaded body */ }
100+ { this . tableBody &&
101+ ! this . isLoading &&
102+ ! this . isLoadingError &&
103+ this . tableBody . map ( ( item : any ) => (
104+ < tr class = "hover:bg-gray-100 transition" >
105+ { this . tableHeader . map ( ( id : any ) => (
106+ // <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{item[id.alias]}</td>
107+ < 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+ ) }
122+ </ td >
166123 ) ) }
167- </ select >
124+ </ tr >
125+ ) ) }
126+ </ tbody >
127+
128+ { /* error screen */ }
129+ { ! this . isLoading && this . isLoadingError && (
130+ < tbody >
131+ < tr >
132+ < td colSpan = { this . tableHeader . length } rowSpan = { 10 } class = "px-6 py-4 whitespace-nowrap text-sm text-center text-gray-900" >
133+ < p > Error Found</ p >
134+ </ td >
135+ < td class = "px-6 py-4 whitespace-nowrap text-sm text-gray-900" > </ td >
136+ </ tr >
137+ { trList }
138+ </ tbody >
139+ ) }
140+ </ table >
141+ </ div >
142+ < div style = { { maxWidth : '72.5rem' } } class = "bg-violet-50 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 >
150+
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 >
163+
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 >
168180 </ div >
169-
170- { /* pagination navigation menu */ }
171- < nav class = "flex gap-4 items-center" >
172- < plain-button color = "gray-500" type = "text" clickHandler = { ( ) => this . prev ( ) } disabledHandler = { this . currentPage === 1 } addClass = "disabled:opacity-50" >
173- prev
174- </ plain-button >
175- < plain-button
176- color = "gray-500"
177- type = "text"
178- clickHandler = { ( ) => this . next ( ) }
179- disabledHandler = { parseInt ( this . dataLength ) === this . to }
180- addClass = "disabled:opacity-50"
181- >
182- next
183- </ plain-button >
184- </ nav >
185- </ div >
186- </ td >
187- { this . isLoading && < td class = "text-gray-500" > </ td > }
188- </ tr >
189- </ tfoot >
190- </ table >
191- </ div >
181+ { this . isLoading && < td class = "text-gray-500" > </ td > }
182+ </ div >
192183 </ div >
193184 ) ;
194185 }
0 commit comments