Get rid of unnecessary interface

master
Nikola Forró 6 years ago
parent 170415ec99
commit c52c8b7d43

@ -4,8 +4,3 @@ export interface Quote {
game: string;
date: Date;
}
export interface Quotes {
quotes: Quote[];
totalCount: number;
}

@ -29,7 +29,6 @@ import { fromEvent } from 'rxjs/observable/fromEvent';
import { saveAs } from 'file-saver';
import { Quotes } from '../models/quotes';
import { QuotesService } from '../services/quotes.service';
import { QuotesDataSource } from '../services/quotes.datasource';
@ -112,8 +111,6 @@ export class QuotesComponent implements OnInit, AfterViewInit {
export() {
this.quotesService.findQuotes('', 'id', 'asc', 0, 0)
.subscribe(quotes => {
this.saveFile((<Quotes>quotes).quotes)
});
.subscribe(data => this.saveFile(data.quotes));
}
}

@ -14,10 +14,7 @@ import {
import { QuotesService } from './quotes.service';
import {
Quotes,
Quote
} from '../models/quotes';
import { Quote } from '../models/quote';
export class QuotesDataSource implements DataSource<Quote> {
@ -44,9 +41,9 @@ export class QuotesDataSource implements DataSource<Quote> {
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false))
)
.subscribe(quotes => {
this.quotesSubject.next((<Quotes>quotes).quotes);
this.countSubject.next((<Quotes>quotes).totalCount)
.subscribe(data => {
this.quotesSubject.next(data.quotes);
this.countSubject.next(data.totalCount);
});
}

@ -9,10 +9,7 @@ import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
import {
Quotes,
Quote
} from '../models/quotes';
import { Quote } from '../models/quote';
@Injectable()
@ -21,7 +18,7 @@ export class QuotesService {
findQuotes(
filter = '', sortBy = 'id', sortOrder = 'desc',
pageNumber = 0, pageSize = 20): Observable<Quotes> {
pageNumber = 0, pageSize = 20): Observable<any> {
return this.http.get('/quotes/api/quotes', {
observe: 'response',
@ -32,10 +29,10 @@ export class QuotesService {
.set('page_number', pageNumber.toString())
.set('page_size', pageSize.toString())
}).pipe(
map(res => <Quotes>{
map(res => ({
quotes: <Quote[]>res.body,
totalCount: parseInt(res.headers.get('X-Total-Count'))
})
}))
);
}
}

Loading…
Cancel
Save