diff --git a/.angular-cli.json b/.angular-cli.json index 1290020..f7b4f9c 100644 --- a/.angular-cli.json +++ b/.angular-cli.json @@ -24,9 +24,10 @@ ], "environmentSource": "environments/environment.ts", "environments": { - "dev": "environments/environment.ts", + "dev": "environments/environment.dev.ts", "prod": "environments/environment.prod.ts", - "local": "environments/environment.local.ts" + "local": "environments/environment.local.ts", + "ci": "environments/environment.ci.ts" } } ], diff --git a/.gitignore b/.gitignore index f82ac9f..67d6c52 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,9 @@ testem.log # local env variable /src/environments/environment.local.ts +/src/environments/environment.prod.ts +/src/environments/environment.dev.ts +/src/environments/environment.ci.ts # ========================= # Operating System Files diff --git a/.travis.yml b/.travis.yml index f262434..22ae810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ addons: language: node_js node_js: - 8 +before_install: + - openssl aes-256-cbc -K $encrypted_9d2af3734b6c_key -iv $encrypted_9d2af3734b6c_iv -in src/environments/environment.ci.ts.enc -out src/environments/environment.ci.ts -d before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start diff --git a/package-lock.json b/package-lock.json index 2c53884..b3325ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,14 @@ { - "name": "coreui-angular", - "version": "1.0.0-alpha.5", + "name": "localloop-web", + "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { + "@agm/core": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@agm/core/-/core-1.0.0-beta.1.tgz", + "integrity": "sha512-IVwQGmcaE42SmYY2e5QwqOC0vrSXZCW8BhATY0Vpy3NjbiydSXi9T81hVqKLvuKaB3ves1sv3W++SB1Wj+5B6A==" + }, "@angular-devkit/build-optimizer": { "version": "0.0.13", "resolved": "https://registry.npmjs.org/@angular-devkit/build-optimizer/-/build-optimizer-0.0.13.tgz", diff --git a/package.json b/package.json index 9c56d35..a6bcc31 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,15 @@ "start": "ng serve", "build": "ng build", "test": "ng test", - "test:once": "ng test --watch=false", + "test:ci": "ng test --watch=false --env=ci", "lint": "ng lint", "e2e": "ng e2e", - "ci": "npm run test:once && npm run e2e" + "e2e:ci": "ng e2e --env=ci", + "ci": "npm run test:ci && npm run e2e:ci" }, "private": true, "dependencies": { + "@agm/core": "^1.0.0-beta.1", "@angular/common": "4.0.3", "@angular/compiler": "4.0.3", "@angular/core": "4.0.3", diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 134d8bd..a8c59b0 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -4,6 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { NgxPaginationModule } from 'ngx-pagination'; +import { AgmCoreModule, GoogleMapsAPIWrapper } from '@agm/core'; import { CurrencyPipe } from '@angular/common'; @@ -14,6 +15,7 @@ import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; import { TransactionLogComponent } from './transaction-log.component'; import { PayrollLogComponent } from './payroll-log.component'; +import { MapComponent } from './map.component'; import { GraphWidget } from '../widgets/graph-widget.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; @@ -25,6 +27,9 @@ import { OrgTableComponent } from '../shared/org-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; +// API key env variable import +import { environment } from '../../environments/environment'; + @NgModule({ imports: [ // Angular imports @@ -32,6 +37,9 @@ import { PayrollResultComponent } from '../shared/payroll-result.component'; FormsModule, ReactiveFormsModule, ChartsModule, + AgmCoreModule.forRoot({ + apiKey: environment.mapApiKey + }), BsDropdownModule, NgxPaginationModule, DashboardRoutingModule, @@ -47,13 +55,15 @@ import { PayrollResultComponent } from '../shared/payroll-result.component'; TransactionResultComponent, PayrollLogComponent, PayrollResultComponent, + MapComponent, FeedbackComponent, GraphWidget, OrgBarSnippetComponent, GraphPanel, ], providers: [ - CurrencyPipe + CurrencyPipe, + GoogleMapsAPIWrapper, ], }) export class DashboardModule { } diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index c36cfb2..f28c65e 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -13,6 +13,7 @@ import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; import { TransactionLogComponent } from './transaction-log.component'; import { PayrollLogComponent } from './payroll-log.component'; +import { MapComponent } from './map.component'; // Using child path to allow for FullLayout theming const routes: Routes = [ @@ -49,6 +50,12 @@ const routes: Routes = [ component: TransactionLogComponent, data: { title: 'Transaction Log' }, }, + { + path: 'map', + component: MapComponent, + data: { title: 'Supplier Map' }, + canActivate: [OrgGuard], + }, { path: 'payroll-log', component: PayrollLogComponent, diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html new file mode 100644 index 0000000..1c408a4 --- /dev/null +++ b/src/app/dashboard/map.component.html @@ -0,0 +1,41 @@ +
+
+
+
+
+ Supplier Map + Required Data marked in bold. +
+
+
+ +
+
+ + + + + + + {{m.name}} + + + +
+
+
+
+
+
diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts new file mode 100644 index 0000000..71faed0 --- /dev/null +++ b/src/app/dashboard/map.component.ts @@ -0,0 +1,66 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import { ApiService } from '../providers/api-service'; +import { AgmCoreModule } from '@agm/core'; +import 'rxjs/add/operator/map'; + +@Component({ + templateUrl: 'map.component.html', +}) +export class MapComponent implements OnInit { + + lat: number = 54.0466; + lng: number = -2.8007; + zoom: number = 12; + + dataReceived: string = 'yes'; + + markers: Array<{latitude: number, longitude: number, name: string}>; + + map: any; + + constructor( + private http: Http, + private api: ApiService, + ) { } + + ngOnInit(): void { } + + public onMapReady(map: any) { + this.map = map; + } + + public viewBoundsChanged() { + console.log("finding bounds"); + const resp = this.map.getBounds(); + console.log("found bounds"); + console.log(resp.getNorthEast().lat()); + console.log(resp.getNorthEast().lng()); + console.log(resp.getSouthWest().lat()); + console.log(resp.getSouthWest().lng()); + const mapData = { + north_east: { + latitude: resp.getNorthEast().lat(), + longitude: resp.getNorthEast().lng() + }, + south_west: { + latitude: resp.getSouthWest().lat(), + longitude: resp.getSouthWest().lng() + }, + } + this.api.getMapData(mapData).subscribe( + result => { + this.dataReceived = 'yes'; + this.markers = result.suppliers; + }, + error => { + // this.dataReceived = 'no'; + console.log('Retrieval Error'); + console.log( error._body ); + } + ); + } + + + +} diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index 17f0b57..4fc7f4c 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -40,6 +40,11 @@ Enter Feedback +