mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-23 01:37:59 +00:00
feed table added
This commit is contained in:
@@ -34,30 +34,18 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Feed</th>
|
||||
<th></th>
|
||||
<th>Update</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="filterable-cell">Ford</td>
|
||||
<tr *ngFor="let feed of match.Feeds">
|
||||
<td>
|
||||
<span class="feed-time">{{feed.CreatedAt | date:'shortTime' }}</span>
|
||||
</td>
|
||||
<td class="filterable-cell">
|
||||
<span class="feed-update"> {{feed.Description}} </span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -13,7 +13,7 @@ export class MatchComponent implements OnInit {
|
||||
|
||||
constructor(private feedService: FeedService) { }
|
||||
|
||||
ngOnInit() { }
|
||||
ngOnInit() { }
|
||||
|
||||
subscribe() {
|
||||
console.log(this.match.Id);
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface FeedClient {
|
||||
userDisconnected: (id: string) => void;
|
||||
|
||||
updateMatch: (match: Match) => void;
|
||||
addFeed: (feed: Feed) => void;
|
||||
messageReceived: (message: string) => void;
|
||||
}
|
||||
|
||||
@@ -35,4 +36,12 @@ export interface Match {
|
||||
GuestScore: number;
|
||||
MatchDate: Date;
|
||||
Type: string;
|
||||
Feeds: Feed[];
|
||||
}
|
||||
|
||||
export interface Feed {
|
||||
Id: number;
|
||||
Description: string;
|
||||
CreatedAt: Date;
|
||||
MatchId: number;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import 'rxjs/add/operator/toPromise';
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { Subject } from "rxjs/Subject";
|
||||
|
||||
import { FeedSignalR, FeedProxy, FeedClient, FeedServer, ConnectionState, Match } from '../interfaces';
|
||||
import { FeedSignalR, FeedProxy, FeedClient, FeedServer, ConnectionState, Match, Feed } from '../interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class FeedService {
|
||||
@@ -15,12 +15,14 @@ export class FeedService {
|
||||
userConnected: Observable<any>;
|
||||
|
||||
updateMatch: Observable<Match>;
|
||||
addFeed: Observable<Feed>;
|
||||
messageReceived: Observable<string>;
|
||||
|
||||
private connectionStateSubject = new Subject<ConnectionState>();
|
||||
private userConnectedSubject = new Subject<any>();
|
||||
|
||||
private updateMatchSubject = new Subject<Match>();
|
||||
private addFeedSubject = new Subject<Feed>();
|
||||
private messageReceivedSubject = new Subject<string>();
|
||||
|
||||
private server: FeedServer;
|
||||
@@ -30,6 +32,7 @@ export class FeedService {
|
||||
this.userConnected = this.userConnectedSubject.asObservable();
|
||||
|
||||
this.updateMatch = this.updateMatchSubject.asObservable();
|
||||
this.addFeed = this.addFeedSubject.asObservable();
|
||||
this.messageReceived = this.messageReceivedSubject.asObservable();
|
||||
}
|
||||
|
||||
@@ -48,12 +51,15 @@ export class FeedService {
|
||||
feedHub.client.userConnected = user => this.onUserConnected(user);
|
||||
|
||||
/**
|
||||
* @desc callback when a message is received
|
||||
* @param String to, the conversation id
|
||||
* @param Message data, the message
|
||||
* @desc callback when match score is updated
|
||||
*/
|
||||
feedHub.client.updateMatch = match => this.onUpdateMatch(match);
|
||||
|
||||
/**
|
||||
* @desc callback when a feed is added
|
||||
*/
|
||||
feedHub.client.addFeed = feed => this.onAddFeed(feed);
|
||||
|
||||
/**
|
||||
* @desc callback when a message is received
|
||||
* @param String to, the conversation id
|
||||
@@ -103,6 +109,10 @@ export class FeedService {
|
||||
this.updateMatchSubject.next(match);
|
||||
}
|
||||
|
||||
private onAddFeed(feed: Feed) {
|
||||
this.addFeedSubject.next(feed);
|
||||
}
|
||||
|
||||
private onMessageReceived(message: string) {
|
||||
console.log(message);
|
||||
this.messageReceivedSubject.next(message);
|
||||
|
||||
Reference in New Issue
Block a user