Blame view

src/core/pyros_django/misc/templates/base.html 17.1 KB
da13e230   Alexis Koralewski   update UI of webs...
1
2
3
4
5
6
7
8
9
10
<!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">
042db8a3   Alexis Koralewski   renabling sign in...
11
    <link rel="icon" type="image/png" href="{% static "media/colibrifavicon.png" %}"/>
da13e230   Alexis Koralewski   update UI of webs...
12
    
d38312c2   Alexis Koralewski   updating UI (CSS ...
13
    <title>{{ request.session.obsname}} Control Center - VERSION 2021.0.1</title>
da13e230   Alexis Koralewski   update UI of webs...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

    <!-- 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 %}
	<style> 
  #title {
    font-family: 'Montserra', sans-serif; 
d38312c2   Alexis Koralewski   updating UI (CSS ...
33
    font-size: 3rem;
da13e230   Alexis Koralewski   update UI of webs...
34
35
36
37
38
39
40
41
42
43
  }
  </style>
	{% endblock %}

</head>

<body>
<style>

#page-wrapper {
d38312c2   Alexis Koralewski   updating UI (CSS ...
44
45
  width: 80vw;
  height: 80vh;
da13e230   Alexis Koralewski   update UI of webs...
46
47
48
}

#wrapper {
d38312c2   Alexis Koralewski   updating UI (CSS ...
49
  #padding-left: 10%;
da13e230   Alexis Koralewski   update UI of webs...
50
51
52
}

.side-nav {
d38312c2   Alexis Koralewski   updating UI (CSS ...
53
  max-width: 15vw; /*200px for base_unlogged*/
da13e230   Alexis Koralewski   update UI of webs...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
}

a {
  font-family: 'Montserra', sans-serif;

}

#fas {
  size: 18px;
}

#profile
{
    font-size: 17px;
}

#hour
{
    color: black;
    font-size: 14px;
}

#plc_state
{
    color: black;
    font-size: 18px;
}

#signout {
    color: black;
}

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

#topbar {
    -webkit-transition: background-color 800ms linear;
    -ms-transition: background-color 800ms linear;
    transition: background-color 800ms linear;
    height: 100%;
}
#text_globalmode {
    font-size: 14px;
    color: black;
}

.img_icon {
  height: 18px;
  weight: 18px; 
}

