Basic Report Embed
Simple initialization of the library, plain text authentication and loading a report
by sprilukin
HTML
<script src="https://infra-platforms-phase2-17953-khariyap.pfa.jaspersoft.com/jasperserver-pro/client/visualize.js"></script>
<img src="https://infra-platforms-phase2-17953-khariyap.pfa.jaspersoft.com/jasperserver-pro/rest/login?j_username=joeuser%7Corganization_1&j_password=joeuser"/>
<div id="container"></div>
CSS
#container {
width:400px;
}
JavaScript
// REST login
/*const restAuth = fetch("https://infra-platforms-phase2-17953-khariyap.pfa.jaspersoft.com/jasperserver-pro/rest/login", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: "j_username=joeuser%7Corganization_1&j_password=joeuser"
});*/
/*restAuth.then((response) => {
if (response.status !== 200) {
console.log('Authentication failed');
return;
}
*/
visualize({
// If you will comment out whole `auth` property - it still will work
// because we already authenticated with rest login earlier
// and previous auth cookie will be sent
auth: {
name: "joeuser",
password: "joeuser",
organization: "organization_1"
}
}, function (v) {
v("#container").report({
resource: "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report",
error: (err) => {
alert(err.message);
}
});
});
//})