<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="apple-touch-icon" sizes="76x76" href="static/assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="static/assets/img/favicon.png">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>BAC0 - A Python App for BACnet</title>

	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />


    <!-- Bootstrap core CSS     -->
    <link href="static/assets/css/bootstrap.min.css" rel="stylesheet" />

    <!-- Animation library for notifications   -->
    <link href="static/assets/css/animate.min.css" rel="stylesheet"/>

    <!--  Paper Dashboard core CSS    -->
    <link href="static/assets/css/paper-dashboard.css" rel="stylesheet"/>


    <!--  CSS for Demo Purpose, don't include it in your project     -->
    <link href="static/assets/css/demo.css" rel="stylesheet" />


    <!--  Fonts and icons     -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
    <link href="static/assets/css/themify-icons.css" rel="stylesheet">

</head>
<body>
<div class="wrapper">

{{sidebar|safe}}

    <div class="main-panel">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar bar1"></span>
                        <span class="icon-bar bar2"></span>
                        <span class="icon-bar bar3"></span>
                    </button>
                    <a class="navbar-brand" href="#">Dashboard</a>
                </div>

                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li>
                            <a href="" class="dropdown-toggle" data-toggle="dropdown">							
    								<i class="ti-server"></i>
                                <p id="discover">Discover</p>
                            </a>
                        </li>
                        <li class="dropdown">
                              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="ti-bell"></i>
                                    <p class="notification"></p>
									<p>Notifications</p>
									<b class="caret"></b>
                              </a>
{{notifications|safe}}
                        </li>
                    </ul>

                </div>
            </div>
        </nav>


        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    {{card_number_of_devices|safe}}
                    
                    {{card_number_of_mstp_networks|safe}}

                    {{card_number_of_trends|safe}}
                    
                </div>

                <div class="row">
                    <div class="col-md-6">
                        <div class="card">
                            <div class="header">
                                <h4 class="title">Networks and devices Statistics</h4>
                                <p class="category">Distribution over networks</p>
                            </div>
                            <div class="content">
                                {{bokeh_pie|safe}}
                            </div>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>


        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <ul>

                        <li>
                            <a href="http://www.servisys.com">
                           Servisys inc.    
                            </a>
                        </li>
                        <li>
                            <a href="https://pythoninthebuilding.wordpress.com">
                               Blog
                            </a>
                        </li>
                        <li>
                            <a href="https://github.com/JoelBender/bacpypes">
                                BACpypes
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="copyright pull-right">
                    &copy; <script>document.write(new Date().getFullYear())</script>, Web design made with <i class="fa fa-heart heart"></i> by <a href="http://www.creative-tim.com">Creative Tim</a>
                </div>
            </div>
        </footer>

    </div>
</div>


</body>

    <!--   Core JS Files   -->
    <script src="static/assets/js/jquery-1.10.2.js" type="text/javascript"></script>
	<script src="static/assets/js/bootstrap.min.js" type="text/javascript"></script>

	<!--  Checkbox, Radio & Switch Plugins -->
	<script src="static/assets/js/bootstrap-checkbox-radio.js"></script>

	<!--  Charts Plugin -->
	<script src="static/assets/js/chartist.min.js"></script>

    <!--  Notifications Plugin    -->
    <script src="static/assets/js/bootstrap-notify.js"></script>

    <!--  Google Maps Plugin    -->
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>

    <!-- Paper Dashboard Core javascript and methods for Demo purpose -->
	<script src="static/assets/js/paper-dashboard.js"></script>
    
    <!-- Paper Dashboard DEMO methods, don't include it in your project! -->
	<script src="static/assets/js/demo.js"></script>


	<script type="text/javascript">
	  $(document).ready(function(){

        	updatePieChart();

        	$.notify({
            	icon: 'ti-github',
            	message: "Join the project on Github and contribute to this open source project !"

            },{
                type: 'success',
                timer: 4000
            });

    	});

    	$('#discover').bind('click', function(event){

          callWhois();

        	$.notify({
            	icon: 'ti-world',
            	message: "Discovering devices"

            },{
                type: 'success',
                timer: 1000
            });

    	});

       var intervalID = setInterval(update_values, 1000);
    	function update_values() {
                $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
                $.getJSON($SCRIPT_ROOT+"/_dash_live_stats",
                    function(data) {
                        $("#mstpnetworks").text(data.print_mstpnetworks)
                        $("#lastwhoisupdate").text(data.timestamp)
                    });
                $.getJSON($SCRIPT_ROOT+"/_dash_live_data",
                    function(data) {
                        $("#devices").text(data.number_of_devices)
                        $("#trends").text(data.number_of_registered_trends)
                    });
            }
            
        function callWhois() {
                $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
                $.getJSON($SCRIPT_ROOT+"/_whois");
            }
            
                   
    </script>

</html>
