Skip to content

Commit

Permalink
Prettier formatting and small adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
LAMM26 committed Apr 4, 2024
1 parent 2b640a9 commit 3537860
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface BaseDirectionsSourceOptions {
export interface BaseDirectionsSourceOptionsProfile {
enabled?: boolean;
name: string;
authorization?: BaseDirectionsSourceOptionsProfileAuthorization
authorization?: BaseDirectionsSourceOptionsProfileAuthorization;
}

export interface BaseDirectionsSourceOptionsProfileAuthorization {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Position } from 'geojson';
import { Observable } from 'rxjs';

import { Direction, DirectionOptions } from '../shared/directions.interface';
import { BaseDirectionsSourceOptionsProfile } from './directions-source.interface';
import { Position } from 'geojson';

export abstract class DirectionsSource {
abstract profiles: BaseDirectionsSourceOptionsProfile[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class OsrmDirectionsSource extends DirectionsSource {
this._options.baseUrl = value;
}

get url(): string {
return `${this.baseUrl}${this.getEnabledProfile().name}/`;
}

get profiles(): BaseDirectionsSourceOptionsProfile[] {
return this._options.profiles;
}
Expand Down Expand Up @@ -106,7 +110,7 @@ export class OsrmDirectionsSource extends DirectionsSource {
coordinates: Position[],
params: HttpParams
): Observable<Direction[]> {
const url: string = `${this.baseUrl}${this.getEnabledProfile().name}/`;
const url: string = this.url;
return this._http
.get<JSON[]>(url + coordinates.join(';'), {
params
Expand Down Expand Up @@ -167,7 +171,7 @@ export class OsrmDirectionsSource extends DirectionsSource {
return {
id: uuid(),
title: roadNetworkRoute.legs[0].summary,
source: `${this.baseUrl}${this.getEnabledProfile().name}/`,
source: this.url,
sourceType: SourceDirectionsType.Route,
order: 1,
format: DirectionsFormat.GeoJSON,
Expand Down
5 changes: 3 additions & 2 deletions packages/geo/src/lib/directions/directions.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
>
{{ 'igo.geo.directionsForm.toggleActive' | translate }}
</mat-slide-toggle>
<mat-slide-toggle *ngIf="hasOsrmPrivateAccess && twoSourcesAvailable"
<mat-slide-toggle
*ngIf="hasOsrmPrivateAccess && twoSourcesAvailable"
[checked]="enabledProfileHasAuthorization"
[labelPosition]="'before'"
(change)="onTogglePrivateModeControl($event.checked)"
>
{{ 'igo.geo.directionsForm.toggleType' | translate }}
{{ 'igo.geo.directionsForm.toggleType' | translate }}
</mat-slide-toggle>
</div>

Expand Down
10 changes: 5 additions & 5 deletions packages/geo/src/lib/directions/directions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class DirectionsComponent implements OnInit, OnDestroy {
return [this.selectStopInteraction, this.translateStop, this.selectedRoute];
}

get enabledProfileHasAuthorization() {
return this.directionsSourceService.sources[0].getEnabledProfile()
.authorization;
}

constructor(
private cdRef: ChangeDetectorRef,
private http: HttpClient,
Expand Down Expand Up @@ -167,11 +172,6 @@ export class DirectionsComponent implements OnInit, OnDestroy {
this.freezeStores();
}

get enabledProfileHasAuthorization() {
return this.directionsSourceService.sources[0].getEnabledProfile()
.authorization;
}

private freezeStores() {
this.interactions.map((interaction) =>
this.routesFeatureStore.layer.map.ol.removeInteraction(interaction)
Expand Down
8 changes: 6 additions & 2 deletions packages/geo/src/lib/directions/shared/directions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ConfigService } from '@igo2/core/config';
import { LanguageService } from '@igo2/core/language';
import { SubjectStatus } from '@igo2/utils';

import { Position } from 'geojson';
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import 'jspdf-autotable';
Expand All @@ -24,7 +25,6 @@ import {
formatDuration,
formatInstruction
} from './directions.utils';
import { Position } from 'geojson';

@Injectable({
providedIn: 'root'
Expand All @@ -46,7 +46,11 @@ export class DirectionsService {
if (coordinates.length === 0) {
return;
}
return this.routeSource(this.directionsSourceService.sources[0], coordinates, directionsOptions);
return this.routeSource(
this.directionsSourceService.sources[0],
coordinates,
directionsOptions
);
}

routeSource(
Expand Down
6 changes: 4 additions & 2 deletions projects/demo/src/app/auth/auth-form/auth-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
>
<app-example-viewer codeFolder="auth/auth-form" configFolder="environments">
The dialog opens automatically if you are not logged in
<br>
<br />
<button
mat-raised-button
color="primary"
[disabled]="!logged"
(click)="logout()"
>Log out</button>
>
Log out
</button>
</app-example-viewer>
</app-doc-viewer>
<igo-auth-form></igo-auth-form>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { MatGridListModule } from '@angular/material/grid-list';

import { AuthService } from '@igo2/auth';
import {
IgoDirectionsModule,
IgoMap,
Expand All @@ -21,7 +22,6 @@ import { BehaviorSubject, Subject } from 'rxjs';

import { DocViewerComponent } from '../../components/doc-viewer/doc-viewer.component';
import { ExampleViewerComponent } from '../../components/example/example-viewer/example-viewer.component';
import { AuthService } from '@igo2/auth';

@Component({
selector: 'app-directions',
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const environment: EnvironmentOptions = {
baseUrl: '/apis/itineraire/route/v1/',
profiles: [
{
name: 'driving',
name: 'driving'
},
{
name: 'forestier',
Expand All @@ -20,7 +20,7 @@ export const environment: EnvironmentOptions = {
}
}
]
},
}
},
projections: [
{
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const environment: EnvironmentOptions = {
baseUrl: '/apis/itineraire/route/v1/',
profiles: [
{
name: 'driving',
name: 'driving'
},
{
name: 'forestier',
Expand Down

0 comments on commit 3537860

Please sign in to comment.