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

Feature/logging facade #14

Merged
merged 4 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ ng lint
docker run [-it] -p8080:8080 -p2019:2019 holgerstolzenberg/european-geo-information
```

## Open points
## 📥 Open points

## Features

- ️Add user interactions for layer control
- ️Expandable toolbar
- ️Own location finder
- ️Smoother map animation (only mac chrome so far, retina)
- ️Add loading indicator
- ️Slider for map pitch angle
- ️Map initializing indicator
- ️Add user interactions for layer control
- ️Expandable toolbar
- ️Own location finder
- ️Smoother map animation (only mac chrome so far, retina)
- ️Add loading indicator
- ️Slider for map pitch angle
- ️Map initializing indicator
- Cross-hair on own location
- Also reset map pitch
- Weather or other overlays
Expand All @@ -49,18 +49,19 @@ docker run [-it] -p8080:8080 -p2019:2019 holgerstolzenberg/european-geo-informat
- Investigate 404 on app start
- Better SCSS structure and cleanup
- Cleanup of .whatever configurations (Prettier, ESLint, etc.)
- ☑️Pin package.json versions
- ☑️Glitching focus frame around map
- ✅️Logging service abstraction
- ✅️Pin package.json versions
- ✅️Glitching focus frame around map

## Packaging

- Make Docker image configurable at runtime -> let run at specific context (? env.js)
- ️Caddy based Docker image
- ️Make Caddy proxy requests to tile server
- ️Caddy based Docker image
- ️Make Caddy proxy requests to tile server

## CI

- GitHub CI pipeline
- ️docker build
- ️publish
- ️GitHub pages
- ️docker build
- ️publish
- ️GitHub pages
7 changes: 2 additions & 5 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { BrowserModule } from '@angular/platform-browser';
import { ToolbarComponent } from './toolbar/toolbar.component';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { MapComponent } from './map/map.component';
import { MatIcon } from '@angular/material/icon';
import { MatButton } from '@angular/material/button';
import { environment } from '../environments/environment';
import { OptionPaneComponent } from './option-pane/option-pane.component';
import { MatSlideToggle } from '@angular/material/slide-toggle';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -18,6 +16,7 @@ import { NotificationsModule } from './notifications/notifications.module';
import { MapModule } from './map/map.module';
import { MatSlider, MatSliderModule, MatSliderThumb } from '@angular/material/slider';
import { FormsModule } from '@angular/forms';
import { LoggingModule } from './logging/logging.module';

@NgModule({
declarations: [HeaderComponent, ToolbarComponent, MapComponent, AppComponent, OptionPaneComponent],
Expand All @@ -31,9 +30,7 @@ import { FormsModule } from '@angular/forms';
MatIcon,
MatButton,
MatSlideToggle,
LoggerModule.forRoot({
level: environment.prodMode ? NgxLoggerLevel.WARN : NgxLoggerLevel.DEBUG
}),
LoggingModule,
I18nModule,
NotificationsModule,
MapModule,
Expand Down
19 changes: 19 additions & 0 deletions src/app/logging/logging.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { LoggingService } from './logging.service';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { environment } from '../../environments/environment';

@NgModule({
exports: [],
imports: [
LoggerModule.forRoot({
level: environment.prodMode ? NgxLoggerLevel.WARN : NgxLoggerLevel.DEBUG
})
],
providers: [
LoggingService
]
})
export class LoggingModule {
// nothing here so far
}
16 changes: 16 additions & 0 deletions src/app/logging/logging.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Injectable } from '@angular/core';
import { NGXLogger } from 'ngx-logger';

@Injectable()
export class LoggingService {
constructor(private readonly log: NGXLogger) {
}

trace(message?: string, ...additions: unknown[]) {
this.log.trace(message, additions);
}

debug(message?: string, ...additions: unknown[]) {
this.log.trace(message, additions);
}
}
9 changes: 5 additions & 4 deletions src/app/map/map.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ElementRef, EventEmitter, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { NGXLogger } from 'ngx-logger';
import {
CAPITOLS_LAYER,
DEFAULT_TRANSITION_DURATION_MS,
Expand All @@ -18,6 +17,7 @@ import { GeoBoundingBox, TileLayer } from '@deck.gl/geo-layers/typed';
import { environment } from '../../environments/environment';
import { DeckMetrics } from '@deck.gl/core/typed/lib/deck';
import { GeoService } from './geo.service';
import { LoggingService } from '../logging/logging.service';

@Injectable()
export class MapService {
Expand All @@ -34,7 +34,7 @@ export class MapService {

constructor(
private readonly http: HttpClient,
private readonly log: NGXLogger,
private readonly log: LoggingService,
private readonly geoService: GeoService,
private readonly notificationService: NotificationService
) {
Expand Down Expand Up @@ -181,11 +181,12 @@ export class MapService {

renderSubLayers: props => {
// see: https://github.com/visgl/deck.gl/issues/8467
// tslint:disable-next-line
const { west, north, east, south } = props.tile.bbox as GeoBoundingBox;
const what = { ...props, data: undefined };

return [
new BitmapLayer({
data: undefined,
new BitmapLayer(what, {
image: props.data,
bounds: [west, south, east, north]
})
Expand Down
19 changes: 10 additions & 9 deletions src/app/notifications/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class NotificationService {
private readonly toastrService: ToastrService,
private readonly i18nService: I18nService,
private readonly log: NGXLogger
) {}
) {
}

showError(message: string, error: HttpErrorResponse | GeolocationPositionError) {
this.log.error(message, error);
Expand All @@ -28,18 +29,18 @@ export class NotificationService {
}

showErrorLocalized(messageKey: string, ...additional: unknown[]) {
this.log.error(messageKey, additional);

firstValueFrom(this.i18nService.translateMultiple(['notifications.error-title', messageKey])).then(values =>
this.toastrService.error(values[1] + ' ' + additional, values[0], options)
firstValueFrom(this.i18nService.translateMultiple(['notifications.error-title', messageKey])).then(values => {
this.log.error(values[1], additional);
this.toastrService.error(values[1] + ' ' + additional, values[0], options);
}
);
}

showInfoLocalized(messageKey: string, ...additional: unknown[]) {
this.log.info(messageKey, additional);

firstValueFrom(this.i18nService.translateMultiple(['notifications.info-title', messageKey])).then(values =>
this.toastrService.info(values[1] + ' ' + additional, values[0], options)
firstValueFrom(this.i18nService.translateMultiple(['notifications.info-title', messageKey])).then(values => {
this.log.info(values[1], additional);
this.toastrService.info(values[1] + ' ' + additional, values[0], options);
}
);
}
}