Pārlūkot izejas kodu

feat: add ICT/UTC dual clock widget to IRIS navbar

- ict-clock.js: pure-JS clock that updates every second, computes
  ICT (UTC+7) without tzdata dependency (adds 7h to UTC ms epoch).
  Displayed as "HH:MM:SS ICT | HH:MM:SS UTC" in the navbar.
- navigation.html + navigation_ext.html: inject <li id="navbar-ict-clock">
  into the topbar nav (hidden on small screens via d-none d-md-flex).
- footer.html: load ict-clock.js for all authenticated pages.
- docker-compose.dev.yml: bind-mount the JS file from source into
  /iriswebapp/static so it survives container recreates (ui/dist is
  root-owned and cannot be written from the host directly).

IRIS stores and displays timestamps in UTC by design. This widget
gives analysts both UTC and local ICT time without patching alert
display logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tum 1 dienu atpakaļ
vecāks
revīzija
766f4d209d

+ 1 - 0
iris-web/docker-compose.dev.yml

@@ -44,6 +44,7 @@ services:
44 44
     volumes:
45 45
       - ./source/app:/iriswebapp/app
46 46
       - ./ui/dist:/iriswebapp/static
47
+      - ./source/app/static/assets/js/iris/ict-clock.js:/iriswebapp/static/assets/js/iris/ict-clock.js:ro
47 48
     healthcheck:
48 49
       test: curl --head --fail http://localhost:8000 || exit 1
49 50
       start_period: 60s

+ 38 - 0
iris-web/source/app/static/assets/js/iris/ict-clock.js

@@ -0,0 +1,38 @@
1
+/* ICT / UTC dual clock — injected into IRIS navbar */
2
+(function () {
3
+  function pad(n) { return String(n).padStart(2, '0'); }
4
+
5
+  function tick() {
6
+    var now = new Date();
7
+
8
+    /* UTC */
9
+    var utcH = pad(now.getUTCHours());
10
+    var utcM = pad(now.getUTCMinutes());
11
+    var utcS = pad(now.getUTCSeconds());
12
+
13
+    /* ICT = UTC + 7 */
14
+    var ictMs = now.getTime() + 7 * 3600 * 1000;
15
+    var ict   = new Date(ictMs);
16
+    var ictH  = pad(ict.getUTCHours());
17
+    var ictM  = pad(ict.getUTCMinutes());
18
+    var ictS  = pad(ict.getUTCSeconds());
19
+
20
+    var el = document.getElementById('navbar-ict-clock');
21
+    if (el) {
22
+      el.innerHTML =
23
+        '<span title="Indochina Time (UTC+7)" style="letter-spacing:.02em">' +
24
+          '<i class="fa-regular fa-clock mr-1"></i>' +
25
+          ictH + ':' + ictM + ':' + ictS + ' <span style="opacity:.7">ICT</span>' +
26
+        '</span>' +
27
+        '<span style="opacity:.45;margin:0 6px">|</span>' +
28
+        '<span title="Coordinated Universal Time" style="letter-spacing:.02em">' +
29
+          utcH + ':' + utcM + ':' + utcS + ' <span style="opacity:.7">UTC</span>' +
30
+        '</span>';
31
+    }
32
+  }
33
+
34
+  document.addEventListener('DOMContentLoaded', function () {
35
+    tick();
36
+    setInterval(tick, 1000);
37
+  });
38
+})();

+ 1 - 0
iris-web/source/app/templates/includes/footer.html

@@ -1,6 +1,7 @@
1 1
 
2 2
  
3 3
 {% if current_user.is_authenticated %}
4
+<script src="/static/assets/js/iris/ict-clock.js"></script>
4 5
 
5 6
   <div class="modal " tabindex="-1" role="dialog" id="modal_switch_context" data-backdrop="true">
6 7
       <div class="modal-lg modal-dialog" role="document">

+ 3 - 0
iris-web/source/app/templates/includes/navigation.html

@@ -80,6 +80,9 @@
80 80
 								<i class="flaticon-shapes-1"></i>
81 81
 							</a>
82 82
 						</li>
83
+						<li class="nav-item hidden-caret d-none d-md-flex align-items-center">
84
+							<span id="navbar-ict-clock" class="nav-link text-white" style="font-size:.78rem;white-space:nowrap;cursor:default;padding-top:0;padding-bottom:0;"></span>
85
+						</li>
83 86
 					</ul>
84 87
 				</div>
85 88
 				{% endif %}

+ 3 - 0
iris-web/source/app/templates/includes/navigation_ext.html

@@ -67,6 +67,9 @@
67 67
 								<i class="flaticon-shapes-1"></i>
68 68
 							</a>
69 69
 						</li>
70
+						<li class="nav-item hidden-caret d-none d-md-flex align-items-center">
71
+							<span id="navbar-ict-clock" class="nav-link text-white" style="font-size:.78rem;white-space:nowrap;cursor:default;padding-top:0;padding-bottom:0;"></span>
72
+						</li>
70 73
 					</ul>
71 74
 				</div>
72 75