@@ -154,8 +154,10 @@ async def admin_add_server(request: Request, db: Session = Depends(get_db), user
154
154
RedirectResponse: A redirect to the admin dashboard catalog section
155
155
"""
156
156
form = await request .form ()
157
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
157
158
try :
158
159
logger .debug (f"User { user } is adding a new server with name: { form ['name' ]} " )
160
+
159
161
server = ServerCreate (
160
162
name = form .get ("name" ),
161
163
description = form .get ("description" ),
@@ -167,11 +169,15 @@ async def admin_add_server(request: Request, db: Session = Depends(get_db), user
167
169
await server_service .register_server (db , server )
168
170
169
171
root_path = request .scope .get ("root_path" , "" )
172
+ if is_inactive_checked .lower () == "true" :
173
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
170
174
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
171
175
except Exception as e :
172
176
logger .error (f"Error adding server: { e } " )
173
177
174
178
root_path = request .scope .get ("root_path" , "" )
179
+ if is_inactive_checked .lower () == "true" :
180
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
175
181
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
176
182
177
183
@@ -207,6 +213,7 @@ async def admin_edit_server(
207
213
RedirectResponse: A redirect to the admin dashboard catalog section with a status code of 303
208
214
"""
209
215
form = await request .form ()
216
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
210
217
try :
211
218
logger .debug (f"User { user } is editing server ID { server_id } with name: { form .get ('name' )} " )
212
219
server = ServerUpdate (
@@ -220,11 +227,16 @@ async def admin_edit_server(
220
227
await server_service .update_server (db , server_id , server )
221
228
222
229
root_path = request .scope .get ("root_path" , "" )
230
+
231
+ if is_inactive_checked .lower () == "true" :
232
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
223
233
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
224
234
except Exception as e :
225
235
logger .error (f"Error editing server: { e } " )
226
236
227
237
root_path = request .scope .get ("root_path" , "" )
238
+ if is_inactive_checked .lower () == "true" :
239
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
228
240
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
229
241
230
242
@@ -256,12 +268,15 @@ async def admin_toggle_server(
256
268
form = await request .form ()
257
269
logger .debug (f"User { user } is toggling server ID { server_id } with activate: { form .get ('activate' )} " )
258
270
activate = form .get ("activate" , "true" ).lower () == "true"
271
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
259
272
try :
260
273
await server_service .toggle_server_status (db , server_id , activate )
261
274
except Exception as e :
262
275
logger .error (f"Error toggling server status: { e } " )
263
276
264
277
root_path = request .scope .get ("root_path" , "" )
278
+ if is_inactive_checked .lower () == "true" :
279
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
265
280
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
266
281
267
282
@@ -289,7 +304,12 @@ async def admin_delete_server(server_id: str, request: Request, db: Session = De
289
304
except Exception as e :
290
305
logger .error (f"Error deleting server: { e } " )
291
306
307
+ form = await request .form ()
308
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
292
309
root_path = request .scope .get ("root_path" , "" )
310
+
311
+ if is_inactive_checked .lower () == "true" :
312
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#catalog" , status_code = 303 )
293
313
return RedirectResponse (f"{ root_path } /admin#catalog" , status_code = 303 )
294
314
295
315
@@ -398,12 +418,16 @@ async def admin_toggle_gateway(
398
418
logger .debug (f"User { user } is toggling gateway ID { gateway_id } " )
399
419
form = await request .form ()
400
420
activate = form .get ("activate" , "true" ).lower () == "true"
421
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
422
+
401
423
try :
402
424
await gateway_service .toggle_gateway_status (db , gateway_id , activate )
403
425
except Exception as e :
404
426
logger .error (f"Error toggling gateway status: { e } " )
405
427
406
428
root_path = request .scope .get ("root_path" , "" )
429
+ if is_inactive_checked .lower () == "true" :
430
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#gateways" , status_code = 303 )
407
431
return RedirectResponse (f"{ root_path } /admin#gateways" , status_code = 303 )
408
432
409
433
@@ -650,6 +674,9 @@ async def admin_edit_tool(
650
674
await tool_service .update_tool (db , tool_id , tool )
651
675
652
676
root_path = request .scope .get ("root_path" , "" )
677
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
678
+ if is_inactive_checked .lower () == "true" :
679
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#tools" , status_code = 303 )
653
680
return RedirectResponse (f"{ root_path } /admin#tools" , status_code = 303 )
654
681
except ToolNameConflictError as e :
655
682
return JSONResponse (content = {"message" : str (e ), "success" : False }, status_code = 400 )
@@ -679,7 +706,12 @@ async def admin_delete_tool(tool_id: str, request: Request, db: Session = Depend
679
706
logger .debug (f"User { user } is deleting tool ID { tool_id } " )
680
707
await tool_service .delete_tool (db , tool_id )
681
708
709
+ form = await request .form ()
710
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
682
711
root_path = request .scope .get ("root_path" , "" )
712
+
713
+ if is_inactive_checked .lower () == "true" :
714
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#tools" , status_code = 303 )
683
715
return RedirectResponse (f"{ root_path } /admin#tools" , status_code = 303 )
684
716
685
717
@@ -711,12 +743,15 @@ async def admin_toggle_tool(
711
743
logger .debug (f"User { user } is toggling tool ID { tool_id } " )
712
744
form = await request .form ()
713
745
activate = form .get ("activate" , "true" ).lower () == "true"
746
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
714
747
try :
715
748
await tool_service .toggle_tool_status (db , tool_id , activate , reachable = activate )
716
749
except Exception as e :
717
750
logger .error (f"Error toggling tool status: { e } " )
718
751
719
752
root_path = request .scope .get ("root_path" , "" )
753
+ if is_inactive_checked .lower () == "true" :
754
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#tools" , status_code = 303 )
720
755
return RedirectResponse (f"{ root_path } /admin#tools" , status_code = 303 )
721
756
722
757
@@ -825,6 +860,10 @@ async def admin_edit_gateway(
825
860
await gateway_service .update_gateway (db , gateway_id , gateway )
826
861
827
862
root_path = request .scope .get ("root_path" , "" )
863
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
864
+
865
+ if is_inactive_checked .lower () == "true" :
866
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#gateways" , status_code = 303 )
828
867
return RedirectResponse (f"{ root_path } /admin#gateways" , status_code = 303 )
829
868
830
869
@@ -850,7 +889,12 @@ async def admin_delete_gateway(gateway_id: str, request: Request, db: Session =
850
889
logger .debug (f"User { user } is deleting gateway ID { gateway_id } " )
851
890
await gateway_service .delete_gateway (db , gateway_id )
852
891
892
+ form = await request .form ()
893
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
853
894
root_path = request .scope .get ("root_path" , "" )
895
+
896
+ if is_inactive_checked .lower () == "true" :
897
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#gateways" , status_code = 303 )
854
898
return RedirectResponse (f"{ root_path } /admin#gateways" , status_code = 303 )
855
899
856
900
@@ -942,6 +986,10 @@ async def admin_edit_resource(
942
986
await resource_service .update_resource (db , uri , resource )
943
987
944
988
root_path = request .scope .get ("root_path" , "" )
989
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
990
+
991
+ if is_inactive_checked .lower () == "true" :
992
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#resources" , status_code = 303 )
945
993
return RedirectResponse (f"{ root_path } /admin#resources" , status_code = 303 )
946
994
947
995
@@ -967,7 +1015,12 @@ async def admin_delete_resource(uri: str, request: Request, db: Session = Depend
967
1015
logger .debug (f"User { user } is deleting resource URI { uri } " )
968
1016
await resource_service .delete_resource (db , uri )
969
1017
1018
+ form = await request .form ()
1019
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
970
1020
root_path = request .scope .get ("root_path" , "" )
1021
+
1022
+ if is_inactive_checked .lower () == "true" :
1023
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#resources" , status_code = 303 )
971
1024
return RedirectResponse (f"{ root_path } /admin#resources" , status_code = 303 )
972
1025
973
1026
@@ -999,12 +1052,15 @@ async def admin_toggle_resource(
999
1052
logger .debug (f"User { user } is toggling resource ID { resource_id } " )
1000
1053
form = await request .form ()
1001
1054
activate = form .get ("activate" , "true" ).lower () == "true"
1055
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
1002
1056
try :
1003
1057
await resource_service .toggle_resource_status (db , resource_id , activate )
1004
1058
except Exception as e :
1005
1059
logger .error (f"Error toggling resource status: { e } " )
1006
1060
1007
1061
root_path = request .scope .get ("root_path" , "" )
1062
+ if is_inactive_checked .lower () == "true" :
1063
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#resources" , status_code = 303 )
1008
1064
return RedirectResponse (f"{ root_path } /admin#resources" , status_code = 303 )
1009
1065
1010
1066
@@ -1098,6 +1154,10 @@ async def admin_edit_prompt(
1098
1154
await prompt_service .update_prompt (db , name , prompt )
1099
1155
1100
1156
root_path = request .scope .get ("root_path" , "" )
1157
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
1158
+
1159
+ if is_inactive_checked .lower () == "true" :
1160
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#prompts" , status_code = 303 )
1101
1161
return RedirectResponse (f"{ root_path } /admin#prompts" , status_code = 303 )
1102
1162
1103
1163
@@ -1123,7 +1183,12 @@ async def admin_delete_prompt(name: str, request: Request, db: Session = Depends
1123
1183
logger .debug (f"User { user } is deleting prompt name { name } " )
1124
1184
await prompt_service .delete_prompt (db , name )
1125
1185
1186
+ form = await request .form ()
1187
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
1126
1188
root_path = request .scope .get ("root_path" , "" )
1189
+
1190
+ if is_inactive_checked .lower () == "true" :
1191
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#prompts" , status_code = 303 )
1127
1192
return RedirectResponse (f"{ root_path } /admin#prompts" , status_code = 303 )
1128
1193
1129
1194
@@ -1155,12 +1220,15 @@ async def admin_toggle_prompt(
1155
1220
logger .debug (f"User { user } is toggling prompt ID { prompt_id } " )
1156
1221
form = await request .form ()
1157
1222
activate = form .get ("activate" , "true" ).lower () == "true"
1223
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
1158
1224
try :
1159
1225
await prompt_service .toggle_prompt_status (db , prompt_id , activate )
1160
1226
except Exception as e :
1161
1227
logger .error (f"Error toggling prompt status: { e } " )
1162
1228
1163
1229
root_path = request .scope .get ("root_path" , "" )
1230
+ if is_inactive_checked .lower () == "true" :
1231
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#prompts" , status_code = 303 )
1164
1232
return RedirectResponse (f"{ root_path } /admin#prompts" , status_code = 303 )
1165
1233
1166
1234
@@ -1210,7 +1278,12 @@ async def admin_delete_root(uri: str, request: Request, user: str = Depends(requ
1210
1278
logger .debug (f"User { user } is deleting root URI { uri } " )
1211
1279
await root_service .remove_root (uri )
1212
1280
1281
+ form = await request .form ()
1213
1282
root_path = request .scope .get ("root_path" , "" )
1283
+ is_inactive_checked = form .get ("is_inactive_checked" , "false" )
1284
+
1285
+ if is_inactive_checked .lower () == "true" :
1286
+ return RedirectResponse (f"{ root_path } /admin/?include_inactive=true#roots" , status_code = 303 )
1214
1287
return RedirectResponse (f"{ root_path } /admin#roots" , status_code = 303 )
1215
1288
1216
1289
0 commit comments