Skip to content

Commit 52bd670

Browse files
Dashboard contact map (#368)
* added dashboard contact map * added dashboard map component * fixed lint * added leaflet.fullscreen * updaetd angular.json leaflet.fullscreen * fixes Co-authored-by: constantincrismaruvitagroup <[email protected]>
1 parent f4ee0b7 commit 52bd670

17 files changed

+19406
-91
lines changed

package-lock.json

Lines changed: 19230 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
"@angular/platform-browser-dynamic": "~13.1.1",
3030
"@angular/router": "~13.1.1",
3131
"@asymmetrik/ngx-leaflet": "^8.1.0",
32+
"@bepo65/leaflet.fullscreen": "^2.0.2",
3233
"@ngx-translate/core": "^13.0.0",
3334
"@ngx-translate/http-loader": "^6.0.0",
3435
"alertifyjs": "^1.13.1",
3536
"concurrently": "^5.3.0",
3637
"date-fns": "^2.27.0",
3738
"echarts": "^5.2.2",
3839
"leaflet": "^1.7.1",
40+
"leaflet.fullscreen": "^2.2.0",
3941
"lint-staged": "^10.5.3",
4042
"ng-table-virtual-scroll": "^1.3.5",
4143
"ngx-date-fns": "^8.3.0",

src/app/_constants/common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ export const DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE = {
157157
CONTACT: 'CONTACT',
158158
};
159159

160+
export enum MapType {
161+
Surveillance,
162+
Contacts,
163+
}
164+
160165
export const FacilityCategoryGroups = {
161166
ACCOMMODATION: [
162167
'CAMPSITE',

src/app/dashboard/components/dashboard-case-map/dashboard-case-map.component.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/app/dashboard/components/dashboard-case-map/dashboard-case-map.component.html renamed to src/app/dashboard/components/dashboard-map/dashboard-map.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<section>
22
<header>
3-
<h2>{{ 'strings.headingCaseStatusMap' | translate }}</h2>
3+
<h2>{{ title }}</h2>
44
<app-toggle-view
55
iconViewPrimary="fullscreen_exit_black"
66
iconViewSecondary="fullscreen"

src/app/dashboard/components/dashboard-case-map/dashboard-case-map.component.spec.ts renamed to src/app/dashboard/components/dashboard-map/dashboard-map.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { TranslateModule } from '@ngx-translate/core';
33

4-
import { DashboardCaseMapComponent } from './dashboard-case-map.component';
4+
import { DashboardMapComponent } from './dashboard-map.component';
55

6-
describe('DashboardCaseMapComponent', () => {
7-
let component: DashboardCaseMapComponent;
8-
let fixture: ComponentFixture<DashboardCaseMapComponent>;
6+
describe('DashboardMapComponent', () => {
7+
let component: DashboardMapComponent;
8+
let fixture: ComponentFixture<DashboardMapComponent>;
99

1010
beforeEach(async () => {
1111
await TestBed.configureTestingModule({
12-
declarations: [DashboardCaseMapComponent],
12+
declarations: [DashboardMapComponent],
1313
imports: [TranslateModule.forRoot()],
1414
}).compileComponents();
1515
});
1616

1717
beforeEach(() => {
18-
fixture = TestBed.createComponent(DashboardCaseMapComponent);
18+
fixture = TestBed.createComponent(DashboardMapComponent);
1919
component = fixture.componentInstance;
2020
fixture.detectChanges();
2121
});
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2+
import { latLng, Map, tileLayer } from 'leaflet';
3+
import '@bepo65/leaflet.fullscreen';
4+
import { TranslateService } from '@ngx-translate/core';
5+
import { ViewOptions } from '../../../_models/common';
6+
import { MapType } from '../../../_constants/common';
7+
8+
@Component({
9+
selector: 'app-dashboard-map',
10+
templateUrl: './dashboard-map.component.html',
11+
styleUrls: ['./dashboard-map.component.scss'],
12+
})
13+
export class DashboardMapComponent implements OnInit {
14+
@Output() mapViewUpdate: EventEmitter<ViewOptions> = new EventEmitter();
15+
@Input() mapType: MapType;
16+
17+
map: Map;
18+
initialLat = 51.1657;
19+
initialLong = 10.4515;
20+
initialZoom = 5;
21+
options: any;
22+
title = '';
23+
24+
constructor(public translateService: TranslateService) {}
25+
26+
ngOnInit(): void {
27+
this.options = {
28+
layers: [
29+
tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '' }),
30+
],
31+
zoom: this.initialZoom,
32+
center: latLng(this.initialLat, this.initialLong),
33+
fullscreenControl: true,
34+
fullscreenControlOptions: {
35+
position: 'topleft',
36+
title: this.translateService.instant('viewFullscreen'),
37+
titleCancel: this.translateService.instant('exitFullscreen'),
38+
forceSeparateButton: true,
39+
content:
40+
'<mat-icon id="full-screen-map-btn" class="material-icons-round">fullscreen</mat-icon>',
41+
},
42+
};
43+
this.setMapTitle();
44+
}
45+
46+
onMapReady(map: Map): void {
47+
this.map = map;
48+
49+
this.map.on('enterFullscreen', () => {
50+
// @ts-ignore
51+
document.getElementById('full-screen-map-btn').innerHTML = 'fullscreen_exit_black';
52+
// @ts-ignore
53+
document.getElementById('full-screen-map-btn').classList.add('fullscreen');
54+
});
55+
56+
this.map.on('exitFullscreen', () => {
57+
// @ts-ignore
58+
document.getElementById('full-screen-map-btn').innerHTML = 'fullscreen';
59+
// @ts-ignore
60+
document.getElementById('full-screen-map-btn').classList.remove('fullscreen');
61+
});
62+
}
63+
64+
onLayerUpdate(event: any): void {
65+
// update map based on layer selection
66+
// eslint-disable-next-line no-console
67+
console.log(event);
68+
}
69+
70+
onViewChange(event: ViewOptions): void {
71+
this.mapViewUpdate.emit(event);
72+
73+
setTimeout(() => {
74+
this.map.invalidateSize();
75+
});
76+
}
77+
78+
setMapTitle() {
79+
switch (this.mapType) {
80+
case MapType.Surveillance:
81+
this.title = this.translateService.instant('strings.headingCaseStatusMap');
82+
break;
83+
case MapType.Contacts:
84+
this.title = this.translateService.instant('strings.headingContactMap');
85+
break;
86+
default:
87+
this.title = '';
88+
break;
89+
}
90+
}
91+
}

src/app/dashboard/contacts/contacts.component.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<section class="dashboard-contacts-wrapper" [ngClass]="{'epi-fullscreen': fullscreenEpi}">
1+
<section
2+
class="dashboard-contacts-wrapper"
3+
[ngClass]="{ 'epi-fullscreen': fullscreenEpi, 'map-fullscreen': fullScreenMap }"
4+
>
25
<mat-card class="dashboard-contacts-filters">
36
<app-dashboard-filters></app-dashboard-filters>
47
</mat-card>
@@ -24,7 +27,9 @@
2427
></app-dashboard-epidemiological-curve>
2528
</mat-card>
2629
<mat-card class="dashboard-contacts-map">
27-
<app-dashboard-case-map></app-dashboard-case-map>
30+
<app-dashboard-map [mapType]="MapType.Contacts"
31+
(mapViewUpdate)="onMapViewChange($event)"
32+
></app-dashboard-map>
2833
</mat-card>
2934
<mat-card class="dashboard-transmission-chain">
3035
<app-dashboard-transmission-chain></app-dashboard-transmission-chain>

src/app/dashboard/contacts/contacts.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
'epi_curve epi_curve epi_curve'
1414
}
1515
}
16+
.map-fullscreen {
17+
.dashboard-contacts-contacts, .dashboard-contacts-under-follow-up, .dashboard-contacts-stopped-follow-up,
18+
.dashboard-contacts-visits, .dashboard-contacts-contact-stats, .dashboard-contacts-epi-curve, .dashboard-transmission-chain {
19+
display: none;
20+
}
21+
22+
&.dashboard-contacts-wrapper {
23+
grid-template-columns: 1fr 1fr 1fr;
24+
grid-template-areas:
25+
'filter filter filter'
26+
'map map map'
27+
}
28+
}
1629

1730
.dashboard-contacts-wrapper {
1831
display: grid;

src/app/dashboard/contacts/contacts.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE } from '../../_constants/common';
2+
import { DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE, MapType } from '../../_constants/common';
33
import { VIEW_OPTIONS, ViewOptions } from '../../_models/common';
44

55
@Component({
@@ -10,8 +10,14 @@ import { VIEW_OPTIONS, ViewOptions } from '../../_models/common';
1010
export class ContactsComponent {
1111
dashboardEpidemiologicalCurveType = DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE;
1212
fullscreenEpi = false;
13+
fullScreenMap = false;
14+
MapType = MapType;
1315

1416
onEpiCurveViewChange(event: ViewOptions): void {
1517
this.fullscreenEpi = event === VIEW_OPTIONS.SECONDARY;
1618
}
19+
20+
onMapViewChange(event: ViewOptions): void {
21+
this.fullScreenMap = event === VIEW_OPTIONS.SECONDARY;
22+
}
1723
}

src/app/dashboard/dashboard.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { DashboardNewCasesComponent } from './components/dashboard-new-cases/das
1616
import { DashboardNewEventsComponent } from './components/dashboard-new-events/dashboard-new-events.component';
1717
import { DashboardTestResultsComponent } from './components/dashboard-test-results/dashboard-test-results.component';
1818
import { DashboardEpidemiologicalCurveComponent } from './components/dashboard-epidemiological-curve/dashboard-epidemiological-curve.component';
19-
import { DashboardCaseMapComponent } from './components/dashboard-case-map/dashboard-case-map.component';
2019
import { DashboardContactsComponent } from './components/dashboard-contacts/dashboard-contacts.component';
2120
import { DashboardUnderFollowUpComponent } from './components/dashboard-under-follow-up/dashboard-under-follow-up.component';
2221
import { DashboardStoppedFollowUpComponent } from './components/dashboard-stopped-follow-up/dashboard-stopped-follow-up.component';
@@ -28,6 +27,7 @@ import { MapLegendComponent } from './components/map-legend/map-legend.component
2827
import { MapLayersComponent } from './components/map-layers/map-layers.component';
2928
import { DynamicFormModule } from '../shared/dynamic-form/dynamic-form.module';
3029
import { ProgressBarColor } from '../_directives/progress-bar-color.directive';
30+
import { DashboardMapComponent } from './components/dashboard-map/dashboard-map.component';
3131

3232
@NgModule({
3333
declarations: [
@@ -43,7 +43,6 @@ import { ProgressBarColor } from '../_directives/progress-bar-color.directive';
4343
DashboardNewEventsComponent,
4444
DashboardTestResultsComponent,
4545
DashboardEpidemiologicalCurveComponent,
46-
DashboardCaseMapComponent,
4746
DashboardContactsComponent,
4847
DashboardUnderFollowUpComponent,
4948
DashboardStoppedFollowUpComponent,
@@ -53,6 +52,7 @@ import { ProgressBarColor } from '../_directives/progress-bar-color.directive';
5352
MapLegendComponent,
5453
MapLayersComponent,
5554
ProgressBarColor,
55+
DashboardMapComponent,
5656
],
5757
imports: [
5858
CommonModule,

src/app/dashboard/surveillance/surveillance.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</mat-card>
4141

4242
<mat-card [hidden]="hideMap" class="map">
43-
<app-dashboard-case-map (mapViewUpdate)="onMapViewChange($event)"></app-dashboard-case-map>
43+
<app-dashboard-map [mapType]="MapType.Surveillance" (mapViewUpdate)="onMapViewChange($event)"></app-dashboard-map>
4444
</mat-card>
4545
</div>
4646
</div>

src/app/dashboard/surveillance/surveillance.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component } from '@angular/core';
22
import { ViewOptions, VIEW_OPTIONS } from '../../_models/common';
3-
import { DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE } from '../../_constants/common';
3+
import { DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE, MapType } from '../../_constants/common';
44

55
@Component({
66
selector: 'app-surveillance',
@@ -13,6 +13,7 @@ export class SurveillanceComponent {
1313
hideEpiCurve = false;
1414
hideMap = false;
1515
dashboardEpidemiologicalCurveType = DASHBOARD_EPIDEMIOLOGICAL_CURVE_TYPE;
16+
MapType = MapType;
1617

1718
onMapViewChange(event: ViewOptions): void {
1819
this.hideDiseaseBurden = event === VIEW_OPTIONS.SECONDARY;

src/assets/i18n/custom-translations.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,7 @@
172172
"NotFound.needHelp": "need help?",
173173
"NotFound.contactUs": "Contact Us",
174174
"contactFollowupVisitsView": "Follow-up",
175-
"headingLabMessages": "Lab messages"
175+
"headingLabMessages": "Lab messages",
176+
"viewFullscreen": "View fullscreen",
177+
"exitFullscreen": "Exit fullscreen"
176178
}

0 commit comments

Comments
 (0)