Get rid of unnecessary interface

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

@ -4,8 +4,3 @@ export interface Quote {
game: string; game: string;
date: Date; 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 { saveAs } from 'file-saver';
import { Quotes } from '../models/quotes';
import { QuotesService } from '../services/quotes.service'; import { QuotesService } from '../services/quotes.service';
import { QuotesDataSource } from '../services/quotes.datasource'; import { QuotesDataSource } from '../services/quotes.datasource';
@ -112,8 +111,6 @@ export class QuotesComponent implements OnInit, AfterViewInit {
export() { export() {
this.quotesService.findQuotes('', 'id', 'asc', 0, 0) this.quotesService.findQuotes('', 'id', 'asc', 0, 0)
.subscribe(quotes => { .subscribe(data => this.saveFile(data.quotes));
this.saveFile((<Quotes>quotes).quotes)
});
} }
} }

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

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

Loading…
Cancel
Save