Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Institut für Informatik
QE Research Group
FORTE
Frontend
Commits
02309b22
Commit
02309b22
authored
1 year ago
by
Bilal Hassan
Browse files
Options
Downloads
Patches
Plain Diff
-working on implementation of station config
parent
62905b4a
No related branches found
No related tags found
4 merge requests
!25
Draft: Resolve #78
,
!7
fixUrlPath
,
!4
merge dev into main
,
!1
after meeting with zoe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/module/pages/home/station-config/station-config.component.ts
+78
-9
78 additions, 9 deletions
...ule/pages/home/station-config/station-config.component.ts
with
78 additions
and
9 deletions
src/app/module/pages/home/station-config/station-config.component.ts
+
78
−
9
View file @
02309b22
...
...
@@ -10,7 +10,7 @@ import {
HostControllerService
,
SensorControllerService
,
Station
,
StationControllerService
}
from
"
../../../../../../projects/generated-api/src
"
;
import
{
combineLatest
,
finalize
,
Observable
,
tap
}
from
"
rxjs
"
;
import
{
combineLatest
,
concatMap
,
finalize
,
Observable
,
of
,
switchMap
,
tap
}
from
"
rxjs
"
;
import
{
StationModel
}
from
"
../../admin/stationManagement/station/station.model
"
;
import
{
map
}
from
"
rxjs/operators
"
;
...
...
@@ -183,31 +183,100 @@ export class StationConfigComponent implements OnInit{
children
:[]
}
let
returnNode
=
(
name
:
string
,
type
:
NodeType
):
DateTreeNode
=>
{
return
{
let
returnNode
=
(
name
:
string
,
type
:
NodeType
,
childs
:
DateTreeNode
[]
):
DateTreeNode
=>
{
return
{
name
:
name
?
name
:
'
UNDEFINED
'
,
type
:
type
,
children
:
[]
,
children
:
childs
,
}};
let
returnMultiNode
=
(
names
:
string
[],
type
:
NodeType
):
DateTreeNode
[]
=>
{
return
names
.
map
(
name
=>
returnNode
(
name
,
type
))
let
returnMulti
ple
Node
s
=
(
names
:
string
[],
type
:
NodeType
):
DateTreeNode
[]
=>
{
return
names
.
map
(
name
=>
returnNode
(
name
,
type
,[]
))
}
let
returnNodeMulti
Node
=
(
p_name
:
string
,
p_type
:
NodeType
,
c_names
:
string
[],
c_type
:
NodeType
):
DateTreeNode
=>
{
return
{
let
returnNode
With
Multi
Child
=
(
p_name
:
string
,
p_type
:
NodeType
,
c_names
:
string
[],
c_type
:
NodeType
):
DateTreeNode
=>
{
return
{
name
:
p_name
?
p_name
:
'
UNDEFINED
'
,
type
:
p_type
,
children
:
returnMultiNode
(
c_names
,
c_type
),
children
:
returnMulti
ple
Node
s
(
c_names
,
c_type
),
}};
let
saveClients
=
(
client_names
:
string
[],
treeNode
:
DateTreeNode
)
=>
{
let
data
:
DateTreeNode
[]
=
[]
let
clients
:
Observable
<
Client
>
[]
=
client_names
.
map
(
name
=>
this
.
clientController
.
getClientById
(
name
))
combineLatest
(
clients
).
pipe
(
tap
(
clients
=>
clients
.
forEach
(
client
=>
data
.
push
(
returnNodeMultiNode
(
client
.
name
??
""
,
NodeType
.
Client
,
client
.
sensors
??
[],
NodeType
.
Sensor
)))),
finalize
(()
=>
console
.
log
(
"
finally got names
"
,
data
))
tap
(
clients
=>
clients
.
forEach
(
client
=>
data
.
push
(
returnNodeWithMultiChild
(
client
.
name
??
""
,
NodeType
.
Client
,
client
.
sensors
??
[],
NodeType
.
Sensor
)))),
finalize
(()
=>
console
.
log
(
"
TreeData of Clients
"
,
data
))
).
subscribe
()
}
let
saveClients2
=
(
client_names
:
string
[],
treeNode
:
DateTreeNode
[])
=>
{
let
clients
:
Observable
<
Client
>
[]
=
client_names
.
map
(
name
=>
this
.
clientController
.
getClientById
(
name
))
combineLatest
(
clients
).
pipe
(
tap
(
clients
=>
clients
.
forEach
(
client
=>
treeNode
.
push
(
returnNodeWithMultiChild
(
client
.
name
??
""
,
NodeType
.
Client
,
client
.
sensors
??
[],
NodeType
.
Sensor
)))),
finalize
(()
=>
console
.
log
(
"
TreeData of Clients
"
,
treeNode
))
).
subscribe
()
}
let
saveClients3
=
(
client_names
:
string
[],
treeNode
:
DateTreeNode
[]):
Observable
<
Client
[]
>=>
{
let
clients
:
Observable
<
Client
>
[]
=
client_names
.
map
(
name
=>
this
.
clientController
.
getClientById
(
name
))
return
combineLatest
(
clients
).
pipe
(
tap
(
clients
=>
clients
.
forEach
(
client
=>
treeNode
.
push
(
returnNodeWithMultiChild
(
client
.
name
??
""
,
NodeType
.
Client
,
client
.
sensors
??
[],
NodeType
.
Sensor
)))),
finalize
(()
=>
console
.
log
(
"
TreeData of Clients
"
,
treeNode
))
)
}
saveClients
([
"
ibk_c_id_1
"
,
"
ibk_c_id_2
"
,
"
ibk_c_id_3
"
],
treeNode
)
let
saveStation
=
()
=>
{
let
clientsDataTree
:
DateTreeNode
[]
=
[]
let
station
:
Station
=
{}
//1 step
this
.
stationController
.
getById
(
"
ibk_s_id_1
"
).
pipe
(
tap
(
s
=>
station
=
s
)).
subscribe
()
//2 steo
saveClients
(
station
.
clients
??
[],
treeNode
)
//3 step
let
staionNodes
:
DateTreeNode
=
returnNodeWithMultiChild
(
station
.
name
??
""
,
NodeType
.
Station
,
station
.
clients
??
[],
NodeType
.
Client
);
let
treNodeFinal
:
DateTreeNode
this
.
stationController
.
getById
(
"
ibk_s_id
"
).
pipe
(
tap
(
s
=>
station
=
s
),
switchMap
(()
=>
{
// Step 2: Call saveClients function
console
.
log
(
"
fiiiiiiiiiiiiiiiiirs
"
);
return
saveClients3
(
station
.
clients
??
[],
clientsDataTree
);
}),
switchMap
(
data
=>
{
console
.
log
(
"
seeeeeecond
"
);
console
.
log
(
"
data
"
,
clientsDataTree
)
// Step 3: Create station nodes
let
sN
:
DateTreeNode
=
returnNode
(
station
.
name
??
""
,
NodeType
.
Station
,
clientsDataTree
);
// Do something with stationNodes or return it as needed
return
of
(
sN
);
})
).
subscribe
(
sNN
=>
{
// Handle the final result of stationNodes
console
.
log
(
'
final result:
'
,
sNN
);
});
}
let
staiton
:
Observable
<
Station
[]
>=
this
.
stationController
.
getAll
()
staiton
.
subscribe
(
stations
=>
{
}
)
saveStation
()
this
.
stationController
.
getAll
().
pipe
().
subscribe
(
stations
=>
{
console
.
log
(
"
stations
"
,
stations
)})
}
...
...
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