From 5de8b434ab8ebf5fb471cbe31ce6bca0a10383a8 Mon Sep 17 00:00:00 2001 From: ilhangeoksu Date: Tue, 16 Jan 2018 15:22:53 +0100 Subject: [PATCH] add visit places component with mock data --- web/angular/.angular-cli.json | 7 +- web/angular/package.json | 2 +- web/angular/src/app/app.module.ts | 12 ++- .../app/views/components/map/map.component.ts | 2 +- .../components/place/place.component.html | 32 ++++++ .../components/place/place.component.scss | 5 + .../views/components/place/place.component.ts | 97 ++++++++++++++++++ .../statistic/statistic.component.html | 5 +- web/angular/src/assets/img/marker_place.png | Bin 0 -> 697 bytes 9 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 web/angular/src/app/views/components/place/place.component.html create mode 100644 web/angular/src/app/views/components/place/place.component.scss create mode 100644 web/angular/src/app/views/components/place/place.component.ts create mode 100644 web/angular/src/assets/img/marker_place.png diff --git a/web/angular/.angular-cli.json b/web/angular/.angular-cli.json index 50b6e38..507531d 100644 --- a/web/angular/.angular-cli.json +++ b/web/angular/.angular-cli.json @@ -22,11 +22,14 @@ "../node_modules/font-awesome/css/font-awesome.css", "../node_modules/simple-line-icons/css/simple-line-icons.css", "../src/scss/style.scss", - "../node_modules/ngx-toastr/toastr.css" + "../node_modules/leaflet/dist/leaflet.css", + "../node_modules/ngx-toastr/toastr.css", + "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css" ], "scripts": [ "../node_modules/chart.js/dist/Chart.bundle.min.js", - "../node_modules/chart.js/dist/Chart.min.js" + "../node_modules/chart.js/dist/Chart.min.js", + "../node_modules/leaflet/dist/leaflet.js" ], "environmentSource": "environments/environment.ts", "environments": { diff --git a/web/angular/package.json b/web/angular/package.json index c8cecbd..2ac2f0c 100644 --- a/web/angular/package.json +++ b/web/angular/package.json @@ -32,7 +32,7 @@ "leaflet-easybutton": "^2.2.4", "moment": "2.19.1", "ng2-charts": "1.6.0", - "ngx-bootstrap": "1.9.3", + "ngx-bootstrap": "^2.0.0-rc.0", "ngx-toastr": "^8.0.0", "rxjs": "5.5.2", "simple-line-icons": "^2.4.1", diff --git a/web/angular/src/app/app.module.ts b/web/angular/src/app/app.module.ts index 26384df..c23740c 100755 --- a/web/angular/src/app/app.module.ts +++ b/web/angular/src/app/app.module.ts @@ -1,6 +1,6 @@ import { BrowserModule } from '@angular/platform-browser'; import {FormsModule} from "@angular/forms"; -import { NgModule } from '@angular/core'; +import {NgModule, LOCALE_ID} from '@angular/core'; import {LocationStrategy, HashLocationStrategy, PathLocationStrategy} from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -32,6 +32,7 @@ import {ResetPasswordComponent} from "./views/pages/reset-password/reset-passwor import {ResetPasswordEmailComponent} from "./views/pages/reset-password-email/reset-password-email.component"; import {AdminComponent} from "./views/components/admin/admin.component"; import {UserManagementComponent} from "./views/components/user-management/user-management.component"; +import {PlaceComponent} from "./views/components/place/place.component"; // Import containers import { @@ -90,7 +91,8 @@ const APP_COMPONENTS = [ ResetPasswordComponent, ResetPasswordEmailComponent, AdminComponent, - UserManagementComponent + UserManagementComponent, + PlaceComponent ]; // Import directives @@ -118,6 +120,7 @@ import { PaginationModule } from 'ngx-bootstrap/pagination'; import { ModalModule } from 'ngx-bootstrap/modal'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { ToastrModule } from 'ngx-toastr'; +import { DatepickerModule, BsDatepickerModule } from 'ngx-bootstrap/datepicker'; @NgModule({ imports: [ @@ -133,7 +136,9 @@ import { ToastrModule } from 'ngx-toastr'; ChartsModule, ToastrModule.forRoot({ newestOnTop:true - }) + }), + BsDatepickerModule.forRoot(), + DatepickerModule.forRoot() ], declarations: [ AppComponent, @@ -149,6 +154,7 @@ import { ToastrModule } from 'ngx-toastr'; // add two global interceptors (one two slow down the server and one for authentication) {provide: HTTP_INTERCEPTORS, useClass: DelayInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}, + { provide: LOCALE_ID, useValue: 'de' }, // add our application services (api access, logging, authentication) ApiClientService, ConsoleService, AuthGuard, NotAuthGuard, ParentAuthGuard, AuthService, LocationService ], diff --git a/web/angular/src/app/views/components/map/map.component.ts b/web/angular/src/app/views/components/map/map.component.ts index dbce31d..5a52454 100755 --- a/web/angular/src/app/views/components/map/map.component.ts +++ b/web/angular/src/app/views/components/map/map.component.ts @@ -20,7 +20,7 @@ import { OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks'; @Component({ selector: 'app-map', templateUrl: './map.component.html', - styleUrls: ['./map.component.scss', '../../../../../node_modules/leaflet/dist/leaflet.css'], + styleUrls: ['./map.component.scss'], encapsulation: ViewEncapsulation.None }) export class MapComponent implements OnInit, OnDestroy { diff --git a/web/angular/src/app/views/components/place/place.component.html b/web/angular/src/app/views/components/place/place.component.html new file mode 100644 index 0000000..ec6f5c3 --- /dev/null +++ b/web/angular/src/app/views/components/place/place.component.html @@ -0,0 +1,32 @@ +
+
+
+
+
Besuchte Orte
+
+
+
+ Besuchte Orte am {{datepickerModel | date:'fullDate'}} +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
diff --git a/web/angular/src/app/views/components/place/place.component.scss b/web/angular/src/app/views/components/place/place.component.scss new file mode 100644 index 0000000..7378794 --- /dev/null +++ b/web/angular/src/app/views/components/place/place.component.scss @@ -0,0 +1,5 @@ +#map { + height: 50vh; + width: 100%; + border: 1px solid black; +} diff --git a/web/angular/src/app/views/components/place/place.component.ts b/web/angular/src/app/views/components/place/place.component.ts new file mode 100644 index 0000000..1bf6685 --- /dev/null +++ b/web/angular/src/app/views/components/place/place.component.ts @@ -0,0 +1,97 @@ +import {Component, OnInit} from "@angular/core"; +import {ActivatedRoute} from "@angular/router"; +import {LocationService} from "../../../location.service"; +import {ConsoleService} from "../../../console.service"; +import {ToastrService} from "ngx-toastr"; +import { registerLocaleData } from '@angular/common'; +import localeDe from '@angular/common/locales/de'; + +import * as L from 'leaflet'; +import 'leaflet-easybutton'; +import { BsDatepickerConfig , BsLocaleService} from 'ngx-bootstrap/datepicker'; +import { defineLocale } from 'ngx-bootstrap/bs-moment'; +import { de } from 'ngx-bootstrap/locale'; + + +@Component({ + selector: 'app-place', + templateUrl: './place.component.html', + styleUrls: ['./place.component.scss'] +}) +export class PlaceComponent implements OnInit { + places = []; + datepickerModel: Date; + minDate: Date; + maxDate: Date; + colorTheme = 'theme-orange'; + bsConfig: Partial; + + private map: L.Map; + private tileLayer: L.TileLayer; + private defaultIcon = new L.Icon({ + iconUrl: require('../../../../assets/img/marker_place.png'), + iconAnchor: [25, 63], // point of the icon which will correspond to marker's location + popupAnchor: [0, -50] // point from which the popup should open relative to the iconAnchor + }); + + constructor( + private route: ActivatedRoute, + private locationService: LocationService, + private consoleService: ConsoleService, + private toastService: ToastrService, + private _localeService: BsLocaleService + ) { + // set german calendar + registerLocaleData(localeDe, 'de'); + defineLocale('de', de); + this._localeService.use('de'); + // calendar config + this.bsConfig = Object.assign({}, { containerClass: this.colorTheme }); + this.datepickerModel = new Date(); + this.minDate = new Date(); + this.maxDate = new Date(); + this.minDate.setDate(this.minDate.getDate()-7); // day of registration + this.maxDate.setDate(this.maxDate.getDate()); // future dates are not possible + } + + ngOnInit() { + this.map = new L.Map('map'); + this.requestPlaces(); + this.map.fitBounds(this.places); +/* + this.tileLayer = new L.TileLayer('https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png', { + attribution: 'Maptology', + maxZoom: 18 + }).addTo(this.map);*/ + this.tileLayer = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
 + attribution: 'Map data © OpenStreetMap contributors',
 + maxZoom: 18
 + }).addTo(this.map); + } + + // replace later with api request + requestPlaces(){ + // Mock data + var i = 0; + for(i=0; i<5; i++){ + this.places.push(new L.LatLng(this.getRandomArbitrary(51,51.16), this.getRandomArbitrary(10,10.45))); + } + var j = 0; + for(j=0; j<5; j++){ + new L.Marker(this.places[j], + { + icon: this.defaultIcon + }).addTo(this.map).bindPopup("This is adress of place "+j).openPopup(); + } + } + + getRandomArbitrary(min, max) { + return Math.random() * (max - min) + min; + } + + // date methods + // day changed + onChange() { + setTimeout(()=>{console.log(this.datepickerModel)}, 100); + } +} diff --git a/web/angular/src/app/views/components/statistic/statistic.component.html b/web/angular/src/app/views/components/statistic/statistic.component.html index 918bac4..4dbf5bb 100755 --- a/web/angular/src/app/views/components/statistic/statistic.component.html +++ b/web/angular/src/app/views/components/statistic/statistic.component.html @@ -1,4 +1 @@ -
