Skip to content

Commit

Permalink
Merge pull request #98 from paulmojicatech/video-2-start
Browse files Browse the repository at this point in the history
Video 2 start
  • Loading branch information
paulmojicatech authored Jul 9, 2023
2 parents de06a4c + ed18060 commit 4d98bb9
Show file tree
Hide file tree
Showing 21 changed files with 808 additions and 314 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ libs/fantalytic-web-scraper/env.ts
libs/fantalytic-web-scraper/package-lock.json
libs/fantalytic-web-scraper/output/*
apps/fantalytic-public/src/assets/stats/*
apps/fantalytic-api/local.settings.json
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@
"env": {
"NODE_TLS_REJECT_UNAUTHORIZED": "0"
}
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/apps/fantalytic-api/bin/Debug/net6.0/Pmt.FantalyticApi.dll",
"args": [],
"cwd": "${workspaceFolder}/apps/fantalytic-api",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/apps/fantalytic-api/Pmt.FantalyticApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/apps/fantalytic-api/Pmt.FantalyticApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/apps/fantalytic-api/Pmt.FantalyticApi.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
35 changes: 35 additions & 0 deletions apps/fantalytic-api/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/Pmt.FantalyticApi.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions apps/fantalytic-api/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Pmt.FantalyticApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Pmt.FantalyticApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Pmt.FantalyticApi.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ export class FfaRssFeedService extends EspnRssFeedService {
}

protected override parseRssItemResponse(item: Element): Topic {
const title = item.getElementsByTagName('title')[0].textContent ?? '';
const description =
item
.getElementsByTagName('description')[0]
.firstChild?.textContent?.replace('<p>', '')
.replace('</p>', '') ?? '';
const link =
item.getElementsByTagName('link')[0].firstChild?.textContent ?? '';
const publishedDate =
item.getElementsByTagName('pubDate')[0].textContent ?? '';
const topic = { title, description, publishedDate, link };
return topic;

}
}
3 changes: 2 additions & 1 deletion apps/fantalytic-ssr/src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ApplicationConfig } from '@angular/core';
import { provideClientHydration } from '@angular/platform-browser';
import { provideFileRouter } from '@analogjs/router';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
providers: [provideFileRouter(), provideClientHydration(), provideHttpClient()],
providers: [provideFileRouter(), provideClientHydration(), provideHttpClient(), provideAnimations()],
};
16 changes: 16 additions & 0 deletions apps/fantalytic-ssr/src/app/pages/fantasy-football.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { ToolbarComponent } from '../shared/components/toolbar/toolbar.component';

@Component({
standalone: true,
imports: [ToolbarComponent],
template: `
<pmt-toolbar></pmt-toolbar>
<main>
Test Page
</main>
`
})
export default class FantasyFootballPageComponent {

}
47 changes: 38 additions & 9 deletions apps/fantalytic-ssr/src/app/pages/index.page.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import { AsyncPipe, DatePipe, NgFor, NgIf } from '@angular/common';
import { Component, inject } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
import { ToolbarComponent } from '../shared/components/toolbar/toolbar.component';
import { EspnRssFeedService } from '../topics/services/espn-rss-feed.service';
import { MatToolbarModule } from '@angular/material/toolbar';
import {MatCardModule} from '@angular/material/card';
import { FfaRssFeedService } from '../topics/services/ffa-rss-feed.service';
import { FootballersRssService } from '../topics/services/footballers-rss.service';

@Component({
selector: 'fantalytic-ssr-home',
standalone: true,
imports: [AsyncPipe, NgFor, DatePipe, NgIf, MatToolbarModule, MatCardModule],
imports: [AsyncPipe, NgFor, DatePipe, NgIf, ToolbarComponent, MatCardModule],
host: {
class:
'flex min-h-screen flex-col text-zinc-900 bg-zinc-50 w-[100vw]',
},
template: `
<mat-toolbar color="primary">
<span class="text-white">Fantalytic.io</span>
</mat-toolbar>
<main class="p-0 w-[100vw] flex flex-wrap">
<div *ngFor="let topic of topics$ | async" class="w-[30%] m-2">
<pmt-toolbar></pmt-toolbar>
<main class="p-0 w-[100vw] flex flex-wrap">
<div class="inline-flex m-2 w-full">
<label class="mr-2">RSS Feeds:</label>
<select (change)="handleRssFeedChange($event.target)">
<option *ngFor="let rssFeed of RSS_FEEDS" value="{{rssFeed}}">{{rssFeed}}</option>
</select>
</div>
<div *ngFor="let topic of topics$ | async" class="w-full lg:w-[30%] m-2">
<mat-card class="h-full">
<mat-card-header>
<mat-card-title>
{{topic.title}}
</mat-card-title>
</mat-card-header>
<mat-card-content>
<img mat-card-image src="{{topic.imageUrl}}" alt="ESPN Image" />
<img *ngIf="topic.imageUrl" mat-card-image src="{{topic.imageUrl}}" alt="Image" />
<div class="mt-2">{{topic.description}}</div>
</mat-card-content>
<mat-card-actions>
Expand All @@ -41,5 +47,28 @@ import {MatCardModule} from '@angular/material/card';
})
export default class HomeComponent {
private _espnRssFeedSvc = inject(EspnRssFeedService);
private _ffaRssFeedSvc = inject(FfaRssFeedService);
private _footballersRssFeedSvc = inject(FootballersRssService);
readonly RSS_FEEDS = ['ESPN', 'Footballers'];


topics$ = this._espnRssFeedSvc.getTopics();

handleRssFeedChange(ev: EventTarget | null): void {
const rssFeed = (ev as HTMLSelectElement).value;
switch (rssFeed) {
case 'ESPN':
this.topics$ = this._espnRssFeedSvc.getTopics();
break;
case 'FFA':
this.topics$ = this._ffaRssFeedSvc.getTopics();
break;
case 'Footballers':
this.topics$ = this._footballersRssFeedSvc.getTopics();
break;
default:
break;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<mat-toolbar color="primary">
<div class="inline-flex justify-between w-full">
<span class="text-white">Fantalytic.io</span>
<button mat-button [matMenuTriggerFor]="menu">
<div class="flex-col h-full justify-around">
<div class="w-[2rem] text-white border-b-2 mb-2"></div>
<div class="w-[2rem] text-white border-b-2 mb-2"></div>
<div class="w-[2rem] text-white border-b-2 mb-2"></div>
</div>

</button>
<mat-menu #menu="matMenu">
<ul>
<li class="p-2">
<button routerLink="/">Topics</button>
</li>
<li class="p-2">
<button routerLink="/fantasy-football">Fantasy Football</button>
</li>
</ul>
</mat-menu>
</div>

</mat-toolbar>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ToolbarComponent } from './toolbar.component';

describe('ToolbarComponent', () => {
let component: ToolbarComponent;
let fixture: ComponentFixture<ToolbarComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ToolbarComponent],
}).compileComponents();

fixture = TestBed.createComponent(ToolbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatMenuModule } from '@angular/material/menu';
import { RouterLink } from '@angular/router';
import { MatToolbarModule } from '@angular/material/toolbar';

@Component({
selector: 'pmt-toolbar',
standalone: true,
imports: [CommonModule, MatToolbarModule, MatMenuModule, RouterLink],
templateUrl: './toolbar.component.html',
styleUrls: ['./toolbar.component.scss'],
})
export class ToolbarComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { Observable, catchError, map, throwError } from 'rxjs';
})
export class EspnRssFeedService {

private readonly RSS_URL = `https://www.espn.com/espn/rss/news`;
protected RSS_URL = `https://www.espn.com/espn/rss/news`;

private _http = inject(HttpClient);
protected _http = inject(HttpClient);

getTopics(): Observable<Topic[]> {
const options = {responseType: 'text' as 'json'};
return this._http.get<any>(this.RSS_URL, options).pipe(
map(resp => {
return parseESPNRSSFeed(resp);
return this.parseRssReponse(resp);
}),
catchError(err => {
console.error('ERROR', err);
Expand All @@ -25,4 +25,8 @@ export class EspnRssFeedService {
)
}

protected parseRssReponse(resp: any): Topic[] {
return parseESPNRSSFeed(resp);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { FfaRssFeedService } from './ffa-rss-feed.service';

describe('FfaRssFeedService', () => {
let service: FfaRssFeedService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FfaRssFeedService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
Loading

0 comments on commit 4d98bb9

Please sign in to comment.