ignore metadata improvements

This commit is contained in:
2021-10-05 08:41:38 +02:00
parent 2ac686824b
commit e225e78639
18 changed files with 373 additions and 84 deletions
+4 -1
View File
@@ -11,6 +11,7 @@ import { PageNotFound } from './pages/notfound/notfound.page';
import { PageSettings } from './pages/settings/settings.page';
import { PageSubmission } from './pages/submission/submission.page';
import { PageTop } from './pages/top/top.page';
import { PageUnavailable } from './pages/unavailable/unavailable.page';
import { PageUser } from './pages/user/user.page';
import { PageUserComments } from './pages/user/usercomments/usercomments.page';
import { PageUserEntries } from './pages/user/userentries/userentries.page';
@@ -30,7 +31,9 @@ const routes: Routes = [
{ path: 'bookmarks', component: PageBookmarks, canActivate: [ AuthenticatedGuard ] },
{ path: 'submit', component: PageSubmission, canActivate: [ AuthenticatedGuard ] },
{ path: 'login', component: PageLogin, canActivate: [ AnonymousGuard ] },
{ path: 'settings', component: PageSettings, canActivate: [ AuthenticatedGuard ] },
{ path: 'settings', component: PageSettings, canActivate: [ AuthenticatedGuard ] },
{ path: 'unavailable', component: PageUnavailable },
{ path: '**', component: PageNotFound, pathMatch: 'full', canActivate: [ AuthUpdateGuard ] },
]
},
];
+1 -1
View File
@@ -1,6 +1,6 @@
<div class="container">
<page-notfound *ngIf="notfound"></page-notfound>
<ng-container *ngIf="comment">
<ui-comment class="comment" [comment]="comment"></ui-comment>
<ui-comment class="comment" [comment]="comment" [ignore]="ignoreSubcomments" [subcomments]="true"></ui-comment>
</ng-container>
</div>
+1 -5
View File
@@ -15,16 +15,14 @@ export class PageComment implements OnInit {
id: number;
comment: any;
notfound: boolean = false;
ignoreSubcomments : string[] = ['entry'];
constructor(private commentService: CommentService,
private route: ActivatedRoute) { }
ngOnInit(): void {
this.id = +this.route.snapshot.paramMap.get('id');
this.refresh();
}
refresh() {
this.commentService.getComment(this.id).subscribe((data) => {
this.comment = data;
}, (error) => {
@@ -34,6 +32,4 @@ export class PageComment implements OnInit {
})
}
}
+1 -1
View File
@@ -7,6 +7,6 @@
<ui-commentform [target]="entry.id" (replyCommentEvent)="replyCallback($event)"></ui-commentform>
<ui-comments #comments [target]="entry.id"></ui-comments>
<ui-comments #comments [target]="entry.id" [subcomments]="true"></ui-comments>
</ng-container>
</div>
@@ -29,7 +29,7 @@ export class PageUnavailable implements OnInit {
if (!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") {
this.location.back;
} else {
this.router.navigate([ this.targetRoute ], { skipLocationChange: true });
this.router.navigate([ this.targetRoute ]);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ export class PageUser implements OnInit {
this.userService.getUser(this.username).subscribe((data) => {
this.user = data;
}, (error) => {
if (error.status == 404) {
if (error.status == 422) {
this.notfound = true;
}
})
@@ -6,27 +6,7 @@
<p>{{'user.commentsBy' | i18n}}<a routerLink="/u/{{username}}">{{username}}</a></p>
<ng-container *ngFor="let comment of comments.content; let i = index">
<mat-divider class="divider" *ngIf="i > 0"></mat-divider>
<div class="comment">
<div mat-line>
<small>
<a routerLink="/c/{{comment.id}}" matTooltip="{{comment.created | datef:'LLLL'}}">{{comment.created
| datef}}</a>
<span *ngIf="comment.metadata && comment.metadata.entry">
{{'comment.on' | i18n}} <a routerLink="/e/{{comment.target}}">{{comment.metadata.entry ||
'entry'}}</a>
</span>
</small>
</div>
<div mat-line class="text"
[style.opacity]="comment.metadata && comment.metadata.points && comment.metadata.points < 0 ? 1 + (comment.metadata.points / 10) : '1.0'">
{{comment.text}}</div>
<div mat-line>
<small>
<a *ngIf="moderator" href="javascript:" (click)="deleteComment(comment)">{{'comment.delete' | i18n}}</a>
</small>
</div>
</div>
<ui-comment [comment]="comment" [ignore]="ignore"></ui-comment>
</ng-container>
<mat-list *ngIf="comments.totalElements == 0">
@@ -14,19 +14,20 @@ export class PageUserComments implements OnInit {
username: string;
comments: any = {};
init: boolean = true;
ignore : string[] = ["author"];
constructor(private commentService: CommentService, private router: Router, private route: ActivatedRoute) { }
ngOnInit(): void {
this.username = this.route.snapshot.paramMap.get('username');
this.commentService.getByUser(this.username, this.comments.number || 0, this.comments.size || 30).subscribe((data: any) => {
this.commentService.getByUser(this.username, this.comments.number || 0, this.comments.size || 30, this.ignore).subscribe((data: any) => {
this.comments = data;
}, (error) => { })
}
showMore() {
const oldContent: any[] = this.comments.content;
this.commentService.getByUser(this.username, this.comments.number + 1, this.comments.size).subscribe((data) => {
this.commentService.getByUser(this.username, this.comments.number + 1, this.comments.size, this.ignore).subscribe((data) => {
this.comments = data;
for (let comment of this.comments.content) {
oldContent.push(comment);
+14 -14
View File
@@ -10,24 +10,24 @@ export class CommentService {
constructor(private http: HttpClient) {
}
getRanked(target: number, page: number, size: number) {
return this.http.get(environment.apiUrl + "/comments/" + target + "?page=" + page + "&size=" + size);
getRanked(target: number, page: number, size: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/" + target + "?page=" + page + "&size=" + size + "&ignore=" + ignore);
}
getRankedByParent(target: number, parent: number, page: number, size: number) {
return this.http.get(environment.apiUrl + "/comments/" + target + "/" + parent + "?page=" + page + "&size=" + size);
getRankedByParent(target: number, parent: number, page: number, size: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/" + target + "/" + parent + "?page=" + page + "&size=" + size+ "&ignore=" + ignore);
}
getNew(target: number, page: number, size: number) {
return this.http.get(environment.apiUrl + "/comments/new/" + target + "?page=" + page + "&size=" + size);
getNew(target: number, page: number, size: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/new/" + target + "?page=" + page + "&size=" + size+ "&ignore=" + ignore);
}
getNewByParent(target: number, parent: number, page: number, size: number) {
return this.http.get(environment.apiUrl + "/comments/new/" + target + "/" + parent + "?page=" + page + "&size=" + size);
getNewByParent(target: number, parent: number, page: number, size: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/new/" + target + "/" + parent + "?page=" + page + "&size=" + size+ "&ignore=" + ignore);
}
getByUser(username: string, page: number, size: number) {
return this.http.get(environment.apiUrl + "/comments/byuser/" + username + "?page=" + page + "&size=" + size);
getByUser(username: string, page: number, size: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/byuser/" + username + "?page=" + page + "&size=" + size+ "&ignore=" + ignore);
}
count(target: number) {
@@ -38,13 +38,13 @@ export class CommentService {
return this.http.get(environment.apiUrl + "/comments/count/" + target + "/" + parent);
}
getComment(id: number) {
return this.http.get(environment.apiUrl + "/comments/comment/" + id);
getComment(id: number, ignore : string[] = []) {
return this.http.get(environment.apiUrl + "/comments/comment/" + id + "?ignore=" + ignore);
}
create(comment: any) {
create(comment: any, ignore : string[] = []) {
comment.type = 'COMMENT';
return this.http.post(environment.apiUrl + "/comments", comment);
return this.http.post(environment.apiUrl + "/comments?ignore=" + ignore, comment);
}
}
+4 -4
View File
@@ -9,8 +9,8 @@ import { Subject } from 'rxjs';
})
export class I18nService {
locale: string = "en";
locales: any[] = [ "en" ];
locale: string = "de-informal";
locales: any[] = [ "de-informal", "en" ];
i18n: any;
constructor(private http: HttpClient) {
@@ -22,7 +22,7 @@ export class I18nService {
}
getLocale() {
return this.locale || 'en';
return this.locale || 'de-informal';
}
setLocale(locale) {
@@ -96,7 +96,7 @@ export class I18nService {
if (args && args.length > 0) {
return key + "[" + args + "]";
}
return key;
}
+4 -3
View File
@@ -18,9 +18,10 @@
</span>
<a routerLink="/c/{{comment.id}}" matTooltip="{{comment.created | datef:'LLLL'}}">{{comment.created
| datef}}</a>
<span *ngIf="comment.metadata && comment.metadata.entry"> {{'comment.on' | i18n}} <a
<span *ngIf="comment.metadata && comment.metadata.author"> {{'comment.author' | i18n}}<a
routerLink="/u/{{comment.author}}">{{comment.author}}</a></span>
<span *ngIf="comment.metadata && comment.metadata.entry"> {{'comment.on' | i18n}} <a class="entry"
routerLink="/e/{{comment.target}}">{{comment.metadata.entry || 'entry'}}</a></span>
{{'comment.author' | i18n}}<a routerLink="/u/{{comment.author}}">{{comment.author}}</a>
<span *ngIf="comment.metadata && comment.metadata.unvote"> | </span>
<a *ngIf="comment.metadata.unvote" href="javascript:" (click)="unvote()">{{'comment.unvote' | i18n}}</a>
</small>
@@ -44,4 +45,4 @@
</div>
</div>
<ui-comments #subcomments [target]="comment.target" [parent]="comment.id"></ui-comments>
<ui-comments *ngIf="subcomments && comment.metadata && comment.metadata.comments > 0" #subcomments [target]="comment.target" [parent]="comment.id" [subcomments]="subcomments"></ui-comments>
+2 -2
View File
@@ -1,9 +1,9 @@
small > a {
small a:not(.entry) {
color: inherit !important;
text-decoration: none;
}
small > a:hover {
small a:not(.entry):hover {
color: inherit !important;
text-decoration: underline;
}
+9 -9
View File
@@ -18,7 +18,9 @@ export class UiComment implements OnInit {
moderator: boolean = false;
@Input() comment: any;
@Input() change: Function;
@ViewChild('subcomments') subcomments: UiComments;
@Input() ignore: string[] = [];
@Input() subcomments: boolean = false;
@ViewChild('subcomments') comments: UiComments;
constructor(private authService: AuthService, private commentService: CommentService, private voteService: VoteService,
private moderationService: ModerationService, public dialog: MatDialog) { }
@@ -33,15 +35,11 @@ export class UiComment implements OnInit {
}
}
})
this.commentService.countParent(this.comment.target, this.comment.id).subscribe((data) => {
this.comment.metadata.comments = +data;
});
}
voteUp() {
this.voteService.voteCommentUp(this.comment.id).subscribe((result) => {
this.commentService.getComment(this.comment.id).subscribe((data) => {
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
this.comment = data;
})
});
@@ -49,7 +47,7 @@ export class UiComment implements OnInit {
voteDown() {
this.voteService.voteCommentDown(this.comment.id).subscribe((result) => {
this.commentService.getComment(this.comment.id).subscribe((data) => {
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
this.comment = data;
})
});
@@ -57,7 +55,7 @@ export class UiComment implements OnInit {
unvote() {
this.voteService.unvoteComment(this.comment.id).subscribe((result) => {
this.commentService.getComment(this.comment.id).subscribe((data) => {
this.commentService.getComment(this.comment.id, this.ignore).subscribe((data) => {
this.comment = data;
})
});
@@ -68,7 +66,9 @@ export class UiComment implements OnInit {
}
replyCallback(comment): void {
this.subcomments.addComment(comment);
if (this.subcomments) {
this.comments.addComment(comment);
}
this.comment.metadata.reply = false;
this.comment.metadata.comments = (this.comment.metadata.comments || 0) + 1;
}
+1 -1
View File
@@ -3,7 +3,7 @@
<div *ngIf="comments && comments.content" fxLayout="column" fxFlexFill class="comments">
<ng-container *ngFor="let comment of comments.content; let i = index">
<mat-divider class="divider" *ngIf="i > 0"></mat-divider>
<ui-comment class="comment" [comment]="comment" [change]="boundRefresh"></ui-comment>
<ui-comment class="comment" [comment]="comment" [change]="boundRefresh" [subcomments]="subcomments" [ignore]="ignore"></ui-comment>
</ng-container>
<mat-list *ngIf="comments.totalElements == 0 && !parent">
+6 -4
View File
@@ -13,6 +13,8 @@ export class UiComments implements OnInit {
comments: any;
@Input() target: number;
@Input() parent: number;
@Input() ignore: string[] = [];
@Input() subcomments: boolean = false;
boundRefresh: Function;
constructor(private commentService: CommentService) { }
@@ -24,11 +26,11 @@ export class UiComments implements OnInit {
refresh(): void {
if (this.parent) {
this.commentService.getNewByParent(this.target, this.parent, 0, 30).subscribe((data) => {
this.commentService.getNewByParent(this.target, this.parent, 0, 30, this.ignore).subscribe((data) => {
this.comments = data;
})
} else {
this.commentService.getNew(this.target, 0, 30).subscribe((data) => {
this.commentService.getNew(this.target, 0, 30, this.ignore).subscribe((data) => {
this.comments = data;
})
}
@@ -51,7 +53,7 @@ export class UiComments implements OnInit {
showMore() {
const oldContent: any[] = this.comments.content;
if (this.parent) {
this.commentService.getNewByParent(this.target, this.parent, this.comments.number + 1, this.comments.size).subscribe((data) => {
this.commentService.getNewByParent(this.target, this.parent, this.comments.number + 1, this.comments.size, this.ignore).subscribe((data) => {
this.comments = data;
for (let comment of this.comments.content) {
oldContent.push(comment);
@@ -59,7 +61,7 @@ export class UiComments implements OnInit {
this.comments.content = oldContent;
})
} else {
this.commentService.getNew(this.target, this.comments.number + 1, this.comments.size).subscribe((data) => {
this.commentService.getNew(this.target, this.comments.number + 1, this.comments.size, this.ignore).subscribe((data) => {
this.comments = data;
for (let comment of this.comments.content) {
oldContent.push(comment);
+10 -12
View File
@@ -6,18 +6,16 @@
</div>
<div mat-line>
<small>
<ng-container *ngIf="entry.metadata && !entry.metadata.unvote">
<a href="javascript:" (click)="voteUp(entry.id)" matTooltip="{{'vote.up' | i18n}}">
<mat-icon inline="true">thumb_up</mat-icon>
</a>
<span>&nbsp;</span>
<!--
<a href="javascript:" (click)="voteDown(entry.id)" matTooltip="{{'vote.down' | i18n}}">
<mat-icon inline="true">thumb_down</mat-icon>
</a>
<span>&nbsp;</span>
-->
</ng-container>
<a *ngIf="entry.metadata && entry.metadata.vote" href="javascript:" (click)="voteUp(entry.id)"
matTooltip="{{'vote.up' | i18n}}">
<mat-icon inline="true">thumb_up</mat-icon>
</a>
<span *ngIf="entry.metadata && entry.metadata.vote">&nbsp;</span>
<a *ngIf="entry.metadata && entry.metadata.unvote" href="javascript:" (click)="voteDown(entry.id)"
matTooltip="{{'vote.down' | i18n}}">
<mat-icon inline="true">thumb_down</mat-icon>
</a>
<span *ngIf="entry.metadata && entry.metadata.unvote">&nbsp;</span>
<span class="voted" *ngIf="entry.metadata && entry.metadata.unvote">
<mat-icon *ngIf="entry.metadata && entry.metadata.upvoted" inline="true">thumb_up</mat-icon>
<mat-icon *ngIf="entry.metadata && entry.metadata.downvoted" inline="true">thumb_down</mat-icon>