@@ -67,8 +67,9 @@ limitations under the License. -->
67
67
<el-pagination
68
68
class =" pagination flex-h"
69
69
layout =" prev, pager, next"
70
+ :current-page =" currentPage"
70
71
:page-size =" pageSize"
71
- :total =" pods.length"
72
+ :total =" searchText ? pods.filter((d: any) => d.label.includes(searchText)).length : pods.length"
72
73
@current-change =" changePage"
73
74
@prev-click =" changePage"
74
75
@next-click =" changePage"
@@ -122,6 +123,7 @@ limitations under the License. -->
122
123
const dashboardStore = useDashboardStore ();
123
124
const chartLoading = ref <boolean >(false );
124
125
const instances = ref <Instance []>([]); // current instances
126
+ const currentPage = ref <number >(1 );
125
127
const pageSize = 10 ;
126
128
const searchText = ref <string >(" " );
127
129
const colMetrics = ref <string []>([]);
@@ -213,18 +215,22 @@ limitations under the License. -->
213
215
}
214
216
215
217
function changePage(pageIndex : number ) {
216
- instances .value = pods .value .filter ((d : unknown , index : number ) => {
217
- if (index >= (pageIndex - 1 ) * pageSize && index < pageIndex * pageSize ) {
218
- return d ;
219
- }
220
- });
218
+ let podList = pods .value ;
219
+ if (searchText .value ) {
220
+ podList = pods .value .filter ((d : { label: string }) => d .label .includes (searchText .value ));
221
+ }
222
+ instances .value = podList .filter (
223
+ (_ , index : number ) => index >= (pageIndex - 1 ) * pageSize && index < pageIndex * pageSize ,
224
+ );
221
225
queryInstanceMetrics (instances .value );
226
+ currentPage .value = pageIndex ;
222
227
}
223
228
224
229
function searchList() {
225
230
const searchInstances = pods .value .filter ((d : { label: string }) => d .label .includes (searchText .value ));
226
- instances .value = searchInstances .filter ((d : unknown , index : number ) => index < pageSize );
231
+ instances .value = searchInstances .filter ((_ , index : number ) => index < pageSize );
227
232
queryInstanceMetrics (instances .value );
233
+ currentPage .value = 1 ;
228
234
}
229
235
230
236
watch (
0 commit comments