ignore metadata improvements

This commit is contained in:
_Bastler 2021-10-05 08:41:38 +02:00
parent 2ac686824b
commit e225e78639
18 changed files with 373 additions and 84 deletions

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';
@ -31,6 +32,8 @@ const routes: Routes = [
{ path: 'submit', component: PageSubmission, canActivate: [ AuthenticatedGuard ] },
{ path: 'login', component: PageLogin, canActivate: [ AnonymousGuard ] },
{ path: 'settings', component: PageSettings, canActivate: [ AuthenticatedGuard ] },
{ path: 'unavailable', component: PageUnavailable },
{ path: '**', component: PageNotFound, pathMatch: 'full', canActivate: [ AuthUpdateGuard ] },
]
},
];

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>

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 {
})
}
}

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>

View File

@ -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 ]);
}
}

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;
}
})

View File

@ -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">

View File

@ -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);

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);
}
}

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) {

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>

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;
}

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;
}

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">

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);

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}}">
<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>&nbsp;</span>
<!--
<a href="javascript:" (click)="voteDown(entry.id)" matTooltip="{{'vote.down' | i18n}}">
<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>&nbsp;</span>
-->
</ng-container>
<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>

View File

@ -1 +1,155 @@
{}
{
"bookmarks": {
".": "Lesezeichen",
"add": "Lesezeichen hinzufügen",
"remove": "Lesezeichen entfernen"
},
"bstlboard": {
".": "βstlβoard"
},
"cancel": "Abbrechen",
"comment": {
".": "Kommentar",
"author": "von ",
"confirmDelete": "Bitte bestätige die Löschung des Kommentars von '{1}'!",
"create": "Kommentieren",
"delete": "Löschen?",
"on": "zu ",
"reply": "Antworten",
"replyHide": "Abbrechen",
"text": {
".": "Text",
"error": "Text erforderlich!"
},
"unvote": "unvoten"
},
"comments": {
".": "Kommentare",
"nothing": "Keine Kommentare bisher",
"showMore": "Zeige mehr Kommentare",
"subcomments": {
".": "Unterkommentare",
"showMore": "Zeige mehr Unterkommentare"
}
},
"confirm": "Bestätigen",
"darkTheme": "Dunkles Thema",
"entries": {
"nothing": "Keine Beiträge bisher"
},
"entry": {
".": "Beitrag",
"author": "von ",
"comment": "1 Kommentar",
"comments": "{0} Kommentare",
"confirmDelete": "Bitte bestätige die Löschung des Beitrages '{0}' von '{1}'!",
"delete": "Löschen?",
"unvote": "unvoten"
},
"entryType": {
"DISCUSSION": {
".": "Diskussion",
"icon": "insert_comment"
},
"INTERN": {
".": "Intern",
"icon": "lock"
},
"LINK": {
".": "Link",
"icon": "link"
},
"QUESTION": {
".": "Frage",
"icon": "contact_support"
}
},
"locale": {
"de-informal": {
"long": "Deutsch",
"short": "DE"
},
"en": {
"long": "english",
"short": "EN"
}
},
"login": {
".": "Login",
"autologin": "Automatisch einloggen",
"external": {
".": "Login",
"client": "mit {0} einloggen",
"invalid": "Login fehlgeschlagen"
},
"internal": "Login intern",
"invalid": "Falscher Username oder Password",
"keepSession": "eingeloggt bleiben"
},
"logout": "Logout",
"new": "Neuste",
"not-found": {
".": "Nicht gefunden",
"text": "Seite nicht gefunden"
},
"paginator": {
"firstPage": "Erste Seite",
"itemsPerPage": "Einträge pro Seite:",
"lastPage": "Letzte Seite",
"nextPage": "Nächste Seite",
"previousPage": "Vorherige Seite",
"range": "Seite {0} von {1}"
},
"password": "Passwort",
"point": "1 Punkt",
"points": "{0} Punkte",
"service-unavailable": {
".": "Dienst nicht erreichbar",
"retry": "Seite neu laden",
"support": "Support",
"text": "Zurzeit scheint der Dienst nicht erreichbar zu sein. Wenn diese Meldung länger besteht, melde dich beim Support!"
},
"settings": {
".": "Einstellungen",
"about": "Über",
"darkTheme": "Dunkles Thema",
"update": "Aktualisieren",
"username": "Username"
},
"submission": {
".": "Neuer Beitrag",
"create": "Beitrag erstellen",
"entryType": {
".": "Typ",
"error": "Typ auswählen"
},
"info": "Neuen Beitrag erstellen",
"text": {
".": "Text"
},
"title": {
".": "Titel",
"error": "Titel erforderlich"
},
"url": {
".": "Url",
"error": "Url erforderlich"
}
},
"top": "Top",
"user": {
".": "User",
"about": "Über",
"comments": "Kommentare",
"commentsBy": "Kommentare von ",
"entries": "Beiträge",
"entriesBy": "Beiträge von ",
"points": "Karma",
"username": "User"
},
"username": "Username",
"vote": {
"down": "Negativ bewerten",
"up": "Positiv bewerten"
}
}

