Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nav visual instructions base ready #25

Merged
merged 15 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db
/src/assets/config.json
3 changes: 3 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<mat-sidenav-container class="search-sidenav-container">
<mat-sidenav-content>
<div class="app-container">
<div class="instructions-container">
<app-instructions-display></app-instructions-display>
</div>
<app-search-page></app-search-page>
<div class="map-container">
<app-map></app-map>
Expand Down
21 changes: 17 additions & 4 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,31 @@
}

.app-container {
display: flex;
//display: flex;
height: 100%;
flex-direction: column;
justify-content: space-between;

}

.map-container {
flex-grow: 1;
//flex-grow: 1;
//flex: 1 1 auto;
height: calc(100% - 100px);
}

.controlBarContainer {
//margin: 10px;
//flex-basis: 30px;
//flex-shrink: 0;
//flex: 0 0 auto;
height: 50px;

}

.controlBarContainer {
margin: 10px;
.instructions-container {
//margin: 10px;
//flex: 0 0 auto;
height: 50px;
}

5 changes: 5 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component } from '@angular/core';
import { GeolocationService } from './modules/service-providers/services/position/geolocation.service';
import { NavigationService } from './modules/service-providers/services/navigation/navigation.service';

@Component({
selector: 'app-root',
Expand All @@ -7,4 +9,7 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'Phraze';

constructor(private geolocationService: GeolocationService,
private navigationService: NavigationService) {}
}
4 changes: 4 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ import { StoreModule } from '@ngrx/store';
import { navFeatureKey } from './store/nav.selectors';
import { navReducer } from './store/nav.reducer';
import { FormsModule } from '@angular/forms';
import { InstructionsDisplayComponent } from './components/instructions-display/instructions-display.component';
import { InstructionsVoiceComponent } from './components/instructions-voice/instructions-voice.component';


@NgModule({
declarations: [
AppComponent,
ControlBarComponent,
SearchPageComponent,
InstructionsDisplayComponent,
InstructionsVoiceComponent,

],
imports: [
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/control-bar/control-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<div class="settingsButtonContainer">
<button mat-raised-button (click)="startNavigation()">Start</button>
</div>
<div class="remaining-distance-display-container">
<span class="remain-span">{{distanceToEndpoint$ | async}} </span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be displayed as integer and in quantizations (for distance of 10-100km should update every 10km, for 1-10km show update every 1km, for 100-1000m show update every 100m an so on).
Also, the display unit should be shown (km/m)

Please add an issue for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#33
please advise - this is not the way to our main competitor works.

</div>

</div>
12 changes: 11 additions & 1 deletion src/app/components/control-bar/control-bar.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
.controlBarContainer {
height: 30px;
display: flex;
}
.remaining-distance-display-container {
display: flex;
flex-direction: column;
align-content: space-around;
position: relative;
}

.remain-span {
position: absolute;
top: 50%;
}
13 changes: 9 additions & 4 deletions src/app/components/control-bar/control-bar.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { SetActiveNavAction, SetShowSearchAction } from '../../store/nav.actions';
import { routePointSelector, routeSelector } from '../../store/nav.selectors';
import { SetNextWaypointIndexAction, SetPhrazeStateAction, SetShowSearchAction } from '../../store/nav.actions';
import { distanceToEndpointSelector, routePointsSelector } from '../../store/nav.selectors';
import { tap } from 'rxjs/operators';
import { PhrazeState } from '../../interface/nav.interface';

@Component({
selector: 'app-control-bar',
Expand All @@ -11,19 +12,23 @@ import { tap } from 'rxjs/operators';
})
export class ControlBarComponent implements OnInit {

distanceToEndpoint$;

constructor(private store: Store<any>) { }

ngOnInit() {
this.distanceToEndpoint$ = this.store.pipe(select(distanceToEndpointSelector));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to be on init.
Can be in constructor or before on the variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

}

openSearchPage() {
this.store.dispatch(new SetShowSearchAction({isShowSearch: true}));
}

startNavigation() {
this.store.dispatch(new SetActiveNavAction({isActiveNav: true}));
this.store.dispatch(new SetPhrazeStateAction({phrazeState: PhrazeState.NAVIGATION}));
this.store.dispatch(new SetNextWaypointIndexAction({nextWaypointIndex: 1}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should be part of set state reducer in order to avoid two actions
Also order matters, next should be before state

this.store.pipe(
select(routePointSelector),
select(routePointsSelector),
tap(route => {
const from = <any>route[0];
const to = <any>route[route.length - 1];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="instructions-container">
in {{distanceToNextWaypoint$ | async}} {{nextWaypointManeuver$ | async}} to {{nextWaypointName$ | async}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark of how to display km/m in proper quantizations.
Maneuver should be shown as image or at least separated to words

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#34

</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { InstructionsDisplayComponent } from './instructions-display.component';

describe('InstructionsDisplayComponent', () => {
let component: InstructionsDisplayComponent;
let fixture: ComponentFixture<InstructionsDisplayComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InstructionsDisplayComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(InstructionsDisplayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Component, OnInit } from '@angular/core';
import { select, Store } from '@ngrx/store';
import {
nextWaypointDistanceSelector,
nextWaypointIndexSelector,
phrazeStateSelector,
routeDetailsSelector
} from '../../store/nav.selectors';
import { filter, map, withLatestFrom } from 'rxjs/operators';
import { PhrazeState } from '../../interface/nav.interface';

@Component({
selector: 'app-instructions-display',
templateUrl: './instructions-display.component.html',
styleUrls: ['./instructions-display.component.scss']
})
export class InstructionsDisplayComponent implements OnInit {
distanceToNextWaypoint$;
nextWaypoint$;
nextWaypointManeuver$;
nextWaypointName$;

constructor(private store: Store<any>) {
}

ngOnInit() {

this.distanceToNextWaypoint$ = this.store.pipe(select(nextWaypointDistanceSelector));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also be shown only on navigation and otherwise hidden/some value


this.nextWaypoint$ = this.store.pipe(select(nextWaypointIndexSelector),
withLatestFrom(this.store.pipe(select(routeDetailsSelector)), this.store.pipe(select(phrazeStateSelector))),
filter(([nextWpIndex, routeDetails, navState]) => navState === PhrazeState.NAVIGATION));

this.nextWaypointManeuver$ = this.nextWaypoint$.pipe(
map(([nextWpIndex, routeDetails, navState]) => routeDetails.routeLegs[nextWpIndex].maneuverType)
);

this.nextWaypointName$ = this.nextWaypoint$.pipe(
map(([nextWpIndex, routeDetails, navState]) => routeDetails.routeLegs[nextWpIndex].name)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
instructions-voice works!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voice component shouldn't have an UI

</p>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { InstructionsVoiceComponent } from './instructions-voice.component';

describe('InstructionsVoiceComponent', () => {
let component: InstructionsVoiceComponent;
let fixture: ComponentFixture<InstructionsVoiceComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InstructionsVoiceComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(InstructionsVoiceComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-instructions-voice',
templateUrl: './instructions-voice.component.html',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voice component shouldn't have an UI

styleUrls: ['./instructions-voice.component.scss']
})
export class InstructionsVoiceComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
27 changes: 15 additions & 12 deletions src/app/components/search-page/search-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { GeocodingService } from '../../modules/service-providers/services/geocoding/geocoding.service';
import { RoutesService } from '../../modules/service-providers/services/routes/routes.service';
import { GeolocationService } from '../../modules/service-providers/services/position/geolocation.service';
import { select, Store } from '@ngrx/store';
import { SetActiveNavAction, SetRouteAction, SetShowSearchAction } from '../../store/nav.actions';
import { routeSelector, getShowSearchSelector, routePointSelector } from '../../store/nav.selectors';
import { SetPhrazeStateAction, SetRouteAction, SetShowSearchAction } from '../../store/nav.actions';
import { currentPositionSelector, getShowSearchSelector, routePointsSelector } from '../../store/nav.selectors';
import { PhrazeState } from '../../interface/nav.interface';
import { take, tap } from 'rxjs/operators';

@Component({
selector: 'app-search-page',
Expand All @@ -15,17 +16,15 @@ export class SearchPageComponent implements OnInit {

searchResults;
routePoints$;
currentPosition;
isShowSearch$;
searchAddress = 'בן יהודה 5 ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default should be from configuration and empty of production



constructor(private store: Store<any>,
private geocodingService: GeocodingService,
private routesService: RoutesService,
private geolocationService: GeolocationService) {
private routesService: RoutesService) {
this.routePoints$ = this.store.pipe(
select(routePointSelector)
select(routePointsSelector)
);
this.isShowSearch$ = this.store.pipe(
select(getShowSearchSelector)
Expand All @@ -43,15 +42,19 @@ export class SearchPageComponent implements OnInit {
}

selectDestination(entry) {
this.currentPosition = this.geolocationService.lastPos.coords;
this.calcRoute(this.currentPosition, entry.coords);
this.closeSearchPage();
this.store.dispatch(new SetActiveNavAction({isActiveNav: false}));
this.store.pipe(
select(currentPositionSelector),
take(1),
tap(currentPosition => {
this.calcRoute(currentPosition, entry.coords);
this.closeSearchPage();
this.store.dispatch(new SetPhrazeStateAction({phrazeState: PhrazeState.PREVIEW}));
})
).subscribe();
}

calcRoute(from, to) {
this.routesService.getRoute(from, to).subscribe(data => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be via action and effect not directly via service.

console.log(data);
this.store.dispatch(new SetRouteAction(data));
});
}
Expand Down
26 changes: 24 additions & 2 deletions src/app/interface/nav.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@

export interface NavInterface {
routeDetails: RouteDetails;
isActiveNav: boolean;
phrazeState: PhrazeState;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store should be split (refactored) into domains.
For example isShowSearch and currentPosition doesn't belong together.

isShowSearch: boolean;
currentPosition: GeoPosition;
nextWaypointIndex: number;
nextWaypointDistance: number;
isNextWpNotified: boolean;
distanceToEndpoint: number;
previousPosition: GeoPosition;
previousPositionTimeStamp: number;
currentPositionTimeStamp: number;
}

export interface RouteDetails {
Expand All @@ -14,7 +22,21 @@ export interface RouteDetails {

export interface LegDetails {
index: number;
coords: [];
coords: Array<number>;
text: string;
maneuverType: string;
name: string;
}

export enum PhrazeState {
IDLE = 'IDLE',
PREVIEW = 'PREVIEW',
NAVIGATION = 'NAVIGATION'
}

export interface GeoPosition {
latitude: number;
longitude: number;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ac-layer acFor="let nextWp of nextWpUpdate$" [context]="this">
<ac-billboard-primitive-desc props="{
position: nextWp.position,
image: './assets/images/jeep.svg',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a pin.
Open an issue (and other issues for each required change)

scale: 1.5
}">
</ac-billboard-primitive-desc>
</ac-layer>
Loading