deprecated-oc-search/views/swagger.tpl
2023-08-26 22:04:56 +02:00

46 lines
1.2 KiB
Smarty

<script src="/static/js/swagger-client.browser.min.js"></script>
<script>
const swg_proto = "http://"
const swg_port = "49618"
const swg_suffix = "/swagger/swagger.json"
var specUrl = swg_proto + window.location.hostname + ":" + swg_port + swg_suffix
/**
switch (window.location.hostname) {
case 'localhost':
case '127.0.0.1':
var specUrl = 'http://localhost:49618/swagger/swagger.json';
break;
default:
var specUrl = 'https://' + window.location.hostname + ':8443/swagger.json';
break;
}
**/
var oc_catalog_api = new SwaggerClient(specUrl)
.then(client => {
return client;
})
.catch(err => {
alert("NO API AVAILABLE (" + specUrl + ") :" + err) // we will see what to do with it later
});
function WorkspaceAddElement(rid, rtype, callback) {
oc_catalog_api.then(client => {
client.apis
.workspace
.WorkspaceController_Add_model_to_workspace({id: rid, rtype: rtype})
.then(callback)
.catch((error) => {
console.log("ERROR: " + error)
});
});
}
</script>