Visualize.js: Basic dashboard login/logout

Login and logout/destroy the current user session with dashboards

HTML

<script src="https://mobiledemo.jaspersoft.com/jasperserver-pro/client/visualize.js"></script>

<button>Logout</button>

<div id="dashboard">
      <div><p>Loading...</p></div>
</div>

CSS

#dashboard {
    width: 1000px;
    height: 600px;
}

/* 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: Login and logout/destroy session with dashboards

visualize({
    auth: {
        name: "joeuser",
        password: "joeuser",
        organization: "organization_1"
    }
}, function (v) {
    var dashboard = v.dashboard({
        resource: "/public/Samples/Dashboards/4._New_Dashboard",
        container: "#dashboard",
        error: function(e) {
            alert(e);
        }
    });
    
    $("button").on("click", function(e) {
        dashboard
            .destroy()
            .fail(function(e) { alert(e); })
            .done(function() { console.log("dashboard destroyed"); });
    });
});