From 45e6d5f10f781f980abeb7db279475ac152af99e Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Wed, 7 Apr 2021 13:19:24 +0200 Subject: [PATCH 1/9] Create build.yml --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8b35afb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +on: push +name: Build Angular +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + + steps: + - uses: actions/checkout@v1 + + - name: Cache node modules + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install and npm run build + run: | + npm i + npm run build:prod + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + repository: openhistorymap/ohm-map/ohm-map + tag_with_ref: true From af778f81a9230d7c935d91b15e52e6802a452b14 Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Wed, 7 Apr 2021 13:21:47 +0200 Subject: [PATCH 2/9] Update build.yml --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b35afb..b7af840 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,10 +21,6 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: npm install and npm run build - run: | - npm i - npm run build:prod - name: Push to GitHub Packages uses: docker/build-push-action@v1 with: From e702919149e7aa0cd1a22729c7d44529e45d2015 Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Tue, 29 Jun 2021 17:02:33 +0200 Subject: [PATCH 3/9] matomo --- src/index.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 6e2a1c2..d290981 100644 --- a/src/index.html +++ b/src/index.html @@ -15,7 +15,22 @@ - + + + + From 42d10c3ac8b63c341ea08e59641073d869bdb7db Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Tue, 6 Jul 2021 19:36:14 +0200 Subject: [PATCH 4/9] udpates --- .vscode/settings.json | 3 +++ angular.json | 5 ++++- src/app/map/map.component.html | 9 +++++---- src/app/map/map.component.scss | 7 +++++++ src/assets/info.json | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2e22645 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "angular.enable-strict-mode-prompt": false +} \ No newline at end of file diff --git a/angular.json b/angular.json index d1310b7..d261e26 100644 --- a/angular.json +++ b/angular.json @@ -127,5 +127,8 @@ } } }, - "defaultProject": "ohm-map" + "defaultProject": "ohm-map", + "cli": { + "analytics": false + } } \ No newline at end of file diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index 2c3a88c..e6ff334 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -26,10 +26,11 @@

OpenHistoryMap

- About - How to join - How to help - Donate + OHM Home + OHM Blog + OHM Index + About OHM + How to help/donate to OHM diff --git a/src/app/map/map.component.scss b/src/app/map/map.component.scss index 1781cb1..421ba8d 100644 --- a/src/app/map/map.component.scss +++ b/src/app/map/map.component.scss @@ -17,8 +17,15 @@ width: 256px; background-color: #3f51b5; color: white; + a{ + color:white; + } } .info{ padding: 16px; + color:white; + a, a:hover, a:visited{ + color:white; + } } \ No newline at end of file diff --git a/src/assets/info.json b/src/assets/info.json index c3e5f08..e8bc6d1 100644 --- a/src/assets/info.json +++ b/src/assets/info.json @@ -1,3 +1,3 @@ { - "info": "OpenHistoryMap si propone di accorciare questo divario seppur in maniera minima, dando la possibilità a chiunque di consultare ed avere esperienza dei dati archeologici pubblicati." + "info": "OpenHistoryMap is an italian non profit association (APS) founded by a team of archaeologists and software developers based in Bologna, Italy. The aim is the creation of a web-GIS platform containing spatial historical and archaeological data.

OHM is an open source project using open source tools. The code is available on github

