Merge branch 'twitter_api'
# Conflicts: # frontend/src/app/component/tweets/tweets.component.ts
This commit is contained in:
@@ -10,22 +10,22 @@
|
||||
<br>
|
||||
<span>Schau später noch einmal vorbei!</span>
|
||||
</div>
|
||||
<div *ngIf="feeds.length !== 0">
|
||||
<div>
|
||||
<div style="padding-bottom: 10px" class="container" *ngFor="let tweet of tweets">
|
||||
<mat-card style="background-color: #f5f5f5">
|
||||
<div class="row">
|
||||
<div class="col-2 text-center padding-0 margin-auto">
|
||||
<img class="feed-icon" src="{{tweet.icon}}" alt="Feed-Icon">
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<p class="overflow-break">{{tweet.text}}
|
||||
<span class="white-space-no-wrap"> - {{tweet.created_date}}</span><br>
|
||||
<a href="{{tweet.url}}" style="cursor: pointer">{{tweet.url}}</a></p>
|
||||
</div>
|
||||
<div *ngIf="tweets.length !== 0">
|
||||
<div>
|
||||
<div style="padding-bottom: 10px" class="container" *ngFor="let tweet of tweets">
|
||||
<mat-card style="background-color: #f5f5f5">
|
||||
<div class="row">
|
||||
<div class="col-2 text-center padding-0 margin-auto">
|
||||
<img class="feed-icon" src="{{tweet.icon}}" alt="Feed-Icon">
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<p class="overflow-break">{{tweet.text}}
|
||||
<span class="white-space-no-wrap"> - {{tweet.created_date}}</span><br>
|
||||
<a href="{{tweet.url}}" target='_blank' style="cursor: pointer">{{tweet.url}}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button (click)="loadMore()" mat-button color="primary">Mehr laden</button>
|
||||
|
||||
@@ -3,10 +3,13 @@ import {AuthService} from '../../services/auth.service';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {FeedService} from '../../services/feed.service';
|
||||
import {IFeed} from '../../interfaces/feed.interface';
|
||||
import {Observable} from 'rxjs';
|
||||
import {throwError} from 'rxjs';
|
||||
import {Tweet} from '../../interfaces/interface';
|
||||
import {SnackbarService} from '../../services/snackbar.service';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {DialogComponent} from '../dialog/dialog.component';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -17,20 +20,25 @@ import {environment} from '../../../environments/environment';
|
||||
export class TweetsComponent implements OnInit {
|
||||
|
||||
tweets: Tweet[] = [];
|
||||
feeds: Observable<IFeed>[] = [];
|
||||
feeds: IFeed[] = [];
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private authService: AuthService,
|
||||
private _feedService: FeedService,
|
||||
private _snackbarService: SnackbarService) {
|
||||
private _snackbarService: SnackbarService,
|
||||
private _dialog: MatDialog,
|
||||
private _logger: NGXLogger) {
|
||||
this._feedService.getFeeds().subscribe(
|
||||
(data: any) => {
|
||||
this.feeds = data;
|
||||
},
|
||||
err => {
|
||||
this.errorDialog();
|
||||
this._logger.error(err);
|
||||
return throwError(err);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -57,8 +65,12 @@ export class TweetsComponent implements OnInit {
|
||||
for (const tweet of data) {
|
||||
const position = tweet.text.search(': http');
|
||||
tweet.text = tweet.text.substring(0, position);
|
||||
this.tweets.push(tweet);
|
||||
}
|
||||
},
|
||||
err => {
|
||||
this.errorDialog();
|
||||
this._logger.error(err);
|
||||
return throwError(err);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -73,9 +85,27 @@ export class TweetsComponent implements OnInit {
|
||||
tweet.text = tweet.text.substring(0, position);
|
||||
this.tweets.push(tweet);
|
||||
}
|
||||
},
|
||||
err => {
|
||||
this.errorDialog();
|
||||
this._logger.error(err);
|
||||
return throwError(err);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public errorDialog() {
|
||||
const dialogRef = this._dialog.open(DialogComponent, {
|
||||
data: {
|
||||
title: 'Serverfehler',
|
||||
body: 'Fehler bei der Kommunikation mit Twitter").',
|
||||
abort: 'Abbrechen',
|
||||
confirm: 'OK',
|
||||
hideAbort: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user