diff --git a/USERRIGHTS.md b/USERRIGHTS.md index 8d58d29..b8f6f2c 100644 --- a/USERRIGHTS.md +++ b/USERRIGHTS.md @@ -1,9 +1,8 @@ -# User rights -| id | Role | rights | -|----|---------------|-------------| -| 1 | Limited Guest | list dir | -| 2 | Guest | +search | -| 3 | User | +share | -| 4 | Admin | +settings | -| 5 | Developer | +see errors | +| id | Role | rights | who has it | +|----|---------------|----------------------|------------| +| 1 | Limited Guest | listing directory | using shared link | +| 2 | Guest | + search | one one (you can set manually in the db, if necessary) | +| 3 | User | + share | default role | +| 4 | Admin | + settings | dDefault (pregenerated) user (also the default right if authentication is off) | +| 5 | Developer | + see errors | one one (you can set manually in the db, if necessary) | diff --git a/angular.json b/angular.json index b7bfd24..dcab19b 100644 --- a/angular.json +++ b/angular.json @@ -17,9 +17,15 @@ "tsConfig": "frontend/tsconfig.app.json", "polyfills": "frontend/polyfills.ts", "assets": [ + { + "glob": "**/*", + "input": "./node_modules/leaflet/dist/images", + "output": "/" + }, "frontend/assets" ], "styles": [ + "node_modules/leaflet/dist/leaflet.css", "node_modules/ngx-toastr/toastr.css", "node_modules/bootstrap/dist/css/bootstrap.css", "node_modules/open-iconic/font/css/open-iconic-bootstrap.css", diff --git a/backend/middlewares/user/AuthenticationMWs.ts b/backend/middlewares/user/AuthenticationMWs.ts index 1918156..9839c0e 100644 --- a/backend/middlewares/user/AuthenticationMWs.ts +++ b/backend/middlewares/user/AuthenticationMWs.ts @@ -95,7 +95,6 @@ export class AuthenticationMWs { sharingKey: req.query[QueryParams.gallery.sharingKey_short] || req.params[QueryParams.gallery.sharingKey_long] }); - console.log(sharing); if (!sharing || sharing.expires < Date.now() || (Config.Client.Sharing.passwordProtected === true && (sharing.password) diff --git a/backend/model/diagnostics/ConfigDiagnostics.ts b/backend/model/diagnostics/ConfigDiagnostics.ts index 92d3a96..e261153 100644 --- a/backend/model/diagnostics/ConfigDiagnostics.ts +++ b/backend/model/diagnostics/ConfigDiagnostics.ts @@ -12,8 +12,8 @@ import {ProjectPath} from '../../ProjectPath'; import {SQLConnection} from '../sql/SQLConnection'; import * as fs from 'fs'; import {ClientConfig} from '../../../common/config/public/ConfigClass'; -import VideoConfig = ClientConfig.VideoConfig; import {FFmpegFactory} from '../FFmpegFactory'; +import VideoConfig = ClientConfig.VideoConfig; import MetaFileConfig = ClientConfig.MetaFileConfig; const LOG_TAG = '[ConfigDiagnostics]'; @@ -155,8 +155,9 @@ export class ConfigDiagnostics { static async testMapConfig(map: ClientConfig.MapConfig) { - if (map.enabled === true && (!map.googleApiKey || map.googleApiKey.length === 0)) { - throw new Error('Maps need a valid google api key'); + if (map.enabled === true && map.mapProvider === ClientConfig.MapProviders.Custom && + (!map.tileUrl || map.tileUrl.length === 0)) { + throw new Error('Custom maps need a valid tile url'); } } @@ -270,11 +271,11 @@ export class ConfigDiagnostics { await ConfigDiagnostics.testMapConfig(Config.Client.Map); } catch (ex) { const err: Error = ex; - NotificationManager.warning('Maps is not supported with these settings. Disabling temporally. ' + + NotificationManager.warning('Maps is not supported with these settings. Using open street maps temporally. ' + 'Please adjust the config properly.', err.toString()); - Logger.warn(LOG_TAG, 'Maps is not supported with these settings. Disabling temporally. ' + + Logger.warn(LOG_TAG, 'Maps is not supported with these settings. Using open street maps temporally ' + 'Please adjust the config properly.', err.toString()); - Config.Client.Map.enabled = false; + Config.Client.Map.mapProvider = ClientConfig.MapProviders.OpenStreetMap; } } diff --git a/common/Utils.ts b/common/Utils.ts index 8624129..de5a8dc 100644 --- a/common/Utils.ts +++ b/common/Utils.ts @@ -7,6 +7,12 @@ export class Utils { return R; } + static wait(time: number) { + return new Promise((resolve) => { + setTimeout(resolve, time); + }); + } + static removeNullOrEmptyObj(obj: any) { if (typeof obj !== 'object' || obj == null) { diff --git a/common/config/public/ConfigClass.ts b/common/config/public/ConfigClass.ts index f2abd83..ca7d55a 100644 --- a/common/config/public/ConfigClass.ts +++ b/common/config/public/ConfigClass.ts @@ -2,6 +2,11 @@ import {SortingMethods} from '../../entities/SortingMethods'; import {UserRoles} from '../../entities/UserDTO'; export module ClientConfig { + + export enum MapProviders { + OpenStreetMap, Custom + } + export interface SearchConfig { enabled: boolean; instantSearchEnabled: boolean; @@ -23,7 +28,8 @@ export module ClientConfig { export interface MapConfig { enabled: boolean; - googleApiKey: string; + mapProvider: MapProviders; + tileUrl: string; } export interface ThumbnailConfig { @@ -100,7 +106,8 @@ export class PublicConfigClass { }, Map: { enabled: true, - googleApiKey: '' + mapProvider: ClientConfig.MapProviders.OpenStreetMap, + tileUrl: '' }, RandomPhoto: { enabled: true diff --git a/frontend/app/app.module.ts b/frontend/app/app.module.ts index 02a1031..ee47f41 100644 --- a/frontend/app/app.module.ts +++ b/frontend/app/app.module.ts @@ -8,7 +8,6 @@ import { } from '@angular/core'; import {BrowserModule, HAMMER_GESTURE_CONFIG, HammerGestureConfig} from '@angular/platform-browser'; import {FormsModule} from '@angular/forms'; -import {AgmCoreModule} from '@agm/core'; import {AppComponent} from './app.component'; import {appRoutes} from './app.routing'; import {UserService} from './model/network/user.service'; @@ -20,6 +19,7 @@ import {FullScreenService} from './gallery/fullscreen.service'; import {AuthenticationService} from './model/network/authentication.service'; import {UserMangerSettingsComponent} from './settings/usermanager/usermanager.settings.component'; import {FrameComponent} from './frame/frame.component'; +import {YagaModule} from '@yaga/leaflet-ng2'; import {GalleryLightboxMediaComponent} from './gallery/lightbox/media/media.lightbox.gallery.component'; import {GalleryPhotoLoadingComponent} from './gallery/grid/photo/loading/loading.photo.grid.gallery.component'; import {GalleryNavigatorComponent} from './gallery/navigator/navigator.gallery.component'; @@ -36,8 +36,6 @@ import {GalleryMapComponent} from './gallery/map/map.gallery.component'; import {GalleryMapLightboxComponent} from './gallery/map/lightbox/lightbox.map.gallery.component'; import {ThumbnailManagerService} from './gallery/thumnailManager.service'; import {OverlayService} from './gallery/overlay.service'; -import {Config} from '../../common/config/public/Config'; -import {LAZY_MAPS_API_CONFIG} from '@agm/core/services'; import {SlimLoadingBarModule} from 'ng2-slim-loading-bar'; import {GalleryShareComponent} from './gallery/share/share.gallery.component'; import {ShareLoginComponent} from './sharelogin/share-login.component'; @@ -78,14 +76,6 @@ import {DurationPipe} from './pipes/DurationPipe'; import {MapService} from './gallery/map/map.service'; import {MetaFileSettingsComponent} from './settings/metafiles/metafile.settings.component'; -@Injectable() -export class GoogleMapsConfig { - apiKey: string; - - constructor() { - this.apiKey = Config.Client.Map.googleApiKey; - } -} @Injectable() export class MyHammerConfig extends HammerGestureConfig { @@ -131,9 +121,9 @@ export function translationsFactory(locale: string) { ModalModule.forRoot(), CollapseModule.forRoot(), BsDropdownModule.forRoot(), - AgmCoreModule.forRoot(), SlimLoadingBarModule.forRoot(), - BsDatepickerModule.forRoot() + BsDatepickerModule.forRoot(), + YagaModule ], declarations: [AppComponent, LoginComponent, @@ -179,7 +169,6 @@ export function translationsFactory(locale: string) { ], providers: [ {provide: UrlSerializer, useClass: CustomUrlSerializer}, - {provide: LAZY_MAPS_API_CONFIG, useClass: GoogleMapsConfig}, {provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig}, NetworkService, ShareService, diff --git a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css index 7b3e503..a6b5349 100644 --- a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css +++ b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css @@ -1,7 +1,7 @@ .content { background-color: #F7F7F7; height: 100%; - overflow-y: scroll; + overflow-y: auto; } .row { @@ -30,7 +30,7 @@ padding-right: 5px; } -.sebm-google-map-container { +.yaga-map { width: 100%; height: 100%; } @@ -45,9 +45,14 @@ font-size: 1.2rem; } -.dir-link{ +.dir-link { cursor: pointer; } -.dir-link:hover{ + +.dir-link:hover { text-decoration: underline; } + +.modal-header { + padding: 0.4rem 1rem; +} diff --git a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html index 10258de..2a89017 100644 --- a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html +++ b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html @@ -29,7 +29,7 @@
- {{ media.metadata.creationDate | date: (isThisYear() ? 'MMMM d': 'longDate')}} + {{ media.metadata.creationDate | date: (isThisYear() ? 'MMMM d' : 'longDate')}}
{{ media.metadata.creationDate | date :'EEEE'}}, {{getTime()}}
@@ -47,8 +47,13 @@ {{"Video"}}
-
duration: {{VideoData.duration | duration}}
-
bit rate: {{calcSize(VideoData.bitRate)}}/s
+
+ duration + : {{VideoData.duration | duration}}
+
+ bit rate + : {{calcSize(VideoData.bitRate)}}/s +
@@ -93,17 +98,14 @@
- - - - + + + + +
diff --git a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts index 8047c70..5c2f2ca 100644 --- a/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts +++ b/frontend/app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts @@ -1,10 +1,11 @@ -import {Component, ElementRef, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Input, Output} from '@angular/core'; import {CameraMetadata, PhotoDTO, PositionMetaData} from '../../../../../common/entities/PhotoDTO'; import {Config} from '../../../../../common/config/public/Config'; import {MediaDTO} from '../../../../../common/entities/MediaDTO'; import {VideoDTO, VideoMetadata} from '../../../../../common/entities/VideoDTO'; import {Utils} from '../../../../../common/Utils'; import {QueryService} from '../../../model/query.service'; +import {MapService} from '../../map/map.service'; @Component({ selector: 'app-info-panel', @@ -17,7 +18,8 @@ export class InfoPanelLightboxComponent { public mapEnabled = true; - constructor(public queryService: QueryService) { + constructor(public queryService: QueryService, + public mapService: MapService) { this.mapEnabled = Config.Client.Map.enabled; } @@ -38,7 +40,6 @@ export class InfoPanelLightboxComponent { } - calcSize(size: number) { const postFixes = ['B', 'KB', 'MB', 'GB', 'TB']; let index = 0; diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css index 3968beb..0afd86d 100644 --- a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css @@ -83,3 +83,4 @@ top: calc(50% - 25px); left: calc(50% - 25px); } + diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html index f11dfe9..f29eb2b 100644 --- a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html @@ -6,64 +6,50 @@ [style.top.px]="lightboxDimension.top" [style.left.px]="lightboxDimension.left" [style.opacity]="opacity"> - - - - - - - - - - - - - - + + + - - + + - + [lat]="photo.lat" + [lng]="photo.lng"> + +
+ [style.height.px]="photo.preview.height">
-
-
-
+ + + + + diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts index 8ce7f52..7c16bb1 100644 --- a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -2,7 +2,6 @@ import {Component, ElementRef, HostListener, Input, OnChanges, ViewChild, AfterV import {PhotoDTO} from '../../../../../common/entities/PhotoDTO'; import {Dimension} from '../../../model/IRenderable'; import {FullScreenService} from '../../fullscreen.service'; -import {AgmMap, LatLngBounds, MapsAPILoader} from '@agm/core'; import {IconThumbnail, Thumbnail, ThumbnailManagerService} from '../../thumnailManager.service'; import {MediaIcon} from '../../MediaIcon'; import {Media} from '../../Media'; @@ -10,11 +9,12 @@ import {PageHelper} from '../../../model/page.helper'; import {OrientationTypes} from 'ts-exif-parser'; import {MediaDTO} from '../../../../../common/entities/MediaDTO'; import {FileDTO} from '../../../../../common/entities/FileDTO'; -import {NetworkService} from '../../../model/network/network.service'; import {Utils} from '../../../../../common/Utils'; import {Config} from '../../../../../common/config/public/Config'; -import {MapPath, MapService} from '../map.service'; - +import {MapService} from '../map.service'; +import {LatLng, Point} from 'leaflet'; +import {MapComponent} from '@yaga/leaflet-ng2'; +import {FixOrientationPipe} from '../../FixOrientationPipe'; @Component({ selector: 'app-gallery-map-lightbox', @@ -32,19 +32,16 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { public controllersVisible = false; public opacity = 1.0; mapPhotos: MapPhoto[] = []; - paths: MapPath[][] = []; - pathOutlines: MapPath[][] = []; - mapCenter = {latitude: 0, longitude: 0}; + paths: LatLng[][] = []; @ViewChild('root') elementRef: ElementRef; + @ViewChild('yagaMap') yagaMap: MapComponent; - @ViewChild(AgmMap) map: AgmMap; - + public iconSize = new Point(Config.Client.Thumbnail.iconSize, Config.Client.Thumbnail.iconSize); constructor(public fullScreenService: FullScreenService, private thumbnailService: ThumbnailManagerService, - private mapService: MapService, - private mapsAPILoader: MapsAPILoader) { + public mapService: MapService) { } ngOnChanges() { @@ -58,7 +55,8 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { } - public show(position: Dimension) { + + public async show(position: Dimension) { this.hideImages(); this.visible = true; this.opacity = 1.0; @@ -71,21 +69,20 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { width: this.getScreenWidth(), height: this.getScreenHeight() }; - this.map.triggerResize().then(() => { - this.controllersVisible = true; - }); - + this.showImages(); + this.centerMap(); PageHelper.hideScrollY(); - - setTimeout(() => { - this.lightboxDimension = { - top: 0, - left: 0, - width: this.getScreenWidth(), - height: this.getScreenHeight() - }; - this.showImages(); - }, 0); + await Utils.wait(0); + this.lightboxDimension = { + top: 0, + left: 0, + width: this.getScreenWidth(), + height: this.getScreenHeight() + }; + await Utils.wait(350); + this.yagaMap.invalidateSize(); + this.centerMap(); + this.controllersVisible = true; } public hide() { @@ -105,6 +102,7 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { setTimeout(() => { this.visible = false; this.hideImages(); + this.yagaMap.zoom = 2; }, 500); } @@ -127,8 +125,8 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { const iconTh = this.thumbnailService.getIcon(new MediaIcon(p)); iconTh.Visible = true; const obj: MapPhoto = { - latitude: p.metadata.positionData.GPSData.latitude, - longitude: p.metadata.positionData.GPSData.longitude, + lat: p.metadata.positionData.GPSData.latitude, + lng: p.metadata.positionData.GPSData.longitude, iconThumbnail: iconTh, orientation: p.metadata.orientation, preview: { @@ -139,37 +137,31 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { }; if (iconTh.Available === true) { - obj.iconUrl = iconTh.Src; + FixOrientationPipe.transform(iconTh.Src, p.metadata.orientation).then((icon) => { + obj.iconUrl = icon; + }); } else { iconTh.OnLoad = () => { - obj.iconUrl = iconTh.Src; + FixOrientationPipe.transform(iconTh.Src, p.metadata.orientation).then((icon) => { + obj.iconUrl = icon; + }); }; } return obj; }); - if (this.gpxFiles) { this.loadGPXFiles().catch(console.error); } } - - private gpxFilter(list: MapPath[]) { - let last = list[0]; - const out = []; - for (let i = 1; i < list.length; i++) { - if (this.mapService.calcDistance(list[i], last) > 0.5) { - out.push(list[i]); - last = list[i]; - } + private centerMap() { + if (this.mapPhotos.length > 0) { + this.yagaMap.fitBounds(this.mapPhotos); } - if (out.length < 2) { - out.push(list[list.length - 1]); - } - return out; } + private async loadGPXFiles(): Promise { this.paths = []; for (let i = 0; i < this.gpxFiles.length; i++) { @@ -181,8 +173,7 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { if (path.length === 0) { continue; } - this.paths.push(path); - this.pathOutlines.push(this.gpxFilter(path)); + this.paths.push(path); } } @@ -193,7 +184,6 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { } hideImages() { - this.mapCenter = {longitude: 0, latitude: 0}; this.mapPhotos.forEach((mp) => { mp.iconThumbnail.destroy(); mp.preview.thumbnail.destroy(); @@ -228,8 +218,8 @@ export class GalleryMapLightboxComponent implements OnChanges, AfterViewInit { } export interface MapPhoto { - latitude: number; - longitude: number; + lat: number; + lng: number; iconUrl?: string; iconThumbnail: IconThumbnail; orientation: OrientationTypes; diff --git a/frontend/app/gallery/map/map.gallery.component.css b/frontend/app/gallery/map/map.gallery.component.css index 716da1f..c98b616 100644 --- a/frontend/app/gallery/map/map.gallery.component.css +++ b/frontend/app/gallery/map/map.gallery.component.css @@ -1,4 +1,4 @@ -.sebm-google-map-container { +.yaga-map{ width: 100%; height: 100%; } diff --git a/frontend/app/gallery/map/map.gallery.component.html b/frontend/app/gallery/map/map.gallery.component.html index 25ad157..b883735 100644 --- a/frontend/app/gallery/map/map.gallery.component.html +++ b/frontend/app/gallery/map/map.gallery.component.html @@ -1,21 +1,23 @@
- - + - - + [lat]="photo.lat" + [lng]="photo.lng"> + + + +
diff --git a/frontend/app/gallery/map/map.gallery.component.ts b/frontend/app/gallery/map/map.gallery.component.ts index 19eccaf..1c5b780 100644 --- a/frontend/app/gallery/map/map.gallery.component.ts +++ b/frontend/app/gallery/map/map.gallery.component.ts @@ -2,10 +2,9 @@ import {Component, ElementRef, Input, OnChanges, ViewChild, AfterViewInit} from import {PhotoDTO} from '../../../../common/entities/PhotoDTO'; import {Dimension, IRenderable} from '../../model/IRenderable'; import {GalleryMapLightboxComponent} from './lightbox/lightbox.map.gallery.component'; -import {ThumbnailManagerService} from '../thumnailManager.service'; -import {FullScreenService} from '../fullscreen.service'; -import {LatLngBounds, MapsAPILoader, AgmMap} from '@agm/core'; import {FileDTO} from '../../../../common/entities/FileDTO'; +import {MapService} from './map.service'; +import {MapComponent} from '@yaga/leaflet-ng2'; @Component({ selector: 'app-gallery-map', @@ -18,12 +17,13 @@ export class GalleryMapComponent implements OnChanges, IRenderable, AfterViewIni @Input() metaFiles: FileDTO[]; @ViewChild(GalleryMapLightboxComponent) mapLightbox: GalleryMapLightboxComponent; - mapPhotos: Array<{ latitude: number, longitude: number }> = []; + mapPhotos: Array<{ lat: number, lng: number }> = []; @ViewChild('map') mapElement: ElementRef; + @ViewChild('yagaMap') yagaMap: MapComponent; height: number = null; - constructor(private mapsAPILoader: MapsAPILoader) { + constructor(public mapService: MapService) { } ngOnChanges() { @@ -32,17 +32,25 @@ export class GalleryMapComponent implements OnChanges, IRenderable, AfterViewIni p.metadata.positionData.GPSData.latitude && p.metadata.positionData.GPSData.longitude; }).map(p => { return { - latitude: p.metadata.positionData.GPSData.latitude, - longitude: p.metadata.positionData.GPSData.longitude + lat: p.metadata.positionData.GPSData.latitude, + lng: p.metadata.positionData.GPSData.longitude }; }); + if (this.yagaMap) { + this.yagaMap.setView(this.mapPhotos[0], 0); + this.yagaMap.fitBounds(this.mapPhotos); + this.yagaMap.zoom = 0; + } } ngAfterViewInit() { setTimeout(() => { this.height = this.mapElement.nativeElement.clientHeight; + this.yagaMap.setView(this.mapPhotos[0], 0); + this.yagaMap.fitBounds(this.mapPhotos); + this.yagaMap.zoom = 0; }, 0); } diff --git a/frontend/app/gallery/map/map.service.ts b/frontend/app/gallery/map/map.service.ts index fada51d..789bad7 100644 --- a/frontend/app/gallery/map/map.service.ts +++ b/frontend/app/gallery/map/map.service.ts @@ -2,6 +2,9 @@ import {Injectable} from '@angular/core'; import {NetworkService} from '../../model/network/network.service'; import {FileDTO} from '../../../../common/entities/FileDTO'; import {Utils} from '../../../../common/Utils'; +import {OSM_TILE_LAYER_URL} from '@yaga/leaflet-ng2'; +import {Config} from '../../../../common/config/public/Config'; +import {ClientConfig} from '../../../../common/config/public/ConfigClass'; @Injectable() export class MapService { @@ -11,21 +14,6 @@ export class MapService { } - public calcDistance(loc: MapPath, loc2: MapPath): number { - const radlat1 = Math.PI * loc.latitude / 180; - const radlat2 = Math.PI * loc2.latitude / 180; - const theta = loc.longitude - loc2.longitude; - const radtheta = Math.PI * theta / 180; - let dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); - if (dist > 1) { - dist = 1; - } - dist = Math.acos(dist); - dist = dist * 180 / Math.PI; - dist = dist * 60 * 1.1515; - return dist * 1.609344; - } - public async getMapPath(file: FileDTO): Promise { const filePath = Utils.concatUrls(file.directory.path, file.directory.name, file.name); const gpx = await this.networkService.getXML('/gallery/content/' + filePath); @@ -33,17 +21,29 @@ export class MapService { const points: MapPath[] = []; for (let i = 0; i < elements.length; i++) { points.push({ - latitude: parseFloat(elements[i].getAttribute('lat')), - longitude: parseFloat(elements[i].getAttribute('lon')) + lat: parseFloat(elements[i].getAttribute('lat')), + lng: parseFloat(elements[i].getAttribute('lon')) }); } return points; } + + public get Attributions(): string[] { + return ['© OpenStreetMap']; + } + + public get MapLayer(): string { + if (Config.Client.Map.mapProvider === ClientConfig.MapProviders.Custom) { + return Config.Client.Map.tileUrl; + } + return OSM_TILE_LAYER_URL; + } + } export interface MapPath { - latitude: number; - longitude: number; + lat: number; + lng: number; } diff --git a/frontend/app/settings/database/database.settings.component.ts b/frontend/app/settings/database/database.settings.component.ts index 1341c8f..de03a22 100644 --- a/frontend/app/settings/database/database.settings.component.ts +++ b/frontend/app/settings/database/database.settings.component.ts @@ -17,7 +17,7 @@ import {I18n} from '@ngx-translate/i18n-polyfill'; }) export class DatabaseSettingsComponent extends SettingsComponent implements OnInit { - public types: Array = []; + public types: { key: number, value: string }[] = []; public DatabaseType: any; constructor(_authService: AuthenticationService, @@ -30,8 +30,7 @@ export class DatabaseSettingsComponent extends SettingsComponent ngOnInit() { super.ngOnInit(); - this.types = Utils - .enumToArray(DatabaseType); + this.types = Utils.enumToArray(DatabaseType); this.DatabaseType = DatabaseType; } diff --git a/frontend/app/settings/map/map.settings.component.html b/frontend/app/settings/map/map.settings.component.html index 06f15bf..406bbe1 100644 --- a/frontend/app/settings/map/map.settings.component.html +++ b/frontend/app/settings/map/map.settings.component.html @@ -22,17 +22,25 @@
- +
- + +
+
+ +
+ +
+ - To show the images on a map,  - google api key  - is need. + The map module will use this url to fetch the map tiles.
diff --git a/frontend/app/settings/map/map.settings.component.ts b/frontend/app/settings/map/map.settings.component.ts index fd3cf03..8469b34 100644 --- a/frontend/app/settings/map/map.settings.component.ts +++ b/frontend/app/settings/map/map.settings.component.ts @@ -6,6 +6,7 @@ import {NavigationService} from '../../model/navigation.service'; import {NotificationService} from '../../model/notification.service'; import {ClientConfig} from '../../../../common/config/public/ConfigClass'; import {I18n} from '@ngx-translate/i18n-polyfill'; +import {Utils} from '../../../../common/Utils'; @Component({ @@ -17,12 +18,17 @@ import {I18n} from '@ngx-translate/i18n-polyfill'; }) export class MapSettingsComponent extends SettingsComponent { + public mapProviders: { key: number, value: string }[] = []; + public MapProviders = ClientConfig.MapProviders; + constructor(_authService: AuthenticationService, _navigation: NavigationService, _settingsService: MapSettingsService, notification: NotificationService, i18n: I18n) { super(i18n('Map'), _authService, _navigation, _settingsService, notification, i18n, s => s.Client.Map); + + this.mapProviders = Utils.enumToArray(ClientConfig.MapProviders); } diff --git a/frontend/app/settings/settings.service.ts b/frontend/app/settings/settings.service.ts index a830518..0256f86 100644 --- a/frontend/app/settings/settings.service.ts +++ b/frontend/app/settings/settings.service.ts @@ -4,6 +4,7 @@ import {DatabaseType, IPrivateConfig, ReIndexingSensitivity, ThumbnailProcessing import {NetworkService} from '../model/network/network.service'; import {SortingMethods} from '../../../common/entities/SortingMethods'; import {UserRoles} from '../../../common/entities/UserDTO'; +import {ClientConfig} from '../../../common/config/public/ConfigClass'; @Injectable() export class SettingsService { @@ -32,7 +33,8 @@ export class SettingsService { }, Map: { enabled: true, - googleApiKey: '' + mapProvider: ClientConfig.MapProviders.OpenStreetMap, + tileUrl: '' }, RandomPhoto: { enabled: true diff --git a/frontend/index.html b/frontend/index.html index decf219..153f902 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -18,18 +18,15 @@ - -
- -

Loading...

-
-
+ +

Loading...

+
- diff --git a/frontend/translate/messages.en.xlf b/frontend/translate/messages.en.xlf index 6d0a89a..1970291 100644 --- a/frontend/translate/messages.en.xlf +++ b/frontend/translate/messages.en.xlf @@ -343,7 +343,7 @@ duration app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html - 50 + 51 duration @@ -351,7 +351,7 @@ bit rate app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html - 51 + 54 bit rate @@ -580,44 +580,36 @@ Map settings - - Google maps api key + + Map provider app/settings/map/map.settings.component.html 25 - Google maps api key + Map provider - - To show the images on a map, + + Map tile url app/settings/map/map.settings.component.html - 32 + 37 - To show the images on a map, + Map tile url - - google api key + + The map module will use this url to fetch the map tiles. app/settings/map/map.settings.component.html - 34 + 43 - google api key - - - is need. - - app/settings/map/map.settings.component.html - 35 - - is need. + The map module will use this url to fetch the map tiles. Save app/settings/map/map.settings.component.html - 42 + 50 app/settings/thumbnail/thumbanil.settings.component.html @@ -658,7 +650,7 @@ app/settings/map/map.settings.component.html - 45 + 53 app/settings/thumbnail/thumbanil.settings.component.html diff --git a/frontend/translate/messages.hu.xlf b/frontend/translate/messages.hu.xlf index 50e3e0f..c68cd84 100644 --- a/frontend/translate/messages.hu.xlf +++ b/frontend/translate/messages.hu.xlf @@ -343,7 +343,7 @@ duration app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html - 50 + 51 hossz @@ -351,7 +351,7 @@ bit rate app/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html - 51 + 54 bit ráta @@ -580,44 +580,36 @@ Térképbeállítások - - Google maps api key + + Map provider app/settings/map/map.settings.component.html 25 - Google maps api kulcs + Térképszolgáltató - - To show the images on a map, + + Map tile url app/settings/map/map.settings.component.html - 32 + 37 - Ahhoz, hogy megjelenjenek a képet a térképen, + Térképes csempe url - - google api key + + The map module will use this url to fetch the map tiles. app/settings/map/map.settings.component.html - 34 + 43 - google api kulcsra - - - is need. - - app/settings/map/map.settings.component.html - 35 - - szükség van. + A térkép modul ezt az URL-t fogja használni a térkép letöltéséhez. Save app/settings/map/map.settings.component.html - 42 + 50 app/settings/thumbnail/thumbanil.settings.component.html @@ -658,7 +650,7 @@ app/settings/map/map.settings.component.html - 45 + 53 app/settings/thumbnail/thumbanil.settings.component.html diff --git a/package.json b/package.json index b807963..cfb8d90 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "winston": "2.4.2" }, "devDependencies": { - "@agm/core": "1.0.0-beta.5", "@angular-devkit/build-angular": "0.11.0", "@angular-devkit/build-optimizer": "0.11.0", "@angular/animations": "7.1.1", @@ -74,6 +73,7 @@ "@types/node": "10.12.11", "@types/sharp": "0.21.0", "@types/winston": "2.3.9", + "@yaga/leaflet-ng2": "^1.0.0", "bootstrap": "4.1.3", "chai": "4.2.0", "codelyzer": "4.5.0", @@ -95,7 +95,7 @@ "karma-jasmine": "2.0.1", "karma-jasmine-html-reporter": "1.4.0", "karma-remap-istanbul": "0.6.0", - "karma-systemjs": "0.16.0", + "karma-systemjs": "0.16.0", "merge2": "1.2.3", "mocha": "5.2.0", "ng2-cookies": "1.0.12",