From fe9d3f2720fe559151264b99f23c28c1c2923dab Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Wed, 11 Apr 2018 14:20:06 +0530 Subject: [PATCH] Fixed ng-app accordingly and distribution is building --- core/pom.xml | 61 +++ .../java/org/augur/sense/web/RestServer.java | 26 +- dist/src/main/assembly/default.xml | 14 + dist/src/main/bin/cramp.sh | 47 +- dist/src/main/resources/etc/log4j2.xml | 19 + .../resources/{log4j2.xml => log4j2-dev.xml} | 0 ngapp/.angular-cli.json | 2 +- ngapp/src/app/app.module.ts | 33 +- .../app/heatmaps/heatmap/heatmap.component.ts | 4 +- .../movement-direction.component.html | 2 +- ngapp/src/app/re-id/re-id.component.css | 0 ngapp/src/app/re-id/re-id.component.html | 154 ------ ngapp/src/app/re-id/re-id.component.spec.ts | 25 - ngapp/src/app/re-id/re-id.component.ts | 467 ------------------ .../realtime-info/realtime-info.component.ts | 30 +- .../realtime-map/realtime-map.component.html | 9 +- .../realtime-map/realtime-map.component.ts | 2 +- .../time-line/time-line.component.html | 5 - .../time-line/time-line.component.ts | 16 +- ngapp/src/app/zones/zone/zone.component.ts | 4 +- 20 files changed, 205 insertions(+), 715 deletions(-) create mode 100644 dist/src/main/resources/etc/log4j2.xml rename dist/src/main/resources/{log4j2.xml => log4j2-dev.xml} (100%) delete mode 100644 ngapp/src/app/re-id/re-id.component.css delete mode 100644 ngapp/src/app/re-id/re-id.component.html delete mode 100644 ngapp/src/app/re-id/re-id.component.spec.ts delete mode 100644 ngapp/src/app/re-id/re-id.component.ts diff --git a/core/pom.xml b/core/pom.xml index 109a65ee..b555c313 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -110,4 +110,65 @@ libtensorflow_jni + + + + + maven-antrun-plugin + + + compile + + run + + + + Base: ${project.basedir} + User Dir: ${user.dir} + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + exec-npm-install + generate-sources + + ${project.basedir}/../ngapp + npm + + install + + + + exec + + + + exec-npm-ng-build + generate-sources + + ${project.basedir}/../ngapp + ng + + build + --base-href=./ + --prod + + + + exec + + + + + + + \ No newline at end of file diff --git a/core/src/main/java/org/augur/sense/web/RestServer.java b/core/src/main/java/org/augur/sense/web/RestServer.java index 4361c201..0ef31571 100644 --- a/core/src/main/java/org/augur/sense/web/RestServer.java +++ b/core/src/main/java/org/augur/sense/web/RestServer.java @@ -28,9 +28,6 @@ import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.resource.PathResource; -import org.augur.sense.api.annotations.AutoStart; -import org.augur.sense.api.annotations.Mode; -import org.augur.sense.api.config.Startable; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletContainer; import org.slf4j.Logger; @@ -38,6 +35,7 @@ import java.io.File; import java.io.IOException; +import java.net.URL; import java.nio.file.Path; import java.util.HashSet; import java.util.Set; @@ -98,16 +96,18 @@ private void startRestServer() { ServletHolder servlet = new ServletHolder(servletContainer); context.addServlet(servlet, CONTEXT_PATH); -// DefaultServlet defaultServlet = new DefaultServlet(); -// ServletHolder servletHolder = new ServletHolder("default", defaultServlet); -// URL path = this.getClass().getClassLoader().getResource("ng"); -// try { -// servletHolder.setInitParameter("resourceBase", path.toURI().toASCIIString()); -// } catch (URISyntaxException e) { -// logger.error("Error occurred", e); -// } -// servletHolder.setInitParameter("dirAllowed", "true"); -// context.addServlet(servletHolder, "/"); + /* Adding NG App to a default servlet */ + DefaultServlet defaultServlet = new DefaultServlet(); + ServletHolder servletHolder = new ServletHolder("default", defaultServlet); + servletHolder.setInitParameter("dirAllowed", "true"); + URL path = this.getClass().getClassLoader().getResource("ng"); + try { + servletHolder.setInitParameter("resourceBase", path.toURI().toASCIIString()); + context.addServlet(servletHolder, "/"); + } catch (Exception e) { + logger.error("Error occurred when starting web server", e); + // throw new IllegalStateException("Unable to start web server", e); + } jettyServer.setHandler(context); logger.debug("Starting REST server"); diff --git a/dist/src/main/assembly/default.xml b/dist/src/main/assembly/default.xml index 910d39b8..9517cee6 100644 --- a/dist/src/main/assembly/default.xml +++ b/dist/src/main/assembly/default.xml @@ -37,5 +37,19 @@ 755 + + . + logs + + */** + + + + . + run + + */** + + \ No newline at end of file diff --git a/dist/src/main/bin/cramp.sh b/dist/src/main/bin/cramp.sh index d96049d8..77f5e93e 100644 --- a/dist/src/main/bin/cramp.sh +++ b/dist/src/main/bin/cramp.sh @@ -26,16 +26,45 @@ done LIB_DEPS="${CRAMP_HOME}/etc/log4j2.xml:${LIB_DEPS}" -echo "Starting Accumulator ..." +case "$1" in + start) + echo "Starting CRAMP ..." -$JAVA_HOME/bin/java \ - -cp ${LIB_DEPS} \ - -Ddb.user=${DB_USER} \ - -Ddb.password=${DB_PASSWORD} \ - -Ddb.jdbc.url=${DB_URL} \ - -Dorg.augur.sense.mode=${CRAMP_MODE} \ - org.augur.sense.ui.CHASS "$@" + $JAVA_HOME/bin/java \ + -cp ${LIB_DEPS} \ + -Ddb.user=${DB_USER} \ + -Ddb.password=${DB_PASSWORD} \ + -Ddb.jdbc.url=${DB_URL} \ + -Dorg.augur.sense.mode=${CRAMP_MODE} \ + -Dlog4j.configurationFile=${CRAMP_HOME}/etc/log4j2.xml \ + org.augur.sense.ui.CHASS "$@" & + + echo $! > ${CRAMP_HOME}/run/cramp.pid + echo "STARTED" + sleep 2 + ;; + stop) + echo -n "Shutting down CRAMP" + kill `cat ${CRAMP_HOME}/run/cramp.pid` + rm -f ${CRAMP_HOME}/run/cramp.pid + echo "OK" + ;; + restart) + $0 stop + $0 start + ;; + status) + if [ -e ${CRAMP_HOME}/run/cramp.pid ] ; then + pid=`cat ${CRAMP_HOME}/run/cramp.pid` + echo "CRAMP is running with pid: $pid" + else + echo "CRAMP is not running" + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 +esac -echo "FINISHED" sleep 1 exit 0 \ No newline at end of file diff --git a/dist/src/main/resources/etc/log4j2.xml b/dist/src/main/resources/etc/log4j2.xml new file mode 100644 index 00000000..43b55563 --- /dev/null +++ b/dist/src/main/resources/etc/log4j2.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/dist/src/main/resources/log4j2.xml b/dist/src/main/resources/log4j2-dev.xml similarity index 100% rename from dist/src/main/resources/log4j2.xml rename to dist/src/main/resources/log4j2-dev.xml diff --git a/ngapp/.angular-cli.json b/ngapp/.angular-cli.json index e2351a4f..d7726fee 100644 --- a/ngapp/.angular-cli.json +++ b/ngapp/.angular-cli.json @@ -6,7 +6,7 @@ "apps": [ { "root": "src", - "outDir": "../resources/ng", + "outDir": "../core/src/main/resources/ng", "assets": [ "assets", "favicon.ico" diff --git a/ngapp/src/app/app.module.ts b/ngapp/src/app/app.module.ts index cb527e53..175eda62 100644 --- a/ngapp/src/app/app.module.ts +++ b/ngapp/src/app/app.module.ts @@ -3,12 +3,12 @@ import {FormsModule} from '@angular/forms'; import {HttpClientModule} from '@angular/common/http'; import {BrowserModule} from '@angular/platform-browser'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; -import {CalendarModule, ChartModule, CheckboxModule, RadioButton, SliderModule} from 'primeng/primeng'; +import {CalendarModule, ChartModule, CheckboxModule, RadioButtonModule, SliderModule} from 'primeng/primeng'; -import {AppComponent} from "./app.component"; -import {AppRoutingModule} from "./app-routing.module"; -import {DashboardComponent} from "./dashboard/dashboard.component"; -import {HeatmapsComponent} from "./heatmaps/heatmaps.component"; +import {AppComponent} from './app.component'; +import {AppRoutingModule} from './app-routing.module'; +import {DashboardComponent} from './dashboard/dashboard.component'; +import {HeatmapsComponent} from './heatmaps/heatmaps.component'; import {PeopleCountComponent} from './people-count/people-count.component'; import {PointMappingComponent} from './settings/point-mapping/point-mapping.component'; import {ZonesComponent} from './zones/zones.component'; @@ -16,14 +16,13 @@ import {ZoneInfoComponent} from './zones/zone-info/zone-info.component'; import {RealtimeMapComponent} from './realtime-map/realtime-map.component'; import {RealtimeInfoComponent} from './realtime-info/realtime-info.component'; import {TimeBoundMapComponent} from './time-bound-map/time-bound-map.component'; -import {PersonStopPointsComponent} from "./person-stop-points/person-stop-points.component"; -import {ReIdComponent} from './re-id/re-id.component'; +import {PersonStopPointsComponent} from './person-stop-points/person-stop-points.component'; import {TimelineComponent} from './timeline/timeline.component'; import {TimeVelocityDistributionComponent} from './time-velocity-distribution/time-velocity-distribution.component'; import {DirectionRingComponent} from './direction-ring/direction-ring.component'; import {MovementDirectionComponent} from './movement-direction/movement-direction.component'; -import {AnalyticsService} from "./services/analytics.service"; -import {ConfigService} from "./services/config.service"; +import {AnalyticsService} from './services/analytics.service'; +import {ConfigService} from './services/config.service'; import { MatButtonModule, @@ -44,9 +43,10 @@ import {ConfigComponent} from './settings/config/config.component'; import {ZonesConfigInfoComponent} from './settings/zones-config/zones-config-info/zones-config-info.component'; import {SuccessMessageComponent} from './helpers/success-message/success-message.component'; import {ZoneUiComponent} from './settings/zones-config/zone-ui/zone-ui.component'; -import {ZoneComponent} from "./zones/zone/zone.component"; -import {HeatmapComponent} from "./heatmaps/heatmap/heatmap.component"; -import {TimeLineComponent} from "./time-bound-map/time-line/time-line.component"; +import {ZoneComponent} from './zones/zone/zone.component'; +import {HeatmapComponent} from './heatmaps/heatmap/heatmap.component'; +import {TimeLineComponent} from './time-bound-map/time-line/time-line.component'; +import {HashLocationStrategy, LocationStrategy} from '@angular/common'; @NgModule({ @@ -68,12 +68,10 @@ import {TimeLineComponent} from "./time-bound-map/time-line/time-line.component" TimeBoundMapComponent, TimeLineComponent, PersonStopPointsComponent, - ReIdComponent, TimelineComponent, TimeVelocityDistributionComponent, DirectionRingComponent, MovementDirectionComponent, - RadioButton, ZonesConfigComponent, ConfigComponent, ZonesConfigInfoComponent, @@ -91,6 +89,7 @@ import {TimeLineComponent} from "./time-bound-map/time-line/time-line.component" ChartModule, SliderModule, MatMenuModule, + RadioButtonModule, MatSidenavModule, MatButtonModule, MatToolbarModule, @@ -103,7 +102,11 @@ import {TimeLineComponent} from "./time-bound-map/time-line/time-line.component" MatChipsModule, MatSliderModule ], - providers: [AnalyticsService, ConfigService], + providers: [ + AnalyticsService, + ConfigService, + {provide: LocationStrategy, useClass: HashLocationStrategy} + ], bootstrap: [AppComponent] }) diff --git a/ngapp/src/app/heatmaps/heatmap/heatmap.component.ts b/ngapp/src/app/heatmaps/heatmap/heatmap.component.ts index 9e2922da..c89bbf30 100644 --- a/ngapp/src/app/heatmaps/heatmap/heatmap.component.ts +++ b/ngapp/src/app/heatmaps/heatmap/heatmap.component.ts @@ -134,11 +134,11 @@ export class HeatmapComponent implements OnInit, OnDestroy { this.generateHeatMap(); } - private get from(): number { + get from(): number { return this.secondRange[0]; } - private get to(): number { + get to(): number { return this.secondRange[1]; } diff --git a/ngapp/src/app/movement-direction/movement-direction.component.html b/ngapp/src/app/movement-direction/movement-direction.component.html index 8ab70bd2..5fc7c829 100644 --- a/ngapp/src/app/movement-direction/movement-direction.component.html +++ b/ngapp/src/app/movement-direction/movement-direction.component.html @@ -53,7 +53,7 @@

Movement Direction Map

-
+

Frequency

diff --git a/ngapp/src/app/re-id/re-id.component.css b/ngapp/src/app/re-id/re-id.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/ngapp/src/app/re-id/re-id.component.html b/ngapp/src/app/re-id/re-id.component.html deleted file mode 100644 index da2c1fb1..00000000 --- a/ngapp/src/app/re-id/re-id.component.html +++ /dev/null @@ -1,154 +0,0 @@ -
- -
-
-
{{ getDateString(person.timestamp) }}
-
-
- -
- -
- -
- -
-
-
Search
-
-
- - -
-
- - -
- Click search to trigger re-identification system. - -
-
- -
- -
-
- Searching... -
-
-
-
-
-
{{ getDateString(matchedPerson.timestamp) }}
- -
- -
-
- - -
-
-
{{ getDateString(matchedPerson.timestamp) }}
- -
- -
- -
-
- - -
-
- -
- -
- - - - -
- - - - - -
-
-
-
-
-

Selection Count: {{personSnapshots.length}} - - -

-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
-
-
-
- Timeline -
-
- -
-
- -
-
- - - - - - -
diff --git a/ngapp/src/app/re-id/re-id.component.spec.ts b/ngapp/src/app/re-id/re-id.component.spec.ts deleted file mode 100644 index 58fe0f1c..00000000 --- a/ngapp/src/app/re-id/re-id.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ReIdComponent } from './re-id.component'; - -describe('ReIdComponent', () => { - let component: ReIdComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ReIdComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ReIdComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/ngapp/src/app/re-id/re-id.component.ts b/ngapp/src/app/re-id/re-id.component.ts deleted file mode 100644 index 56d51fb3..00000000 --- a/ngapp/src/app/re-id/re-id.component.ts +++ /dev/null @@ -1,467 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute, Params} from '@angular/router'; -import {AnalyticsService} from "../services/analytics.service"; -import {ConfigService} from "../services/config.service"; -import {PersonSnapshot} from "../resources/person-snapshot"; -import {PersonImage} from "../resources/person-image"; -import {Observable} from "rxjs/Observable"; -import {GlobalMap} from "../resources/global-map"; -import {TimelineTrack} from "../resources/timeline-track"; - -@Component({ - selector: 'app-re-id', - templateUrl: './re-id.component.html', - styleUrls: ['./re-id.component.css'] -}) -export class ReIdComponent implements OnInit { - get selectedSegmentIndex(): number { - return this._selectedSegmentIndex; - } - - set selectedSegmentIndex(value: number) { - this._selectedSegmentIndex = value; - } - - get selectedTrackIndex(): number { - return this._selectedTrackIndex; - } - - set selectedTrackIndex(value: number) { - this._selectedTrackIndex = value; - } - - get useTrackSegments(): boolean { - return this._useTrackSegments; - } - - - set useTrackSegments(value: boolean) { - this._useTrackSegments = value; - this.selectedIndices.length = 0; - this.timelineTracks.length = 0; - this.updateMapTracks(); - this.loadMainTimeline(); - } - - globalMap: GlobalMap; - - private _useTrackSegments: boolean = true; - private _selectedTrackIndex: number = -1; - private _selectedSegmentIndex: number = -1; - - personSnapshots: PersonSnapshot[][] = []; - currentPersonSnapshots: PersonSnapshot[] = []; - - private mainTimeline: TimelineTrack = null; - - - private isSelected(p: PersonSnapshot): boolean { - if (p.ids.length == 0) - return false; - - if (!this.useTrackSegments) { - return p.ids[0] == this.selectedTrackIndex; - } - else { - return p.ids[0] == this.selectedTrackIndex && p.trackSegmentIndex == this.selectedSegmentIndex; - } - } - - - private getColour(index: number): string { - return "rgb(" + Math.round(((index / 256 / 256) * 40) % 256).toString() + "," + Math.round(((index / 256) * 40) % 256).toString() + "," + Math.round((index * 40) % 256).toString() + ")"; - } - - private getStandSitColour(person: PersonSnapshot): string { - const standCol = Math.round(person.standProbability * 255); - const sitCol = Math.round(person.sitProbability * 255); - - return "rgb(" + standCol.toString() + ", " + sitCol.toString() + ",255 )"; - } - - private backgroundClicked(): void { - this.selectedTrackIndex = -1; - } - - private trackClicked(track: PersonSnapshot[]): void { - if (track[0].ids.length > 0) - this.selectedTrackIndex = track[0].ids[0]; - console.log("Track clicked" + track[0].ids[0].toString()); - console.log(track); - } - - get selectedIndices(): number[][] { - return this._selectedIndices; - } - - set selectedIndices(value: number[][]) { - this._selectedIndices = value; - } - - get matchedPersons(): PersonImage[] { - return this._matchedPersons; - } - - get startTime(): Date { - return this._startTime; - } - - set startTime(value: Date) { - this._startTime = value; - } - - get endTime(): Date { - return this._endTime; - } - - set endTime(value: Date) { - this._endTime = value; - } - - _uuid: string; - - private _matchedPersons: PersonImage[] = null; - - set matchedPersons(value: PersonImage[]) { - this._matchedPersons = value; - } - - private _startTime: Date = new Date(0); - private _endTime: Date = new Date(); - - _person: PersonImage; - - private _selectedIndices: number[][] = []; - - toggleSelection(p: PersonSnapshot): void { - if (this.useTrackSegments) { - if (this.selectedIndices.filter((v) => v[0] == p.ids[0] && v[1] == p.trackSegmentIndex).length > 0) { - let i = this.selectedIndices.indexOf(this.selectedIndices.filter((v) => v[0] == p.ids[0] && v[1] == p.trackSegmentIndex)[0]); - this.selectedIndices.splice(i, 1); - - this.personSnapshots.filter((t) => t[0].ids[0] == p.ids[0] && t[0].trackSegmentIndex == p.trackSegmentIndex).forEach((t) => { - let i2 = this.personSnapshots.indexOf(t); - this.personSnapshots.splice(i2, 1); - }); - - this.timelineTracks.filter((t) => t.person.ids[0] == p.ids[0] && t.person.trackSegmentIndex == p.trackSegmentIndex).forEach((t) => { - if (this.mainTimeline == t) - return; - let i2 = this.timelineTracks.indexOf(t); - this.timelineTracks.splice(i2, 1); - this.timelineTracksUI = this.timelineTracks.slice(0); - console.log("Spliced"); - }); - - - } - else { - this.selectedIndices.push([p.ids[0], p.trackSegmentIndex]); - this.addMapTrack(p); - this.addTimeline(p); - } - } - else { - if (this.selectedIndices.filter((v) => v[0] == p.ids[0]).length > 0) { - let i = this.selectedIndices.indexOf(this.selectedIndices.filter((v) => v[0] == p.ids[0])[0]); - this.selectedIndices.splice(i, 1); - this.personSnapshots.filter((t) => t[0].ids[0] == p.ids[0]).forEach((t) => { - let i2 = this.personSnapshots.indexOf(t); - this.personSnapshots.splice(i2, 1); - }); - - this.timelineTracks.filter((t) => t.person.ids[0] == p.ids[0]).forEach((t) => { - if (this.mainTimeline == t) - return; - let i2 = this.timelineTracks.indexOf(t); - this.timelineTracks.splice(i2, 1); - this.timelineTracksUI = this.timelineTracks.slice(0); - console.log("Spliced-NonSegment"); - }); - this.loadMainTimeline(); - } - else { - this.selectedIndices.push([p.ids[0], p.trackSegmentIndex]); - this.addMapTrack(p); - this.addTimeline(p); - } - } - - } - - get uuid(): string { - return this._uuid; - } - - get person(): PersonImage { - return this._person; - } - - set uuid(value: string) { - this._uuid = value; - this.updateProfile(); - } - - getDateString(timestamp: number) { - return new Date(timestamp).toLocaleString(); - } - - updateProfile(): void { - this.analyticsService.getProfile(this.uuid) - .then(person => { - this._person = person; - - console.log(this._person); - - this.loadMainTimeline(); - - //this.drawOnCanvas(personSnapshots); - }) - .catch(reason => console.log(reason)); - - this.updateMapTracks(); - - } - - updateMapTracks(): void { - console.debug("Loading target track history"); - this.analyticsService.getTrackFromUUID(this.startTime.getTime(), this.endTime.getTime(), this.uuid, this.useTrackSegments) - .then(ps => { - - console.debug("target track history loaded"); - this.currentPersonSnapshots = ps; - ps[0]["colour"] = this.getColour(ps[0].ids[0]); - ps[0]["standSitColour"] = this.getStandSitColour(ps[0]); - - console.log(ps); - - - //this.drawOnCanvas(personSnapshots); - }) - .catch(reason => console.log(reason)); - - let clonePersons = this.personSnapshots.splice(0); - this.personSnapshots.length = 0; - clonePersons.forEach((clone_person) => { - this.addMapTrack(clone_person[0]); - }); - - } - - timelineTracks: TimelineTrack[] = []; - - timelineTracksUI: TimelineTrack[] = []; - - private searchInvoked: boolean = false; - - // loadedTimelineTracks: TimelineTrack[] = [ - // { - // label: "Person1", - // person: null, - // timelineZones:[ - // { - // zoneId: 1, - // startTime: 100, - // endTime: 200, - // zoneName: "bottom", - // person: null, - // colour: "red" - // }, - // { - // zoneId: 2, - // startTime: 200, - // endTime: 220, - // zoneName: "center", - // person: null, - // colour: "green" - // } - // ] - // }, - // { - // trackName: "Person2", - // person: null, - // timelineZones:[ - // { - // zoneId: 1, - // startTime: 50, - // endTime: 200, - // zoneName: "left", - // person: null, - // colour: "blue" - // }, - // { - // zoneId: 2, - // startTime: 250, - // endTime: 350, - // zoneName: "right", - // person: null, - // colour: "yellow" - // } - // ] - // }, - // { - // trackName: "Person3", - // person: null, - // timelineZones:[ - // { - // zoneId: 1, - // startTime: 0, - // endTime: 100, - // zoneName: "in", - // person: null, - // colour: "orange" - // }, - // { - // zoneId: 2, - // startTime: 150, - // endTime: 350, - // zoneName: "out", - // person: null, - // colour: "purple" - // } - // ] - // } - // ]; - - private startResultsLoop(): void { - Observable.interval(2000).subscribe(x => { - if (this.searchInvoked) { - console.debug("Loading search results..."); - this.getReIdResults(); - } - - }); - } - - constructor(private activatedRoute: ActivatedRoute, private analyticsService: AnalyticsService, private configService: ConfigService) { - } - - ngOnInit() { - // subscribe to router event - this.activatedRoute.params.subscribe((params: Params) => { - this.uuid = params['id']; - console.log(this.uuid); - }); - - this.configService.getMap().then((globalMap) => { - this.globalMap = globalMap; - console.log(this.globalMap); - }); - - this.startResultsLoop(); - - - } - - loadedMainTimelineId: number = -1; - loadedMainTimelineSegment: number = -1; - loadedSegmented: boolean; - - loadMainTimeline(): void { - if (this.loadedMainTimelineId == this.person.ids[0] && this.loadedMainTimelineSegment == this.person.trackSegmentIndex && this.loadedSegmented == this.useTrackSegments) - return; - - if (this.timelineTracks.includes(this.mainTimeline)) { - return; - } - - console.log("Loading main timeline"); - this.analyticsService.getTimelineFromTrack(this.person.ids[0], this.person.trackSegmentIndex, this.useTrackSegments).then(result => { - this.mainTimeline = result; - this.mainTimeline.label = "Probe"; - console.log("Main timeline:"); - console.log(result); - this.loadedMainTimelineId = this.person.ids[0]; - this.loadedMainTimelineSegment = this.person.trackSegmentIndex; - this.loadedSegmented = this.useTrackSegments; - this.timelineTracks = [this.mainTimeline].concat(this.timelineTracks); - this.timelineTracksUI = this.timelineTracks.slice(0); - }); - } - - - triggerReId(): void { - this.analyticsService.invokeReId(this.uuid, this.startTime.getTime(), this.endTime.getTime(), this.useTrackSegments).then(result => { - if (result) { - console.log("Re-id invoked"); - this.searchInvoked = true; - } - else { - console.log("Re-id invoke failed"); - } - }); - } - - getReIdResults(): void { - this.analyticsService.getReIdResults(this.uuid, this.startTime.getTime(), this.endTime.getTime(), this.useTrackSegments).then(result => { - if (result.completed) { - console.log("RE_ID_Results"); - console.log(result.results); - this.matchedPersons = result.results; - - this.matchedPersons.forEach((v) => { - v["colour"] = this.getColour(v.ids[0]); - }); - - console.log("Completed"); - this.searchInvoked = false; - - } - else { - console.log(result); - } - }); - } - - isImageSelected(matchedPerson: PersonImage): boolean { - if (this.useTrackSegments) { - if (this.selectedIndices.filter((v) => matchedPerson.ids.includes(v[0]) && matchedPerson.trackSegmentIndex == v[1]).length > 0) { - return true; - } - } - else { - if (this.selectedIndices.filter((v) => matchedPerson.ids.includes(v[0])).length > 0) { - return true; - } - } - return false; - } - - private addTimeline(p: PersonSnapshot): void { - console.debug("Loading timeline for"); - console.debug(p); - this.analyticsService.getTimelineFromTrack(p.ids[0], p.trackSegmentIndex, this.useTrackSegments).then(result => { - if (result.person == null) { - console.debug("Received no person"); - return; - } - - if (this.selectedIndices.filter((v) => (this.useTrackSegments && v[0] == result.person.ids[0] && v[1] == result.person.trackSegmentIndex) || (!this.useTrackSegments && v[0] == result.person.ids[0])).length > 0) { - this.timelineTracks.push(result); - this.timelineTracksUI = this.timelineTracks.slice(0); - console.log("Timeline Tracks:"); - console.log(this.timelineTracks); - } - }).catch(reason => console.error(reason)); - } - - - private addMapTrack(p: PersonSnapshot) { - console.debug("Requesting track for"); - console.debug(p); - - this.analyticsService.getTrackFromUUID(this.startTime.getTime(), this.endTime.getTime(), p.uuid, this.useTrackSegments) - .then(ps => { - if (this.selectedIndices.filter((v) => (this.useTrackSegments && v[0] == ps[0].ids[0] && v[1] == ps[0].trackSegmentIndex) || (!this.useTrackSegments && v[0] == ps[0].ids[0])).length > 0) { - this.personSnapshots.push(ps); - ps[0]["colour"] = this.getColour(ps[0].ids[0]); - ps[0]["standSitColour"] = this.getStandSitColour(ps[0]); - - console.log(this.personSnapshots); - } - - //this.drawOnCanvas(personSnapshots); - }) - .catch(reason => console.log(reason)); - } -} diff --git a/ngapp/src/app/realtime-info/realtime-info.component.ts b/ngapp/src/app/realtime-info/realtime-info.component.ts index 51cdb440..d565ac36 100644 --- a/ngapp/src/app/realtime-info/realtime-info.component.ts +++ b/ngapp/src/app/realtime-info/realtime-info.component.ts @@ -17,7 +17,7 @@ export class RealtimeInfoComponent implements OnInit { @Input() private useRealtimeEndpoint = true; - private personImages: PersonImage[] = null; + private _personImages: PersonImage[] = null; private _from = 0; private _to = 0; @@ -89,7 +89,7 @@ export class RealtimeInfoComponent implements OnInit { @Input() set showAll(value: boolean) { this._showAll = value; - this.personImages = null; + this._personImages = null; this.refresh(); } @@ -104,7 +104,7 @@ export class RealtimeInfoComponent implements OnInit { @Input() set id(value: number) { this._id = value; console.log('id' + value.toString()); - this.personImages = null; + this._personImages = null; this.refresh(); } @@ -114,7 +114,7 @@ export class RealtimeInfoComponent implements OnInit { if (this.useRealtimeEndpoint) { if (!this.showAll) { if (this.id < 0) { - this.personImages = null; + this._personImages = null; return; } else { this.analyticsService.getRealtimeInfo(this.id).then((pi) => { @@ -122,7 +122,7 @@ export class RealtimeInfoComponent implements OnInit { return; } - this.personImages = pi; + this._personImages = pi; console.log(pi); }); } @@ -133,7 +133,7 @@ export class RealtimeInfoComponent implements OnInit { return; } - this.personImages = pi; + this._personImages = pi; console.log(pi); }); } @@ -141,7 +141,7 @@ export class RealtimeInfoComponent implements OnInit { } else { if (!this.showAll) { if (this.id < 0) { - this.personImages = null; + this._personImages = null; console.log('cleared'); return; } else { @@ -150,7 +150,7 @@ export class RealtimeInfoComponent implements OnInit { return; } console.log('fetched ' + this.id); - this.personImages = pi; + this._personImages = pi; console.log(pi); }); } @@ -161,18 +161,22 @@ export class RealtimeInfoComponent implements OnInit { return; } - this.personImages = pi; + this._personImages = pi; console.log(pi); }); } - - } - - } getDateString(timestamp: number) { return new Date(timestamp).toLocaleString(); } + + get personImages(): PersonImage[] { + return this._personImages; + } + + set personImages(value: PersonImage[]) { + this._personImages = value; + } } diff --git a/ngapp/src/app/realtime-map/realtime-map.component.html b/ngapp/src/app/realtime-map/realtime-map.component.html index a418bb54..21c0461b 100644 --- a/ngapp/src/app/realtime-map/realtime-map.component.html +++ b/ngapp/src/app/realtime-map/realtime-map.component.html @@ -55,9 +55,12 @@

{{cameraGroup.name}}

- + +
diff --git a/ngapp/src/app/realtime-map/realtime-map.component.ts b/ngapp/src/app/realtime-map/realtime-map.component.ts index 512f30df..bf6d8909 100644 --- a/ngapp/src/app/realtime-map/realtime-map.component.ts +++ b/ngapp/src/app/realtime-map/realtime-map.component.ts @@ -48,7 +48,7 @@ export class RealtimeMapComponent implements OnInit, OnDestroy { console.log('Person clicked' + person.id.toString()); } - private backgroundClicked(): void { + backgroundClicked(): void { this.selectedTrackIndex = -1; this.showAllInInfo = true; } diff --git a/ngapp/src/app/time-bound-map/time-line/time-line.component.html b/ngapp/src/app/time-bound-map/time-line/time-line.component.html index fe0cc25d..eed26ae3 100644 --- a/ngapp/src/app/time-bound-map/time-line/time-line.component.html +++ b/ngapp/src/app/time-bound-map/time-line/time-line.component.html @@ -17,11 +17,6 @@

-
- -
diff --git a/ngapp/src/app/time-bound-map/time-line/time-line.component.ts b/ngapp/src/app/time-bound-map/time-line/time-line.component.ts index 9042c6c3..58a9344a 100644 --- a/ngapp/src/app/time-bound-map/time-line/time-line.component.ts +++ b/ngapp/src/app/time-bound-map/time-line/time-line.component.ts @@ -13,7 +13,7 @@ export class TimeLineComponent implements OnInit { private _startTime: Date; private _endTime: Date; private _secondRange: number[] = [0, 60]; - private personSnapshots: PersonSnapshot[][] = []; + private _personSnapshots: PersonSnapshot[][] = []; private _cameraGroup: CameraGroup; private _selectedTrackIndex = -1; @@ -76,14 +76,14 @@ export class TimeLineComponent implements OnInit { return 'rgb(' + standCol.toString() + ', ' + sitCol.toString() + ',255 )'; } - private get from(): number { + get from(): number { if (this.startTime == null || this.secondRange[0] == null) { return null; } return this.startTime.getTime() + this.secondRange[0] * 1000; } - private get to(): number { + get to(): number { if (this.endTime == null || this.secondRange[1] == null) { return null; } @@ -117,7 +117,7 @@ export class TimeLineComponent implements OnInit { this.analyticsService.getTimeboundMap(this.cameraGroup.id, this.from, this.to) .then(ps => { - this.personSnapshots = ps; + this._personSnapshots = ps; console.log('Snaps', ps[0]); ps.forEach((item) => { item.reverse(); @@ -146,4 +146,12 @@ export class TimeLineComponent implements OnInit { this._cameraGroup = value; this.refresh(); } + + get personSnapshots(): PersonSnapshot[][] { + return this._personSnapshots; + } + + set personSnapshots(value: PersonSnapshot[][]) { + this._personSnapshots = value; + } } diff --git a/ngapp/src/app/zones/zone/zone.component.ts b/ngapp/src/app/zones/zone/zone.component.ts index 7ea1e493..82afd669 100644 --- a/ngapp/src/app/zones/zone/zone.component.ts +++ b/ngapp/src/app/zones/zone/zone.component.ts @@ -60,11 +60,11 @@ export class ZoneComponent implements OnInit, OnDestroy { }); } - private zoneClicked(index: number): void { + zoneClicked(index: number): void { this.selectedZoneIndex = index; } - private backgroundClicked() { + backgroundClicked() { this.selectedZoneIndex = -1; console.log('Unselected');