Skip to content

Commit e39d29a

Browse files
committed
Add component for requesting shelter
1 parent 89431e2 commit e39d29a

File tree

9 files changed

+130
-3
lines changed

9 files changed

+130
-3
lines changed

client/src/app/app-routing.module.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { HomeComponent } from './home/home.component';
55
import { LoginComponent } from './login/login.component';
66
import { SheltersComponent } from './shelters/shelters.component';
77
import { AuthGuard } from './_guards/auth.guard';
8+
import { RequestShelterComponent } from './request-shelter/request-shelter.component';
89

910
const routes: Routes = [
1011
{
@@ -41,6 +42,18 @@ const routes: Routes = [
4142
}
4243
}
4344
},
45+
{
46+
path: 'request',
47+
component: RequestShelterComponent,
48+
canActivate: [AuthGuard],
49+
data: {
50+
title: 'Request a Shelter',
51+
metatags: {
52+
desciption: 'Request a Shelter',
53+
keywords: ''
54+
}
55+
}
56+
},
4457
{
4558
path: '',
4659
component: HomeComponent,

client/src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { SheltersComponent } from './shelters/shelters.component';
1818
import { environment } from 'src/environments/environment.prod';
1919
import { AddShelterComponent } from './shelters/add-shelter/add-shelter.component';
2020
import { ShelterCardComponent } from './shelters/shelter-card/shelter-card.component';
21+
import { RequestShelterComponent } from './request-shelter/request-shelter.component';
2122

2223
@NgModule({
2324
declarations: [
@@ -28,7 +29,8 @@ import { ShelterCardComponent } from './shelters/shelter-card/shelter-card.compo
2829
LoginComponent,
2930
SheltersComponent,
3031
AddShelterComponent,
31-
ShelterCardComponent
32+
ShelterCardComponent,
33+
RequestShelterComponent
3234
],
3335
imports: [
3436
BrowserModule,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#map {
22
width: 100%;
33
height: 100vh;
4+
}
5+
6+
.mapboxgl-popup {
7+
max-width: 200px;
8+
}
9+
10+
.mapboxgl-popup-content {
11+
text-align: center;
412
}

client/src/app/home/home.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ export class HomeComponent implements AfterViewInit {
5656
shelterMarkerDiv.style.width = '50px';
5757
shelterMarkerDiv.style.height = '50px';
5858
shelterMarkerDiv.style.backgroundRepeat = 'no-repeat'
59-
59+
6060
const shelter = res[i];
61-
console.log(shelter);
6261

6362
new mapboxgl.Marker(shelterMarkerDiv)
6463
.setLngLat(shelter.lngLat.split(','))
64+
.setPopup(
65+
new mapboxgl.Popup({ offset: 25 }) // add popups
66+
.setHTML('<h3 class="subtitle">' + shelter.name + '</h3><p>' + shelter.contact + '</p>')
67+
)
6568
.addTo(map);
6669
}
6770
},

client/src/app/navbar/navbar.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
</a>
3333
</div>
3434
</div>
35+
<div class="navbar-item" *ngIf="authService.isAuthenticated()">
36+
<div class="buttons">
37+
<a class="button is-outlined is-info" routerLink="request">
38+
<strong>Request a Shelter</strong>
39+
</a>
40+
</div>
41+
</div>
3542
<div class="navbar-item" *ngIf="authService.isAuthenticated()">
3643
<div class="buttons">
3744
<a class="button is-danger" (click)="authService.logout()">
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.request-shelter-container {
2+
display: flex;
3+
min-height: 100vh;
4+
flex-direction: column;
5+
}
6+
7+
#map {
8+
width: 100%;
9+
flex: 1;
10+
}
11+
12+
.mapboxgl-popup {
13+
max-width: 200px;
14+
}
15+
16+
.mapboxgl-popup-content {
17+
text-align: center;
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="request-shelter-container">
2+
<div class="columns has-background-primary is-marginless">
3+
<div class="column">
4+
<div class="container">
5+
<div class="section content">
6+
<h2 class="has-text-white">Locate your position on map</h2>
7+
<button class="button is-info">Clear</button>
8+
</div>
9+
</div>
10+
</div>
11+
</div>
12+
<div id="map"></div>
13+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { RequestShelterComponent } from './request-shelter.component';
4+
5+
describe('RequestShelterComponent', () => {
6+
let component: RequestShelterComponent;
7+
let fixture: ComponentFixture<RequestShelterComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ RequestShelterComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(RequestShelterComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Component, AfterViewInit } from '@angular/core';
2+
import { environment } from 'src/environments/environment';
3+
import * as mapboxgl from 'mapbox-gl';
4+
import * as MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
5+
6+
@Component({
7+
selector: 'app-request-shelter',
8+
templateUrl: './request-shelter.component.html',
9+
styleUrls: ['./request-shelter.component.css']
10+
})
11+
export class RequestShelterComponent implements AfterViewInit {
12+
mapboxAccessToken = environment.mapboxAccessToken;
13+
14+
constructor() { }
15+
16+
ngAfterViewInit() {
17+
Object.getOwnPropertyDescriptor(mapboxgl, "accessToken").set(this.mapboxAccessToken);
18+
19+
var map = new mapboxgl.Map({
20+
container: 'map',
21+
style: 'mapbox://styles/mapbox/navigation-guidance-night-v4',
22+
center: [72.914294, 19.130722],
23+
zoom: 12
24+
});
25+
26+
map.addControl(new mapboxgl.GeolocateControl({
27+
positionOptions: {
28+
enableHighAccuracy: true
29+
},
30+
trackUserLocation: true
31+
}));
32+
33+
map.addControl(new MapboxGeocoder({
34+
accessToken: mapboxgl.accessToken
35+
}));
36+
}
37+
38+
}

0 commit comments

Comments
 (0)