dot graph map
[kismet-logviewer.git] / logviewer / static / js / kismet.ui.adsb.js
1
2 "use strict";
3
4 var local_uri_prefix = ""; 
5 if (typeof(KISMET_URI_PREFIX) !== 'undefined')
6     local_uri_prefix = KISMET_URI_PREFIX;
7
8 /* Highlight ADSB devices */
9 kismet_ui.AddDeviceRowHighlight({
10     name: "ADSB Government",
11     description: "Government & related ADSB-tagged vehicles",
12     priority: 50,
13     //defaultcolor: "#efe0c3",
14     defaultcolor: "#ffb3b3",
15     defaultenable: true,
16     fields: [
17         'kismet.device.base.phyname',
18         'adsb.device'
19     ],
20     selector: function(data) {
21         var aircraft_info = [
22             'department',
23             'police',
24             'agency',
25             'dep',
26             'gov',
27             'federal',
28             'royal',
29             'force',
30             'state',
31             'army',
32             'navy',
33             'patrol',
34             'sqdn',
35             'city of',
36             'sheriff',
37         ];
38
39         var exclude_list = [
40             'express',
41             'air freight',
42         ]
43
44         var icao_list = [
45             'acf181', 'a980fa', 'a7fb8f', 'ae4bd7', 'a47604',
46             'a03bc8', 'a0b8d6', 'a0d9f2', 'a12d51', 'a15f1d',
47             'a169d7', 'a16c6d', 'a193c1', 'a32524', 'a328db',
48             'a32c92', 'a33049', 'a33dc3', 'a3c1be', 'a3c92c',
49             'a3e6e3', 'a3e6e4', 'a410bc', 'a4182a', 'a44360',
50             'a4724d', 'a483df', 'a4bc36', 'a4bfed', 'a51a10',
51             'a51dc7', 'a54b56', 'a54f0d', 'a552c4', 'a5ed09',
52             'a5f9f7', 'a64217', 'a645ce', 'a64985', 'a64d3c',
53             'a654aa', 'aac551', 'abaf9c', 'ac742b', 'ac7b99',
54         ];
55
56         if (data['kismet.device.base.phyname'] === 'ADSB') {
57             for (var re of aircraft_info) {
58                  var retval = false;
59                  if (data['adsb.device']['kismet.adsb.icao_record']['adsb.icao.owner'].toLowerCase().includes(re)) {
60                     retval = true;
61                     for (var excld of exclude_list) {
62                       if (data['adsb.device']['kismet.adsb.icao_record']['adsb.icao.owner'].toLowerCase().includes(excld)) {
63                         retval=false;
64                       }
65                     }
66                  }
67
68                  if (Boolean(retval)) {
69                      return true;
70                  }
71             }
72             for (var re of icao_list) {
73                  if (data['adsb.device']['adsb.device.icao'].toLowerCase().includes(re))
74                     return true;
75             }
76         }
77         return false;
78     }
79 });
80
81 kismet_ui.AddDeviceDetail("adsb", "ADSB (SDR)", 0, {
82     filter: function(data) {
83         return (data['kismet.device.base.phyname'] === "ADSB");
84     },
85     draw: function(data, target) {
86         target.devicedata(data, {
87             "id": "adsbData",
88             "fields": [
89             {
90                 field: "adsb.device/adsb.device.icao",
91                 liveupdate: true,
92                 title: "Plane ICAO",
93                 empty: "<i>Unknown</i>"
94             },
95             {
96                 field: "adsb.device/adsb.device.callsign",
97                 liveupdate: true,
98                 title: "Callsign",
99                 filterOnZero: true,
100                 filterOnEmpty: true,
101                 help: "Flight registration / Callsign",
102             },
103             {
104                 field: "adsb.device/adsb.device.callsign",
105                 id: "fa_callsign",
106                 liveupdate: true,
107                 title: "Flightaware",
108                 filterOnZero: true,
109                 filterOnEmpty: true,
110                 draw: function(opts) {
111                     return '<a href="https://flightaware.com/live/flight/' + opts['value'] + '" target="_new">Track ' + opts['value'] + ' on FlightAware</a>';
112                 },
113             },
114             {
115                 field: "adsb.device/kismet.adsb.icao_record/adsb.icao.regid",
116                 liveupdate: true,
117                 title: "Registration ID",
118                 filterOnZero: true,
119                 filterOnEmpty: true,
120                 help: "Aircraft registration ID or tail number",
121             },
122             {
123                 field: "adsb.device/kismet.adsb.icao_record/adsb.icao.atype",
124                 liveupdate: true,
125                 title: "Aircraft Classification",
126                 filterOnZero: true,
127                 filterOnEmpty: true,
128                 help: "Aircraft classification type",
129             },
130             {
131                 field: "adsb.device/kismet.adsb.icao_record/adsb.icao.model",
132                 liveupdate: true,
133                 title: "Model",
134                 filterOnZero: true,
135                 filterOnEmpty: true,
136                 help: "Aircraft model (general model type)",
137             },
138             {
139                 field: "adsb.device/kismet.adsb.icao_record/adsb.icao.type",
140                 liveupdate: true,
141                 title: "Type",
142                 filterOnZero: true,
143                 filterOnEmpty: true,
144                 help: "Aircraft type (specific model type)",
145             },
146             {
147                 field: "adsb.device/kismet.adsb.icao_record/adsb.icao.owner",
148                 liveupdate: true,
149                 title: "Aircraft Operator",
150                 filterOnZero: true,
151                 filterOnEmpty: true,
152                 help: "Aircraft operator or owner of record",
153             },
154             {
155                 field: "adsb.device/adsb.device.altitude",
156                 liveupdate: true,
157                 title: "Altitude",
158                 filterOnZero: true,
159             },
160             {
161                 field: "adsb.device/adsb.device.speed",
162                 liveupdate: true,
163                 title: "Speed",
164                 filterOnZero: true,
165             },
166             {
167                 field: "adsb.device/adsb.device.heading",
168                 liveupdate: true,
169                 title: "Heading",
170                 filterOnZero: true,
171                 draw: function(opts) {
172
173                     return Math.round(opts['value']) + '&deg; <i class="fa fa-plane" style="transform: rotate(' + (opts['value'] -45) + 'deg)" />';
174
175                 },
176             },
177             {
178                 field: "adsb.device/adsb.device.latitude",
179                 liveupdate: true,
180                 title: "Location",
181                 filterOnZero: true,
182                 filterOnEmpty: true,
183                 draw: function(opts) {
184                     try {
185                         return opts['data']['adsb.device']['adsb.device.latitude'] + ', ' + opts['data']['adsb.device']['adsb.device.longitude'] + ' <a target="_new" href="https://openstreetmap.org/?&mlat=' + opts['data']['adsb.device']['adsb.device.latitude'] + '&mlon=' + opts['data']['adsb.device']['adsb.device.longitude'] + '">View on Open Street Maps</a>';
186                     } catch (error) {
187                         return 'n/a'
188                     }
189
190                 },
191             },
192             {
193                 field: "adsb.device/adsb.device.asgs",
194                 liveupdate: true,
195                 title: "Airspeed(AS) / Groundspeed (GS)",
196                 filterOnZero: true,
197             },
198             ],
199         });
200     },
201 });
202
203 kismet_ui_tabpane.AddTab({
204     id: 'adsb_live',
205     tabTitle: 'ADSB Live',
206     expandable: false,
207     createCallback: function(div) {
208         var url = new URL(parent.document.URL);
209         url.searchParams.append('parent_url', url.origin)
210         url.searchParams.append('local_uri_prefix', local_uri_prefix);
211         url.searchParams.append('KISMET_PROXY_PREFIX', KISMET_PROXY_PREFIX);
212         url.pathname = `${local_uri_prefix}${KISMET_PROXY_PREFIX}adsb_map_panel.html`;
213
214         div.append(
215             $('<iframe>', {
216                 width: '100%',
217                 height: '100%',
218                 src: url.href,
219             })
220         );
221     },
222     priority: -100,
223
224 }, 'center');
225