Commit e82057fff5ced9506e2a10105bd5d8e90c911ce3

Authored by Yarik
2 parents a619dba6 d7a8b3bb

Merge branch 'master' of gitlab.artweb.com.ua:root/maps-admin

1 { 1 {
2 - "name": "covalent-quickstart",  
3 - "version": "1.0.0-beta.1",  
4 - "private": true,  
5 - "description": "Quickstart App with @covalent packages",  
6 - "keywords": [  
7 - "angular",  
8 - "components",  
9 - "reusable"  
10 - ],  
11 - "scripts": {  
12 - "e2e": "protractor",  
13 - "e2e-test": "protractor ./protractor.conf.js",  
14 - "lint": "tslint -c ./tslint.json \"./src/**/*.ts\" -e \"./src/**/typings.d.ts\" -e \"./src/environments/**\"",  
15 - "reinstall": "rm -rf node_modules tmp deploy dist && npm i",  
16 - "postinstall": "webdriver-manager update",  
17 - "start-api": "cd mock-api && covalent-data &",  
18 - "stop-api": "pkill covalent-data",  
19 - "webdriver-update": "bash ./node_modules/.bin/webdriver-manager update",  
20 - "test": "ng test --code-coverage --single-run",  
21 - "ghpages-deploy": "ng build --base-href /covalent-quickstart/ --aot -prod && bash scripts/ghpages-deploy"  
22 - },  
23 - "engines": {  
24 - "node": ">4.4 < 7",  
25 - "npm": ">3"  
26 - },  
27 - "repository": {  
28 - "type": "git",  
29 - "url": "https://github.com/teradata/covalent-quickstart.git"  
30 - },  
31 - "license": "MIT",  
32 - "author": "Teradata UX",  
33 - "contributors": [  
34 - "Kyle Ledbetter <kyle.ledbetter@teradata.com>",  
35 - "Richa Vyas <richa.vyas@teradata.com>",  
36 - "Ed Morales <eduardo.morales@teradata.com>",  
37 - "Jason Weaver <jason.weaver@teradata.com>",  
38 - "Jeremy Smartt <jeremy.smartt@teradata.com>",  
39 - "Ilsun Park <ilsun.park@teradata.com>"  
40 - ],  
41 - "dependencies": {  
42 - "@angular/common": "2.4.5",  
43 - "@angular/compiler": "2.4.5",  
44 - "@angular/core": "2.4.5",  
45 - "@angular/forms": "2.4.5",  
46 - "@angular/http": "2.4.5",  
47 - "@angular/material": "2.0.0-beta.1",  
48 - "@angular/platform-browser": "2.4.5",  
49 - "@angular/platform-browser-dynamic": "2.4.5",  
50 - "@angular/platform-server": "2.4.5",  
51 - "@angular/router": "3.4.5",  
52 - "@covalent/core": "1.0.0-beta.1",  
53 - "@covalent/charts": "1.0.0-beta.1",  
54 - "@covalent/dynamic-forms": "1.0.0-beta.1",  
55 - "@covalent/highlight": "1.0.0-beta.1",  
56 - "@covalent/http": "1.0.0-beta.1",  
57 - "@covalent/markdown": "1.0.0-beta.1",  
58 - "@swimlane/ngx-charts": "^3.1.2",  
59 - "core-js": "^2.4.1",  
60 - "hammerjs": "^2.0.8",  
61 - "highlight.js": "9.9.0",  
62 - "rxjs": "^5.0.1",  
63 - "showdown": "1.6.0",  
64 - "zone.js": "^0.7.2",  
65 - "moment": "^2.17.1",  
66 - "d3": "^4.4.0",  
67 - "ag-grid": "7.2.x",  
68 - "ag-grid-ng2": "7.2.x"  
69 - },  
70 - "devDependencies": {  
71 - "@angular/compiler-cli": "2.4.5",  
72 - "@types/hammerjs": "2.0.30",  
73 - "@types/jasmine": "2.2.31",  
74 - "@types/node": "6.0.34",  
75 - "@types/selenium-webdriver": "2.53.36",  
76 - "angular-cli": "1.0.0-beta.26",  
77 - "codelyzer": "2.0.0-beta.4",  
78 - "ember-cli-inject-live-reload": "1.4.0",  
79 - "jasmine-core": "2.4.1",  
80 - "jasmine-spec-reporter": "2.5.0",  
81 - "karma": "1.2.0",  
82 - "karma-chrome-launcher": "2.0.0",  
83 - "karma-cli": "1.0.1",  
84 - "karma-jasmine": "1.0.2",  
85 - "karma-remap-istanbul": "0.2.1",  
86 - "karma-firefox-launcher": "1.0.0",  
87 - "karma-phantomjs-launcher": "1.0.1",  
88 - "node-sass": "3.8.0",  
89 - "phantomjs-prebuilt": "2.1.7",  
90 - "protractor": "4.0.5",  
91 - "sass-loader": "^4.0.2",  
92 - "ts-node": "1.2.1",  
93 - "tslint": "^4.3.1",  
94 - "typescript": "2.1.5"  
95 - },  
96 - "optionalDependencies": {  
97 - "@covalent/data": "0.4.0"  
98 - }  
99 -}  
100 \ No newline at end of file 2 \ No newline at end of file
  3 + "name": "covalent-quickstart",
  4 + "version": "1.0.0-beta.1",
  5 + "private": true,
  6 + "description": "Quickstart App with @covalent packages",
  7 + "keywords": [
  8 + "angular",
  9 + "components",
  10 + "reusable"
  11 + ],
  12 + "scripts": {
  13 + "e2e": "protractor",
  14 + "e2e-test": "protractor ./protractor.conf.js",
  15 + "lint": "tslint -c ./tslint.json \"./src/**/*.ts\" -e \"./src/**/typings.d.ts\" -e \"./src/environments/**\"",
  16 + "reinstall": "rm -rf node_modules tmp deploy dist && npm i",
  17 + "postinstall": "webdriver-manager update",
  18 + "start-api": "cd mock-api && covalent-data &",
  19 + "stop-api": "pkill covalent-data",
  20 + "webdriver-update": "bash ./node_modules/.bin/webdriver-manager update",
  21 + "test": "ng test --code-coverage --single-run",
  22 + "ghpages-deploy": "ng build --base-href /covalent-quickstart/ --aot -prod && bash scripts/ghpages-deploy"
  23 + },
  24 + "engines": {
  25 + "node": ">4.4 < 7",
  26 + "npm": ">3"
  27 + },
  28 + "repository": {
  29 + "type": "git",
  30 + "url": "https://github.com/teradata/covalent-quickstart.git"
  31 + },
  32 + "license": "MIT",
  33 + "author": "Teradata UX",
  34 + "contributors": [
  35 + "Kyle Ledbetter <kyle.ledbetter@teradata.com>",
  36 + "Richa Vyas <richa.vyas@teradata.com>",
  37 + "Ed Morales <eduardo.morales@teradata.com>",
  38 + "Jason Weaver <jason.weaver@teradata.com>",
  39 + "Jeremy Smartt <jeremy.smartt@teradata.com>",
  40 + "Ilsun Park <ilsun.park@teradata.com>"
  41 + ],
  42 + "dependencies": {
  43 + "@angular/common": "2.4.5",
  44 + "@angular/compiler": "2.4.5",
  45 + "@angular/core": "2.4.5",
  46 + "@angular/forms": "2.4.5",
  47 + "@angular/http": "2.4.5",
  48 + "@angular/material": "2.0.0-beta.1",
  49 + "@angular/platform-browser": "2.4.5",
  50 + "@angular/platform-browser-dynamic": "2.4.5",
  51 + "@angular/platform-server": "2.4.5",
  52 + "@angular/router": "3.4.5",
  53 + "@covalent/charts": "1.0.0-beta.1",
  54 + "@covalent/core": "1.0.0-beta.1",
  55 + "@covalent/dynamic-forms": "1.0.0-beta.1",
  56 + "@covalent/highlight": "1.0.0-beta.1",
  57 + "@covalent/http": "1.0.0-beta.1",
  58 + "@covalent/markdown": "1.0.0-beta.1",
  59 + "@swimlane/ngx-charts": "^3.1.2",
  60 + "@types/leaflet": "^1.0.54",
  61 + "ag-grid": "7.2.x",
  62 + "ag-grid-ng2": "7.2.x",
  63 + "core-js": "^2.4.1",
  64 + "d3": "^4.4.0",
  65 + "hammerjs": "^2.0.8",
  66 + "highlight.js": "9.9.0",
  67 + "leaflet": "^1.0.3",
  68 + "moment": "^2.17.1",
  69 + "rxjs": "^5.0.1",
  70 + "showdown": "1.6.0",
  71 + "zone.js": "^0.7.2"
  72 + },
  73 + "devDependencies": {
  74 + "@angular/compiler-cli": "2.4.5",
  75 + "@types/hammerjs": "2.0.30",
  76 + "@types/jasmine": "2.2.31",
  77 + "@types/node": "6.0.34",
  78 + "@types/selenium-webdriver": "2.53.36",
  79 + "angular-cli": "1.0.0-beta.26",
  80 + "codelyzer": "2.0.0-beta.4",
  81 + "ember-cli-inject-live-reload": "1.4.0",
  82 + "jasmine-core": "2.4.1",
  83 + "jasmine-spec-reporter": "2.5.0",
  84 + "karma": "1.2.0",
  85 + "karma-chrome-launcher": "2.0.0",
  86 + "karma-cli": "1.0.1",
  87 + "karma-jasmine": "1.0.2",
  88 + "karma-remap-istanbul": "0.2.1",
  89 + "karma-firefox-launcher": "1.0.0",
  90 + "karma-phantomjs-launcher": "1.0.1",
  91 + "node-sass": "3.8.0",
  92 + "phantomjs-prebuilt": "2.1.7",
  93 + "protractor": "4.0.5",
  94 + "sass-loader": "^4.0.2",
  95 + "ts-node": "1.2.1",
  96 + "tslint": "^4.3.1",
  97 + "typescript": "2.1.5"
  98 + },
  99 + "optionalDependencies": {
  100 + "@covalent/data": "0.4.0"
  101 + }
  102 +}
