Skip to content
Snippets Groups Projects
Commit 4f9d2198 authored by User expired's avatar User expired
Browse files

-working on Refactoring implementation of station config

parent 3109cc52
No related branches found
No related tags found
4 merge requests!25Draft: Resolve #78,!7fixUrlPath,!4merge dev into main,!1after meeting with zoe
......@@ -18,4 +18,5 @@
</mat-tree-node>
</mat-tree>
</section>
{{this.dataSate}}
import {Component, OnInit} from '@angular/core';
import {MatTreeFlatDataSource, MatTreeFlattener, MatTreeModule} from '@angular/material/tree';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
import {FlatTreeControl} from "@angular/cdk/tree";
import {
Client,
......@@ -10,9 +8,8 @@ import {
HostControllerService, SensorControllerService, Station,
StationControllerService
} from "../../../../../../projects/generated-api/src";
import {combineLatest, concatMap, finalize, Observable, of, switchMap, tap} from "rxjs";
import {StationModel} from "../../admin/stationManagement/station/station.model";
import {map} from "rxjs/operators";
import {combineLatest, Observable, of, switchMap, tap} from "rxjs";
/**
......@@ -21,12 +18,7 @@ import {map} from "rxjs/operators";
*/
const staiton: Station = {
name: 'Test Station',
host: 'Test Host',
clients: ['1','2','3'],
}
interface TreeNode {
name: string;
......@@ -49,7 +41,7 @@ interface DateTreeNode {
const TREE_DATA: TreeNode[] = [
{
name: 'Fruit',
name: 'Fruitss',
children: [{name: 'Apple'}, {name: 'Banana'}, {name: 'Fruit loops'}],
},
{
......@@ -140,8 +132,8 @@ interface ExampleFlatNode {
export class StationConfigComponent implements OnInit{
private dataSate=false;
private treeStation?:DateTreeNode
public dataSate=false;
public treeStation?:DateTreeNode
private _transformer = (node: TreeNode, level: number) => {
return {
expandable: !!node.children && node.children.length > 0,
......@@ -213,16 +205,15 @@ export class StationConfigComponent implements OnInit{
tap(s => station = s),
switchMap(() => {
// Step 2: Call saveClients function
console.log("fiiiiiiiiiiiiiiiiirs");
return saveClients3(station.clients ?? [], clientsDataTree);
}),
).subscribe(sNN => {
).subscribe(() => {
// Handle the final result of stationNodes
let sN: DateTreeNode = returnNode(station.name ?? "", NodeType.Station, clientsDataTree);
this.treeStation=sN;
let dateTreeNode: DateTreeNode = returnNode(station.name ?? "", NodeType.Station, clientsDataTree);
this.treeStation=dateTreeNode;
this.dataSate=true;
console.log('final result:', sN);
console.log('final result:', dateTreeNode);
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment