@@ -147,31 +147,70 @@ document.addEventListener("DOMContentLoaded", function () {
147
147
}
148
148
} ) ;
149
149
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,
159
+ // })
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
+ // });
175
+
150
176
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 ,
177
+ . getElementById ( "add-gateway-form" )
178
+ . addEventListener ( "submit" , ( e ) => {
179
+ e . preventDefault ( ) ;
180
+
181
+ const form = e . target ;
182
+ const formData = new FormData ( form ) ;
183
+
184
+ const status = document . getElementById ( "status-gateways" ) ;
185
+ const loading = document . getElementById ( "add-gateway-loading" ) ;
186
+
187
+ // Show loading and clear previous status
188
+ loading . style . display = "block" ;
189
+ status . textContent = "" ;
190
+ status . classList . remove ( "error-status" ) ;
191
+
192
+ fetch ( `${ window . ROOT_PATH } /admin/gateways` , {
193
+ method : "POST" ,
194
+ body : formData ,
195
+ } )
196
+ . then ( ( response ) => {
197
+ if ( ! response . ok ) {
198
+ status . textContent = "Connection failed!" ;
199
+ status . classList . add ( "error-status" ) ;
200
+ } else {
201
+ location . reload ( ) ; // Will exit before hiding spinner
202
+ }
159
203
} )
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
- } ) ;
204
+ . catch ( ( error ) => {
205
+ console . error ( "Error:" , error ) ;
206
+ status . textContent = "An error occurred!" ;
207
+ status . classList . add ( "error-status" ) ;
208
+ } )
209
+ . finally ( ( ) => {
210
+ loading . style . display = "none" ; // Hide loading
211
+ } ) ;
212
+ } ) ;
213
+
175
214
176
215
document
177
216
. getElementById ( "add-resource-form" )
@@ -319,7 +358,7 @@ document.addEventListener("DOMContentLoaded", function () {
319
358
320
359
const requestTypeMap = {
321
360
MCP : [ "SSE" , "STREAMABLE" , "STDIO" ] ,
322
- REST : [ "GET" , "POST" , "PUT" , "PATCH" , " DELETE"] ,
361
+ REST : [ "GET" , "POST" , "PUT" , "DELETE" ] ,
323
362
} ;
324
363
325
364
@@ -1650,9 +1689,9 @@ async function runToolTest() {
1650
1689
const formData = new FormData ( form ) ;
1651
1690
const params = { } ;
1652
1691
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" ) ;
1692
+ if ( isNaN ( value ) ) {
1693
+ if ( value . toLowerCase ( ) === "true" || value . toLowerCase ( ) === "false" ) {
1694
+ params [ key ] = value . toLowerCase ( ) === "true" ;
1656
1695
} else {
1657
1696
params [ key ] = value ;
1658
1697
}
@@ -1661,46 +1700,47 @@ async function runToolTest() {
1661
1700
}
1662
1701
}
1663
1702
1664
- // Build the JSON-RPC payload using the tool's name as the method
1665
1703
const payload = {
1666
1704
jsonrpc : "2.0" ,
1667
1705
id : Date . now ( ) ,
1668
1706
method : currentTestTool . name ,
1669
1707
params : params ,
1670
1708
} ;
1671
1709
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 ;
1710
+ // Show loading
1711
+ const loadingElement = document . getElementById ( "tool-test-loading" ) ;
1712
+ loadingElement . style . display = "block" ;
1713
+ const resultContainer = document . getElementById ( "tool-test-result" ) ;
1714
+ resultContainer . innerHTML = "" ;
1715
+
1716
+ try {
1717
+ const response = await fetch ( `${ window . ROOT_PATH } /rpc` , {
1718
+ method : "POST" ,
1719
+ headers : {
1720
+ "Content-Type" : "application/json" ,
1721
+ } ,
1722
+ body : JSON . stringify ( payload ) ,
1723
+ credentials : "include" ,
1701
1724
} ) ;
1725
+
1726
+ const result = await response . json ( ) ;
1727
+ const resultStr = JSON . stringify ( result , null , 2 ) ;
1728
+
1729
+ toolTestResultEditor = window . CodeMirror ( resultContainer , {
1730
+ value : resultStr ,
1731
+ mode : "application/json" ,
1732
+ theme : "monokai" ,
1733
+ readOnly : true ,
1734
+ lineNumbers : true ,
1735
+ } ) ;
1736
+ } catch ( error ) {
1737
+ resultContainer . innerText = "Error: " + error ;
1738
+ } finally {
1739
+ loadingElement . style . display = "none" ; // Hide loading after fetch or error
1740
+ }
1702
1741
}
1703
1742
1743
+
1704
1744
/* ---------------------------------------------------------------
1705
1745
* Utility: copy a JSON string (or any text) to the system clipboard
1706
1746
* ------------------------------------------------------------- */
@@ -1759,7 +1799,7 @@ function closeModal(modalId, clearId=null) {
1759
1799
1760
1800
const integrationRequestMap = {
1761
1801
MCP : [ "SSE" , "STREAMABLE" , "STDIO" ] ,
1762
- REST : [ "GET" , "POST" , "PUT" , "PATCH" , " DELETE"] ,
1802
+ REST : [ "GET" , "POST" , "PUT" , "DELETE" ] ,
1763
1803
} ;
1764
1804
1765
1805
function updateRequestTypeOptions ( preselectedValue = null ) {
0 commit comments