src/app/app.module.ts
@@ -15,8 +15,7 @@ import { TemplatesComponent } from &#39;./templates/templates.component&#39;; @@ -15,8 +15,7 @@ import { TemplatesComponent } from &#39;./templates/templates.component&#39;;
15 import { appRoutes, appRoutingProviders } from './app.routes'; 15 import { appRoutes, appRoutingProviders } from './app.routes';
16 import { AgGridModule } from 'ag-grid-ng2/main'; 16 import { AgGridModule } from 'ag-grid-ng2/main';
17 import { ChartComponent } from '../components/chart/chart.component'; 17 import { ChartComponent } from '../components/chart/chart.component';
18 -import { CandTLeafletComponent } from 'angular2.leaflet.components';  
19 -import { CandTLeafletService } from 'angular2.leaflet.components'; 18 +
20 19
21 import { RequestInterceptor } from '../config/interceptors/request.interceptor'; 20 import { RequestInterceptor } from '../config/interceptors/request.interceptor';
22 21
@@ -30,6 +29,8 @@ import { RoadToCategoryComponent } from &#39;./data/road-to-category/road-to-categor @@ -30,6 +29,8 @@ import { RoadToCategoryComponent } from &#39;./data/road-to-category/road-to-categor
30 import { CrossSectionComponent } from './data/cross-section/cross-section.component'; 29 import { CrossSectionComponent } from './data/cross-section/cross-section.component';
31 import { EditorComponent } from '../helpers/editor.component'; 30 import { EditorComponent } from '../helpers/editor.component';
32 import { RendererComponent } from '../helpers/renderer.component'; 31 import { RendererComponent } from '../helpers/renderer.component';
  32 +import { MapEditorComponent } from '../helpers/map-editor.component';
  33 +import { MapRendererComponent } from '../helpers/map-renderer.component';
