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
3109cc52
Commit
3109cc52
authored
1 year ago
by
Bilal Hassan
Browse files
Options
Downloads
Patches
Plain Diff
-working on Refactoring implementation of station config
parent
02309b22
No related branches found
Branches containing commit
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
+15
-119
15 additions, 119 deletions
...ule/pages/home/station-config/station-config.component.ts
with
15 additions
and
119 deletions
src/app/module/pages/home/station-config/station-config.component.ts
+
15
−
119
View file @
3109cc52
...
...
@@ -139,6 +139,9 @@ interface ExampleFlatNode {
})
export
class
StationConfigComponent
implements
OnInit
{
private
dataSate
=
false
;
private
treeStation
?:
DateTreeNode
private
_transformer
=
(
node
:
TreeNode
,
level
:
number
)
=>
{
return
{
expandable
:
!!
node
.
children
&&
node
.
children
.
length
>
0
,
...
...
@@ -146,6 +149,7 @@ export class StationConfigComponent implements OnInit{
level
:
level
,
};
};
hasChild
=
(
_
:
number
,
node
:
ExampleFlatNode
)
=>
node
.
expandable
;
treeControl
=
new
FlatTreeControl
<
ExampleFlatNode
>
(
node
=>
node
.
level
,
...
...
@@ -170,19 +174,13 @@ export class StationConfigComponent implements OnInit{
this
.
dataSource
.
data
=
TREE_DATA
;
}
ngOnInit
():
void
{
// this.fetchData();
this
.
test
()
this
.
fetchData
()
;
}
test
(){
let
treeNode
:
DateTreeNode
=
{
name
:
"
root
"
,
type
:
NodeType
.
Station
,
children
:[]
}
fetchData
(){
let
returnNode
=
(
name
:
string
,
type
:
NodeType
,
childs
:
DateTreeNode
[]):
DateTreeNode
=>
{
return
{
name
:
name
?
name
:
'
UNDEFINED
'
,
type
:
type
,
...
...
@@ -197,51 +195,20 @@ export class StationConfigComponent implements OnInit{
type
:
p_type
,
children
:
returnMultipleNodes
(
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
(
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
))
tap
(
clients
=>
{
clients
.
forEach
(
client
=>
treeNode
.
push
(
returnNodeWithMultiChild
(
client
.
name
??
""
,
NodeType
.
Client
,
client
.
sensors
??
[],
NodeType
.
Sensor
)))
})
)
}
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
// Step 1: Call getById function
this
.
stationController
.
getById
(
"
ibk_s_id
"
).
pipe
(
tap
(
s
=>
station
=
s
),
switchMap
(()
=>
{
...
...
@@ -249,85 +216,14 @@ export class StationConfigComponent implements OnInit{
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
sN
:
DateTreeNode
=
returnNode
(
station
.
name
??
""
,
NodeType
.
Station
,
clientsDataTree
);
this
.
treeStation
=
sN
;
this
.
dataSate
=
true
;
console
.
log
(
'
final result:
'
,
sN
);
});
}
let
staiton
:
Observable
<
Station
[]
>=
this
.
stationController
.
getAll
()
staiton
.
subscribe
(
stations
=>
{
}
)
saveStation
()
this
.
stationController
.
getAll
().
pipe
().
subscribe
(
stations
=>
{
console
.
log
(
"
stations
"
,
stations
)})
}
fetchData
(){
console
.
log
(
"
fetching data
"
)
let
station
:
Station
[]
let
stationTree
:
DateTreeNode
[]
=
[]
let
returnNode
=
(
name
:
string
,
type
:
NodeType
):
DateTreeNode
=>
{
return
{
name
:
name
?
name
:
'
UNDEFINED
'
,
type
:
type
,
children
:
[],
}};
let
callClients
=
(
station_index
:
number
,
clients
:
string
[])
=>
{
clients
.
forEach
((
client
,
client_index
)
=>
this
.
clientController
.
getClientById
(
client
).
pipe
(
tap
(
x
=>
{
console
.
log
(
"
station ibk_c_id_1
"
,
x
)
stationTree
.
push
(
returnNode
(
x
.
name
??
""
,
NodeType
.
Client
))
stationTree
.
at
(
station_index
)?.
children
?.
at
(
client_index
)?.
children
?.
push
(
returnNode
(
x
.
name
??
""
,
NodeType
.
Sensor
))
}
)).
subscribe
())
}
this
.
stationController
.
getAll
().
pipe
(
tap
(
stations
=>
stations
.
forEach
(
item
=>
stationTree
.
push
({
name
:
''
+
item
.
name
,
type
:
NodeType
.
Station
,
children
:
item
.
clients
?.
map
(
x
=>
returnNode
(
x
,
NodeType
.
Client
))}))),
finalize
(
()
=>
{
console
.
log
(
"
stationTree
"
,
stationTree
)
stationTree
.
forEach
((
station
,
staion_index
)
=>
callClients
(
staion_index
,
station
.
children
?.
map
(
x
=>
x
.
name
??
""
)
??
[]))
})
).
subscribe
()
this
.
hostController
.
getAll1
().
pipe
(
tap
(
x
=>
console
.
log
(
x
))).
subscribe
()
let
clienName
:
string
;
//clienName=stationTree.at(0)?.name??""
clienName
=
stationTree
.
at
(
0
)?.
children
?.
at
(
0
)?.
name
??
""
console
.
log
(
"
clienName
"
,
clienName
)
this
.
clientController
.
getClientById
(
"
ibk_c_id_1
"
).
pipe
(
tap
(
x
=>
console
.
log
(
"
station ibk_c_id_1
"
,
x
))).
subscribe
();
this
.
clientController
.
getAllClients
().
pipe
(
tap
(
x
=>
console
.
log
(
"
all clients
"
,
x
))).
subscribe
();
this
.
sensorController
.
getAllSensors
().
pipe
(
tap
(
x
=>
console
.
log
(
x
))).
subscribe
();
}
hasChild
=
(
_
:
number
,
node
:
ExampleFlatNode
)
=>
node
.
expandable
;
}
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