Skip to content

Commit d3716ce

Browse files
committed
refactor(app): refactor core and dashboard modules
- Relocate all dialog services to their corresponding components. - Use Typescript Partial to make all properties in WeatherData interface optional and remove the question mark ? in each property. - Remove unused updateGeolocationPosition method in DashboardService.
1 parent edfd1c0 commit d3716ce

File tree

11 files changed

+17
-21
lines changed

11 files changed

+17
-21
lines changed

src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { LOCATION } from '@ng-web-apis/common';
66

77
import { ConnectionService } from 'ng-connection-service';
88

9-
import { AppUpdateDialogService } from './core/dialog/app-update-dialog.service';
10-
import { ErrorDialogService } from './core/dialog/error-dialog.service';
9+
import { AppUpdateDialogService } from './core/dialog/app-update-dialog/app-update-dialog.service';
10+
import { ErrorDialogService } from './core/dialog/error-dialog/error-dialog.service';
1111
import { SnackbarComponent } from './core/snackbar/snackbar.component';
1212

1313
@Component({

src/app/core/dialog/agreement-dialog.service.ts renamed to src/app/core/dialog/agreement-dialog/agreement-dialog.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatDialogRef, MatDialog } from '@angular/material/dialog';
33

4-
import { AgreementDialogComponent } from './agreement-dialog/agreement-dialog.component';
4+
import { AgreementDialogComponent } from './agreement-dialog.component';
55

66
@Injectable({
77
providedIn: 'root'

src/app/core/dialog/app-update-dialog.service.ts renamed to src/app/core/dialog/app-update-dialog/app-update-dialog.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatDialogRef, MatDialog } from '@angular/material/dialog';
33

4-
import { AppUpdateDialogComponent } from './app-update-dialog/app-update-dialog.component';
4+
import { AppUpdateDialogComponent } from './app-update-dialog.component';
55

66
@Injectable({
77
providedIn: 'root'

src/app/core/dialog/error-dialog.service.ts renamed to src/app/core/dialog/error-dialog/error-dialog.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
33

4-
import { ErrorDialogComponent } from './error-dialog/error-dialog.component';
4+
import { ErrorDialogComponent } from './error-dialog.component';
55

66
@Injectable({
77
providedIn: 'root'

src/app/core/dialog/loading-dialog.service.ts renamed to src/app/core/dialog/loading-dialog/loading-dialog.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
33

4-
import { LoadingDialogComponent } from './loading-dialog/loading-dialog.component';
4+
import { LoadingDialogComponent } from './loading-dialog.component';
55

66
@Injectable({
77
providedIn: 'root'

src/app/core/errors/global-error-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ErrorHandler, Injectable, NgZone } from '@angular/core';
22

3-
import { ErrorDialogService } from '../dialog/error-dialog.service';
3+
import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
44

55
@Injectable()
66
export class GlobalErrorHandler implements ErrorHandler {

src/app/core/errors/http-error.interceptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { Injectable } from '@angular/core';
1010
import { Observable, throwError } from 'rxjs';
1111
import { catchError, finalize } from 'rxjs/operators';
1212

13-
import { ErrorDialogService } from '../dialog/error-dialog.service';
14-
import { LoadingDialogService } from '../dialog/loading-dialog.service';
13+
import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
14+
import { LoadingDialogService } from '../dialog/loading-dialog/loading-dialog.service';
1515

1616

1717
@Injectable({

src/app/core/services/geolocation-api.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { BehaviorSubject, Observable, Subject, throwError } from 'rxjs';
77
import { catchError, take, takeUntil } from 'rxjs/operators';
88

99
import { GeolocationPosition, GeolocationPositionError } from 'src/app/shared/models/geolocation-position.model';
10-
import { AgreementDialogService } from '../dialog/agreement-dialog.service';
11-
import { ErrorDialogService } from '../dialog/error-dialog.service';
10+
import { AgreementDialogService } from '../dialog/agreement-dialog/agreement-dialog.service';
11+
import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
1212
import { WebStorageApiService } from './web-storage-api.service';
1313
import { OpenWeatherApiService } from '../api/openweather-api.service';
1414

src/app/core/services/web-storage-api.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Inject, Injectable } from '@angular/core';
33
import { LOCAL_STORAGE } from '@ng-web-apis/common';
44

55
interface WeatherData {
6-
geolocationStatus?: string;
7-
geolocationName?: string;
8-
coords?: { lat: number, lng: number };
6+
geolocationStatus: string;
7+
geolocationName: string;
8+
coords: { lat: number, lng: number };
99
}
1010

1111
@Injectable({
@@ -25,8 +25,8 @@ export class WebStorageApiService {
2525
this.localStorage.setItem(this.WEATHER_DATA, JSON.stringify({ ...value }));
2626
}
2727

28-
updateLocalStorageItem(value: WeatherData): void {
29-
const weatherDataParse: WeatherData = this.getLocalStorageItem();
28+
updateLocalStorageItem(value: Partial<WeatherData>): void {
29+
const weatherDataParse = this.getLocalStorageItem();
3030
this.setLocalStorageItem({ ...weatherDataParse, ...value });
3131
}
3232
}

src/app/core/toolbar/toolbar.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { } from 'googlemaps';
1313

1414
import { debounceTime, distinctUntilChanged, filter, tap } from 'rxjs/operators';
1515

16-
import { ErrorDialogService } from '../dialog/error-dialog.service';
16+
import { ErrorDialogService } from '../dialog/error-dialog/error-dialog.service';
1717
import { GeolocationApiService } from '../services/geolocation-api.service';
1818

1919
@Component({

0 commit comments

Comments
 (0)