Basic Dashboard Embed

Simple initialization of the library, plain text authentication and loading a dashboard

by tara5

HTML

<script src="http://localhost:8080/jasperserver-pro/client/visualize.js"></script>

<!-- JQuery - Latest compiled and minified -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

<div style="height: 500px;">

</div>

<div id="container" style="height: 1500px;">
    <div id="dashboard">
      <div><p>Loading...</p></div>
    </div>
</div>

CSS

/* #container {
    width: 1110px;
    height: 630px;
}

You can replace the following with your own custom loading indicator
@import "compass/css3";

@keyframes fadeIn {
  from { opacity: 0; }
}

p {
  position: relative;
  top: 50px;
  right: 250px;

  font: italic bold 1.2em/1 Bodoni, serif;
  color: #555;
  text-align: center;

  animation: fadeIn 1s infinite alternate;
} */

JavaScript

visualize({
    auth: {
        name: "superuser",
        password: "superuser",
    }
}, function (v) {

    //render report from provided resource
    v("#container").dashboard({
        resource: "/public/New_Dashboard",
        error: handleError
    });

    //show error
    function handleError(err) {
        alert(err.message);
    }
});