JRIO Cancel and Refresh
by Stas_P
HTML
<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script src="http://localhost:8080/jrio-client/optimized-scripts/client/jrio.js"></script>
<button id="cancel">Cancel</button>
<button id="rerun" disabled>Re-run</button>
<div id="reportContainer"></div>
JavaScript
jrio.config({
server: "http://localhost:8080/jrio",
scripts: "http://localhost:8080/jrio-client/optimized-scripts",
theme: {
href: "http://localhost:8080/jrio-client/themes/default"
},
locale: "en_US"
});
jrio(function(jrioClient) {
let button = $("button");
let report = jrioClient.report({
resource: "/samples/reports/SlowReport",
container: "#reportContainer",
events: {
changeTotalPages: function() {
reportDone();
}
}
});
$("#cancel").click(function() {
report
.cancel()
.then(function() {
reportDone();
alert("Report Canceled!");
})
.fail(function() {
alert("Can't Cancel Report");
});
});
$("#rerun").click(function() {
reportInProgress();
report
.refresh()
.fail(function() {
alert("Report Refresh did not complete");
});
});
function reportInProgress() {
$("#cancel").prop("disabled", false);
$("#rerun").prop("disabled", true);
}
function reportDone() {
$("#cancel").prop("disabled", true);
$("#rerun").prop("disabled", false);
}
});