Technology and academia are the main sources of data, as you can see in our OHM Data Index, but end users can contribute as well, by sharing their datasets and by exploring the map and the data." } \ No newline at end of file From 12c28a59af04cd3e2927fae013a0163e80cb44af Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Tue, 6 Jul 2021 19:51:44 +0200 Subject: [PATCH 5/9] update --- package-lock.json | 5 +++++ package.json | 1 + src/app/app.component.ts | 3 +++ src/app/app.module.ts | 2 ++ src/app/map/map.component.ts | 6 +++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a61356a..c8ce9dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7864,6 +7864,11 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "ngx-matomo": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/ngx-matomo/-/ngx-matomo-0.1.4.tgz", + "integrity": "sha512-AKZMnJGyytZqAxuSh+k/AulyQhgqlnnsmtkfvHMJyNuh5g+wVpIbwac36RyeFU3El6INgZVso2CCLElV3bQnBQ==" + }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", diff --git a/package.json b/package.json index eed9c5a..440c2c1 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@modalnodes/mn-configurator": "0.0.4", "@modalnodes/mn-docker": "0.0.3", "@modalnodes/mn-registry": "0.0.3", + "ngx-matomo": "^0.1.4", "ol": "^6.4.3", "rxjs": "~6.5.5", "tslib": "^2.0.0", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5e37108..7fb47fa 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { MnDockerService } from '@modalnodes/mn-docker'; import { HttpClient } from '@angular/common/http'; +import { MatomoInjector } from 'ngx-matomo'; import env from '../assets/env.json'; @@ -15,8 +16,10 @@ declare const mapboxgl; export class AppComponent implements OnInit { constructor( + private matomoInjector: MatomoInjector ) {} ngOnInit() { + this.matomoInjector.init('//tracker.openhistorymap.org/', 2); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 237e764..463bf76 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -4,6 +4,7 @@ import { MnConfiguratorModule } from '@modalnodes/mn-configurator'; import { MnDockerModule } from '@modalnodes/mn-docker'; import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import { MatomoModule } from 'ngx-matomo'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -29,6 +30,7 @@ import { DateComponent } from './date/date.component'; MnDockerModule, MnConfiguratorModule, SharedModule, + MatomoModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 7a1da78..a5d534e 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -13,6 +13,7 @@ import { NicedatePipe } from '../nicedate.pipe'; import { timeInterval } from 'rxjs/operators'; import { MatDialog } from '@angular/material/dialog'; import { Observable } from 'rxjs'; +import { MatomoTracker } from 'ngx-matomo'; declare const mapboxgl; declare const vis; @@ -63,7 +64,9 @@ export class MapComponent implements OnInit { private l: Location, private md: MatDialog, private ohm: OhmService, - private http: HttpClient + private http: HttpClient, + private matomoTracker: MatomoTracker + ) { } ngOnInit(): void { @@ -151,6 +154,7 @@ export class MapComponent implements OnInit { changeUrl(ev = null): void{ const c = this.map.getCenter(); this.l.go(`/${this.atDate}/${this.map.getZoom()}/${c.lat}/${c.lng}` + (this.rels ? '/' + this.rels : '')); + this.matomoTracker.trackPageView(`/${this.atDate}/${this.map.getZoom()}/${c.lat}/${c.lng}` + (this.rels ? '/' + this.rels : '')); if (ev) { this.map.getSource('ohm').setSourceProperty(() => { }); this.map.getSource('ohm-boundaries')?.setSourceProperty(() => { }); From 314bebd6429bdee59d75b552138b0a12bbb825cf Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Thu, 6 Jan 2022 16:55:02 +0100 Subject: [PATCH 6/9] up --- src/app/decimaldate.pipe.ts | 1 - src/app/map/map.component.html | 4 ++++ src/app/map/map.component.ts | 35 +++++++++++++++++++++++++++++----- src/app/ohm.service.ts | 23 +++++++++++++++++++--- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/app/decimaldate.pipe.ts b/src/app/decimaldate.pipe.ts index a9df7a7..b51874c 100644 --- a/src/app/decimaldate.pipe.ts +++ b/src/app/decimaldate.pipe.ts @@ -58,5 +58,4 @@ export class DecimaldatePipe implements PipeTransform { ret.setMilliseconds(rest); return ret; } - } diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index e6ff334..76a973c 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -17,6 +17,7 @@

OpenHistoryMap

+ @@ -33,6 +34,9 @@

OpenHistoryMap

How to help/donate to OHM
+ + {{selectedFeatures|json}} +

Events

diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index a5d534e..95a288b 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -1,19 +1,17 @@ import { OhmService } from './../ohm.service'; import { DateComponent } from './../date/date.component'; import { DecimaldatePipe } from './../decimaldate.pipe'; -import { Component, OnInit, Input, isDevMode } from '@angular/core'; +import { Component, OnInit, Input, isDevMode, ViewChild } from '@angular/core'; import { MnDockerService } from '@modalnodes/mn-docker'; import { HttpClient } from '@angular/common/http'; -import env from '../../assets/env.json'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; -import { NicedatePipe } from '../nicedate.pipe'; -import { timeInterval } from 'rxjs/operators'; import { MatDialog } from '@angular/material/dialog'; import { Observable } from 'rxjs'; import { MatomoTracker } from 'ngx-matomo'; +import { MatSidenav } from '@angular/material/sidenav'; declare const mapboxgl; declare const vis; @@ -57,7 +55,9 @@ export class MapComponent implements OnInit { infoData: any; + @ViewChild('ibar') ibar: MatSidenav; + selectedFeatures = []; constructor( private ds: MnDockerService, private ar: ActivatedRoute, @@ -124,6 +124,29 @@ export class MapComponent implements OnInit { this.map.on('moveend', () => { this.changeUrl(); }); + this.map.on('mouseenter', () => { + this.map.getCanvas().style.cursor = 'pointer'; + }); + + // Change it back to a pointer when it leaves. + this.map.on('mouseleave', () => { + this.map.getCanvas().style.cursor = ''; + }); + this.map.on('click', (e) => { + console.log(e.lngLat); + this.ohm.drilldown(e.lngLat).subscribe(feats=>{ + this.ibar.open(); + if(feats.length > 0) { + this.selectedFeatures = feats; + console.log(feats[0].properties); + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .addTo(this.map); + } + + }) + }); + const container = document.getElementById('visualization'); @@ -166,7 +189,9 @@ export class MapComponent implements OnInit { changeStyle(style): void { this.style = style; - this.map.setStyle(style); + try{ + this.map.setStyle(style); + } catch(ex) { } } toDateFloat(date: Date): number{ diff --git a/src/app/ohm.service.ts b/src/app/ohm.service.ts index f99a177..91e1c6f 100644 --- a/src/app/ohm.service.ts +++ b/src/app/ohm.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; +import { Observable, of } from 'rxjs'; @Injectable({ providedIn: 'root' @@ -11,7 +11,24 @@ export class OhmService { private http: HttpClient ) { } - getEvents(date, amount = 20): Observable { - return this.http.get('http://51.15.160.236:9034/events/' + date + '?limit=' + amount); + getEvents(date, bbox=null, amount = 20, from=null, to=null): Observable { + if(bbox){ + return this.http.get('https://api.events.openhistorymap.org/events/timeline.json?bbox='+bbox.join(',')+'&date=' + date + '&limit=' + amount+'&from='+from+'&to='+to); + } else { + return of([]); + } + } + + getStats(date, bbox=null, amount = 20, from=null, to=null): Observable { + if(bbox){ + return this.http.get('https://api.stats.openhistorymap.org/stats.json?bbox='+bbox.join(',')+'&date=' + date + '&limit=' + amount+'&from='+from+'&to='+to); + } else { + return of([]); + } + } + + drilldown(lnglat, radius=100, time='now'): Observable{ + console.log('getting the elements around the selected point') + return of([]); } } From bc96873fb5a449f8a17c9cf9dbdb68a00ef69df6 Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Thu, 6 Jan 2022 17:22:21 +0100 Subject: [PATCH 7/9] update --- src/app/map/map.component.html | 12 +++++++++--- src/app/map/map.component.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index 76a973c..9501a50 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -16,8 +16,8 @@

OpenHistoryMap

- - + +
@@ -35,7 +35,13 @@

OpenHistoryMap

- {{selectedFeatures|json}} + +

What is here

+
+ + + {{event.properties.name}} +
diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 95a288b..941ac72 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -135,7 +135,7 @@ export class MapComponent implements OnInit { this.map.on('click', (e) => { console.log(e.lngLat); this.ohm.drilldown(e.lngLat).subscribe(feats=>{ - this.ibar.open(); + //this.ibar.open(); if(feats.length > 0) { this.selectedFeatures = feats; console.log(feats[0].properties); From 234578f41f48b2c85f03b8f2e50811e9a23227bb Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Wed, 19 Jan 2022 16:09:00 +0100 Subject: [PATCH 8/9] update --- package-lock.json | 72 ++++++++++++++++++++++++++++++++++ package.json | 1 + src/app/app.module.ts | 2 + src/app/map/map.component.html | 9 ++++- src/app/map/map.component.ts | 22 ++++++++++- src/app/ohm.service.ts | 4 ++ 6 files changed, 107 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8ce9dc..62bcefe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1745,6 +1745,14 @@ "@types/node": "*" } }, + "@types/html2canvas": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/html2canvas/-/html2canvas-1.0.0.tgz", + "integrity": "sha512-BJpVf+FIN9UERmzhbtUgpXj6XBZpG67FMgBLLoj9HZKd9XifcCpSV+UnFcwTZfEyun4U/KmCrrVOG7829L589w==", + "requires": { + "html2canvas": "*" + } + }, "@types/jasmine": { "version": "3.5.14", "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.5.14.tgz", @@ -3756,6 +3764,21 @@ "timsort": "^0.3.0" } }, + "css-line-break": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.0.1.tgz", + "integrity": "sha512-gwKYIMUn7xodIcb346wgUhE2Dt5O1Kmrc16PWi8sL4FTfyDj8P5095rzH7+O8CTZudJr+uw2GCI/hwEkDJFI2w==", + "requires": { + "base64-arraybuffer": "^0.2.0" + }, + "dependencies": { + "base64-arraybuffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", + "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==" + } + } + }, "css-loader": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-3.5.3.tgz", @@ -5735,6 +5758,15 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "html2canvas": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.3.2.tgz", + "integrity": "sha512-4+zqv87/a1LsaCrINV69wVLGG8GBZcYBboz1JPWEgiXcWoD9kroLzccsBRU/L9UlfV2MAZ+3J92U9IQPVMDeSQ==", + "requires": { + "css-line-break": "2.0.1", + "text-segmentation": "^1.0.2" + } + }, "http-cache-semantics": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", @@ -7864,6 +7896,23 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "ngx-capture": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/ngx-capture/-/ngx-capture-0.12.1.tgz", + "integrity": "sha512-rMTIIEV0HQAA95Hlf+THdmXfJdPDfjDX9vB1VAOWxVcmHtnPCukhcSz9ck+7kf5VsmvcQ/7QQFcbttVSAPKAFw==", + "requires": { + "@types/html2canvas": "1.0.0", + "html2canvas": "1.3.2", + "tslib": "^2.2.0" + }, + "dependencies": { + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + } + } + }, "ngx-matomo": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/ngx-matomo/-/ngx-matomo-0.1.4.tgz", @@ -12175,6 +12224,14 @@ } } }, + "text-segmentation": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.2.tgz", + "integrity": "sha512-uTqvLxdBrVnx/CFQOtnf8tfzSXFm+1Qxau7Xi54j4OPTZokuDOX8qncQzrg2G8ZicAMOM8TgzFAYTb+AqNO4Cw==", + "requires": { + "utrie": "^1.0.1" + } + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -12724,6 +12781,21 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, + "utrie": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.1.tgz", + "integrity": "sha512-JPaDXF3vzgZxfeEwutdGzlrNoVFL5UvZcbO6Qo9D4GoahrieUPoMU8GCpVpR7MQqcKhmShIh8VlbEN3PLM3EBg==", + "requires": { + "base64-arraybuffer": "^1.0.1" + }, + "dependencies": { + "base64-arraybuffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.1.tgz", + "integrity": "sha512-vFIUq7FdLtjZMhATwDul5RZWv2jpXQ09Pd6jcVEOvIsqCWTRFD/ONHNfyOS8dA/Ippi5dsIgpyKWKZaAKZltbA==" + } + } + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", diff --git a/package.json b/package.json index 440c2c1..bab1b09 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@modalnodes/mn-configurator": "0.0.4", "@modalnodes/mn-docker": "0.0.3", "@modalnodes/mn-registry": "0.0.3", + "ngx-capture": "^0.12.1", "ngx-matomo": "^0.1.4", "ol": "^6.4.3", "rxjs": "~6.5.5", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 463bf76..366a1bf 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,6 +13,7 @@ import { StyleSelectorComponent } from './style-selector/style-selector.componen import { DecimaldatePipe } from './decimaldate.pipe'; import { NicedatePipe } from './nicedate.pipe'; import { DateComponent } from './date/date.component'; +import {ClipboardModule} from '@angular/cdk/clipboard'; @NgModule({ declarations: [ @@ -27,6 +28,7 @@ import { DateComponent } from './date/date.component'; BrowserModule, BrowserAnimationsModule, AppRoutingModule, + ClipboardModule, MnDockerModule, MnConfiguratorModule, SharedModule, diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index 9501a50..41120a1 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -16,6 +16,7 @@

OpenHistoryMap

+ @@ -52,7 +53,13 @@

Events

{{event.properties.name}}
- + + +

Sharing

+
+ +
+ diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 941ac72..45f9dad 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -12,6 +12,9 @@ import { MatDialog } from '@angular/material/dialog'; import { Observable } from 'rxjs'; import { MatomoTracker } from 'ngx-matomo'; import { MatSidenav } from '@angular/material/sidenav'; +import { Clipboard } from '@angular/cdk/clipboard'; +import { MatSnackBar } from '@angular/material/snack-bar'; +import { NgxCaptureService } from 'ngx-capture'; declare const mapboxgl; declare const vis; @@ -56,6 +59,7 @@ export class MapComponent implements OnInit { infoData: any; @ViewChild('ibar') ibar: MatSidenav; + @ViewChild('screen') screen: any; selectedFeatures = []; constructor( @@ -65,8 +69,10 @@ export class MapComponent implements OnInit { private md: MatDialog, private ohm: OhmService, private http: HttpClient, - private matomoTracker: MatomoTracker - + private matomoTracker: MatomoTracker, + private _snackBar: MatSnackBar, + private clipboard: Clipboard, + private capture: NgxCaptureService ) { } ngOnInit(): void { @@ -95,6 +101,7 @@ export class MapComponent implements OnInit { style: this.style, // stylesheet location center: this.start.center, // starting position [lng, lat] zoom: this.start.zoom, // starting zoom + preserveDrawingBuffer: true, transformRequest: (url, resourceType) => { let nurl = url; if (isDevMode()) { @@ -174,6 +181,17 @@ export class MapComponent implements OnInit { }); } + copy_url(){ + this.capture.getImage(this.screen.elementRef.nativeElement, true).subscribe(img=>{ + this.ohm.su(window.location.href, img).subscribe(data =>{ + this.clipboard.copy(data); + this._snackBar.open('Address ready to share','Close', { + duration: 1000 + }); + }); + }) + } + changeUrl(ev = null): void{ const c = this.map.getCenter(); this.l.go(`/${this.atDate}/${this.map.getZoom()}/${c.lat}/${c.lng}` + (this.rels ? '/' + this.rels : '')); diff --git a/src/app/ohm.service.ts b/src/app/ohm.service.ts index 91e1c6f..390a8b5 100644 --- a/src/app/ohm.service.ts +++ b/src/app/ohm.service.ts @@ -31,4 +31,8 @@ export class OhmService { console.log('getting the elements around the selected point') return of([]); } + + su(url: string, image:string = null): Observable{ + return this.http.post('https://su.openhistorymap.org/?url='+url, image); + } } From 49889e939772007bb718ac4ea3af7e9f12a58931 Mon Sep 17 00:00:00 2001 From: Marco Montanari Date: Fri, 21 Jan 2022 20:45:30 +0100 Subject: [PATCH 9/9] update --- src/app/app.module.ts | 4 +++- src/app/map/map.component.html | 31 +++++++++++++++++++++++++------ src/app/map/map.component.ts | 7 ++++++- src/app/share.directive.spec.ts | 8 ++++++++ src/app/share.directive.ts | 18 ++++++++++++++++++ 5 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 src/app/share.directive.spec.ts create mode 100644 src/app/share.directive.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 366a1bf..6809d97 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,6 +14,7 @@ import { DecimaldatePipe } from './decimaldate.pipe'; import { NicedatePipe } from './nicedate.pipe'; import { DateComponent } from './date/date.component'; import {ClipboardModule} from '@angular/cdk/clipboard'; +import { ShareDirective } from './share.directive'; @NgModule({ declarations: [ @@ -22,7 +23,8 @@ import {ClipboardModule} from '@angular/cdk/clipboard'; StyleSelectorComponent, DecimaldatePipe, NicedatePipe, - DateComponent + DateComponent, + ShareDirective ], imports: [ BrowserModule, diff --git a/src/app/map/map.component.html b/src/app/map/map.component.html index 41120a1..c9d1363 100644 --- a/src/app/map/map.component.html +++ b/src/app/map/map.component.html @@ -1,5 +1,5 @@ - +

OpenHistoryMap

@@ -8,9 +8,9 @@

OpenHistoryMap

- - - + + + @@ -18,6 +18,7 @@

OpenHistoryMap

+
@@ -53,17 +54,35 @@

Events

{{event.properties.name}} + + +

Ephemeral

+
+ + + {{event.properties.name}} + +

Sharing

+ +
+ + facebook Share on Facebook + twitter Share on Twitter + Share on Linkedin + class Share on Classroom + +
- - + +
diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 45f9dad..e80f9ce 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -59,8 +59,11 @@ export class MapComponent implements OnInit { infoData: any; @ViewChild('ibar') ibar: MatSidenav; + @ViewChild('sharebar') sharebar: MatSidenav; @ViewChild('screen') screen: any; + share_link: string; + selectedFeatures = []; constructor( private ds: MnDockerService, @@ -185,6 +188,8 @@ export class MapComponent implements OnInit { this.capture.getImage(this.screen.elementRef.nativeElement, true).subscribe(img=>{ this.ohm.su(window.location.href, img).subscribe(data =>{ this.clipboard.copy(data); + this.share_link = data; + this.sharebar.open(); this._snackBar.open('Address ready to share','Close', { duration: 1000 }); @@ -236,7 +241,7 @@ export class MapComponent implements OnInit { this.atDate = parseFloat(this.atDate.toString()) + delta; this.timeline.setCustomTime(this.toFloatDate(this.atDate), 'atTime'); this.changeUrl(this.atDate); - }, this.speed); + }, 4000); } else { clearInterval(this.startstopInterval); } diff --git a/src/app/share.directive.spec.ts b/src/app/share.directive.spec.ts new file mode 100644 index 0000000..1c1e580 --- /dev/null +++ b/src/app/share.directive.spec.ts @@ -0,0 +1,8 @@ +import { ShareDirective } from './share.directive'; + +describe('ShareDirective', () => { + it('should create an instance', () => { + const directive = new ShareDirective(); + expect(directive).toBeTruthy(); + }); +}); diff --git a/src/app/share.directive.ts b/src/app/share.directive.ts new file mode 100644 index 0000000..9c71c55 --- /dev/null +++ b/src/app/share.directive.ts @@ -0,0 +1,18 @@ +import { Directive, Input } from '@angular/core'; + +@Directive({ + selector: '[share]', + host: { + "(click)": "onClick($event)" + } +}) +export class ShareDirective { + + @Input('share') url = '' + constructor() { } + + onClick(e){ + window.open(this.url, 'share', "width=400,height=300,toolbar=no,status=no,menubar=no"); + } + +}