restructure entries pages, last comments
This commit is contained in:
@@ -1 +1 @@
|
||||
<ui-entries [entries]="entries" [refresh]="boundRefresh" [update]="boundUpdate"></ui-entries>
|
||||
<page-entries [fetch]="boundFetch"></page-entries>
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
|
||||
import { BookmarksService } from '../../services/bookmarks.service';
|
||||
|
||||
@@ -9,73 +7,16 @@ import { BookmarksService } from '../../services/bookmarks.service';
|
||||
templateUrl: './bookmarks.page.html'
|
||||
})
|
||||
export class PageBookmarks implements OnInit {
|
||||
boundFetch: Function;
|
||||
|
||||
@Input() entries: any;
|
||||
boundRefresh: Function;
|
||||
boundUpdate: Function;
|
||||
init: boolean = true;
|
||||
|
||||
constructor(private bookmarksService: BookmarksService, private router: Router, private route: ActivatedRoute) { }
|
||||
constructor(private bookmarksService: BookmarksService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if (this.init) {
|
||||
this.entries = {};
|
||||
if (params[ 'p' ]) {
|
||||
this.entries.number = +params[ 'p' ] - 1;
|
||||
if (this.entries.number < 0) {
|
||||
this.entries.number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params[ 's' ]) {
|
||||
this.entries.size = +params[ 's' ];
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.init = false;
|
||||
}
|
||||
});
|
||||
this.boundFetch = this.fetch.bind(this);
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (!this.entries) {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
this.entries.content = null;
|
||||
this.bookmarksService.getEntriesPages(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
this.entries.bookmarks = true;
|
||||
}, (error) => { })
|
||||
|
||||
}
|
||||
|
||||
update(event: PageEvent) {
|
||||
this.entries.content = null;
|
||||
const params: any = { p: null, s: null };
|
||||
|
||||
if (event.pageIndex != 0) {
|
||||
params.p = event.pageIndex + 1;
|
||||
}
|
||||
|
||||
if (event.pageSize != 30) {
|
||||
params.s = event.pageSize;
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
|
||||
this.bookmarksService.getEntriesPages(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
fetch(page: number, size: number) {
|
||||
return this.bookmarksService.getEntries(page,size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<ui-entries [entries]="entries" [refresh]="boundRefresh" [update]="boundUpdate"></ui-entries>
|
||||
@@ -0,0 +1,81 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
|
||||
@Component({
|
||||
selector: 'page-entries',
|
||||
templateUrl: './entries.page.html'
|
||||
})
|
||||
export class PageEntries implements OnInit {
|
||||
|
||||
@Input() fetch: Function;
|
||||
entries: any;
|
||||
boundRefresh: Function;
|
||||
boundUpdate: Function;
|
||||
init: boolean = true;
|
||||
|
||||
constructor(private router: Router, private route: ActivatedRoute) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if (this.init) {
|
||||
this.entries = {};
|
||||
if (params[ 'p' ]) {
|
||||
this.entries.number = +params[ 'p' ] - 1;
|
||||
if (this.entries.number < 0) {
|
||||
this.entries.number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params[ 's' ]) {
|
||||
this.entries.size = +params[ 's' ];
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.init = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (!this.entries) {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
this.entries.content = null;
|
||||
this.fetch(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
|
||||
}
|
||||
|
||||
update(event: PageEvent) {
|
||||
this.entries.content = null;
|
||||
const params: any = { p: null, s: null };
|
||||
|
||||
if (event.pageIndex != 0) {
|
||||
params.p = event.pageIndex + 1;
|
||||
}
|
||||
|
||||
if (event.pageSize != 30) {
|
||||
params.s = event.pageSize;
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
|
||||
this.fetch(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<ng-container *ngIf="entry">
|
||||
<ui-entry [entry]="entry" [change]="boundRefresh"></ui-entry>
|
||||
|
||||
<p class="text">{{entry.text}}</p>
|
||||
<p class="text" [innerHTML]="entry.text | urltext"></p>
|
||||
|
||||
<ui-commentform [target]="entry.id" (replyCommentEvent)="replyCallback($event)"></ui-commentform>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<ui-entries [entries]="entries" [refresh]="boundRefresh" [update]="boundUpdate"></ui-entries>
|
||||
<page-entries [fetch]="boundFetch"></page-entries>
|
||||
@@ -11,71 +11,16 @@ import { PageEvent } from '@angular/material/paginator';
|
||||
})
|
||||
export class PageHot implements OnInit {
|
||||
|
||||
entries: any;
|
||||
boundRefresh: Function;
|
||||
boundUpdate: Function;
|
||||
init: boolean = true;
|
||||
boundFetch: Function;
|
||||
|
||||
constructor(private entriesService: EntriesService, private router: Router, private route: ActivatedRoute) { }
|
||||
constructor(private entriesService: EntriesService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if (this.init) {
|
||||
this.entries = {};
|
||||
if (params[ 'p' ]) {
|
||||
this.entries.number = +params[ 'p' ] - 1;
|
||||
if (this.entries.number < 0) {
|
||||
this.entries.number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params[ 's' ]) {
|
||||
this.entries.size = +params[ 's' ];
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.init = false;
|
||||
}
|
||||
});
|
||||
this.boundFetch = this.fetch.bind(this);
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (!this.entries) {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
this.entries.content = null;
|
||||
this.entriesService.getComments(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
|
||||
}
|
||||
|
||||
update(event: PageEvent) {
|
||||
this.entries.content = null;
|
||||
const params: any = { p: null, s: null };
|
||||
|
||||
if (event.pageIndex != 0) {
|
||||
params.p = event.pageIndex + 1;
|
||||
}
|
||||
|
||||
if (event.pageSize != 30) {
|
||||
params.s = event.pageSize;
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
|
||||
this.entriesService.getComments(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
fetch(page: number, size: number) {
|
||||
return this.entriesService.getComments(page,size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<page-entries [fetch]="boundFetch"></page-entries>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { EntriesService } from '../../services/entries.service';
|
||||
|
||||
@Component({
|
||||
selector: 'page-last',
|
||||
templateUrl: './last.page.html'
|
||||
})
|
||||
export class PageLast implements OnInit {
|
||||
|
||||
boundFetch: Function;
|
||||
|
||||
constructor(private entriesService: EntriesService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundFetch = this.fetch.bind(this);
|
||||
}
|
||||
|
||||
fetch(page: number, size: number) {
|
||||
return this.entriesService.getLastComment(page,size);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<ui-entries [entries]="entries" [refresh]="boundRefresh" [update]="boundUpdate"></ui-entries>
|
||||
<page-entries [fetch]="boundFetch"></page-entries>
|
||||
@@ -10,71 +10,16 @@ import { EntriesService } from '../../services/entries.service';
|
||||
})
|
||||
export class PageNew implements OnInit {
|
||||
|
||||
entries: any;
|
||||
boundRefresh: Function;
|
||||
boundUpdate: Function;
|
||||
init: boolean = true;
|
||||
boundFetch: Function;
|
||||
|
||||
constructor(private entriesService: EntriesService, private router: Router, private route: ActivatedRoute) { }
|
||||
constructor(private entriesService: EntriesService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if (this.init) {
|
||||
this.entries = {};
|
||||
if (params[ 'p' ]) {
|
||||
this.entries.number = +params[ 'p' ] - 1;
|
||||
if (this.entries.number < 0) {
|
||||
this.entries.number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params[ 's' ]) {
|
||||
this.entries.size = +params[ 's' ];
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.init = false;
|
||||
}
|
||||
});
|
||||
this.boundFetch = this.fetch.bind(this);
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (!this.entries) {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
this.entries.content = null;
|
||||
this.entriesService.getNew(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
|
||||
}
|
||||
|
||||
update(event: PageEvent) {
|
||||
this.entries.content = null;
|
||||
const params: any = { p: null, s: null };
|
||||
|
||||
if (event.pageIndex != 0) {
|
||||
params.p = event.pageIndex + 1;
|
||||
}
|
||||
|
||||
if (event.pageSize != 30) {
|
||||
params.s = event.pageSize;
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
|
||||
this.entriesService.getNew(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
fetch(page: number, size: number) {
|
||||
return this.entriesService.getNew(page,size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { EntriesService } from '../../services/entries.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
|
||||
import { tap, distinctUntilChanged, debounceTime } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'page-submission',
|
||||
@@ -38,6 +39,16 @@ export class PageSubmission implements OnInit {
|
||||
this.form.get('url').setValidators([ Validators.nullValidator ]);
|
||||
}
|
||||
});
|
||||
|
||||
this.form.get('url').valueChanges.pipe(
|
||||
debounceTime(800),
|
||||
distinctUntilChanged()).subscribe((value) => {
|
||||
if (value && !this.form.get('title').value) {
|
||||
this.entriesService.titleHelper(value).subscribe((title: string) => {
|
||||
this.form.get('title').setValue(title);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
hasError(controlName: string): boolean {
|
||||
|
||||
@@ -1 +1 @@
|
||||
<ui-entries [entries]="entries" [refresh]="boundRefresh" [update]="boundUpdate"></ui-entries>
|
||||
<page-entries [fetch]="boundFetch"></page-entries>
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { EntriesService } from '../../services/entries.service';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
|
||||
@Component({
|
||||
selector: 'page-top',
|
||||
@@ -11,71 +8,16 @@ import { PageEvent } from '@angular/material/paginator';
|
||||
})
|
||||
export class PageTop implements OnInit {
|
||||
|
||||
entries: any;
|
||||
boundRefresh: Function;
|
||||
boundUpdate: Function;
|
||||
init: boolean = true;
|
||||
boundFetch: Function;
|
||||
|
||||
constructor(private entriesService: EntriesService, private router: Router, private route: ActivatedRoute) { }
|
||||
constructor(private entriesService: EntriesService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.boundRefresh = this.refresh.bind(this);
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if (this.init) {
|
||||
this.entries = {};
|
||||
if (params[ 'p' ]) {
|
||||
this.entries.number = +params[ 'p' ] - 1;
|
||||
if (this.entries.number < 0) {
|
||||
this.entries.number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (params[ 's' ]) {
|
||||
this.entries.size = +params[ 's' ];
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.init = false;
|
||||
}
|
||||
});
|
||||
this.boundFetch = this.fetch.bind(this);
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
if (!this.entries) {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
this.entries.content = null;
|
||||
this.entriesService.getRanked(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
|
||||
}
|
||||
|
||||
update(event: PageEvent) {
|
||||
this.entries.content = null;
|
||||
const params: any = { p: null, s: null };
|
||||
|
||||
if (event.pageIndex != 0) {
|
||||
params.p = event.pageIndex + 1;
|
||||
}
|
||||
|
||||
if (event.pageSize != 30) {
|
||||
params.s = event.pageSize;
|
||||
}
|
||||
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
relativeTo: this.route,
|
||||
queryParams: params,
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
|
||||
this.entriesService.getRanked(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
||||
this.entries = data;
|
||||
}, (error) => { })
|
||||
fetch(page: number, size: number) {
|
||||
return this.entriesService.getRanked(page,size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user