mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 00:10:14 +01:00
home page
This commit is contained in:
parent
dd1b2763d8
commit
5608fa4184
18 changed files with 546 additions and 103 deletions
|
|
@ -1,36 +1,14 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { delay, map } from 'rxjs/operators';
|
||||
import { Apollo } from 'apollo-angular';
|
||||
import { FIND_UNIQUE_BANNER, LIST_BANNERS } from './graphql/queries';
|
||||
import { Banner } from './banner.model';
|
||||
import { CREATE_BANNER, UPDATE_BANNER } from './graphql/mutations';
|
||||
|
||||
const TOTAL_PAGES = 7;
|
||||
|
||||
export class NewsPost {
|
||||
title: string;
|
||||
link: string;
|
||||
creator: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class BannerService {
|
||||
|
||||
constructor(private http: HttpClient, private readonly apollo: Apollo) {}
|
||||
|
||||
load(page: number, pageSize: number): Observable<NewsPost[]> {
|
||||
const startIndex = ((page - 1) % TOTAL_PAGES) * pageSize;
|
||||
|
||||
return this.http
|
||||
.get<NewsPost[]>('assets/data/news.json')
|
||||
.pipe(
|
||||
map(news => news.splice(startIndex, pageSize)),
|
||||
delay(1500),
|
||||
);
|
||||
}
|
||||
constructor(private readonly apollo: Apollo) {}
|
||||
|
||||
listBanners(): Observable<any> {
|
||||
return this.apollo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue