Blame view

src/misc/templates/base.html 14.3 KB
94082e77   haribo   Date: 03/06/2016
1
2
3
4
5
<!DOCTYPE html>
<html lang="en">
<head>

    {% load staticfiles %}
94082e77   haribo   Date: 03/06/2016
6
7
8
9
10
    <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">
e7876d61   Patrick Maeght   colibrifavicon
11
    <link rel="icon" type="image/png" href="../public/static/media/colibrifavicon.png" />
94082e77   haribo   Date: 03/06/2016
12
    
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
13
    <title >Colibri Control Center</title>
94082e77   haribo   Date: 03/06/2016
14
15
16
17
18
19
20
21

    <!-- 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 -->
ba1d1f2b   Quentin Durand   implémentation Fr...
22
    <!--    <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css"> -->
94082e77   haribo   Date: 03/06/2016
23
24
    
    <!-- JsTree -->
6dc0b213   theophile.puhl@epitech.eu   Création du dashb...
25
26
27
    <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">
94082e77   haribo   Date: 03/06/2016
28
29
	
	{% block head %}
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
30
31
32
33
34
35
	<style> 
  #title {
    font-family: 'Montserra', sans-serif; 
    font-size: 50px;
  }
  </style>
94082e77   haribo   Date: 03/06/2016
36
37
38
39
40
	{% endblock %}

</head>

<body>
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
41
<style>
17096d96   theophile.puhl@epitech.eu   Fixing Merge Issues
42

e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
43
44
45
#page-wrapper {
  padding: 15px 60px;
}
d5fce214   theopuhl   Dashboard color c...
46

e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
47
48
#wrapper {
  padding-left: 10%;
17096d96   theophile.puhl@epitech.eu   Fixing Merge Issues
49
  
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
50
51
52
53
54
}

.side-nav {
  margin-left: -200px;
  left: 200px;
9f5133c2   Unknown   Implmentation of ...
55
  width: 125px;
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
56
57
58
59
}

a {
  font-family: 'Montserra', sans-serif;
94082e77   haribo   Date: 03/06/2016
60

e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
61
62
63
}

#fas {
d5fce214   theopuhl   Dashboard color c...
64
  size: 18px;
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
65
}
d5fce214   theopuhl   Dashboard color c...
66

17096d96   theophile.puhl@epitech.eu   Fixing Merge Issues
67
68
#profile
{
d5fce214   theopuhl   Dashboard color c...
69
    font-size: 17px;
17096d96   theophile.puhl@epitech.eu   Fixing Merge Issues
70
}
fca58359   Unknown   Updating site tim...
71

fca58359   Unknown   Updating site tim...
72
73
#hour
{
d5fce214   theopuhl   Dashboard color c...
74
75
76
77
    color: black;
    font-size: 14px;
}

6973f7df   Quentin Durand   PLC STATE + MODE
78
79
#plc_state
{
c830a3bc   Quentin Durand   PLC ACK + plc tim...
80
    color: black;
6973f7df   Quentin Durand   PLC STATE + MODE
81
82
83
    font-size: 18px;
}

d5fce214   theopuhl   Dashboard color c...
84
85
#signout {
    color: black;
fca58359   Unknown   Updating site tim...
86
}
d5fce214   theopuhl   Dashboard color c...
87
88
89
90
91
92

.nav>li>a:focus, .nav>li>a:hover {
        text-decoration: none;
        background-color: transparent !important;
}

d10a07d4   theopuhl   Update Images
93
94
95
96
#topbar {
    -webkit-transition: background-color 800ms linear;
    -ms-transition: background-color 800ms linear;
    transition: background-color 800ms linear;
6aec6155   theopuhl   Majordome algorit...
97
98
99
100
    height: 100%;
}
#text_globalmode {
    font-size: 14px;
fc957772   Quentin Durand   Control command P...
101
    color: black;
fca58359   Unknown   Updating site tim...
102
}
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
103
</style>
fca58359   Unknown   Updating site tim...
104

