@@ -16,12 +16,10 @@ app.get("/api/jobs", async (req, res) => {
16
16
try {
17
17
const namespace = req . query . namespace || "" ;
18
18
const searchTerm = req . query . search || "" ;
19
- const page = parseInt ( req . query . page ) || 1 ;
20
- const limit = parseInt ( req . query . limit ) || 10 ;
21
19
const queueFilter = req . query . queue || "" ;
22
20
const statusFilter = req . query . status || "" ;
23
21
24
- console . log ( 'Fetching jobs with params:' , { page , limit , searchTerm, namespace , queueFilter } ) ;
22
+ console . log ( 'Fetching jobs with params:' , { namespace , searchTerm, queueFilter , statusFilter } ) ;
25
23
26
24
let response ;
27
25
if ( namespace === "" || namespace === "All" ) {
@@ -61,17 +59,9 @@ app.get("/api/jobs", async (req, res) => {
61
59
) ;
62
60
}
63
61
64
- const totalCount = filteredJobs . length ;
65
- const startIndex = ( page - 1 ) * limit ;
66
- const endIndex = Math . min ( startIndex + limit , totalCount ) ;
67
- const paginatedJobs = filteredJobs . slice ( startIndex , endIndex ) ;
68
-
69
62
res . json ( {
70
- items : paginatedJobs ,
71
- totalCount : totalCount ,
72
- page : page ,
73
- limit : limit ,
74
- totalPages : Math . ceil ( totalCount / limit )
63
+ items : filteredJobs ,
64
+ totalCount : filteredJobs . length ,
75
65
} ) ;
76
66
} catch ( err ) {
77
67
console . error ( "Error fetching jobs:" , err ) ;
@@ -186,6 +176,8 @@ app.get("/api/queues", async (req, res) => {
186
176
const searchTerm = req . query . search || "" ;
187
177
const stateFilter = req . query . state || "" ;
188
178
179
+ console . log ( 'Fetching queues with params:' , { page, limit, searchTerm, stateFilter} ) ;
180
+
189
181
const response = await k8sApi . listClusterCustomObject (
190
182
"scheduling.volcano.sh" ,
191
183
"v1beta1" ,
@@ -230,7 +222,6 @@ app.get("/api/queues", async (req, res) => {
230
222
// get all ns
231
223
app . get ( "/api/namespaces" , async ( req , res ) => {
232
224
try {
233
-
234
225
const response = await k8sCoreApi . listNamespace ( )
235
226
236
227
res . json ( {
@@ -246,54 +237,47 @@ app.get("/api/namespaces", async (req, res) => {
246
237
} ) ;
247
238
248
239
app . get ( '/api/pods' , async ( req , res ) => {
249
- const namespace = req . query . namespace || "" ;
250
- const searchTerm = req . query . search || "" ;
251
- const page = parseInt ( req . query . page ) || 1 ;
252
- const limit = parseInt ( req . query . limit ) || 10 ;
253
- const statusFilter = req . query . status || "" ;
254
-
255
- let response ;
256
- if (
257
- namespace === "" || namespace === "All" ) {
258
- response = await k8sCoreApi . listPodForAllNamespaces ( ) ;
259
- } else {
260
- response = await k8sCoreApi . listNamespacedPod ( namespace ) ;
261
- }
262
-
263
- let filteredPods = response . body . items || [ ] ;
264
-
265
- // Apply search filter
266
- if ( searchTerm ) {
267
- filteredPods = filteredPods . filter ( pod =>
268
- pod . metadata . name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
269
- ) ;
270
- }
240
+ try {
241
+ const namespace = req . query . namespace || "" ;
242
+ const searchTerm = req . query . search || "" ;
243
+ const statusFilter = req . query . status || "" ;
271
244
272
- if ( statusFilter && statusFilter !== "All" ) {
273
- filteredPods = filteredPods . filter ( ( pod ) =>
274
- pod . status . phase === statusFilter
275
- ) ;
276
- }
245
+ console . log ( 'Fetching pods with params:' , { namespace, searchTerm, statusFilter} ) ;
277
246
278
- // Calculate the total
279
- const totalCount = filteredPods . length ;
247
+ let response ;
248
+ if (
249
+ namespace === "" || namespace === "All" ) {
250
+ response = await k8sCoreApi . listPodForAllNamespaces ( ) ;
251
+ } else {
252
+ response = await k8sCoreApi . listNamespacedPod ( namespace ) ;
253
+ }
280
254
255
+ let filteredPods = response . body . items || [ ] ;
281
256
282
- // Apply pagination
283
- const startIndex = ( page - 1 ) * limit ;
284
- const endIndex = Math . min ( startIndex + limit , totalCount ) ;
285
- const paginatedPods = filteredPods . slice ( startIndex , endIndex ) ;
257
+ // Apply search filter
258
+ if ( searchTerm ) {
259
+ filteredPods = filteredPods . filter ( pod =>
260
+ pod . metadata . name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
261
+ ) ;
262
+ }
286
263
287
- console . log ( `Page: ${ page } , Limit: ${ limit } , Total: ${ totalCount } ` ) ;
288
- console . log ( `Showing pods from ${ startIndex } to ${ endIndex } ` ) ;
264
+ if ( statusFilter && statusFilter !== "All" ) {
265
+ filteredPods = filteredPods . filter ( ( pod ) =>
266
+ pod . status . phase === statusFilter
267
+ ) ;
268
+ }
289
269
290
- res . json ( {
291
- items : paginatedPods ,
292
- totalCount : totalCount ,
293
- page : page ,
294
- limit : limit ,
295
- totalPages : Math . ceil ( totalCount / limit )
296
- } ) ;
270
+ res . json ( {
271
+ items : filteredPods ,
272
+ totalCount : filteredPods . length ,
273
+ } ) ;
274
+ } catch ( err ) {
275
+ console . error ( "Error fetching pods:" , err ) ;
276
+ res . status ( 500 ) . json ( {
277
+ error : "Failed to fetch pods" ,
278
+ details : err . message
279
+ } ) ;
280
+ }
297
281
} ) ;
298
282
299
283
// Get details of a specific Pod
0 commit comments