Skip to content

Commit

Permalink
dashbaord login pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
rahatjaan committed Aug 19, 2015
1 parent d4e179f commit 3292abb
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 196 deletions.
207 changes: 11 additions & 196 deletions server/src/main/webapp/home.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,12 @@
</div>

</div>
<div>
<div style="display: none;">
<h2>Successful login</h2>
<h:inputTextarea value="#{metricService.successJson}" ></h:inputTextarea>


</div>

<div>
<h:inputTextarea value="#{metricService.successJson}" id="successJson"></h:inputTextarea>

<h2>failed login</h2>
<h:inputTextarea value="#{metricService.failureJson}" ></h:inputTextarea>
<h:inputTextarea value="#{metricService.failureJson}" id="failedJson"></h:inputTextarea>


</div>
Expand Down Expand Up @@ -126,7 +122,7 @@

<div class="box-body">
<div class="row">
<div class="col-md-8">
<div class="col-md-10">
<p class="text-center">
<strong></strong>
</p>
Expand All @@ -138,19 +134,18 @@

</div>

<div class="col-md-4">
<div class="col-md-2">

<div class="progress-group">
<span class="progress-text">Single Sign-On
Authentication Errors</span>
<span class="progress-text">Login Successful</span>
<div class="progress sm">
<div class="progress-bar progress-bar-aqua"
style="width: 100%; background-color: rgb(75, 148, 192);"></div>
</div>
</div>

<div class="progress-group">
<span class="progress-text">API Requests</span>
<span class="progress-text">Login Failed</span>
<div class="progress sm">
<div class="progress-bar progress-bar-red"
style="width: 100%; background-color: rgb(210, 214, 222);"></div>
Expand Down Expand Up @@ -205,177 +200,7 @@
</div>

</div>

<div class="row">
<section class="col-lg-7">
<div class="box box-solid bg-green-gradient">
<div class="box-header">
<i class="fa fa-th"></i>
<h3 class="box-title">Server Activity</h3>
<div class="box-tools pull-right">
<button class="btn bg-green btn-sm" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
<button class="btn bg-green btn-sm" data-widget="remove">
<i class="fa fa-times"></i>
</button>
</div>

</div>
<div class="box-body border-radius-none">
<div class="chart" id="line-chart" style="height: 250px;"></div>
</div>

<div class="box-footer no-border">
<div class="row">
<div class="col-xs-4 text-center"
style="border-right: 1px solid #f4f4f4">
<input type="text" class="knob" data-readonly="true" value="20"
data-width="60" data-height="60" data-fgcolor="#00BE79" />
<div class="knob-label">New Users</div>
</div>

<div class="col-xs-4 text-center"
style="border-right: 1px solid #f4f4f4">
<input type="text" class="knob" data-readonly="true" value="50"
data-width="60" data-height="60" data-fgcolor="#00BE79" />
<div class="knob-label">Online Users</div>
</div>

<div class="col-xs-4 text-center">
<input type="text" class="knob" data-readonly="true" value="30"
data-width="60" data-height="60" data-fgcolor="#00BE79" />
<div class="knob-label">User Requests</div>
</div>

</div>

</div>

</div>
</section>
<div class="col-md-5">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Browser Usage</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
<button class="btn btn-box-tool" data-widget="remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>

<div class="box-body">
<div class="row">
<div class="col-md-8">
<div class="chart-responsive">
<canvas id="browserUsageChart" height="150"></canvas>
</div>

</div>

<div class="col-md-4">
<ul class="chart-legend clearfix">
<li><i class="fa fa-circle-o text-red"></i> Chrome</li>
<li><i class="fa fa-circle-o text-green"></i> IE</li>
<li><i class="fa fa-circle-o text-yellow"></i> FireFox</li>
<li><i class="fa fa-circle-o text-aqua"></i> Safari</li>
<li><i class="fa fa-circle-o text-light-blue"></i> Opera</li>
<li><i class="fa fa-circle-o text-gray"></i> Navigator</li>
</ul>
</div>

</div>

</div>

</div>


<div class="box box-solid bg-green-gradient">
<div class="box-header">
<i class="fa fa-calendar"></i>
<h3 class="box-title">Calendar</h3>

<div class="pull-right box-tools">
<!-- button with a dropdown -->
<div class="btn-group">
<button class="btn btn-success btn-sm dropdown-toggle"
data-toggle="dropdown">
<i class="fa fa-bars"></i>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="#">Add new event</a></li>
<li><a href="#">Clear events</a></li>
<li class="divider"></li>
<li><a href="#">View calendar</a></li>
</ul>
</div>
<button class="btn btn-success btn-sm" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
<button class="btn btn-success btn-sm" data-widget="remove">
<i class="fa fa-times"></i>
</button>
</div>

</div>