e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
105
{% load tags %}
d3a69adc   theopuhl   Change name to ch...
106
107
108
109
110
111
{% get_level "USER_LEVEL_TAS" as USER_LEVEL_TAC %}
{% get_level "USER_LEVEL_OBSERVER" as USER_LEVEL_OBSERVER %}
{% get_level "USER_LEVEL_IE" as USER_LEVEL_IE %}
{% get_level "USER_LEVEL_OPERATOR" as USER_LEVEL_OPERATOR %}
{% get_level "USER_LEVEL_SUPEROPERATOR" as USER_LEVEL_SUPEROPERATOR %}
{% get_level "USER_LEVEL_PI" as USER_LEVEL_PI %}
a58163bb   theopuhl   New page Simulator
112
{% get_level "USER_LEVEL_PI" as USER_LEVEL_SYSADMIN %}
94082e77   haribo   Date: 03/06/2016
113
114
115
<div id="wrapper">

      <!-- Sidebar -->
6aec6155   theopuhl   Majordome algorit...
116
      <nav class="navbar navbar-inverse navbar-fixed-top navbar-expand-lg" role="navigation">
94082e77   haribo   Date: 03/06/2016
117
118
      <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
e7876d61   Patrick Maeght   colibrifavicon
119
            <img alt="" src="../public/static/media/colibrifavicon.png">
3e870366   Patrick Maeght   colibrifavicon
120
            <a class="navbar-brand" href={% url "index" %} style="color: black;">Colibri Control Center</a>
94082e77   haribo   Date: 03/06/2016
121
        </div>
76dfa189   Unknown   Adding devices lo...
122
123
124
125
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>



94082e77   haribo   Date: 03/06/2016
126
        <!-- Collect the nav links, forms, and other content for toggling -->
d5fce214   theopuhl   Dashboard color c...
127
        <!-- #f9ff93 #6b69f3-->
d10a07d4   theopuhl   Update Images
128
        <div id="topbar" class="collapse navbar-collapse navbar-ex1-collapse navbar-dark bg-primary">
d5fce214   theopuhl   Dashboard color c...
129
        <ul class="nav navbar-nav side-nav navbar-dark bg-primary" id="navbar_list">
2c61f856   theopuhl   Url change to pat...
130
            <li><a href="{% url "weather" %}">Weather</a></li>
d3a69adc   theopuhl   Change name to ch...
131
            {% if USER_LEVEL >= USER_LEVEL_IE %}
2c61f856   theopuhl   Url change to pat...
132
133
134
135
136
                <li><a href="{% url "site" %}">State</a></li>
                <li><a href="{% url "site" %}">Observatory</a></li>
            {% else %}
                <li><a href="{% url "site" %}">Observatory</a></li>
            {% endif %}
d3a69adc   theopuhl   Change name to ch...
137
            {% if USER_LEVEL >= USER_LEVEL_IE %}
2c61f856   theopuhl   Url change to pat...
138
139
140
                <li><a href="{% url "observation_status" %}">Tel & Inst</a></li>
            {% endif %}
            <li><a href="#">Webcams</a></li>
d3a69adc   theopuhl   Change name to ch...
141
            {% if USER_LEVEL >= USER_LEVEL_OBSERVER %}
2c61f856   theopuhl   Url change to pat...
142
143
144
                <li><a href="{% url "proposal" %}">Proposal</a></li>
            {% endif %}
            <li><a href="{% url "requests_list" %}">Request</a></li>
3dbda6a0   haribo   Date: 17/06/2016
145
            <li><a href="{% url "alerts_list" %}">Alerts</a></li>
2c61f856   theopuhl   Url change to pat...
146
147
            <li><a href="{% url "current_schedule" %}">Schedule</a></li>
            <li><a href="#">Images</a></li>
1b9ba1f6   Quentin Durand   Little update on ...
148
            <li><a href="{% url "system" %}">System</a></li>
94082e77   haribo   Date: 03/06/2016
149
          </ul>
6aec6155   theopuhl   Majordome algorit...
150
          <ul class="nav navbar-nav navbar-right navbar-user navbar-expand-lg">
6973f7df   Quentin Durand   PLC STATE + MODE
151
              <li><a id="plc_state"></a></li>
d10a07d4   theopuhl   Update Images
152
            <li><a class="nav-brand" id="hour">Sun elevation :</a></li>
5f7e4955   Quentin Durand   Add some commands...
153
            <li><a class="nav-brand" id="day_night" ><img id="day_night_img"></a></li>
d66e0d93   Quentin Durand   observatory statu...
154
             <li><a class="nav-brand" id="observatory_state" href="{% url "site" %}"><img id="obs_state_img"></a></li>
d5fce214   theopuhl   Dashboard color c...
155
            <li><a class="nav-brand" id="wind" href="{% url "weather" %}"><img id="wind_img"></a></li>
