Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
c5a1a20a
Commit
c5a1a20a
authored
1 year ago
by
Jörn Künsemöller
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-2688
: cleanup
parent
a7fcaf6f
No related branches found
No related tags found
1 merge request
!1195
TMSS-2688: websockets
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/WeekView.js
+3
-31
3 additions, 31 deletions
...TMSS/frontend/tmss_webapp/src/routes/Timeline/WeekView.js
with
3 additions
and
31 deletions
SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/WeekView.js
+
3
−
31
View file @
c5a1a20a
...
@@ -279,12 +279,10 @@ export default function WeekView() {
...
@@ -279,12 +279,10 @@ export default function WeekView() {
*/
*/
function
handleData
(
event
)
{
function
handleData
(
event
)
{
const
jsonData
=
JSON
.
parse
(
event
?.
data
)
||
{};
const
jsonData
=
JSON
.
parse
(
event
?.
data
)
||
{};
console
.
log
(
'
received websocket data:
'
,
jsonData
)
switch
(
jsonData
.
object_type
)
{
switch
(
jsonData
.
object_type
)
{
case
'
scheduling_unit_blueprint
'
:
{
case
'
scheduling_unit_blueprint
'
:
{
switch
(
jsonData
.
action
)
{
switch
(
jsonData
.
action
)
{
case
'
delete
'
:
{
case
'
delete
'
:
{
console
.
log
(
'
ws delete SU
'
);
const
schedulingUnits
=
data
.
schedulingUnits
const
schedulingUnits
=
data
.
schedulingUnits
_
.
remove
(
schedulingUnits
,
function
(
su
)
{
return
su
.
id
===
jsonData
.
object_details
.
id
});
_
.
remove
(
schedulingUnits
,
function
(
su
)
{
return
su
.
id
===
jsonData
.
object_details
.
id
});
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
@@ -297,7 +295,6 @@ export default function WeekView() {
...
@@ -297,7 +295,6 @@ export default function WeekView() {
break
;
break
;
}
}
case
'
update
'
:
{
case
'
update
'
:
{
console
.
log
(
"
ws update SU
"
);
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
prevData
,
...
prevData
,
schedulingUnits
:
prevData
.
schedulingUnits
.
map
(
schedulingUnits
:
prevData
.
schedulingUnits
.
map
(
...
@@ -321,8 +318,7 @@ export default function WeekView() {
...
@@ -321,8 +318,7 @@ export default function WeekView() {
break
;
break
;
}
}
case
'
create
'
:
{
case
'
create
'
:
{
console
.
log
(
"
ws create SU
"
);
// The websocket message only contains a subset of the details we need, so fetch the full set
// the ws message only contains a subset of the details we need, so fetch the full set */
ScheduleService
.
getTimelineSlimBlueprints
(
undefined
,
undefined
,
jsonData
.
object_details
.
id
)
// todo: check time
ScheduleService
.
getTimelineSlimBlueprints
(
undefined
,
undefined
,
jsonData
.
object_details
.
id
)
// todo: check time
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
@@ -330,13 +326,6 @@ export default function WeekView() {
...
@@ -330,13 +326,6 @@ export default function WeekView() {
schedulingUnits
:
prevData
.
schedulingUnits
.
concat
(
response
)
schedulingUnits
:
prevData
.
schedulingUnits
.
concat
(
response
)
}));
}));
});
});
/** Note: the following works in principle, but the ws message is missing details which are
quite extensive to get broadcasted. Still, could be added in the websocket service.
setData(prevData => ({
...prevData,
schedulingUnits: prevData.schedulingUnits.concat([jsonData.object_details])
}));
*/
break
;
break
;
}
}
default
:
{
break
;
}
default
:
{
break
;
}
...
@@ -346,7 +335,6 @@ export default function WeekView() {
...
@@ -346,7 +335,6 @@ export default function WeekView() {
case
'
reservation
'
:
{
case
'
reservation
'
:
{
switch
(
jsonData
.
action
)
{
switch
(
jsonData
.
action
)
{
case
'
delete
'
:
{
case
'
delete
'
:
{
console
.
log
(
'
ws delete reservation
'
);
const
reservations
=
data
.
reservations
const
reservations
=
data
.
reservations
_
.
remove
(
reservations
,
function
(
res
)
{
return
res
.
id
===
jsonData
.
object_details
.
id
});
_
.
remove
(
reservations
,
function
(
res
)
{
return
res
.
id
===
jsonData
.
object_details
.
id
});
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
@@ -359,7 +347,6 @@ export default function WeekView() {
...
@@ -359,7 +347,6 @@ export default function WeekView() {
break
;
break
;
}
}
case
'
update
'
:
{
case
'
update
'
:
{
console
.
log
(
"
ws update reservation
"
);
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
prevData
,
...
prevData
,
reservations
:
prevData
.
reservations
.
map
(
reservations
:
prevData
.
reservations
.
map
(
...
@@ -367,16 +354,15 @@ export default function WeekView() {
...
@@ -367,16 +354,15 @@ export default function WeekView() {
),
),
}));
}));
if
(
summaryItem
?.
id
===
jsonData
.
object_details
.
id
)
{
if
(
summaryItem
?.
id
===
jsonData
.
object_details
.
id
)
{
//
Note: this t
rigger
s
a full
fetch again to get all details (see SU above).
//
T
rigger a full
refresh of the details panel
setSummaryItem
({
id
:
jsonData
.
object_details
.
id
,
type
:
"
RESERVATION
"
});
setSummaryItem
({
id
:
jsonData
.
object_details
.
id
,
type
:
"
RESERVATION
"
});
}
}
break
;
break
;
}
}
case
'
create
'
:
{
case
'
create
'
:
{
console
.
log
(
"
ws create reservation
"
);
const
shouldFetchReservations
=
getStore
(
UIConstants
.
STORE_KEY_TIMELINE
).
reservationsToggle
;
const
shouldFetchReservations
=
getStore
(
UIConstants
.
STORE_KEY_TIMELINE
).
reservationsToggle
;
if
(
shouldFetchReservations
)
{
if
(
shouldFetchReservations
)
{
//
t
he w
s
message only contains a subset of the details we need, so fetch the full set
//
T
he w
ebsocket
message only contains a subset of the details we need, so fetch the full set
ReservationService
.
getTimelineReservations
(
undefined
,
undefined
,
jsonData
.
object_details
.
id
)
// todo: check time
ReservationService
.
getTimelineReservations
(
undefined
,
undefined
,
jsonData
.
object_details
.
id
)
// todo: check time
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
setData
(
prevData
=>
({
setData
(
prevData
=>
({
...
@@ -385,15 +371,6 @@ export default function WeekView() {
...
@@ -385,15 +371,6 @@ export default function WeekView() {
}));
}));
});
});
}
}
/** Note: the following works in principle without fetching details, but new items don't render,
most likely due to missing details in the ws message, which need to be added in the websocket
service for this to work.
setData(prevData => ({
...prevData,
reservations: prevData.reservations.concat([jsonData.object_details])
}));
*/
break
;
break
;
}
}
default
:
{
break
;
}
default
:
{
break
;
}
...
@@ -404,11 +381,6 @@ export default function WeekView() {
...
@@ -404,11 +381,6 @@ export default function WeekView() {
}
}
}
}
// debug logging whenever the SU and reservation data gets updated
useEffect
(()
=>
{
console
.
log
(
'
data update:
'
,
data
);
},
[
data
])
// websocket hook that opens and allows interaction via the wss connection
// websocket hook that opens and allows interaction via the wss connection
const
{
const
{
sendMessage
,
sendMessage
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment