Skip to content

Commit

Permalink
fixup! feat(docs-infra): created new widget for events page
Browse files Browse the repository at this point in the history
  • Loading branch information
ajitsinghkaler committed Apr 8, 2020
1 parent bf62aab commit 3be5189
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions aio/src/app/custom-elements/events/events.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</thead>
<tbody >
<tr *ngFor="let event of upcomingEvents">
<th><a href="{{event.linkUrl}}" title={{event.title}}>{{event.title}}</a></th>
<td><a href="{{event.linkUrl}}" title={{event.title}}>{{event.title}}</a></td>
<td>{{event.address}}</td>
<td>{{event.info}}</td>
</tr>
Expand All @@ -27,7 +27,7 @@
</thead>
<tbody>
<tr *ngFor="let event of prevEvents">
<th><a href="{{event.linkUrl}}" title={{event.title}}>{{event.title}}</a></th>
<td><a href="{{event.linkUrl}}" title={{event.title}}>{{event.title}}</a></td>
<td>{{event.address}}</td>
<td>{{event.info}}</td>
</tr>
Expand Down
18 changes: 9 additions & 9 deletions aio/src/app/custom-elements/events/events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface Event {
address: string; // "Oslo, Norway",
title: string; // "ngVikings",
linkUrl: string; // "https://ngvikings.org/",
name: string // "ngVikings",
info: string // "May 25-26 conference, 27 workshops, 2020"
name: string; // "ngVikings",
info: string; // "May 25-26 conference, 27 workshops, 2020"
}

@Component({
Expand All @@ -20,17 +20,17 @@ export class EventComponent implements OnInit {
prevEvents: Event[];
upcomingEvents: Event[];

constructor(private eventsService: EventsService,) { }
constructor( private eventsService: EventsService ) { }

ngOnInit() {
this.eventsService.events.subscribe((events:Event[]) => {
this.prevEvents = events.filter(event=>{
return new Date(event.endDate).valueOf() < Date.now()
this.eventsService.events.subscribe(( events: Event[] ) => {
this.prevEvents = events.filter( event => {
return new Date(event.endDate).valueOf() < Date.now();
});

this.upcomingEvents = events.filter(event=>{
return new Date(event.endDate).valueOf() > Date.now()
this.upcomingEvents = events.filter( event => {
return new Date(event.endDate).valueOf() > Date.now();
});
});
}
}
}
20 changes: 10 additions & 10 deletions aio/src/app/custom-elements/events/events.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Observable } from "rxjs";
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { Event } from "./events.component";
import { CONTENT_URL_PREFIX } from "app/documents/document.service";
import { Event } from './events.component';
import { CONTENT_URL_PREFIX } from 'app/documents/document.service';

const resourcesPath = CONTENT_URL_PREFIX + "events.json";
const resourcesPath = CONTENT_URL_PREFIX + 'events.json';

@Injectable()
export class EventsService {
Expand All @@ -19,11 +19,11 @@ export class EventsService {

private getEvents() {
return this.http.get<any>(resourcesPath).pipe(
map(data=> data.sort(compareEvents))
)
map(data => data.sort(compareEvents))
);
}
}

function compareEvents(l: Event, r: Event){
return (new Date(l.endDate) < new Date(r.endDate) ? 1: -1);
function compareEvents( l: Event, r: Event ) {
return (new Date(l.endDate) < new Date(r.endDate) ? 1 : -1);
}

0 comments on commit 3be5189

Please sign in to comment.