6973f7df   Quentin Durand   PLC STATE + MODE
156
            <li><a class="nav-brand" id="weather" href="{% url "weather" %}"><img id="weather_img"></a></li>
fc957772   Quentin Durand   Control command P...
157
            <li><a class="nav-brand" id="globalmode" style="color: black;"> <p id="text_globalmode"  >{% global_mode  request %} </p></a>
c830a3bc   Quentin Durand   PLC ACK + plc tim...
158

e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
159
            <li>
d5fce214   theopuhl   Dashboard color c...
160
                <a class="nav-brand" href="{% url "profile" %}" style="color: black;"><i id="profile" class="fas fa-cog "></i></a>              
94082e77   haribo   Date: 03/06/2016
161
            </li>
e31b2208   theophile.puhl@epitech.eu   Severals Changes ...
162
            <li>
d5fce214   theopuhl   Dashboard color c...
163
              <a id="signout" href="{% url "user_logout" %}" ><i class="fa fa-power-off"></i> Log Out</a>             
94082e77   haribo   Date: 03/06/2016
164
            </li>
76dfa189   Unknown   Adding devices lo...
165

94082e77   haribo   Date: 03/06/2016
166
          </ul>
757a9ae5   Unknown   fixing js in base...
167
            <script>
76dfa189   Unknown   Adding devices lo...
168
169
              var TOO_STRONG_WIND = 60; //Totally arbitrary values, just for demonstration
              var MAX_CLOUD_VALUE = 1;
40ee3b96   Quentin Durand   adding sunelevati...
170
              var REFRESH_ICONS_FREQUENCE_MILLISECONDS = 1000;
76dfa189   Unknown   Adding devices lo...
171
172
              var MAX_RAIN_RATE = 10;

c830a3bc   Quentin Durand   PLC ACK + plc tim...
173
174
              var check_change = true;

