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 @@ ...@@ -18,4 +18,5 @@
</mat-tree-node> </mat-tree-node>
</mat-tree> </mat-tree>
</section> </section>
{{this.dataSate}}
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {MatTreeFlatDataSource, MatTreeFlattener, MatTreeModule} from '@angular/material/tree'; import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import {FlatTreeControl} from "@angular/cdk/tree"; import {FlatTreeControl} from "@angular/cdk/tree";
import { import {
Client, Client,
...@@ -10,9 +8,8 @@ import { ...@@ -10,9 +8,8 @@ import {
HostControllerService, SensorControllerService, Station, HostControllerService, SensorControllerService, Station,
StationControllerService StationControllerService
} from "../../../../../../projects/generated-api/src"; } from "../../../../../../projects/generated-api/src";
import {combineLatest, concatMap, finalize, Observable, of, switchMap, tap} from "rxjs"; import {combineLatest, Observable, of, switchMap, tap} from "rxjs";
import {StationModel} from "../../admin/stationManagement/station/station.model";
import {map} from "rxjs/operators";
/** /**
...@@ -21,12 +18,7 @@ import {map} from "rxjs/operators"; ...@@ -21,12 +18,7 @@ import {map} from "rxjs/operators";
*/ */
const staiton: Station = {
name: 'Test Station',
host: 'Test Host',
clients: ['1','2','3'],
}
interface TreeNode { interface TreeNode {
name: string; name: string;
...@@ -49,7 +41,7 @@ interface DateTreeNode { ...@@ -49,7 +41,7 @@ interface DateTreeNode {
const TREE_DATA: TreeNode[] = [ const TREE_DATA: TreeNode[] = [
{ {
name: 'Fruit', name: 'Fruitss',
children: [{name: 'Apple'}, {name: 'Banana'}, {name: 'Fruit loops'}], children: [{name: 'Apple'}, {name: 'Banana'}, {name: 'Fruit loops'}],
}, },
{ {
...@@ -140,8 +132,8 @@ interface ExampleFlatNode { ...@@ -140,8 +132,8 @@ interface ExampleFlatNode {
export class StationConfigComponent implements OnInit{ export class StationConfigComponent implements OnInit{
private dataSate=false; public dataSate=false;
private treeStation?:DateTreeNode public treeStation?:DateTreeNode
private _transformer = (node: TreeNode, level: number) => { private _transformer = (node: TreeNode, level: number) => {
return { return {
expandable: !!node.children && node.children.length > 0, expandable: !!node.children && node.children.length > 0,
...@@ -213,16 +205,15 @@ export class StationConfigComponent implements OnInit{ ...@@ -213,16 +205,15 @@ export class StationConfigComponent implements OnInit{
tap(s => station = s), tap(s => station = s),
switchMap(() => { switchMap(() => {
// Step 2: Call saveClients function // Step 2: Call saveClients function
console.log("fiiiiiiiiiiiiiiiiirs");
return saveClients3(station.clients ?? [], clientsDataTree); return saveClients3(station.clients ?? [], clientsDataTree);
}), }),
).subscribe(sNN => { ).subscribe(() => {
// Handle the final result of stationNodes // Handle the final result of stationNodes
let sN: DateTreeNode = returnNode(station.name ?? "", NodeType.Station, clientsDataTree); let dateTreeNode: DateTreeNode = returnNode(station.name ?? "", NodeType.Station, clientsDataTree);
this.treeStation=sN; this.treeStation=dateTreeNode;
this.dataSate=true; 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