whitebox-plugin-flight-annotations 0.1.7__tar.gz → 0.1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/PKG-INFO +1 -1
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/pyproject.toml +1 -1
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/handlers.py +35 -13
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationsServiceComponent.jsx +11 -10
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationsServiceComponent.test.jsx +27 -5
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/stores/annotations.js +2 -2
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/models.py +2 -1
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/whitebox_plugin_flight_annotations.py +2 -2
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/LICENSE +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/README.md +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/__init__.py +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/apps.py +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationCard.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationCard.test.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationInput.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationInput.test.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/Annotations.css +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/Annotations.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/Annotations.test.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/AnnotationsOverlay.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/jsx/Avatar.jsx +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/migrations/0001_initial.py +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/migrations/__init__.py +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/serializers.py +0 -0
- {whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/whitebox_plugin_flight_annotations/services.py +0 -0
{whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "whitebox-plugin-flight-annotations"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.9"
|
|
4
4
|
description = "A plugin for whitebox that enables flight annotations."
|
|
5
5
|
authors = ["avilabss <contact@avilabs.net>", "WhiteBox <contact@whitebox.aero>"]
|
|
6
6
|
license = "GNU Affero General Public License v3"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from channels.layers import get_channel_layer
|
|
2
2
|
|
|
3
3
|
from whitebox.plugins import get_class
|
|
4
|
-
from whitebox.events import EventHandlerException,
|
|
4
|
+
from whitebox.events import EventHandlerException, RequestResponseEventHandler
|
|
5
5
|
from .serializers import AnnotationSerializer
|
|
6
6
|
from .services import FlightAnnotationService
|
|
7
7
|
|
|
@@ -12,9 +12,17 @@ FlightService = get_class("flight.FlightService")
|
|
|
12
12
|
channel_layer = get_channel_layer()
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class FlightAnnotationSendHandler(
|
|
15
|
+
class FlightAnnotationSendHandler(RequestResponseEventHandler):
|
|
16
16
|
"""
|
|
17
|
-
Handler for
|
|
17
|
+
Handler for the ``command.flight.annotation.send`` request and the
|
|
18
|
+
matching ``observation.flight.annotation.list`` replacement-list
|
|
19
|
+
broadcast.
|
|
20
|
+
|
|
21
|
+
Wire convention: the originating client gets a per-client
|
|
22
|
+
``{type: "message", ...}`` ack via
|
|
23
|
+
``RequestResponseEventHandler.response``; every other connected
|
|
24
|
+
client gets the full replacement-list broadcast on the
|
|
25
|
+
``observation.flight.annotation.list`` Channels group.
|
|
18
26
|
"""
|
|
19
27
|
|
|
20
28
|
@staticmethod
|
|
@@ -23,10 +31,14 @@ class FlightAnnotationSendHandler(WebsocketEventHandler):
|
|
|
23
31
|
annotations = ctx.get("annotations", [])
|
|
24
32
|
|
|
25
33
|
if flight_session_id:
|
|
34
|
+
# Snapshot broadcast — subscribers overwrite their local
|
|
35
|
+
# annotation list with this payload. ``SquawkConsumer``
|
|
36
|
+
# clients that subscribed via ``command.session.event.
|
|
37
|
+
# subscribe`` receive it verbatim.
|
|
26
38
|
await channel_layer.group_send(
|
|
27
|
-
"flight",
|
|
39
|
+
"observation.flight.annotation.list",
|
|
28
40
|
{
|
|
29
|
-
"type": "flight.annotation.list",
|
|
41
|
+
"type": "observation.flight.annotation.list",
|
|
30
42
|
"flight_session_id": flight_session_id,
|
|
31
43
|
"annotations": annotations,
|
|
32
44
|
},
|
|
@@ -62,14 +74,24 @@ class FlightAnnotationSendHandler(WebsocketEventHandler):
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
|
|
65
|
-
class FlightAnnotationLoadHandler(
|
|
77
|
+
class FlightAnnotationLoadHandler(RequestResponseEventHandler):
|
|
66
78
|
"""
|
|
67
|
-
Handler for
|
|
79
|
+
Handler for the ``command.flight.annotation.load`` request.
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
Used by a single client to fetch the annotations it hasn't seen yet
|
|
82
|
+
(typically on entering a flight session tab).
|
|
83
|
+
|
|
84
|
+
Wire convention: the response payload ``type`` field is
|
|
85
|
+
``observation.flight.annotation.list`` — the same wire name as the
|
|
86
|
+
fan-out broadcast from ``FlightAnnotationSendHandler``. JSX
|
|
87
|
+
subscribers register one ``Whitebox.sockets.subscribe`` for both
|
|
88
|
+
cases.
|
|
70
89
|
"""
|
|
71
90
|
|
|
72
|
-
|
|
91
|
+
# Stored under a non-method name so it doesn't shadow the inherited
|
|
92
|
+
# ``response()`` method that ``RequestResponseEventHandler`` exposes
|
|
93
|
+
# as the canonical WS-reply hook.
|
|
94
|
+
_response_payload: dict = None
|
|
73
95
|
|
|
74
96
|
async def handle(self, data):
|
|
75
97
|
flight_session_id = data.get("flight_session_id")
|
|
@@ -101,12 +123,12 @@ class FlightAnnotationLoadHandler(WebsocketEventHandler):
|
|
|
101
123
|
# Make a copy of this response so that it's exactly what we return, as
|
|
102
124
|
# the event apparatus may mutate the return value before passing it to
|
|
103
125
|
# the websocket handler
|
|
104
|
-
self.
|
|
126
|
+
self._response_payload = result.copy()
|
|
105
127
|
|
|
106
128
|
return result
|
|
107
129
|
|
|
108
|
-
async def
|
|
130
|
+
async def response(self):
|
|
109
131
|
return {
|
|
110
|
-
"type": "flight.annotation.list",
|
|
111
|
-
**self.
|
|
132
|
+
"type": "observation.flight.annotation.list",
|
|
133
|
+
**self._response_payload,
|
|
112
134
|
}
|
|
@@ -10,8 +10,8 @@ const AnnotationsServiceComponentToWrap = () => {
|
|
|
10
10
|
const setAnnotations = useAnnotationsStore((state) => state.setAnnotations);
|
|
11
11
|
|
|
12
12
|
const requestFlightAnnotations = (flightSession) => {
|
|
13
|
-
Whitebox.sockets.send("
|
|
14
|
-
type: "flight.annotation.load",
|
|
13
|
+
Whitebox.sockets.send("squawk", {
|
|
14
|
+
type: "command.flight.annotation.load",
|
|
15
15
|
flight_session_id: flightSession?.id,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -45,15 +45,16 @@ const AnnotationsServiceComponentToWrap = () => {
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
const unmountCallbacks = [];
|
|
47
47
|
|
|
48
|
-
//
|
|
48
|
+
// Subscribe to ``observation.flight.annotation.list`` instead of
|
|
49
|
+
// parsing every squawk frame. ``SquawkConsumer`` joins the
|
|
50
|
+
// per-event Channels group; the ``FlightAnnotationSendHandler``
|
|
51
|
+
// default callback broadcasts there.
|
|
49
52
|
unmountCallbacks.push(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}),
|
|
53
|
+
Whitebox.sockets.subscribe(
|
|
54
|
+
"squawk",
|
|
55
|
+
"observation.flight.annotation.list",
|
|
56
|
+
(data) => setAnnotations(data.annotations),
|
|
57
|
+
),
|
|
57
58
|
);
|
|
58
59
|
|
|
59
60
|
// Request new data on mode change
|
|
@@ -5,6 +5,7 @@ const { mockWhiteboxStateStore, resetWhiteboxStateStoreMocks } = WhiteboxTest;
|
|
|
5
5
|
|
|
6
6
|
describe("AnnotationsServiceComponent", () => {
|
|
7
7
|
let missionControlHandlers;
|
|
8
|
+
let annotationListSubscribers;
|
|
8
9
|
|
|
9
10
|
const setupMissionControlStore = (overrides = {}) => {
|
|
10
11
|
missionControlHandlers = {};
|
|
@@ -23,8 +24,17 @@ describe("AnnotationsServiceComponent", () => {
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
beforeEach(() => {
|
|
27
|
+
annotationListSubscribers = [];
|
|
26
28
|
Whitebox.sockets = {
|
|
27
|
-
|
|
29
|
+
// ``subscribe`` registers a callback; the returned unsubscribe
|
|
30
|
+
// removes it. Mock by collecting the callbacks so tests can
|
|
31
|
+
// drive them directly.
|
|
32
|
+
subscribe: vi.fn((socketName, eventName, callback) => {
|
|
33
|
+
if (socketName === "squawk" && eventName === "observation.flight.annotation.list") {
|
|
34
|
+
annotationListSubscribers.push(callback);
|
|
35
|
+
}
|
|
36
|
+
return vi.fn();
|
|
37
|
+
}),
|
|
28
38
|
send: vi.fn(),
|
|
29
39
|
};
|
|
30
40
|
});
|
|
@@ -33,6 +43,18 @@ describe("AnnotationsServiceComponent", () => {
|
|
|
33
43
|
resetWhiteboxStateStoreMocks();
|
|
34
44
|
});
|
|
35
45
|
|
|
46
|
+
it("subscribes to the observation.flight.annotation.list event on mount", () => {
|
|
47
|
+
setupMissionControlStore();
|
|
48
|
+
|
|
49
|
+
render(<AnnotationsServiceComponent />);
|
|
50
|
+
|
|
51
|
+
expect(Whitebox.sockets.subscribe).toHaveBeenCalledWith(
|
|
52
|
+
"squawk",
|
|
53
|
+
"observation.flight.annotation.list",
|
|
54
|
+
expect.any(Function),
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
36
58
|
it("loads annotations when mounted during playback", async () => {
|
|
37
59
|
setupMissionControlStore({
|
|
38
60
|
mode: "playback",
|
|
@@ -45,8 +67,8 @@ describe("AnnotationsServiceComponent", () => {
|
|
|
45
67
|
render(<AnnotationsServiceComponent />);
|
|
46
68
|
|
|
47
69
|
await waitFor(() => {
|
|
48
|
-
expect(Whitebox.sockets.send).toHaveBeenCalledWith("
|
|
49
|
-
type: "flight.annotation.load",
|
|
70
|
+
expect(Whitebox.sockets.send).toHaveBeenCalledWith("squawk", {
|
|
71
|
+
type: "command.flight.annotation.load",
|
|
50
72
|
flight_session_id: 42,
|
|
51
73
|
});
|
|
52
74
|
});
|
|
@@ -68,8 +90,8 @@ describe("AnnotationsServiceComponent", () => {
|
|
|
68
90
|
});
|
|
69
91
|
});
|
|
70
92
|
|
|
71
|
-
expect(Whitebox.sockets.send).toHaveBeenCalledWith("
|
|
72
|
-
type: "flight.annotation.load",
|
|
93
|
+
expect(Whitebox.sockets.send).toHaveBeenCalledWith("squawk", {
|
|
94
|
+
type: "command.flight.annotation.load",
|
|
73
95
|
flight_session_id: 43,
|
|
74
96
|
});
|
|
75
97
|
});
|
|
@@ -6,8 +6,8 @@ const annotationsStore = (set, get) => ({
|
|
|
6
6
|
sendAnnotation: (message, authorName = "Unknown") => {
|
|
7
7
|
if (!message.trim()) return;
|
|
8
8
|
|
|
9
|
-
Whitebox.sockets.send("
|
|
10
|
-
type: "flight.annotation.send",
|
|
9
|
+
Whitebox.sockets.send("squawk", {
|
|
10
|
+
type: "command.flight.annotation.send",
|
|
11
11
|
message: message.trim(),
|
|
12
12
|
author_name: authorName.trim(),
|
|
13
13
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
from django.utils import timezone
|
|
3
3
|
|
|
4
|
-
from whitebox.db import get_model
|
|
4
|
+
from whitebox.db import get_model, track
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
FlightSession = get_model("flight.FlightSession")
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
@track()
|
|
10
11
|
class FlightAnnotation(models.Model):
|
|
11
12
|
"""
|
|
12
13
|
Model for storing flight annotations/comments during flight sessions.
|
|
@@ -18,8 +18,8 @@ class WhiteboxPluginFlightAnnotations(Plugin):
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
plugin_event_map = {
|
|
21
|
-
"flight.annotation.send": FlightAnnotationSendHandler,
|
|
22
|
-
"flight.annotation.load": FlightAnnotationLoadHandler,
|
|
21
|
+
"command.flight.annotation.send": FlightAnnotationSendHandler,
|
|
22
|
+
"command.flight.annotation.load": FlightAnnotationLoadHandler,
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
exposed_component_map = {
|
{whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/LICENSE
RENAMED
|
File without changes
|
{whitebox_plugin_flight_annotations-0.1.7 → whitebox_plugin_flight_annotations-0.1.9}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|