Basic Dashboard Embed

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

by Gene Arnold

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 id="container">
    <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: "jasperadmin",
        password: "jasperadmin",
        organization: "organization_1"
    }
}, function (v) {

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

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