hide show subscribe buttons

This commit is contained in:
chsakell
2016-10-03 15:03:46 +03:00
parent f23e285a9f
commit 4dc031cf8b
4 changed files with 20 additions and 5 deletions

View File

@@ -19,13 +19,16 @@
<span class="label label-success">{{match.Type}}</span>
</td>
<td>
<button type="button" class="btn btn-default btn-md" (click)="subscribe()">
<button type="button" class="btn btn-default btn-md" (click)="subscribe()" *ngIf="!subscribed">
Subscribe to feed
</button>
<button type="button" class="btn btn-danger btn-md" (click)="unsubscribe()" *ngIf="subscribed">
Unubscribe
</button>
</td>
</tr>
<tr>
<td><button type="button" class="btn btn-default btn-xs">Send</button></td>
<tr *ngIf="subscribed">
<td><button type="button" class="btn btn-default btn-md">Send</button></td>
<td><input type="text" class="form-control" placeholder="Type message.." /></td>
</tr>
<tr>

View File

@@ -10,6 +10,7 @@ import { FeedService } from '../services/feed.service';
export class MatchComponent implements OnInit {
@Input() match: Match;
subscribed: boolean;
constructor(private feedService: FeedService) { }
@@ -17,6 +18,12 @@ export class MatchComponent implements OnInit {
subscribe() {
console.log(this.match.Id);
this.subscribed = true;
this.feedService.subscribeToFeed(this.match.Id);
}
unsubscribe() {
this.subscribed = false;
this.feedService.unsubscribeToFeed(this.match.Id);
}
}

View File

@@ -19,6 +19,7 @@ export interface FeedClient {
export interface FeedServer {
subscribe(matchId: number): void;
unsubscribe(matchId: number): void;
}
export enum ConnectionState {

View File

@@ -121,4 +121,8 @@ export class FeedService {
public subscribeToFeed(matchId: number) {
this.server.subscribe(matchId);
}
public unsubscribeToFeed(matchId: number) {
this.server.unsubscribe(matchId);
}
}