fca58359   Unknown   Updating site tim...
175
              $( document ).ready(function() {
e6eb923f   Quentin Durand   Prototype agent t...
176

40ee3b96   Quentin Durand   adding sunelevati...
177
              function set_elev(sun_elev)
fca58359   Unknown   Updating site tim...
178
              {
40ee3b96   Quentin Durand   adding sunelevati...
179
                  $("#hour").text("Sun elevation : " + sun_elev);
fca58359   Unknown   Updating site tim...
180
              }
fca58359   Unknown   Updating site tim...
181

e6eb923f   Quentin Durand   Prototype agent t...
182
              function change_color_navbar(elevation, elev_threshold)
fca58359   Unknown   Updating site tim...
183
              {
d10a07d4   theopuhl   Update Images
184
                  var color = "";
9f5133c2   Unknown   Implmentation of ...
185
                  if (elevation >= elev_threshold)
d10a07d4   theopuhl   Update Images
186
187
188
189
                    color = "#f9ff93";
                  else
                    color = "#6b69f3";
                $("#topbar").css("background-color", color);
fca58359   Unknown   Updating site tim...
190
              }
e6eb923f   Quentin Durand   Prototype agent t...
191
192
193
194
195

              /*
                function displaying the state of the PLC, called in the main function every REFRESH_ICONS_FREQUENCE_MILLISECONDS
              */

9f5133c2   Unknown   Implmentation of ...
196
              function info_plc(is_safe, mode, ack, timeout, max_plc_timeout)
6973f7df   Quentin Durand   PLC STATE + MODE
197
              {
6973f7df   Quentin Durand   PLC STATE + MODE
198
199
200
201
                  var safe = "UNSAFE";
                  if (is_safe)
                      safe = "SAFE";

c830a3bc   Quentin Durand   PLC ACK + plc tim...
202
                  if (ack) {
fc957772   Quentin Durand   Control command P...
203
                      ack = "ACK: OK";
c830a3bc   Quentin Durand   PLC ACK + plc tim...
204
205
206
207
208
209
210
211
212
213
214
                      if (!check_change)
                          window.location.reload(true);
                      check_change = true;
                  }
                  else
                  {
                      ack = "STAFF ACK: KO";
                      $("#plc_state").css("background-color", "red");
                      check_change = false;
                  }

fc957772   Quentin Durand   Control command P...
215
                  $("#plc_state").text("PLC: " + mode + '\u00A0\u00A0\u00A0\u00A0\u00A0' + safe + '\u00A0\u00A0\u00A0\u00A0\u00A0' + ack);
9f5133c2   Unknown   Implmentation of ...
216
217
218
219
220
221
                   $("#plc_state").css("color", "black");
                   if (timeout > max_plc_timeout)
                  {
                      $("#plc_state").text("Connection to PLC LOST");
                      $("#plc_state").css("color", "red");
                  }
6973f7df   Quentin Durand   PLC STATE + MODE
222
223
              }

e6eb923f   Quentin Durand   Prototype agent t...
224
225


76dfa189   Unknown   Adding devices lo...
226
227
228
              ajax_request();
              interval = setInterval(function() {ajax_request();}, REFRESH_ICONS_FREQUENCE_MILLISECONDS);

e6eb923f   Quentin Durand   Prototype agent t...
229
230
231
232
233
234
235
236
237
               /*
                   Main method called every REFRESH_ICONS_FREQUENCE_MILLISECONDS,  it is responsible of the element
                   in the navbar, it changes the information and the pictures displayed in function of the elemets send
                   by the "retrieve_env_navbar" view : PLC info, sunelev etc

                   This information is retrieved by a HTTP GET on the retrieve_env_navbar url

               */

76dfa189   Unknown   Adding devices lo...
238
239
              function ajax_request() {
                  $.get("{% url 'retrieve_env_navbar' %}", function (weather_status) {
d5fce214   theopuhl   Dashboard color c...
240
                    if (weather_status)
76dfa189   Unknown   Adding devices lo...
241
                      {
bb697c31   Unknown   Auto stash before...
242
                          var sunelev = parseFloat(weather_status[0]['sunelev']);
9f5133c2   Unknown   Implmentation of ...
243
244
245
                          var max_sunelev = parseInt(weather_status[0]['max_sunelev']);

                          set_elev(sunelev);
e6eb923f   Quentin Durand   Prototype agent t...
246
247
248

                          change_color_navbar(sunelev, max_sunelev);

6aec6155   theopuhl   Majordome algorit...
249
                          $("#text_globalmode").text(weather_status[0]["pyros_mode"]);
bb697c31   Unknown   Auto stash before...
250
                          var _img_day_night = document.createElement('img');
9f5133c2   Unknown   Implmentation of ...
251
                          if (sunelev >= max_sunelev)
d5fce214   theopuhl   Dashboard color c...
252
                              _img_day_night.src ="{% static 'media/rising_sun.png' %}";
76dfa189   Unknown   Adding devices lo...
253
                          else
d5fce214   theopuhl   Dashboard color c...
254
                              _img_day_night.src ="{% static 'media/moon.png' %}";
5f7e4955   Quentin Durand   Add some commands...
255
256
                          _img_day_night.width = 22;
                          _img_day_night.height = 22;
76dfa189   Unknown   Adding devices lo...
257
258
                          _img_day_night.id ="day_night_img";
                          _img_day_night.alt="html5";
6b16badb   Quentin Durand   Fix unitests + ne...
259
                           $("#day_night_img").replaceWith(_img_day_night);
76dfa189   Unknown   Adding devices lo...
260

d66e0d93   Quentin Durand   observatory statu...
261
262
263
264
265

                           var _img = document.createElement('img');
                          _img.width = 18;
                          _img.height = 18;
                          _img.id ="obs_state_img";
19e26d9c   Quentin Durand   adding observator...
266
267
268
                          if (parseInt(weather_status[0]["plc_timeout"]) > parseInt(weather_status[0]["max_plc_timeout"]))
                              _img.src = "{% static 'media/observatory_off.png' %}";
                          else if (weather_status[0]["sitewatch_global_status"] === "OK")
d66e0d93   Quentin Durand   observatory statu...
269
270
271
272
273
274
                               _img.src = "{% static 'media/observatory.png' %}";
                          else
                              _img.src = "{% static 'media/observatory_red.png' %}";
                          _img.alt = "html5";
                          $("#obs_state_img").replaceWith(_img);

1b9ba1f6   Quentin Durand   Little update on ...
275

76dfa189   Unknown   Adding devices lo...
276
                          var _img = document.createElement('img');
d5fce214   theopuhl   Dashboard color c...
277
278
                          _img.width = 18;
                          _img.height = 18;
76dfa189   Unknown   Adding devices lo...
279
                          _img.id ="weather_img";
e6eb923f   Quentin Durand   Prototype agent t...
280
281
282
283
284

                          /*
                            The plc_timeout variable is badly named: actually it is "seconds_since_plc_gave_its_last_status"
                            max_plc_timeout is the maximum time that we can wait to the plc to create a status before considering it offline
                          */
9f5133c2   Unknown   Implmentation of ...
285
286
287
                          if (parseInt(weather_status[0]["plc_timeout"]) > parseInt(weather_status[0]["max_plc_timeout"]))
                               _img.src = "{% static 'media/rain_no_plc.png' %}";
                          else if(parseInt(weather_status[0]['fields']['rain']) > MAX_RAIN_RATE)
d5fce214   theopuhl   Dashboard color c...
288
                              _img.src = "{% static 'media/rain.png' %}";
76dfa189   Unknown   Adding devices lo...
289
                          else if (parseInt(weather_status[0]['fields']['cloud']) > MAX_CLOUD_VALUE)
d5fce214   theopuhl   Dashboard color c...
290
                              _img.src = "{% static 'media/cloud.png' %}";
76dfa189   Unknown   Adding devices lo...
291
                          else
d5fce214   theopuhl   Dashboard color c...
292
293
294
                              _img.src = "{% static 'media/sun.png' %}";
                              _img.width = 18;
                              _img.height = 18;
76dfa189   Unknown   Adding devices lo...
295
296
297
298
                              _img.alt = "html5";
                          $("#weather_img").replaceWith(_img);

                          var _im = document.createElement('img');
d5fce214   theopuhl   Dashboard color c...
299
300
                          _im.width = 18;
                          _im.height = 18;
76dfa189   Unknown   Adding devices lo...
301
                          _im.id="wind_img";
9f5133c2   Unknown   Implmentation of ...
302
303
304
                          if (parseInt(weather_status[0]["plc_timeout"]) > parseInt(weather_status[0]["max_plc_timeout"]))
                              _im.src = "{% static 'media/wind_no_plc.png' %}";
                          else if (parseInt(weather_status[0]['fields']['wind']) >= TOO_STRONG_WIND)
d5fce214   theopuhl   Dashboard color c...
305
                            _im.src = "{% static 'media/wind.png' %}";
76dfa189   Unknown   Adding devices lo...
306
                          else
d5fce214   theopuhl   Dashboard color c...
307
                            _im.src= "{% static 'media/windsock_nowind.png' %}";
76dfa189   Unknown   Adding devices lo...
308
                          $("#wind_img").replaceWith(_im);
40ee3b96   Quentin Durand   adding sunelevati...
309

9f5133c2   Unknown   Implmentation of ...
310
311
312
                          info_plc(weather_status[0]["is_safe"], weather_status[0]["plc_mode"],
                              weather_status[0]["ACK"], parseInt(weather_status[0]["plc_timeout"]),
                              parseInt(weather_status[0]["max_plc_timeout"]) );
76dfa189   Unknown   Adding devices lo...
313
314
315
316
317
                      }
                  }, 'json')
                      .fail(function () {
                          console.log('Ajax error: GET request failed\n');
                      })
fca58359   Unknown   Updating site tim...
318
              }});
