| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 6 |
<title>$TITLE</title> |
| 7 |
<meta name="description" content="$DESCRIPTION" /> |
| 8 |
<link rel="icon" type="image/png" href="$FAVICON"> |
| 9 |
<link href="https://unpkg.com/@triply/yasgui@4/build/yasgui.min.css" rel="stylesheet" type="text/css" /> |
| 10 |
<script src="https://unpkg.com/@triply/yasgui@4/build/yasgui.min.js"></script> |
| 11 |
</head> |
| 12 |
|
| 13 |
<body> |
| 14 |
<div id="yasgui"></div> |
| 15 |
<script> |
| 16 |
Yasqe.defaults.value = `$EXAMPLE_QUERY` |
| 17 |
const queries_obj = $EXAMPLE_QUERIES || [] |
| 18 |
|
| 19 |
const url = window.location.href.endsWith('/') ? window.location.href.slice(0, -1) : window.location.href; |
| 20 |
// Make sure the endpoints list is unique |
| 21 |
const endpointsList = [...new Set([url, ...Object.keys(queries_obj).map((label) => {if (queries_obj[label]["endpoint"]) return queries_obj[label]["endpoint"]})])] |
| 22 |
const yasguiEndpoints = endpointsList.map((endpoint) => {return {endpoint: endpoint}}) |
| 23 |
|
| 24 |
const yasgui = new Yasgui(document.getElementById("yasgui"), { |
| 25 |
requestConfig: { endpoint: url, copyEndpointOnNewTab: true, }, |
| 26 |
endpointCatalogueOptions: { |
| 27 |
getData: function () { |
| 28 |
return yasguiEndpoints |
| 29 |
}, |
| 30 |
keys: [], |
| 31 |
}, |
| 32 |
}); |
| 33 |
|
| 34 |
// Add tab to yasgui for each query |
| 35 |
Object.keys(queries_obj).map((label) => { |
| 36 |
const tabsLabel = Object.keys(yasgui._tabs).map(tab => yasgui._tabs[tab].persistentJson.name) |
| 37 |
if (!tabsLabel.includes(label)) { |
| 38 |
yasgui.addTab( |
| 39 |
false, // set as active tab not really working |
| 40 |
{ |
| 41 |
...Yasgui.Tab.getDefaults(), |
| 42 |
name: label, |
| 43 |
requestConfig: { endpoint: queries_obj[label]['endpoint'] }, |
| 44 |
yasqe: { value: queries_obj[label]['query'] } |
| 45 |
} |
| 46 |
); |
| 47 |
} |
| 48 |
}) |
| 49 |
</script> |
| 50 |
</body> |
| 51 |
</html> |