@@ -1070,11 +1070,63 @@ <h2 class="text-2xl font-bold dark:text-gray-200">
1070
1070
</ table >
1071
1071
</ div >
1072
1072
</ div >
1073
-
1074
1073
< div class ="bg-white shadow rounded-lg p-6 dark:bg-gray-800 ">
1075
- < h3 class ="text-lg font-bold mb-4 dark:text-gray-200 ">
1076
- Add New Tool
1077
- </ h3 >
1074
+ < div class ="flex items-center justify-between mb-4 ">
1075
+ < h3 class ="text-lg font-bold dark:text-gray-200 "> Add New Tool</ h3 >
1076
+ < button
1077
+ id ="open-bulk-import "
1078
+ type ="button "
1079
+ class ="inline-flex items-center gap-1 text-sm text-indigo-600 hover:text-indigo-700 "
1080
+ >
1081
+ + Bulk Import Tools
1082
+ </ button >
1083
+ <!-- Right before </body> tag -->
1084
+ < script >
1085
+ // Super simple version - no dependencies
1086
+ window . addEventListener ( 'load' , function ( ) {
1087
+ console . log ( 'Setting up bulk import...' ) ;
1088
+
1089
+ const button = document . getElementById ( 'open-bulk-import' ) ;
1090
+ const modal = document . getElementById ( 'bulk-import-modal' ) ;
1091
+
1092
+ console . log ( 'Button found:' , ! ! button ) ;
1093
+ console . log ( 'Modal found:' , ! ! modal ) ;
1094
+
1095
+ if ( button && modal ) {
1096
+ button . onclick = function ( e ) {
1097
+ e . preventDefault ( ) ;
1098
+ console . log ( 'Button clicked!' ) ;
1099
+ modal . style . display = 'block' ;
1100
+ modal . classList . remove ( 'hidden' ) ;
1101
+ return false ;
1102
+ } ;
1103
+
1104
+ // Close button
1105
+ const closeBtn = document . getElementById ( 'close-bulk-import' ) ;
1106
+ if ( closeBtn ) {
1107
+ closeBtn . onclick = function ( ) {
1108
+ modal . style . display = 'none' ;
1109
+ modal . classList . add ( 'hidden' ) ;
1110
+ } ;
1111
+ }
1112
+
1113
+ // Click backdrop to close
1114
+ const backdrop = document . getElementById ( 'bulk-import-backdrop' ) ;
1115
+ if ( backdrop ) {
1116
+ backdrop . onclick = function ( ) {
1117
+ modal . style . display = 'none' ;
1118
+ modal . classList . add ( 'hidden' ) ;
1119
+ } ;
1120
+ }
1121
+ } else {
1122
+ console . error ( 'Missing elements!' , { button : ! ! button , modal : ! ! modal } ) ;
1123
+ }
1124
+ } ) ;
1125
+ </ script >
1126
+
1127
+ </ div >
1128
+
1129
+
1078
1130
< form id ="add-tool-form ">
1079
1131
< div class ="grid grid-cols-1 gap-6 ">
1080
1132
< div >
@@ -1302,8 +1354,63 @@ <h3 class="text-lg font-bold mb-4 dark:text-gray-200">
1302
1354
</ div >
1303
1355
</ form >
1304
1356
</ div >
1305
- </ div >
1357
+ <!-- Modal -->
1358
+ < div id ="bulk-import-modal " class ="fixed inset-0 z-[60] hidden ">
1359
+ < div id ="bulk-import-backdrop " class ="absolute inset-0 bg-black/50 "> </ div >
1360
+ < div role ="dialog " aria-modal ="true "
1361
+ class ="relative mx-auto my-12 w-full max-w-2xl rounded-xl bg-white p-0 shadow-xl dark:bg-gray-900 ">
1362
+ < div class ="flex items-center justify-between border-b px-5 py-3 dark:border-gray-700 ">
1363
+ < h3 class ="text-base font-semibold dark:text-gray-100 "> Bulk Import Tools</ h3 >
1364
+ < button id ="close-bulk-import " data-close-bulk-import
1365
+ class ="rounded p-1 text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 "
1366
+ aria-label ="Close "> ✕</ button >
1367
+ </ div >
1368
+
1369
+ < form id ="bulk-import-form "
1370
+ hx-post ="{{ root_path }}/admin/tools/import "
1371
+ hx-target ="#bulk-import-result "
1372
+ hx-swap ="innerHTML "
1373
+ hx-indicator ="#bulk-import-indicator "
1374
+ enctype ="multipart/form-data "
1375
+ class ="space-y-4 p-5 ">
1376
+ < p class ="text-sm text-gray-600 dark:text-gray-400 ">
1377
+ Paste a JSON array or upload a < code > .json</ code > file. Max 200 tools.
1378
+ </ p >
1379
+
1380
+ < label class ="block text-sm font-medium dark:text-gray-300 " for ="tools_json "> JSON Data</ label >
1381
+ < textarea id ="tools_json " name ="tools_json " rows ="8 "
1382
+ class ="mt-1 block w-full rounded-md border border-gray-300 font-mono text-sm shadow-sm
1383
+ focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 "
1384
+ placeholder ='[{"name":"tool_name","url":"https://...","integration_type":"REST","request_type":"GET"}] '> </ textarea >
1385
+
1386
+ < div >
1387
+ < label class ="block text-sm font-medium dark:text-gray-300 " for ="tools_file "> Or upload JSON file</ label >
1388
+ < input id ="tools_file " name ="tools_file " type ="file " accept ="application/json,.json "
1389
+ class ="mt-1 block w-full text-sm dark:text-gray-300 " />
1390
+ </ div >
1391
+
1392
+ < div class ="flex items-center gap-3 pt-1 ">
1393
+ < button type ="submit "
1394
+ class ="inline-flex justify-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white
1395
+ hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 ">
1396
+ Import Tools
1397
+ </ button >
1398
+ < span id ="bulk-import-indicator " class ="htmx-indicator flex items-center text-sm text-gray-500 dark:text-gray-400 ">
1399
+ < svg class ="mr-2 h-4 w-4 animate-spin " viewBox ="0 0 24 24 " fill ="none ">
1400
+ < circle class ="opacity-25 " cx ="12 " cy ="12 " r ="10 " stroke ="currentColor " stroke-width ="4 "/>
1401
+ < path class ="opacity-75 " fill ="currentColor "
1402
+ d ="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z "/>
1403
+ </ svg >
1404
+ Processing...
1405
+ </ span >
1406
+ </ div >
1407
+
1408
+ < div id ="bulk-import-result " class ="pt-2 "> </ div >
1409
+ </ form >
1410
+ </ div >
1411
+ </ div >
1306
1412
1413
+
1307
1414
<!-- Resources Panel -->
1308
1415
< div id ="resources-panel " class ="tab-panel hidden ">
1309
1416
< div class ="flex justify-between items-center mb-4 ">
0 commit comments