View File

@ -1 +1,155 @@
{}
{
"bookmarks": {
".": "bookmarks",
"add": "add bookmark",
"remove": "remove bookmark"
},
"bstlboard": {
".": "βstlβoard"
},
"cancel": "cancel",
"comment": {
".": "comment",
"author": "by ",
"confirmDelete": "Please confirm deletion of comment by '{1}'!",
"create": "add comment",
"delete": "delete?",
"on": "on ",
"reply": "reply",
"replyHide": "cancel reply",
"text": {
".": "text",
"error": "text required!"
},
"unvote": "unvote"
},
"comments": {
".": "comments",
"nothing": "no comments yet",
"showMore": "show more comments",
"subcomments": {
".": "subcomments",
"showMore": "show more subcomments"
}
},
"confirm": "confirm",
"darkTheme": "dark theme",
"entries": {
"nothing": "no entries yet"
},
"entry": {
".": "entry",
"author": "by ",
"comment": "1 comment",
"comments": "{0} comments",
"confirmDelete": "Please confirm deletion of entry '{0}' by '{1}'!",
"delete": "delete?",
"unvote": "unvote"
},
"entryType": {
"DISCUSSION": {
".": "discussion",
"icon": "insert_comment"
},
"INTERN": {
".": "intern",
"icon": "lock"
},
"LINK": {
".": "link",
"icon": "link"
},
"QUESTION": {
".": "question",
"icon": "contact_support"
}
},
"locale": {
"de-informal": {
"long": "Deutsch",
"short": "DE"
},
"en": {
"long": "english",
"short": "EN"
}
},
"login": {
".": "login",
"autologin": "login automatically",
"external": {
".": "login",
"client": "login with {0}",
"invalid": "login failed"
},
"internal": "internal login",
"invalid": "wrong username or password",
"keepSession": "stay logged in"
},
"logout": "logout",
"new": "new",
"not-found": {
".": "Not found",
"text": "Page not found"
},
"paginator": {
"firstPage": "first page",
"itemsPerPage": "items per page:",
"lastPage": "last page",
"nextPage": "next page",
"previousPage": "previous page",
"range": "page {0} of {1}"
},
"password": "password",
"point": "1 point",
"points": "{0} points",
"service-unavailable": {
".": "Service unavailable",
"retry": "Reload page",
"support": "Support",
"text": "The service seems currently unavailable. If this message appears over a longer period, please contact our support!"
},
"settings": {
".": "settings",
"about": "about",
"darkTheme": "dark theme",
"update": "update",
"username": "username"
},
"submission": {
".": "new entry",
"create": "create entry",
"entryType": {
".": "type",
"error": "set type"
},
"info": "create a new entry",
"text": {
".": "text"
},
"title": {
".": "title",
"error": "title required"
},
"url": {
".": "url",
"error": "url required"
}
},
"top": "top",
"user": {
".": "user",
"about": "about",
"comments": "comments",
"commentsBy": "comments by ",
"entries": "entries",
"entriesBy": "entries by ",
"points": "karma",
"username": "user"
},
"username": "username",
"vote": {
"down": "vote down",
"up": "vote up"
}
}