Migrating repo

This commit is contained in:
2025-03-03 16:58:25 -06:00
commit 73d70f83d2
33 changed files with 16262 additions and 0 deletions

View File

View File

@@ -0,0 +1 @@
<router-outlet />

View 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
View 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
View 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
View 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}
];

View 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%;
}

File diff suppressed because one or more lines are too long

View 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();
});
});

View 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}`);
}
);
}
}

View 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;
}

View 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>

View 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();
});
});

View 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;
}
}

View 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();
});
});

View 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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.2 MiB

13
src/index.html Normal file
View 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
View 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
View File

@@ -0,0 +1,4 @@
body, html {
margin: 0;
padding: 0;
}