.user_icon{
0b2d14c7   Alexis Koralewski   removing (still a...
108
109
110
  margin-left: 45%;
  margin-bottom: 0.4em;
  margin-top: 0.4em;
da13e230   Alexis Koralewski   update UI of webs...
111
  height: 1.5em;
0b2d14c7   Alexis Koralewski   removing (still a...
112
  
da13e230   Alexis Koralewski   update UI of webs...
113
114
}

d38312c2   Alexis Koralewski   updating UI (CSS ...
115
116
117
118
119
120
#home_icon{
  height: 1.4em;
  width: 1.5em;  
  float:left;
  margin-right:1vw;
}
da13e230   Alexis Koralewski   update UI of webs...
121

0b2d14c7   Alexis Koralewski   removing (still a...
122
123
124
125
126
127
128
.dropdown_user_actions {
  float: left;
  overflow: hidden;
  margin-right: 1vw;
}

.dropdown_user_actions_content {
da13e230   Alexis Koralewski   update UI of webs...
129
  display: none;
0b2d14c7   Alexis Koralewski   removing (still a...
130
  overflow: auto;
da13e230   Alexis Koralewski   update UI of webs...
131
  position: absolute;
da13e230   Alexis Koralewski   update UI of webs...
132
133
134
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
da13e230   Alexis Koralewski   update UI of webs...
135
136
137
  z-index: 1;
}

0b2d14c7   Alexis Koralewski   removing (still a...
138
139
140
141
142
143
144
145
146
147
148
149
150
.dropdown_user_actions_content a {
  float: left;
  overflow: visible;
  color: black;
  margin: 1.2rem;
  padding-right: 1.2em;
  text-decoration: none;
  display: block;
  text-align: left;

}

.dropdown_user_actions:hover .dropdown_user_actions_content {
da13e230   Alexis Koralewski   update UI of webs...
151
152
  display: block;
}
b7becde4   Alexis Koralewski   Updating UI (foot...
153
154

footer{
d38312c2   Alexis Koralewski   updating UI (CSS ...
155
156
157
158
159
160
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  text-align: center;

b7becde4   Alexis Koralewski   Updating UI (foot...
161
}
da13e230   Alexis Koralewski   update UI of webs...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
</style>

{% load tags %}
{% user_level request as USER_LEVEL %}
{% comment %}
  
{% get_level "TAC" as USER_LEVEL_TAC %}
{% get_level "Observer" as USER_LEVEL_OBSERVER %}
{% get_level "Operator" as USER_LEVEL_OPERATOR %}  
{% get_level "PI" as USER_LEVEL_PI %}
{% get_level "Admin" as USER_LEVEL_SYSADMIN %}
{% get_level "Visitor" as USER_LEVEL_VISITOR %}
{% endcomment %}

<div id="wrapper">

      <!-- Sidebar -->
d38312c2   Alexis Koralewski   updating UI (CSS ...
179
180
      <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      
da13e230   Alexis Koralewski   update UI of webs...
181
182
      <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
042db8a3   Alexis Koralewski   renabling sign in...
183
184
185
            {% comment %}
              <img alt="" src="{% static "media/colibrifavicon.png" %}">
            {% endcomment %}
d38312c2   Alexis Koralewski   updating UI (CSS ...
186
187
188
            <a class="navbar-brand" href={% url "index" %} style="color: black;">
            <img src="{% static 'media/home.png'  %}" id="home_icon">
            {{ request.session.obsname }} Control Center</a>
da13e230   Alexis Koralewski   update UI of webs...
189
190
191
192
193
194
195
        </div>
           {# <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> #}
          <script  src="{% static "/js/jquery-1.10.2.js" %}"></script>


        <!-- Collect the nav links, forms, and other content for toggling -->
        <!-- #f9ff93 #6b69f3-->
d38312c2   Alexis Koralewski   updating UI (CSS ...
196
        <div id="topbar" class="collapse navbar-collapse navbar-ex1-collapse bg-primary">
da13e230   Alexis Koralewski   update UI of webs...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
        <ul class="nav navbar-nav side-nav navbar-dark bg-primary" id="navbar_list">
            
              <li><a href="{% url "weather" %}">Weather</a></li>
              <li><a href="{% url "site" %}">Observatory</a></li>
              <li><a href="#">Webcams</a></li>
              <li><a href="{% url "alerts_list" %}">Alerts</a></li>
              <li><a href="{% url "current_schedule" %}">Schedule</a></li>
            {# TODO: TBD #}
            {% if USER_LEVEL|ifinlist:"Admin,Operator,Unit-PI,Management board member,Observer,TAC" %}
              <li><a href="{% url "requests_list" %}">Request</a></li>
              <li><a href="#">Images</a></li>
            {% endif %}
            {% if USER_LEVEL|ifinlist:"Admin,Operator" %}
              <li><a href="{% url "system" %}">System</a></li>
            {% endif %}
            {% if USER_LEVEL == "Admin" %}
              <li><a href="/admin">ADMIN</a></li>
            {% endif %}
            {% if USER_LEVEL|ifinlist:"Admin,Operator,Unit-PI,Management board member,Observer,TAC" %}
            
                <li><a href="{% url "site" %}">State</a></li>
                <li><a href="{% url "site" %}">Observatory</a></li>
                <li><a href="{% url "observation_status" %}">Tel & Inst</a></li>
            {% endif %}
            {% if USER_LEVEL|ifinlist:"Admin,Observer,Unit-PI,TAC,Management board member" %}
                <li><a href="{% url "scientific_program_list" %}">Scientific<br>programs</a></li>
            {% endif %}
          
          </ul>
0b2d14c7   Alexis Koralewski   removing (still a...
226
            
da13e230   Alexis Koralewski   update UI of webs...
227
          <ul class="nav navbar-nav navbar-right navbar-user navbar-expand-lg">
0b2d14c7   Alexis Koralewski   removing (still a...
228
          {% comment %}
da13e230   Alexis Koralewski   update UI of webs...
229
230
231
232
233
234
235
              <li><a id="plc_state"></a></li>
            <li><a class="nav-brand" id="hour">Sun elevation :</a></li>
            <li><a class="nav-brand" id="day_night" ><img id="day_night_img"></a></li>
             <li><a class="nav-brand" id="observatory_state" href="{% url "site" %}"><img id="obs_state_img"></a></li>
            <li><a class="nav-brand" id="wind" href="{% url "weather" %}"><img id="wind_img"></a></li>
            <li><a class="nav-brand" id="weather" href="{% url "weather" %}"><img id="weather_img"></a></li>
            <li><a class="nav-brand" id="globalmode" style="color: black;"> <p id="text_globalmode"  >{% global_mode  request %} </p></a>
0b2d14c7   Alexis Koralewski   removing (still a...
236
          {% endcomment %}
da13e230   Alexis Koralewski   update UI of webs...
237

0b2d14c7   Alexis Koralewski   removing (still a...
238
239
           
            
da13e230   Alexis Koralewski   update UI of webs...
240
            <li>
0b2d14c7   Alexis Koralewski   removing (still a...
241
242
              <div class="dropdown_user_actions">
              {# <a class="nav-brand" href="{% url "user_detail" user.id %}" style="color: black;"> #}
da13e230   Alexis Koralewski   update UI of webs...
243
              
0b2d14c7   Alexis Koralewski   removing (still a...
244
              <img src="{% static 'media/user.png' %}" class="user_icon" ></i>
3778e1f9   Alexis Koralewski   Adding first lett...
245
              <p> Welcome {{ user.first_name|first }} {{user.last_name}}<i class="fa fa-caret-down"></i> </p> 
0b2d14c7   Alexis Koralewski   removing (still a...
246
247
248
249
250
251
252
253
              <ul class="dropdown_user_actions_content">
                <li><a class="nav-brand" href="{% url "user_detail" user.id %}" style="color: black;"> Profile </a></li>
                <li>
                <a class="nav-brand" href="{% url "settings" %}" style="color: black;"><i id="profile" class="fas fa-cog "></i>Settings</a>
                </li>
                <li><a id="signout" href="{% url "user_logout" %}" ><i class="fa fa-power-off"></i> Log Out</a></li>
              </ul>
              </div>
da13e230   Alexis Koralewski   update UI of webs...
254
            </li>
0b2d14c7   Alexis Koralewski   removing (still a...
255
            
da13e230   Alexis Koralewski   update UI of webs...
256
257

          </ul>
0b2d14c7   Alexis Koralewski   removing (still a...
258
259
          {% comment %}
            
da13e230   Alexis Koralewski   update UI of webs...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
            <script>
              var TOO_STRONG_WIND = 60; //Totally arbitrary values, just for demonstration
              var MAX_CLOUD_VALUE = 1;
              var REFRESH_ICONS_FREQUENCE_MILLISECONDS = 1000;
              var MAX_RAIN_RATE = 10;

              var check_change = true;

              $( document ).ready(function() {

              function set_elev(sun_elev)
              {
                  $("#hour").text("Sun elevation : " + sun_elev);
              }

              function change_color_navbar(elevation, elev_threshold)
              {
                  var color = "";
                  if (elevation >= elev_threshold)
                    color = "#f9ff93";
                  else
                    color = "#6b69f3";
                $("#topbar").css("background-color", color);
              }

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

              function info_plc(is_safe, mode, ack, timeout, max_plc_timeout)
              {
                  var safe = "UNSAFE";
                  if (is_safe)
                      safe = "SAFE";

                  if (ack) {
                      ack = "ACK: OK";
                      if (!check_change)
                          window.location.reload(true);
                      check_change = true;
                  }
                  else
                  {
                      ack = "STAFF ACK: KO";
                      $("#plc_state").css("background-color", "red");
                      check_change = false;
                  }

                  if(! mode){
                    mode = "Not connected";
                  }
                  $("#plc_state").text("PLC: " + mode + '\u00A0\u00A0\u00A0\u00A0\u00A0' + safe + '\u00A0\u00A0\u00A0\u00A0\u00A0' + ack);
                   $("#plc_state").css("color", "black");
                   if (timeout > max_plc_timeout)
                  {
                      $("#plc_state").text("Connection to PLC LOST");
                      $("#plc_state").css("color", "red");
                  }
              }



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

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

               */

              function ajax_request() {
                  $.get("{% url 'retrieve_env_navbar' %}", function (weather_status) {
                    if (weather_status)
                      {
                          var sunelev = parseFloat(weather_status[0]['sunelev']);
                          var max_sunelev = parseInt(weather_status[0]['max_sunelev']);

                          set_elev(sunelev);

                          change_color_navbar(sunelev, max_sunelev);

                          $("#text_globalmode").text(weather_status[0]["pyros_mode"]);
                          var _img_day_night = document.createElement('img');
                          if (sunelev >= max_sunelev)
                              _img_day_night.src ="{% static 'media/rising_sun.png' %}";
                          else
                              _img_day_night.src ="{% static 'media/moon.png' %}";
                          _img_day_night.width = 22;
                          _img_day_night.height = 22;
                          _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 = 18;
                          _img.height = 18;
                          _img.id ="obs_state_img";
                          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")
                               _img.src = "{% static 'media/observatory.png' %}";
                          else
                              _img.src = "{% static 'media/observatory_red.png' %}";
                          _img.alt = "html5";
                          $("#obs_state_img").replaceWith(_img);


                          var _img = document.createElement('img');
                          _img.width = 18;
                          _img.height = 18;
                          _img.id ="weather_img";

                          /*
                            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
                          */
                          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)
                              _img.src = "{% static 'media/rain.png' %}";
                          else if (parseInt(weather_status[0]['fields']['cloud']) > MAX_CLOUD_VALUE)
                              _img.src = "{% static 'media/cloud.png' %}";
                          else
                              _img.src = "{% static 'media/sun.png' %}";
                              _img.width = 18;
                              _img.height = 18;
                              _img.alt = "html5";
                          $("#weather_img").replaceWith(_img);

                          var _im = document.createElement('img');
                          _im.width = 18;
                          _im.height = 18;
                          _im.id="wind_img";
                          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)
                            _im.src = "{% static 'media/wind.png' %}";
                          else
                            _im.src= "{% static 'media/windsock_nowind.png' %}";
                          $("#wind_img").replaceWith(_im);

                          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"]) );
                      }
                  }, 'json')
                      .fail(function () {
                          console.log('Ajax error: GET request failed\n');
                      })
              }});
          </script>
0b2d14c7   Alexis Koralewski   removing (still a...
416
          {% endcomment %}
da13e230   Alexis Koralewski   update UI of webs...
417
418
419
420
421
422
423

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

      </nav>
      <div id="page-wrapper">
      
      
042db8a3   Alexis Koralewski   renabling sign in...
424
425
426
        <div class="row">      	
          <center><h2 id="title">{% block title %}  {% endblock %}</h2></center>
		    </div>
da13e230   Alexis Koralewski   update UI of webs...
427
	
042db8a3   Alexis Koralewski   renabling sign in...
428
429
430
431
        {% block content %}
          
          
        {% endblock %}
da13e230   Alexis Koralewski   update UI of webs...
432
433
434
435
436
        

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

    </div><!-- /#wrapper -->
b7becde4   Alexis Koralewski   Updating UI (foot...
437
    
da13e230   Alexis Koralewski   update UI of webs...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
        <!-- Javascript function refreshing weather icons on the navbar -->


    
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script  src="{% static "/js/jqueryui.min.js" %}"></script>
    <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>


    <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>
b7becde4   Alexis Koralewski   Updating UI (foot...
467
468
469
<footer>
      <i>VERSION 2021.0.1</i>
</footer>
94082e77   haribo   Date: 03/06/2016
470
</html>