base.html 7.21 KB
<!DOCTYPE html>
<html lang="en">
<head>

    {% load staticfiles %}
  
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Control center for the SVOM French GFT">
    <meta name="author" content="CNRS-IRAP">
    
    
    <title>SVOM French GFT Control Center</title>

    <!-- Bootstrap core CSS -->
    <link href={% static "bootstrap/css/bootstrap.css" %} rel="stylesheet">

    <link href={% static "bootstrap/css/sb-admin.css" %} rel="stylesheet">
    <link rel="stylesheet" href={% static "bootstrap/font-awesome/css/font-awesome.min.css" %}>

    <!-- Page Specific CSS -->
    <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
    
    <!-- JsTree -->
    <link rel="stylesheet" href={% static "bootstrap/dist/themes/default/style.min.css" %}>
    <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
	
	{% block head %}
	
	{% endblock %}

</head>

<body>
<style>
    #wrapper{
        padding-left: 0px;
    }

    #profile
    {
        font-size: 20px;
    }
</style>
<div id="wrapper">

      <!-- Sidebar -->
      <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <a class="navbar-brand" href={% url "index" %}>SVOM French GFT Control Center</a>
        </div>
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>



        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">

          <ul class="nav navbar-nav navbar-right navbar-user">
              <li><a id="day_night" href="{% url "weather" %}"><img id="day_night_img"></a></li>
              <li><a id="wind" href="{% url "weather" %}"><img id="wind_img"></a></li>
              <li><a id="weather" href="{% url "weather" %}"><img id="weather_img"></a></li>
            <li>
              <a href="{% url "profile" %}"><i id="profile" class="fas fa-cog "></i></a>
            </li>
            <li>
              <a href="{% url "user_logout" %}" ><i class="fa fa-power-off"></i> Log Out</a>             
            </li>

          </ul>
        
        </div><!-- /.navbar-collapse -->
        
        
      </nav>

      <div id="page-wrapper">
      
      
      	<div class="row">      	
			<center><h2 id="title">{% block title %}  {% endblock %}</h2></center>
		</div>
	
		{% block content %}
		   
		   
		{% endblock %}
        

      </div><!-- /#page-wrapper -->

    </div><!-- /#wrapper -->

        <!-- Javascript function refreshing weather icons on the navbar -->

	    <script>
              var TOO_STRONG_WIND = 60; //Totally arbitrary values, just for demonstration
              var MAX_CLOUD_VALUE = 1;
              var REFRESH_ICONS_FREQUENCE_MILLISECONDS = 60000;
              var MAX_RAIN_RATE = 10;

              ajax_request();
              interval = setInterval(function() {ajax_request();}, REFRESH_ICONS_FREQUENCE_MILLISECONDS);

              function ajax_request() {
                  $.get("{% url 'retrieve_env_navbar' %}", function (weather_status) {
                      if (weather_status)
                      {
                          /*
                          *** totally arbitrary method for day/night cycle, just for demonstration
                           */
                          var hour = new Date().getTime();
                          var site_time = new Date(hour - 9 * 3600 * 1000).getHours();
                          var _img_day_night =document.createElement('img');
                          if (site_time > 5 && site_time < 20)
                              _img_day_night.src ="{% static 'media/white_rising_sun_new.png' %}";
                          else
                              _img_day_night.src ="{% static 'media/white_moon_new.png' %}";
                          _img_day_night.width = 30;
                          _img_day_night.height = 30;
                          _img_day_night.id ="day_night_img";
                          _img_day_night.alt="html5";
                          $("#day_night_img").replaceWith(_img_day_night);

                          var _img = document.createElement('img');
                          _img.width = 30;
                          _img.height = 30;
                          _img.id ="weather_img";
                          console.log(weather_status[0]['fields']['global_status']);
                          if(parseInt(weather_status[0]['fields']['rain']) > MAX_RAIN_RATE)
                              _img.src = "{% static 'media/rain_new.png' %}";
                          else if (parseInt(weather_status[0]['fields']['cloud']) > MAX_CLOUD_VALUE)
                              _img.src = "{% static 'media/white_cloud.png' %}";
                          else
                              _img.src = "{% static 'media/white_sun.png' %}";
                              _img.width = 25;
                              _img.height = 25;
                              _img.alt = "html5";
                          $("#weather_img").replaceWith(_img);

                          var _im = document.createElement('img');
                          _im.width = 25;
                          _im.height = 25;
                          _im.id="wind_img";
                          if (parseInt(weather_status[0]['fields']['wind']) >= TOO_STRONG_WIND)
                            _im.src = "{% static 'media/white_wind.png' %}";
                          else
                            _im.src= "{% static 'media/white_windsock_nowind_new.png' %}";
                          $("#wind_img").replaceWith(_im);
                      }
                  }, 'json')
                      .fail(function () {
                          console.log('Ajax error: GET request failed\n');
                      })
              }
          </script>
    
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

    <script src={% static "bootstrap/js/bootstrap.min.js" %}></script>

    <!-- JavaScript -->
{#    <script src={% static "bootstrap/js/jquery-1.10.2.js" %}></script>#}
{#    <script src={% static "bootstrap/js/bootstrap.js" %}></script>#}
        <script src={% static "bootstrap/js/jquery.formset.js" %}></script>

    <!-- Page Specific Plugins -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
    <script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
    <script src={% static "bootstrap/js/morris/chart-data-morris.js" %}></script>
    <script src={% static "bootstrap/js/tablesorter/jquery.tablesorter.js" %}></script>
    <script src={% static "bootstrap/js/tablesorter/tables.js" %}></script>
    
    
</body>
</html>