Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lyse
k3man
Commits
58428edb
Commit
58428edb
authored
Apr 13, 2020
by
Lysander Trischler
Browse files
Add event descriptions in WebSocket support
parent
9d426488
Changes
3
Hide whitespace changes
Inline
Side-by-side
TODO
View file @
58428edb
...
...
@@ -50,4 +50,3 @@ https://stackoverflow.com/questions/3363190/qt-qtableview-how-to-have-a-checkbox
Websocket
* camelCase-Bezeichner
* Aktion-/Dienstbeschreibungen
k3man/model.py
View file @
58428edb
...
...
@@ -510,6 +510,7 @@ class Event(isobeef.core.Object):
# all signals are documented in the class docstring above
eventChanged
=
signal
()
nameChanged
=
signal
()
descriptionChanged
=
signal
()
timeOfDayChanged
=
signal
()
custodianAdded
=
signal
(
Custodian
)
custodianRemoved
=
signal
(
Custodian
)
...
...
@@ -548,6 +549,7 @@ class Event(isobeef.core.Object):
"""
self
.
description
=
description
self
.
descriptionChanged
.
emit
()
self
.
eventChanged
.
emit
()
...
...
k3man/websocket.py
View file @
58428edb
...
...
@@ -24,6 +24,7 @@ class WebSocketSupport(QObject):
self
.
dayEventAddedSlots
=
{}
self
.
dayEventRemovedSlots
=
{}
self
.
eventNameChangedSlots
=
{}
self
.
_eventDescriptionChangedSlots
=
{}
self
.
eventTimeOfDayChangedSlots
=
{}
self
.
eventCustodianAddedSlots
=
{}
self
.
eventCustodianRemovedSlots
=
{}
...
...
@@ -37,6 +38,7 @@ class WebSocketSupport(QObject):
self
.
dayEventAddedSlots
=
{}
self
.
dayEventRemovedSlots
=
{}
self
.
eventNameChangedSlots
=
{}
self
.
_eventDescriptionChangedSlots
=
{}
self
.
eventTimeOfDayChangedSlots
=
{}
self
.
eventCustodianAddedSlots
=
{}
self
.
eventCustodianRemovedSlots
=
{}
...
...
@@ -97,6 +99,10 @@ class WebSocketSupport(QObject):
event
.
nameChanged
.
disconnect
(
nameChangedSlot
)
self
.
eventNameChangedSlots
=
{}
for
event
,
descriptionChangedSlot
in
self
.
_eventDescriptionChangedSlots
.
items
():
event
.
descriptionChanged
.
disconnect
(
descriptionChangedSlot
)
self
.
_eventDescriptionChangedSlots
=
{}
for
event
,
timeOfDayChangedSlot
in
self
.
eventTimeOfDayChangedSlots
.
items
():
event
.
timeOfDayChanged
.
disconnect
(
timeOfDayChangedSlot
)
self
.
eventTimeOfDayChangedSlots
=
{}
...
...
@@ -131,6 +137,16 @@ class WebSocketSupport(QObject):
self
.
eventNameChangedSlots
[
event
]
=
nameChangedSlot
event
.
nameChanged
.
connect
(
nameChangedSlot
)
def
descriptionChanged
(
event
):
def
handler
():
self
.
send
(
'PUT'
,
'/api/v1/events/%s'
%
self
.
eventIDs
[
event
],
{
u
'description'
:
unicode
(
event
.
description
)
if
event
.
description
is
not
None
else
None
})
return
handler
descriptionChangedSlot
=
descriptionChanged
(
event
)
self
.
_eventDescriptionChangedSlots
[
event
]
=
descriptionChangedSlot
event
.
descriptionChanged
.
connect
(
descriptionChangedSlot
)
def
timeOfDayChanged
(
event
):
def
handler
():
self
.
send
(
'PUT'
,
'/api/v1/events/%s'
%
self
.
eventIDs
[
event
],
...
...
@@ -158,6 +174,7 @@ class WebSocketSupport(QObject):
def
_disconnectEvent
(
self
,
event
):
event
.
nameChanged
.
disconnect
(
self
.
eventNameChangedSlots
.
pop
(
event
))
event
.
descriptionChanged
.
disconnect
(
self
.
_eventDescriptionChangedSlots
.
pop
(
event
))
event
.
timeOfDayChanged
.
disconnect
(
self
.
eventTimeOfDayChangedSlots
.
pop
(
event
))
event
.
custodianAdded
.
disconnect
(
self
.
eventCustodianAddedSlots
.
pop
(
event
))
event
.
custodianRemoved
.
disconnect
(
self
.
eventCustodianRemovedSlots
.
pop
(
event
))
...
...
@@ -207,6 +224,7 @@ class WebSocketSupport(QObject):
u
'time_of_day'
:
self
.
timeOfDayIDs
[
event
.
timeOfDay
]
if
event
.
timeOfDay
is
not
None
else
None
,
u
'type'
:
u
'service'
if
isinstance
(
event
,
Service
)
else
u
'action'
,
u
'name'
:
unicode
(
event
.
name
)
if
event
.
name
is
not
None
else
None
,
u
'description'
:
unicode
(
event
.
description
)
if
event
.
description
is
not
None
else
None
,
u
'custodians'
:
[
self
.
custodianIDs
[
c
]
for
c
in
event
.
custodians
]}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment