diff --git a/apps/schedule/src/app/app.module.ts b/apps/schedule/src/app/app.module.ts
index 3dd8a47..e6f1bd4 100644
--- a/apps/schedule/src/app/app.module.ts
+++ b/apps/schedule/src/app/app.module.ts
@@ -27,7 +27,6 @@ import { ScheduleService } from './services/schedule.service';
import { TimeZonePickerService } from './services/timezonepicker.service';
import { CountryNamePipe } from './pipes/countryname.pipe';
import { DaysHoursMinutesPipe } from './pipes/dayshoursminutes.pipe';
-import { GetDateTimePipe } from './pipes/getdatetime.pipe';
import { TimePipe } from './pipes/time.pipe';
@@ -43,7 +42,6 @@ const routes: Routes = [
TimeZonePickerComponent,
CountryNamePipe,
DaysHoursMinutesPipe,
- GetDateTimePipe,
TimePipe
],
imports: [
diff --git a/apps/schedule/src/app/models/event.ts b/apps/schedule/src/app/models/event.ts
new file mode 100644
index 0000000..8c8cbd2
--- /dev/null
+++ b/apps/schedule/src/app/models/event.ts
@@ -0,0 +1,12 @@
+export interface Event {
+ id: string;
+ start: Date;
+ end: Date;
+ title: string;
+ description: string;
+ game_id: number;
+ game_name: string;
+ game_box_small: string;
+ game_box_medium: string;
+ game_box_large: string;
+}
diff --git a/apps/schedule/src/app/pipes/time.pipe.ts b/apps/schedule/src/app/pipes/time.pipe.ts
index 9c0fd37..df022a1 100644
--- a/apps/schedule/src/app/pipes/time.pipe.ts
+++ b/apps/schedule/src/app/pipes/time.pipe.ts
@@ -11,10 +11,12 @@ import * as moment from 'moment-timezone';
})
export class TimePipe implements PipeTransform {
- transform(time: Date, timeZone: string): string {
+ transform(time: string, timeZone: string): string {
+ let m = moment(new Date(time + 'Z')).tz(timeZone);
+
if ((new Date()).toLocaleString().match(/am|pm/i))
- return moment(time).tz(timeZone).format('h:mm A [GMT]Z');
+ return m.format('ll') + ' ' + m.format('h:mm A [GMT]Z');
else
- return moment(time).tz(timeZone).format('H:mm [GMT]Z');
+ return m.format('ll') + ' ' + m.format('H:mm [GMT]Z');
}
}
diff --git a/apps/schedule/src/app/schedule/schedule.component.css b/apps/schedule/src/app/schedule/schedule.component.css
index cec81cf..946752d 100644
--- a/apps/schedule/src/app/schedule/schedule.component.css
+++ b/apps/schedule/src/app/schedule/schedule.component.css
@@ -14,6 +14,10 @@
font-size: 125%;
}
+.mat-column-game_name img, .mat-column-game_name span {
+ vertical-align: middle;
+}
+
.spinner-container {
position: fixed;
left: 50%;
diff --git a/apps/schedule/src/app/schedule/schedule.component.html b/apps/schedule/src/app/schedule/schedule.component.html
index 32b5cbc..9f9d7cd 100644
--- a/apps/schedule/src/app/schedule/schedule.component.html
+++ b/apps/schedule/src/app/schedule/schedule.component.html
@@ -24,9 +24,9 @@
- = 1">In {{countdown | dayshoursminutes}}
+ 0">In {{countdown | dayshoursminutes}}
- Right now!
+ Right now!
@@ -42,19 +42,39 @@
- {{slot.description}}
+
+
+
+
+ {{event.title}}
+
+
+
+
-
+
+
+ {{event.description}}
+
+
+
+
+
+
+
+
+
+ {{event.game_name}}
- {{slot.label}}
+
- {{slot | getdatetime | time : timeZone}}
+ {{event.start | time : timeZone}}
diff --git a/apps/schedule/src/app/schedule/schedule.component.ts b/apps/schedule/src/app/schedule/schedule.component.ts
index fde5b1c..2cf316b 100644
--- a/apps/schedule/src/app/schedule/schedule.component.ts
+++ b/apps/schedule/src/app/schedule/schedule.component.ts
@@ -24,7 +24,8 @@ export class ScheduleComponent implements OnInit {
displayedColumns = [
'title',
- 'day',
+ 'description',
+ 'game_name',
'time'
];
@@ -33,7 +34,7 @@ export class ScheduleComponent implements OnInit {
ngOnInit() {
this.dataSource = new ScheduleDataSource(this.scheduleService);
- this.dataSource.loadSchedule(false);
+ this.dataSource.loadSchedule();
}
changeTimeZone(value) {
diff --git a/apps/schedule/src/app/services/schedule.datasource.ts b/apps/schedule/src/app/services/schedule.datasource.ts
index d50a58e..3432cda 100644
--- a/apps/schedule/src/app/services/schedule.datasource.ts
+++ b/apps/schedule/src/app/services/schedule.datasource.ts
@@ -13,15 +13,13 @@ import {
finalize
} from 'rxjs/operators';
-import { GetDateTimePipe } from '../pipes/getdatetime.pipe';
-
import { ScheduleService } from './schedule.service';
-import { Slot } from '../models/slot';
+import { Event } from '../models/event';
-export class ScheduleDataSource implements DataSource {
- private scheduleSubject = new BehaviorSubject([]);
+export class ScheduleDataSource implements DataSource {
+ private scheduleSubject = new BehaviorSubject([]);
private loadingSubject = new BehaviorSubject(false);
private countdownSubject = new BehaviorSubject(undefined);
@@ -32,17 +30,15 @@ export class ScheduleDataSource implements DataSource {
constructor(private scheduleService: ScheduleService) { }
- loadSchedule(disabled: boolean) {
+ loadSchedule() {
this.loadingSubject.next(true);
- this.scheduleService.getSchedule(disabled)
+ this.scheduleService.findEvents()
.pipe(
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false))
)
- .subscribe((schedule: Slot[]) => {
- schedule = this.sorted(schedule);
-
+ .subscribe((schedule: Event[]) => {
this.scheduleSubject.next(schedule);
timer(0, 1000).subscribe(() => {
@@ -50,18 +46,7 @@ export class ScheduleDataSource implements DataSource {
return;
}
- let nearest = (new GetDateTimePipe()).transform(schedule[0]);
-
- if (schedule.length > 1) {
- let nearest2 = (new GetDateTimePipe()).transform(schedule[1]);
-
- if (nearest.getTime() > nearest2.getTime()) {
- schedule = this.sorted(schedule);
- this.scheduleSubject.next(schedule);
- return;
- }
- }
-
+ let nearest = new Date(schedule[0].start + 'Z');
let countdown = nearest.getTime() - Date.now();
let h = countdown - this.lastCountdown;
@@ -76,17 +61,7 @@ export class ScheduleDataSource implements DataSource {
});
}
- private sorted(schedule) {
- schedule.sort(function(a, b) {
- a = (new GetDateTimePipe()).transform(a);
- b = (new GetDateTimePipe()).transform(b);
- return a.getTime() - b.getTime();
- });
-
- return schedule;
- }
-
- connect(collectionViewer: CollectionViewer): Observable {
+ connect(collectionViewer: CollectionViewer): Observable {
console.log('Connecting data source');
return this.scheduleSubject.asObservable();
}
diff --git a/apps/schedule/src/app/services/schedule.service.ts b/apps/schedule/src/app/services/schedule.service.ts
index 6b27de3..f47c9e9 100644
--- a/apps/schedule/src/app/services/schedule.service.ts
+++ b/apps/schedule/src/app/services/schedule.service.ts
@@ -9,20 +9,19 @@ import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
-import { Slot } from '../models/slot';
+import { Event } from '../models/event';
@Injectable()
export class ScheduleService {
constructor(private http: HttpClient) { }
- getSchedule(disabled = false): Observable {
-
- return this.http.get('https://schedule.twitch.serpent.ai/schedule/92737529')
- .pipe(
- map((res: any) => res.schedule.scheduleSlots.filter(
- (slot: Slot) => disabled || slot.isEnabled
- ))
- );
+ findEvents(): Observable {
+ return this.http.get('/twitch-cache/api/events', {
+ params: new HttpParams()
+ .set('newer_than', (new Date()).toISOString())
+ .set('sort_by', 'start')
+ .set('sort_order', 'asc')
+ });
}
}