()
| 154 | } |
| 155 | |
| 156 | formatSql() { |
| 157 | let sqlText = this.editor.state.doc.toString(); |
| 158 | let editor = this.editor; |
| 159 | |
| 160 | var formData = new FormData(); |
| 161 | formData.append('sql', sqlText); // Append the SQL text to the form data |
| 162 | |
| 163 | // Make the fetch call |
| 164 | fetch(`${window.baseUrlPath}format/`, { |
| 165 | method: "POST", |
| 166 | headers: { |
| 167 | // 'Content-Type': 'application/x-www-form-urlencoded', // Not needed when using FormData, as the browser sets it along with the boundary |
| 168 | 'X-CSRFToken': getCsrfToken() |
| 169 | }, |
| 170 | body: formData // Use the FormData object as the body |
| 171 | }) |
| 172 | .then(response => response.json()) // Parse the JSON response |
| 173 | .then(data => { |
| 174 | editor.dispatch({ |
| 175 | changes: { |
| 176 | from: 0, |
| 177 | to: editor.state.doc.length, |
| 178 | insert: data.formatted |
| 179 | } |
| 180 | }); |
| 181 | }) |
| 182 | .catch(error => console.error('Error:', error)); |
| 183 | } |
| 184 | |
| 185 | showRows() { |
| 186 | let rows = document.getElementById("rows").value; |
no test coverage detected