Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/next' into directions-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LAMM26 committed Nov 11, 2024
2 parents 44911ae + 9bf8df6 commit ff78131
Show file tree
Hide file tree
Showing 26 changed files with 484 additions and 1,372 deletions.
1,609 changes: 349 additions & 1,260 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packages/*",
"projects/*"
],
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/auth",
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/common",
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/context",
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ export class LayerContextDirective implements OnInit, OnDestroy {
}
});

this.layerService
.createAsyncIdbLayers(context.uri)
.pipe(debounceTime(500))
.subscribe((layers: Layer[]) => this.handleAddLayers(layers));
if (this.configService.getConfig('offline')?.enable) {
this.layerService
.createAsyncIdbLayers(context.uri)
.pipe(debounceTime(500))
.subscribe((layers) => this.handleAddLayers(layers));
}
}

private handleAddLayers(layers: Layer[]) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/analytics/src/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class AnalyticsService {
(() => {
this.paq.push(['setTrackerUrl', url + '.php']);
this.paq.push(['setSiteId', this.options.id]);
this.paq.push(['setSecureCookie', location.protocol === 'https:']);
const g = document.createElement('script');
const s = document.getElementsByTagName('script')[0];
g.type = 'text/javascript';
Expand Down
4 changes: 2 additions & 2 deletions packages/core/config/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export interface Version {
}

export const version: Version = {
lib: '18.0.0-next.1',
releaseDate: 1725378824462
lib: '18.0.0-next.3',
releaseDate: 1731344228219
};
4 changes: 1 addition & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/core",
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"keywords": [
Expand Down Expand Up @@ -97,7 +97,6 @@
}
},
"dependencies": {
"@ngx-translate/core": "^15.0.0",
"tslib": "^2.6.0"
},
"peerDependencies": {
Expand All @@ -108,7 +107,6 @@
"@angular/router": "^18.0.0",
"@igo2/utils": "*",
"@sentry/angular": "^8.26.0",
"ngx-indexed-db": "^19.0.0",
"ngx-toastr": "^19.0.0",
"@ngx-translate/core": "^15.0.0",
"@ngx-translate/http-loader": "^8.0.0",
Expand Down
34 changes: 1 addition & 33 deletions packages/core/src/lib/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,13 @@ import { IgoLanguageModule, provideTranslation } from '@igo2/core/language';
import { provideMessage } from '@igo2/core/message';
import { IgoErrorModule } from '@igo2/core/request';

import { DBConfig, NgxIndexedDBModule } from 'ngx-indexed-db';

const dbConfig: DBConfig = {
name: 'igo2DB',
version: 2,
objectStoresMeta: [
{
store: 'geoData',
storeConfig: { keyPath: 'url', autoIncrement: false },
storeSchema: [
{ name: 'regionID', keypath: 'regionID', options: { unique: false } }
]
},
{
store: 'layerData',
storeConfig: { keyPath: 'layerId', autoIncrement: false },
storeSchema: [
{
name: 'layerOptions',
keypath: 'layerOptions',
options: { unique: false }
},
{
name: 'sourceOptions',
keypath: 'sourceOptions',
options: { unique: false }
}
]
}
]
};
@NgModule({
declarations: [],
exports: [IgoActivityModule, IgoErrorModule, IgoLanguageModule],
imports: [
CommonModule,
IgoActivityModule.forRoot(),
IgoErrorModule.forRoot(),
NgxIndexedDBModule.forRoot(dbConfig)
IgoErrorModule.forRoot()
],
providers: [provideMessage(), provideHttpClient(withInterceptorsFromDi())]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@igo2/geo",
"version": "18.0.0-next.1",
"version": "18.0.0-next.3",
"description": "IGO Library",
"author": "IGO Community",
"keywords": [
Expand Down
14 changes: 7 additions & 7 deletions packages/geo/src/lib/layer/shared/layer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export class LayerService {
private http: HttpClient,
private styleService: StyleService,
private dataSourceService: DataSourceService,
private geoNetworkService: GeoNetworkService,
private messageService: MessageService,
private layerDBService: LayerDBService,
@Optional() private authInterceptor: AuthInterceptor
@Optional() private geoNetworkService?: GeoNetworkService,
@Optional() private layerDBService?: LayerDBService,
@Optional() private authInterceptor?: AuthInterceptor
) {}

createLayer(layerOptions: AnyLayerOptions): Layer {
Expand Down Expand Up @@ -204,7 +204,7 @@ export class LayerService {
this.messageService,
this.authInterceptor,
this.geoNetworkService,
this.geoNetworkService.geoDBService,
this.geoNetworkService?.geoDBService,
this.layerDBService
);
}
Expand All @@ -225,7 +225,7 @@ export class LayerService {
this.messageService,
this.authInterceptor,
this.geoNetworkService,
this.geoNetworkService.geoDBService,
this.geoNetworkService?.geoDBService,
this.layerDBService
);
}
Expand All @@ -240,7 +240,7 @@ export class LayerService {
this.messageService,
this.authInterceptor,
this.geoNetworkService,
this.geoNetworkService.geoDBService,
this.geoNetworkService?.geoDBService,
this.layerDBService
);
}
Expand Down Expand Up @@ -388,7 +388,7 @@ export class LayerService {
}

createAsyncIdbLayers(contextUri = '*'): Observable<Layer[]> {
return this.layerDBService.getAll().pipe(
return this.layerDBService?.getAll().pipe(
concatMap((res) => {
const idbLayers =
contextUri !== '*'
Expand Down
6 changes: 1 addition & 5 deletions packages/geo/src/lib/layer/shared/layers/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { DataSource } from '../../../datasource/shared/datasources/datasource';
import { Legend } from '../../../datasource/shared/datasources/datasource.interface';
import type { MapBase } from '../../../map/shared/map.abstract';
import { getResolutionFromScale } from '../../../map/shared/map.utils';
import { GeoDBService } from '../../../offline/geoDB/geoDB.service';
import { LayerDBService } from '../../../offline/layerDB/layerDB.service';
import { LayerOptions } from './layer.interface';

export abstract class Layer {
Expand Down Expand Up @@ -141,9 +139,7 @@ export abstract class Layer {
constructor(
public options: LayerOptions,
protected messageService?: MessageService,
protected authInterceptor?: AuthInterceptor,
protected geoDBService?: GeoDBService,
public layerDBService?: LayerDBService
protected authInterceptor?: AuthInterceptor
) {
this.dataSource = options.source;

Expand Down
8 changes: 1 addition & 7 deletions packages/geo/src/lib/layer/shared/layers/vector-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,7 @@ export class VectorLayer extends Layer {
public geoDBService?: GeoDBService,
public layerDBService?: LayerDBService
) {
super(
options,
messageService,
authInterceptor,
geoDBService,
layerDBService
);
super(options, messageService, authInterceptor);
this.watcher = new VectorWatcher(this);
this.status$ = this.watcher.status$;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/map/shared/hover-feature.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class HoverFeatureDirective implements OnInit, OnDestroy {
this.unlistenToMapPointerMove();
this.unsubscribeToPointerStore();
this.unlistenToMapSingleClick();
this.layers$$.unsubscribe();
this.layers$$?.unsubscribe();
}

/**
Expand Down Expand Up @@ -261,7 +261,7 @@ export class HoverFeatureDirective implements OnInit, OnDestroy {
* @internal
*/
unsubscribeToPointerStore() {
this.store$$.unsubscribe();
this.store$$?.unsubscribe();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import { InsertSourceInsertDBEnum } from './geoDB.enums';
import { DatasToIDB, GeoDBData } from './geoDB.interface';
import { GeoDBService } from './geoDB.service';

@Injectable({
providedIn: 'root'
})
@Injectable()
export class ConfigFileToGeoDBService {
constructor(
private http: HttpClient,
Expand Down
35 changes: 18 additions & 17 deletions packages/geo/src/lib/offline/geoDB/geoDB.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, Optional } from '@angular/core';

import { Compression } from '@igo2/utils';

Expand All @@ -9,16 +9,17 @@ import { concatMap, first, map, take } from 'rxjs/operators';
import { InsertSourceInsertDBEnum } from './geoDB.enums';
import { GeoDBData } from './geoDB.interface';

@Injectable({
providedIn: 'root'
})
@Injectable()
export class GeoDBService {
readonly dbName: string = 'geoData';
public collisionsMap = new Map<number, string[]>();
public _newData = 0;
private compression = new Compression();

constructor(private ngxIndexedDBService: NgxIndexedDBService) {}
constructor(
@Optional()
private ngxIndexedDBService: NgxIndexedDBService
) {}

/**
* Only blob can be compressed
Expand Down Expand Up @@ -60,12 +61,12 @@ export class GeoDBService {
insertSource,
insertEvent
};
return this.ngxIndexedDBService.getByID(this.dbName, url);
return this.ngxIndexedDBService?.getByID(this.dbName, url);
}),
concatMap((dbObject: GeoDBData) => {
if (!dbObject) {
this._newData++;
return this.ngxIndexedDBService.add(this.dbName, geoDBData);
return this.ngxIndexedDBService?.add(this.dbName, geoDBData);
} else {
const currentRegionID = dbObject.regionID;
if (currentRegionID !== regionID) {
Expand All @@ -90,15 +91,15 @@ export class GeoDBService {

private customUpdate(geoDBData: GeoDBData): Observable<GeoDBData> {
const subject = new Subject<GeoDBData>();
const deleteRequest = this.ngxIndexedDBService.deleteByKey(
const deleteRequest = this.ngxIndexedDBService?.deleteByKey(
this.dbName,
geoDBData.url
);
deleteRequest
.pipe(
concatMap((isDeleted) =>
isDeleted
? this.ngxIndexedDBService.add(this.dbName, geoDBData)
? this.ngxIndexedDBService?.add(this.dbName, geoDBData)
: of(undefined)
)
)
Expand All @@ -112,7 +113,7 @@ export class GeoDBService {
}

get(url: string): Observable<any> {
return this.ngxIndexedDBService.getByID(this.dbName, url).pipe(
return this.ngxIndexedDBService?.getByID(this.dbName, url).pipe(
map((data: GeoDBData) => {
if (data) {
const object = data.object;
Expand All @@ -126,11 +127,11 @@ export class GeoDBService {
}

getByID(url: string): Observable<any> {
return this.ngxIndexedDBService.getByID(this.dbName, url);
return this.ngxIndexedDBService?.getByID(this.dbName, url);
}

deleteByKey(url: string): Observable<any> {
return this.ngxIndexedDBService.deleteByKey(this.dbName, url);
return this.ngxIndexedDBService?.deleteByKey(this.dbName, url);
}

getRegionCountByID(id: number): Observable<number> {
Expand All @@ -148,7 +149,7 @@ export class GeoDBService {
}

const IDBKey: IDBKeyRange = IDBKeyRange.only(id);
const dbRequest = this.ngxIndexedDBService.getAllByIndex(
const dbRequest = this.ngxIndexedDBService?.getAllByIndex(
this.dbName,
'regionID',
IDBKey
Expand All @@ -162,14 +163,14 @@ export class GeoDBService {
}

const IDBKey: IDBKeyRange = IDBKeyRange.only(id);
const dbRequest = this.ngxIndexedDBService.getAllByIndex(
const dbRequest = this.ngxIndexedDBService?.getAllByIndex(
this.dbName,
'regionID',
IDBKey
);
dbRequest.subscribe((datas: GeoDBData[]) => {
datas.forEach((data) => {
this.ngxIndexedDBService.deleteByKey(this.dbName, data.url);
this.ngxIndexedDBService?.deleteByKey(this.dbName, data.url);
});
});
return dbRequest;
Expand All @@ -179,7 +180,7 @@ export class GeoDBService {
keyRange: IDBKeyRange = IDBKeyRange.lowerBound(0),
mode: DBMode = DBMode.readonly
) {
const request = this.ngxIndexedDBService.openCursorByIndex(
const request = this.ngxIndexedDBService?.openCursorByIndex(
this.dbName,
'regionID',
keyRange,
Expand All @@ -202,7 +203,7 @@ export class GeoDBService {
for (const [regionID, collisions] of this.collisionsMap) {
for (const url of collisions) {
this.ngxIndexedDBService
.getByKey(this.dbName, url)
?.getByKey(this.dbName, url)
.pipe(take(1))
.subscribe((dbObject: GeoDBData) => {
const updatedObject = dbObject;
Expand Down
2 changes: 2 additions & 0 deletions packages/geo/src/lib/offline/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './geoDB';
export * from './layerDB';
export * from './shared';
export * from './offline.interface';
export * from './offline.provider';
Loading

0 comments on commit ff78131

Please sign in to comment.