33 import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.component'; 34 import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.component';
34 import { RoadComponent } from './data/road/road.component'; 35 import { RoadComponent } from './data/road/road.component';
35 import { RoadServiceComponent } from './data/road-service/road-service.component'; 36 import { RoadServiceComponent } from './data/road-service/road-service.component';
@@ -76,6 +77,8 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [ @@ -76,6 +77,8 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [
76 RoadSurfaceComponent, 77 RoadSurfaceComponent,
77 EditorComponent, 78 EditorComponent,
78 RendererComponent, 79 RendererComponent,
  80 + MapEditorComponent,
  81 + MapRendererComponent,
79 RoadWidthComponent, 82 RoadWidthComponent,
80 RoadToCategoryComponent, 83 RoadToCategoryComponent,
81 FlowIntensityComponent, 84 FlowIntensityComponent,
@@ -83,8 +86,7 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [ @@ -83,8 +86,7 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [
83 CrossSectionComponent, 86 CrossSectionComponent,
84 RoadServiceComponent, 87 RoadServiceComponent,
85 SettlementAddressLinkComponent, 88 SettlementAddressLinkComponent,
86 - MapComponent,  
87 - CandTLeafletComponent 89 + MapComponent
88 ], // directives, components, and pipes owned by this NgModule 90 ], // directives, components, and pipes owned by this NgModule
89 imports: [ 91 imports: [
90 BrowserModule, 92 BrowserModule,
@@ -93,6 +95,8 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [ @@ -93,6 +95,8 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [
93 ServiceObjectComponent, 95 ServiceObjectComponent,
94 EditorComponent, 96 EditorComponent,
95 RendererComponent, 97 RendererComponent,
  98 + MapEditorComponent,
  99 + MapRendererComponent,
96 RoadSurfaceComponent, 100 RoadSurfaceComponent,
97 RoadWidthComponent, 101 RoadWidthComponent,
98 RoadToCategoryComponent, 102 RoadToCategoryComponent,
@@ -139,8 +143,7 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [ @@ -139,8 +143,7 @@ const httpInterceptorProviders: Type&lt;any&gt;[] = [
139 RoadServiceService, 143 RoadServiceService,
140 RoadServiceCreateService, 144 RoadServiceCreateService,
141 SettlementAddressLinkService, 145 SettlementAddressLinkService,
142 - SettlementAddressLinkCreateService,  
143 - CandTLeafletService, 146 + SettlementAddressLinkCreateService
144 ], // additional providers needed for this module 147 ], // additional providers needed for this module
145 entryComponents: [ ], 148 entryComponents: [ ],
146 bootstrap: [ AppComponent ], 149 bootstrap: [ AppComponent ],
src/app/data/bus-stop/bus-stop.component.ts
@@ -8,6 +8,8 @@ import { BusStopService } from &#39;../../../services/bus-stop.service&#39;; @@ -8,6 +8,8 @@ import { BusStopService } from &#39;../../../services/bus-stop.service&#39;;
8 import { BusStop } from '../../../models/bus-stop'; 8 import { BusStop } from '../../../models/bus-stop';
9 import { EditorComponent } from '../../../helpers/editor.component'; 9 import { EditorComponent } from '../../../helpers/editor.component';
10 import { RendererComponent } from '../../../helpers/renderer.component'; 10 import { RendererComponent } from '../../../helpers/renderer.component';
  11 +import { MapEditorComponent } from '../../../helpers/map-editor.component';
  12 +import { MapRendererComponent } from '../../../helpers/map-renderer.component';
11 import { BusStopCreateService } from '../../../services/bus-stop-create.service'; 13 import { BusStopCreateService } from '../../../services/bus-stop-create.service';
12 import { BooleanSelectListService } from '../../../services/boolean-select-list.service'; 14 import { BooleanSelectListService } from '../../../services/boolean-select-list.service';
13 import { RegionSelectList } from '../../../models/region-select-list'; 15 import { RegionSelectList } from '../../../models/region-select-list';
@@ -116,7 +118,6 @@ export class BusStopComponent extends StatementBase { @@ -116,7 +118,6 @@ export class BusStopComponent extends StatementBase {
116 labelCol: 'value', 118 labelCol: 'value',
117 }, 119 },
118 }, 120 },
119 - ,  
120 { 121 {
121 headerName: 'Наявність елементів зупин. майдан', 122 headerName: 'Наявність елементів зупин. майдан',
122 field: 'areaStopAvailability', 123 field: 'areaStopAvailability',
@@ -175,6 +176,16 @@ export class BusStopComponent extends StatementBase { @@ -175,6 +176,16 @@ export class BusStopComponent extends StatementBase {
175 field: 'yearRepair', 176 field: 'yearRepair',
176 editable: true, 177 editable: true,
177 }, 178 },
  179 + {
  180 + headerName: 'position',
  181 + field: 'position',
  182 + editable: true,
  183 + cellEditorFramework: MapEditorComponent,
  184 + cellRendererFramework: MapRendererComponent,
  185 + cellEditorParams: {
  186 + position: 'position'
  187 + },
  188 + },
178 ]; 189 ];
179 } 190 }
180 191
src/helpers/map-editor.component.ts 0 → 100644
  1 +import { Component, ViewContainerRef, ViewChild, AfterViewInit } from '@angular/core';
  2 +
  3 +import { AgEditorComponent } from 'ag-grid-ng2/main';
  4 +import * as L from 'leaflet';
  5 +
  6 +@Component({
  7 + selector: 'editor-cell',
  8 + template: `
  9 + <div class="md-select-panel map-container">
  10 + <div id="mapId"></div>
  11 + </div>
  12 + `
  13 +})
  14 +export class MapEditorComponent implements AgEditorComponent, AfterViewInit {
  15 + @ViewChild('container', {read: ViewContainerRef})
  16 + public container;
  17 + public item: Object = null;
  18 + public data: Object[];
  19 + private params: any;
  20 + public map: L.Map;
  21 + public icon: L.Icon;
  22 + public status: boolean = false;
  23 + ngAfterViewInit() {
  24 +
  25 + }
  26 +
  27 + agInit(params: any): void {
  28 + this.params = params;
  29 + this.icon = L.icon({
  30 + iconUrl: '/assets/icons/marker-icon.png',
  31 + iconSize: [25, 41], // size of the icon
  32 + popupAnchor: [-3, -76], // point from which the popup should open relative to the iconAnchor
  33 + });
  34 + this.map = L.map('mapId').setView([51.505, -0.09], 13);
  35 + L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  36 + maxZoom: 18,
  37 + }).addTo(this.map);
  38 + if(params.value != null){
  39 + this.status = true;
  40 + let options = {
  41 + draggable:true,
  42 + icon: this.icon,
  43 + };
  44 + let latLng = params.value.split(',');
  45 + let marker = L.marker(new L.LatLng(latLng[0],latLng[1]),options);
  46 + marker.on('dragend', this.onDraged.bind(this));
  47 + this.map.addLayer(marker);
  48 + }
  49 + this.data = params.data || [];
  50 + this.map.on('click', this.onMapClick.bind(this));
  51 + console.log(this);
  52 + }
  53 +
  54 + getValue(): any {
  55 + return this.item;
  56 + }
  57 +
  58 + isPopup(): boolean {
  59 + return true;
  60 + }
  61 +
  62 + setValue(item: Object): void {
  63 + this.item = item;
  64 + }
  65 +
  66 + onDraged(e){
  67 + let marker = e.target;
  68 + let position = marker.getLatLng();
  69 + marker.setLatLng(new L.LatLng(position.lat, position.lng),{draggable:true});
  70 + this.item = position.lat +','+ position.lng;
  71 + }
  72 + onClick(item: Object) {
  73 + this.setValue(item);
  74 + this.params.api.stopEditing();
  75 + }
  76 +
  77 + onKeyDown(event): boolean {
  78 + event.stopPropagation();
  79 + return false;
  80 + }
  81 +
  82 + onMapClick(e) {
  83 +
  84 + if(!this.status){
  85 + let options = {
  86 + draggable:true,
  87 + icon: this.icon,
  88 + };
  89 + let marker = L.marker(e.latlng,options);
  90 + this.item = e.latlng.lat +','+ e.latlng.lng;
  91 + this.map.addLayer(marker);
  92 + marker.on('dragend', this.onDraged.bind(this));
  93 + }
  94 + };
  95 +}
src/helpers/map-renderer.component.ts 0 → 100644
  1 +import { Component } from '@angular/core';
  2 +
  3 +import { AgRendererComponent } from 'ag-grid-ng2/main';
  4 +
  5 +import { RegionSelectList } from '../models/region-select-list';
  6 +
  7 +@Component({
  8 + selector: 'render-cell',
  9 + template: `<span *ngIf="this.model !== undefined">{{this.label}}</span>`
  10 +})
  11 +export class MapRendererComponent implements AgRendererComponent {
  12 + private params: any;
  13 + private model: Object = null;
  14 + private label: string = null;
  15 + agInit(params: any): void {
  16 + this.params = params;
  17 + this.setValue(params);
  18 + }
  19 + refresh(params: any): void {
  20 + this.params = params;
  21 + this.setValue(params);
  22 + }
  23 + private setValue(params) {
  24 + this.label = params.value;
  25 + }
  26 +}
src/models/bus-stop.ts
@@ -13,4 +13,5 @@ export class BusStop { @@ -13,4 +13,5 @@ export class BusStop {
13 yearBuild: string; 13 yearBuild: string;
14 yearRepair: string; 14 yearRepair: string;
15 stateCommonId: number; 15 stateCommonId: number;
  16 + position: string;
16 } 17 }
@@ -30,4 +30,13 @@ a[md-icon-button] { @@ -30,4 +30,13 @@ a[md-icon-button] {
30 margin-top: -10px; 30 margin-top: -10px;
31 } 31 }
32 } 32 }
  33 +}
  34 +
  35 +.map-container{
  36 + height: 400px;
  37 + width: 400px;
  38 +}
  39 +#mapId{
  40 + height: 400px;
  41 + width: 400px;
33 } 42 }
34 \ No newline at end of file 43 \ No newline at end of file