From c88fb1a75863e0549ecbc29188362fe963ef5606 Mon Sep 17 00:00:00 2001 From: Johnny Sit Date: Thu, 26 Mar 2020 17:37:43 -0400 Subject: [PATCH] some files weren't committed/pushed --- src/app/app.module.ts | 3 ++- src/app/main/dropdown/dropdown.component.css | 0 src/app/main/dropdown/dropdown.component.html | 13 ++++++++++ .../main/dropdown/dropdown.component.spec.ts | 25 +++++++++++++++++++ src/app/main/dropdown/dropdown.component.ts | 23 +++++++++++++++++ src/app/main/main.component.html | 2 ++ src/app/main/main.component.ts | 1 - src/app/main/tree/tree.component.html | 24 +++++------------- src/app/main/tree/tree.component.ts | 24 +++++++++++------- 9 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 src/app/main/dropdown/dropdown.component.css create mode 100644 src/app/main/dropdown/dropdown.component.html create mode 100644 src/app/main/dropdown/dropdown.component.spec.ts create mode 100644 src/app/main/dropdown/dropdown.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0f35882..f9f0165 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,9 +8,10 @@ import { TreeModule } from 'primeng/tree'; import { MainComponent } from './main/main.component'; import { MainCenterComponent } from './main/main-center/main-center.component'; import { TreeComponent } from './main/tree/tree.component'; +import { DropdownComponent } from './main/dropdown/dropdown.component'; @NgModule({ - declarations: [AppComponent, TreeComponent, MainComponent, MainCenterComponent], + declarations: [AppComponent, TreeComponent, MainComponent, MainCenterComponent, DropdownComponent], imports: [ BrowserModule, AppRoutingModule, diff --git a/src/app/main/dropdown/dropdown.component.css b/src/app/main/dropdown/dropdown.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/main/dropdown/dropdown.component.html b/src/app/main/dropdown/dropdown.component.html new file mode 100644 index 0000000..f46e699 --- /dev/null +++ b/src/app/main/dropdown/dropdown.component.html @@ -0,0 +1,13 @@ +

Please select a model:

+ + +

+
+ + + + +

No information is available for selected model

+
\ No newline at end of file diff --git a/src/app/main/dropdown/dropdown.component.spec.ts b/src/app/main/dropdown/dropdown.component.spec.ts new file mode 100644 index 0000000..e0edf7a --- /dev/null +++ b/src/app/main/dropdown/dropdown.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DropdownComponent } from './dropdown.component'; + +describe('DropdownComponent', () => { + let component: DropdownComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DropdownComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DropdownComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/main/dropdown/dropdown.component.ts b/src/app/main/dropdown/dropdown.component.ts new file mode 100644 index 0000000..04dbe4d --- /dev/null +++ b/src/app/main/dropdown/dropdown.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { XAService } from 'src/app/services/XAService.service'; + +@Component({ + selector: 'app-dropdown', + templateUrl: './dropdown.component.html', + styleUrls: ['./dropdown.component.css'] +}) +export class DropdownComponent implements OnInit { + constructor(private xaService: XAService) { } + + xaList = [{ name: null, value: null }, { name: 'UConn', value: 1 }, { name: 'Test', value: 2 }]; + + selectedXA = ''; + + selectOptionHandler(event: any) { + this.selectedXA = event.target.value; + this.xaService.changeXA(this.selectedXA); + } + + ngOnInit() { + } +} diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html index 425ed99..a8ac724 100644 --- a/src/app/main/main.component.html +++ b/src/app/main/main.component.html @@ -1,3 +1,5 @@ + +

diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 355d203..8334f84 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -6,7 +6,6 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./main.component.css'] }) export class MainComponent implements OnInit { - constructor() { } ngOnInit() { diff --git a/src/app/main/tree/tree.component.html b/src/app/main/tree/tree.component.html index 367c3f6..e752daa 100644 --- a/src/app/main/tree/tree.component.html +++ b/src/app/main/tree/tree.component.html @@ -1,20 +1,4 @@ -

Select XA:

- - -

Please select a model

-
- - - - -

No information is available for selected model

-
- - +
@@ -22,4 +6,8 @@
-
\ No newline at end of file +
+ + +

No XA selected

+
\ No newline at end of file diff --git a/src/app/main/tree/tree.component.ts b/src/app/main/tree/tree.component.ts index 90d4b97..e84b413 100644 --- a/src/app/main/tree/tree.component.ts +++ b/src/app/main/tree/tree.component.ts @@ -1,29 +1,31 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { TreeNode } from 'primeng/api'; +import { Subscription } from 'rxjs'; import { NodeService } from 'src/app/services/node.service'; import { TreeService } from 'src/app/services/tree.service'; +import { XAService } from 'src/app/services/XAService.service'; @Component({ selector: 'app-tree', templateUrl: './tree.component.html', styleUrls: ['./tree.component.css'] }) -export class TreeComponent implements OnInit { +export class TreeComponent implements OnInit, OnDestroy { + private dropdownSubscription: Subscription; + currentXA: string; filesTree: TreeNode[]; - selectedXA = ''; - - selectOptionHandler(event: any) { - this.selectedXA = event.target.value; - } - constructor( private treeService: TreeService, - private nodeService: NodeService + private nodeService: NodeService, + private xaService: XAService ) { } ngOnInit() { + this.dropdownSubscription = this.xaService.xa$.subscribe(async (xa) => { + this.currentXA = xa; + }); this.nodeService.getFiles().then(files => (this.filesTree = files)); } @@ -31,4 +33,8 @@ export class TreeComponent implements OnInit { this.treeService.changeNode(event.node); } + ngOnDestroy() { + this.dropdownSubscription.unsubscribe(); + } + }