Migrating repo
This commit is contained in:
0
src/app/app.component.css
Normal file
0
src/app/app.component.css
Normal file
1
src/app/app.component.html
Normal file
1
src/app/app.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<router-outlet />
|
||||
29
src/app/app.component.spec.ts
Normal file
29
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have the 'd280-project' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('d280-project');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, d280-project');
|
||||
});
|
||||
});
|
||||
13
src/app/app.component.ts
Normal file
13
src/app/app.component.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {RouterOutlet} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [RouterOutlet],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'd280-project';
|
||||
}
|
||||
13
src/app/app.config.ts
Normal file
13
src/app/app.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { provideHttpClient, HttpClient } from '@angular/common/http';
|
||||
import { routes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
HttpClient
|
||||
]
|
||||
};
|
||||
7
src/app/app.routes.ts
Normal file
7
src/app/app.routes.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { MapViewComponent } from './map-view/map-view.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', redirectTo: '/map', pathMatch: 'full'},
|
||||
{path: 'map', component: MapViewComponent}
|
||||
];
|
||||
14
src/app/interactive-map/interactive-map.component.css
Normal file
14
src/app/interactive-map/interactive-map.component.css
Normal file
@@ -0,0 +1,14 @@
|
||||
svg path {
|
||||
fill: black;
|
||||
transition: fill 0.3s ease;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
svg path:hover {
|
||||
fill: #0099aa;
|
||||
transition: fill 0.3s ease;
|
||||
}
|
||||
|
||||
svg {
|
||||
margin: 5%;
|
||||
}
|
||||
261
src/app/interactive-map/interactive-map.component.html
Normal file
261
src/app/interactive-map/interactive-map.component.html
Normal file
File diff suppressed because one or more lines are too long
23
src/app/interactive-map/interactive-map.component.spec.ts
Normal file
23
src/app/interactive-map/interactive-map.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InteractiveMapComponent } from './interactive-map.component';
|
||||
|
||||
describe('InteractiveMapComponent', () => {
|
||||
let component: InteractiveMapComponent;
|
||||
let fixture: ComponentFixture<InteractiveMapComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [InteractiveMapComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(InteractiveMapComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
43
src/app/interactive-map/interactive-map.component.ts
Normal file
43
src/app/interactive-map/interactive-map.component.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import {Component, EventEmitter, Output} from '@angular/core';
|
||||
import { WorldBankService } from '../world-bank.service';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'interactive-map',
|
||||
imports: [],
|
||||
templateUrl: './interactive-map.component.html',
|
||||
styleUrl: './interactive-map.component.css'
|
||||
})
|
||||
export class InteractiveMapComponent {
|
||||
|
||||
@Output() countryDataUpdated = new EventEmitter<any>();
|
||||
|
||||
selectedId: string = "";
|
||||
countryData: any = null;
|
||||
|
||||
constructor(private http: HttpClient, private worldBankService: WorldBankService) {}
|
||||
|
||||
onMouseOver(event: MouseEvent) {
|
||||
const target = event.target as SVGPathElement;
|
||||
if (target && target.id) {
|
||||
this.selectedId = target.id;
|
||||
this.fetchCountryData(this.selectedId);
|
||||
}
|
||||
|
||||
console.log(`Hovering over: ${this.selectedId}`);
|
||||
}
|
||||
|
||||
fetchCountryData(id: string) {
|
||||
this.worldBankService.getCountryData(id).subscribe(
|
||||
(
|
||||
data) => {
|
||||
this.countryData = data[1][0];
|
||||
this.countryDataUpdated.emit(this.countryData);
|
||||
console.log(this.countryData);
|
||||
},
|
||||
error => {
|
||||
console.error(`Error fetching country data: ${error}`);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
61
src/app/map-view/map-view.component.css
Normal file
61
src/app/map-view/map-view.component.css
Normal file
@@ -0,0 +1,61 @@
|
||||
#content {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#header {
|
||||
width: 100vw;
|
||||
height: 5%;
|
||||
background-color: #006699;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#footer {
|
||||
width: 100vw;
|
||||
height: 3%;
|
||||
background-color: #006699;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
.flex-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#map-container {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
align-content: center
|
||||
}
|
||||
|
||||
#data-container {
|
||||
flex: 0.5;
|
||||
padding: 30px;
|
||||
align-content: center;
|
||||
|
||||
background-color: #006699;
|
||||
}
|
||||
|
||||
#data-container ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#data-container ul li {
|
||||
margin-bottom: 10px;
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
#map-container interactive-map {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
24
src/app/map-view/map-view.component.html
Normal file
24
src/app/map-view/map-view.component.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<div id="content">
|
||||
<div id="header">
|
||||
<h1>Interactive Country Map</h1>
|
||||
</div>
|
||||
|
||||
<div class="flex-container">
|
||||
<div id="map-container">
|
||||
<interactive-map (countryDataUpdated)="onCountryDataUpdated($event)"></interactive-map>
|
||||
</div>
|
||||
|
||||
<div id="data-container">
|
||||
<ul *ngIf="countryData">
|
||||
<li>Country Name: {{ countryData.name }}</li>
|
||||
<li>Country Capital: {{ countryData.capitalCity }}</li>
|
||||
<li>Country Region: {{ countryData.region.value }}</li>
|
||||
<li>Income Level: {{ countryData.incomeLevel.value }}</li>
|
||||
<li>Country Code: {{ countryData.iso2Code }}</li>
|
||||
<li>Latitude and Longitude: {{ countryData.latitude }}, {{ countryData.longitude }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
23
src/app/map-view/map-view.component.spec.ts
Normal file
23
src/app/map-view/map-view.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MapViewComponent } from './map-view.component';
|
||||
|
||||
describe('MapViewComponent', () => {
|
||||
let component: MapViewComponent;
|
||||
let fixture: ComponentFixture<MapViewComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [MapViewComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(MapViewComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
20
src/app/map-view/map-view.component.ts
Normal file
20
src/app/map-view/map-view.component.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {InteractiveMapComponent} from '../interactive-map/interactive-map.component';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-map-view',
|
||||
imports: [
|
||||
InteractiveMapComponent,
|
||||
CommonModule
|
||||
],
|
||||
templateUrl: './map-view.component.html',
|
||||
styleUrls: ['./map-view.component.css']
|
||||
})
|
||||
export class MapViewComponent {
|
||||
countryData: any = null;
|
||||
|
||||
onCountryDataUpdated(data: any) {
|
||||
this.countryData = data;
|
||||
}
|
||||
}
|
||||
16
src/app/world-bank.service.spec.ts
Normal file
16
src/app/world-bank.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorldBankService } from './world-bank.service';
|
||||
|
||||
describe('WorldBankService', () => {
|
||||
let service: WorldBankService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(WorldBankService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
18
src/app/world-bank.service.ts
Normal file
18
src/app/world-bank.service.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class WorldBankService {
|
||||
|
||||
private apiUrl: string = "https://api.worldbank.org/v2/country";
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getCountryData(id: string): Observable<any> {
|
||||
const url = `${this.apiUrl}/${id}?format=json`;
|
||||
return this.http.get(url);
|
||||
}
|
||||
}
|
||||
258
src/assets/mapimage.svg
Normal file
258
src/assets/mapimage.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.2 MiB |
13
src/index.html
Normal file
13
src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>D280Project</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
6
src/main.ts
Normal file
6
src/main.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
||||
4
src/styles.css
Normal file
4
src/styles.css
Normal file
@@ -0,0 +1,4 @@
|
||||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user