- Statistic Component! -
- \ No newline at end of file + diff --git a/web/angular/src/assets/img/marker_place.png b/web/angular/src/assets/img/marker_place.png new file mode 100644 index 0000000000000000000000000000000000000000..3bb06fa668f4139441917498c7c1012f7e2cf1ae GIT binary patch literal 697 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&3=B+Wo-U3d z8I5mep7);OC~@50IKN}vl-u79JI|QZE}&~w`Y~i<$tk~}?+#6Rvac@KPYmqb@MPn* z4apNkTO8w<4hk%84w3N8T)JY#?$`VL+sm1a%WsxGOSL)k+~ob~-!}Jue%NQsv*$r! z_oll6dRxmIV;C8WCz zUp+6IF7)kM%(sgF!j@9k$?^Yq*Uvw&-G8bYzrcdSc8@DAvmLNxh_YU^`lR8B=UJ;w z4>UDwVc4KA8hfsO?b01rP3|63>brLFP|TJD?y$1st2QbuNOQ3IcVBCD(lL{}e}si3 zZ&t3Y%9G016L_JxU`O*Q-lj(rGWTq3IOXTh_&r-sq|`lie~ro6?HhZYF8`Z-;Pk5b z;*yE$o=)q{&}Pyyj#J3l(O}^4^!&<>6S0$4%9&d2N>sh=Hu>xyTfg;k8N1{5TW}w! z`oz&WfBx_CuZ30G$?xm_6nDM0yDQ^8ZLaA90sRM3_)tLO_u0pU3tNwmdKI;Vst0EI_2cK`qY literal 0 HcmV?d00001