76dfa189   Unknown   Adding devices lo...
319
          </script>
757a9ae5   Unknown   fixing js in base...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344

        </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 -->


94082e77   haribo   Date: 03/06/2016
345
346
347
348
349
    
    <!-- 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>
fca58359   Unknown   Updating site tim...
350
351
352
353
    <script  src="{% static "/js/moment.min.js" %}"></script>
    <script  src="{% static "/js/moment-timezone.min.js" %}"></script>
    <script  src="{% static "/js/moment-timezone-with-data.min.js" %}"></script>

94082e77   haribo   Date: 03/06/2016
354
355
356
357

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

    <!-- JavaScript -->
e6dd9964   haribo   Date: 19/07/2016
358
359
{#    <script src={% static "bootstrap/js/jquery-1.10.2.js" %}></script>#}
{#    <script src={% static "bootstrap/js/bootstrap.js" %}></script>#}
94082e77   haribo   Date: 03/06/2016
360
361
362
363
        <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>
ba1d1f2b   Quentin Durand   implémentation Fr...
364
    <!--    <script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>    -->
94082e77   haribo   Date: 03/06/2016
365
366
367
368
    <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>
    
6dc0b213   theophile.puhl@epitech.eu   Création du dashb...
369
    
94082e77   haribo   Date: 03/06/2016
370
371
</body>
</html>