<div class="box-body no-padding">
<div id="calendar" style="width: 100%"></div>
</div>

<div class="box-footer text-black">
<div class="row">
<div class="col-sm-6">
<div class="clearfix">
<span class="pull-left">File Server Backup</span> <small
class="pull-right">90%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green"
style="width: 90%;"></div>
</div>
<div class="clearfix">
<span class="pull-left">Database Cloning</span> <small
class="pull-right">70%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green"
style="width: 70%;"></div>
</div>
</div>

<div class="col-sm-6">
<div class="clearfix">
<span class="pull-left">Delete Inactive Users</span> <small
class="pull-right">60%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green"
style="width: 60%;"></div>
</div>
<div class="clearfix">
<span class="pull-left">Task #4</span> <small
class="pull-right">40%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green"
style="width: 40%;"></div>
</div>
</div>

</div>

</div>
</div>

</div>

</div>

</section>

<!-- Scripts -->
Expand All @@ -394,17 +219,7 @@
<script src="#{oxTrustConfigurationService.cssLocation}/../theme/plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<script src="#{oxTrustConfigurationService.cssLocation}/../theme/plugins/slimScroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="#{oxTrustConfigurationService.cssLocation}/../theme/plugins/chartjs/Chart.min.js" type="text/javascript"></script>
<script src="#{oxTrustConfigurationService.cssLocation}/../theme/dist/js/pages/dashboard.js" type="text/javascript"></script>
<script>
/*
var metrics = $("#metrics").val();
console.log("#metrics length:"+metrics.length);
var obj = JSON.stringify(eval(metrics));
console.log(obj);
var obj = JSON.parse(metrics);
console.log(obj);
*/
</script>

<script src="#{request.contextPath}/resources/js/dashboard.js" type="text/javascript"></script>

</ui:define>
</ui:composition>
103 changes: 103 additions & 0 deletions server/src/main/webapp/resources/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

"use strict";

$(function () {

//-----------------------
//- Dashboard > Authentication Requests Chart -
//-----------------------

// Get context with jQuery - using jQuery's .get() method.
var authenticationRequestsChartCanvas = $("#authenticationRequestsChart").get(0).getContext("2d");
// This will get the first returned node in the jQuery collection.
var authenticationRequestsChart = new Chart(authenticationRequestsChartCanvas);

var successJson = JSON.parse($("#successJson").val());
var failedJson = JSON.parse($("#failedJson").val());
console.log(failedJson);
console.log(successJson);
var successLabels = [];
var successValue = [];
for (var field in successJson) {
console.log("field:"+field+",value:"+successJson[field]);
successLabels.push(field);
successValue.push(successJson[field]);
}

var failedLabels = [];
var failedValue = [];
for (var field in failedJson) {
console.log("field:"+field+",value:"+failedJson[field]);
failedLabels.push(field);
failedValue.push(failedJson[field]);
}
var authenticationRequestsChartData = {
labels: successLabels,
datasets: [
{
label: "Successful Login",
fillColor: "rgb(210, 214, 222)",
strokeColor: "rgb(210, 214, 222)",
pointColor: "rgb(210, 214, 222)",
pointStrokeColor: "#c1c7d1",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgb(220,220,220)",
data: successValue
},
{
label: "Failed Attempts",
fillColor: "rgba(60,141,188,0.9)",
strokeColor: "rgba(60,141,188,0.8)",
pointColor: "#3b8bba",
pointStrokeColor: "rgba(60,141,188,1)",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(60,141,188,1)",
data: failedValue
}
]
};

var authenticationRequestsChartOptions = {
//Boolean - If we should show the scale at all
showScale: true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines: false,
//String - Colour of the grid lines
scaleGridLineColor: "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth: 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines: true,
//Boolean - Whether the line is curved between points
bezierCurve: true,
//Number - Tension of the bezier curve between points
bezierCurveTension: 0.3,
//Boolean - Whether to show a dot for each point
pointDot: false,
//Number - Radius of each point dot in pixels
pointDotRadius: 4,
//Number - Pixel width of point dot stroke
pointDotStrokeWidth: 1,
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point
pointHitDetectionRadius: 20,
//Boolean - Whether to show a stroke for datasets
datasetStroke: true,
//Number - Pixel width of dataset stroke
datasetStrokeWidth: 2,
//Boolean - Whether to fill the dataset with a color
datasetFill: true,
//String - A legend template
legendTemplate: "<ul class=\"rahat\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%=datasets[i].label%></li><%}%></ul>",
//Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: false,
//Boolean - whether to make the chart responsive to window resizing
responsive: true
};

//Create the line chart
authenticationRequestsChart.Line(authenticationRequestsChartData, authenticationRequestsChartOptions);


});

0 comments on commit 3292abb

Please sign in to comment.