Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #2 from 3d-system-navigation/selectionDropDown
Added dropdown menu
- Loading branch information
Showing
10 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="d-flex align-items-center p-2"> | ||
<h3 class="mr-2">End Item: </h3> | ||
<p-dropdown [options]="xaList" [(ngModel)]="selectedEndItem" (onChange)="onChange($event)"></p-dropdown> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DropdownComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DropdownComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DropdownComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { EndItemService } from 'src/app/services/enditem.service'; | ||
import { SelectItem } from 'primeng/api'; | ||
|
||
@Component({ | ||
selector: 'app-dropdown', | ||
templateUrl: './dropdown.component.html', | ||
styleUrls: ['./dropdown.component.css'] | ||
}) | ||
export class DropdownComponent { | ||
|
||
constructor( | ||
private endItemService: EndItemService | ||
) {} | ||
|
||
// TODO replace with backend. | ||
xaList: SelectItem[] = [ | ||
{ label: 'None selected', value: null }, | ||
{ label: 'UConn', value: 'Uconn' }, | ||
{ label: 'Test', value: 'Test' } | ||
]; | ||
|
||
selectedEndItem = ''; | ||
|
||
onChange(event: any) { | ||
this.endItemService.setEndItem(this.selectedEndItem); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
|
||
<ng-template #noPdf> | ||
<h1 class="ml-4 mt-4 text-danger">PDF not found</h1> | ||
</ng-template> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<div class="d-flex h-100 w-100"> | ||
<div class="bg-secondary"> | ||
<app-dropdown></app-dropdown> | ||
</div> | ||
<div *ngIf="endItemService.endItem$ | async" class="d-flex h-100 w-100" > | ||
<app-tree></app-tree> | ||
<app-main-center class="w-100"></app-main-center> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
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 { EndItemService } from 'src/app/services/enditem.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; | ||
|
||
selectedEndItem: string; | ||
filesTree: TreeNode[]; | ||
|
||
constructor( | ||
private treeService: TreeService, | ||
private nodeService: NodeService | ||
private nodeService: NodeService, | ||
private endItemService: EndItemService | ||
) { } | ||
|
||
ngOnInit() { | ||
this.dropdownSubscription = this.endItemService.endItem$.subscribe(xa => this.selectedEndItem = xa); | ||
this.nodeService.getFiles().then(files => (this.filesTree = files)); | ||
} | ||
|
||
nodeSelect(event: { node: TreeNode }) { | ||
this.treeService.changeNode(event.node); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.dropdownSubscription.unsubscribe(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class EndItemService { | ||
|
||
private selectedEndItem = new BehaviorSubject<string>(null); | ||
endItem$ = this.selectedEndItem.asObservable(); | ||
|
||
setEndItem(endItem: string) { | ||
this.selectedEndItem.next(endItem); | ||
} | ||
|
||
} |