@@ -148,30 +148,43 @@ document.addEventListener("DOMContentLoaded", function () {
148
148
} ) ;
149
149
150
150
document
151
- . getElementById ( "add-gateway-form" )
152
- . addEventListener ( "submit" , ( e ) => {
153
- e . preventDefault ( ) ;
154
- const form = e . target ;
155
- const formData = new FormData ( form ) ;
156
- fetch ( `${ window . ROOT_PATH } /admin/gateways` , {
157
- method : "POST" ,
158
- body : formData ,
151
+ . getElementById ( "add-gateway-form" )
152
+ . addEventListener ( "submit" , ( e ) => {
153
+ e . preventDefault ( ) ;
154
+
155
+ const form = e . target ;
156
+ const formData = new FormData ( form ) ;
157
+
158
+ const status = document . getElementById ( "status-gateways" ) ;
159
+ const loading = document . getElementById ( "add-gateway-loading" ) ;
160
+
161
+ // Show loading and clear previous status
162
+ loading . style . display = "block" ;
163
+ status . textContent = "" ;
164
+ status . classList . remove ( "error-status" ) ;
165
+
166
+ fetch ( `${ window . ROOT_PATH } /admin/gateways` , {
167
+ method : "POST" ,
168
+ body : formData ,
169
+ } )
170
+ . then ( ( response ) => {
171
+ if ( ! response . ok ) {
172
+ status . textContent = "Connection failed!" ;
173
+ status . classList . add ( "error-status" ) ;
174
+ } else {
175
+ location . reload ( ) ; // Will exit before hiding spinner
176
+ }
159
177
} )
160
- . then ( ( response ) => {
161
- console . log ( response ) ;
162
- if ( ! response . ok ) {
163
- const status = document . getElementById ( "status-gateways" ) ;
164
- status . textContent = "Connection failed!" ;
165
- status . classList . add ( "error-status" ) ;
166
- } else {
167
- location . reload ( ) ;
168
- console . log ( response ) ;
169
- }
170
- } )
171
- . catch ( ( error ) => {
172
- console . error ( "Error:" , error ) ;
173
- } ) ;
174
- } ) ;
178
+ . catch ( ( error ) => {
179
+ console . error ( "Error:" , error ) ;
180
+ status . textContent = "An error occurred!" ;
181
+ status . classList . add ( "error-status" ) ;
182
+ } )
183
+ . finally ( ( ) => {
184
+ loading . style . display = "none" ; // Hide loading
185
+ } ) ;
186
+ } ) ;
187
+
175
188
176
189
document
177
190
. getElementById ( "add-resource-form" )
@@ -319,7 +332,7 @@ document.addEventListener("DOMContentLoaded", function () {
319
332
320
333
const requestTypeMap = {
321
334
MCP : [ "SSE" , "STREAMABLE" , "STDIO" ] ,
322
- REST : [ "GET" , "POST" , "PUT" , "PATCH" , " DELETE"] ,
335
+ REST : [ "GET" , "POST" , "PUT" , "DELETE" ] ,
323
336
} ;
324
337
325
338
@@ -1650,9 +1663,9 @@ async function runToolTest() {
1650
1663
const formData = new FormData ( form ) ;
1651
1664
const params = { } ;
1652
1665
for ( const [ key , value ] of formData . entries ( ) ) {
1653
- if ( isNaN ( value ) ) {
1654
- if ( value . toLowerCase ( ) === "true" || value . toLowerCase ( ) === "false" ) {
1655
- params [ key ] = Boolean ( value . toLowerCase ( ) === "true" ) ;
1666
+ if ( isNaN ( value ) ) {
1667
+ if ( value . toLowerCase ( ) === "true" || value . toLowerCase ( ) === "false" ) {
1668
+ params [ key ] = value . toLowerCase ( ) === "true" ;
1656
1669
} else {
1657
1670
params [ key ] = value ;
1658
1671
}
@@ -1661,46 +1674,47 @@ async function runToolTest() {
1661
1674
}
1662
1675
}
1663
1676
1664
- // Build the JSON-RPC payload using the tool's name as the method
1665
1677
const payload = {
1666
1678
jsonrpc : "2.0" ,
1667
1679
id : Date . now ( ) ,
1668
1680
method : currentTestTool . name ,
1669
1681
params : params ,
1670
1682
} ;
1671
1683
1672
- // Send the request to your /rpc endpoint
1673
- fetch ( `${ window . ROOT_PATH } /rpc` , {
1674
- method : "POST" ,
1675
- headers : {
1676
- "Content-Type" : "application/json" , // ← make sure we include this
1677
- } ,
1678
- body : JSON . stringify ( payload ) ,
1679
- credentials : "include" ,
1680
- } )
1681
- . then ( ( response ) => response . json ( ) )
1682
- . then ( ( result ) => {
1683
- const resultStr = JSON . stringify ( result , null , 2 ) ;
1684
-
1685
- const container = document . getElementById ( "tool-test-result" ) ;
1686
- container . innerHTML = '' ; // clear any old editor
1687
-
1688
- toolTestResultEditor = window . CodeMirror (
1689
- document . getElementById ( "tool-test-result" ) ,
1690
- {
1691
- value : resultStr ,
1692
- mode : "application/json" ,
1693
- theme : "monokai" ,
1694
- readOnly : true ,
1695
- lineNumbers : true ,
1696
- } ,
1697
- ) ;
1698
- } )
1699
- . catch ( ( error ) => {
1700
- document . getElementById ( "tool-test-result" ) . innerText = "Error: " + error ;
1684
+ // Show loading
1685
+ const loadingElement = document . getElementById ( "tool-test-loading" ) ;
1686
+ loadingElement . style . display = "block" ;
1687
+ const resultContainer = document . getElementById ( "tool-test-result" ) ;
1688
+ resultContainer . innerHTML = "" ;
1689
+
1690
+ try {
1691
+ const response = await fetch ( `${ window . ROOT_PATH } /rpc` , {
1692
+ method : "POST" ,
1693
+ headers : {
1694
+ "Content-Type" : "application/json" ,
1695
+ } ,
1696
+ body : JSON . stringify ( payload ) ,
1697
+ credentials : "include" ,
1698
+ } ) ;
1699
+
1700
+ const result = await response . json ( ) ;
1701
+ const resultStr = JSON . stringify ( result , null , 2 ) ;
1702
+
1703
+ toolTestResultEditor = window . CodeMirror ( resultContainer , {
1704
+ value : resultStr ,
1705
+ mode : "application/json" ,
1706
+ theme : "monokai" ,
1707
+ readOnly : true ,
1708
+ lineNumbers : true ,
1701
1709
} ) ;
1710
+ } catch ( error ) {
1711
+ resultContainer . innerText = "Error: " + error ;
1712
+ } finally {
1713
+ loadingElement . style . display = "none" ; // Hide loading after fetch or error
1714
+ }
1702
1715
}
1703
1716
1717
+
1704
1718
/* ---------------------------------------------------------------
1705
1719
* Utility: copy a JSON string (or any text) to the system clipboard
1706
1720
* ------------------------------------------------------------- */
@@ -1759,7 +1773,7 @@ function closeModal(modalId, clearId=null) {
1759
1773
1760
1774
const integrationRequestMap = {
1761
1775
MCP : [ "SSE" , "STREAMABLE" , "STDIO" ] ,
1762
- REST : [ "GET" , "POST" , "PUT" , "PATCH" , " DELETE"] ,
1776
+ REST : [ "GET" , "POST" , "PUT" , "DELETE" ] ,
1763
1777
} ;
1764
1778
1765
1779
function updateRequestTypeOptions ( preselectedValue = null ) {
0 commit comments