Browse Source

Fixes for comments.

pull/575/head
Sebastian 5 years ago
parent
commit
a9a59aaad1
  1. 5
      backend/src/Squidex/Areas/Api/Controllers/Users/UsersController.cs
  2. 2
      frontend/app/features/content/pages/comments/comments-page.component.html
  3. 12
      frontend/app/features/content/pages/comments/comments-page.component.ts
  4. 6
      frontend/app/shared/components/comments/comments.component.ts

5
backend/src/Squidex/Areas/Api/Controllers/Users/UsersController.cs

@ -189,8 +189,8 @@ namespace Squidex.Areas.Api.Controllers.Users
if (!string.IsNullOrWhiteSpace(url)) if (!string.IsNullOrWhiteSpace(url))
{ {
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead)) var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
{
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
var contentType = response.Content.Headers.ContentType.ToString(); var contentType = response.Content.Headers.ContentType.ToString();
@ -210,7 +210,6 @@ namespace Squidex.Areas.Api.Controllers.Users
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex, w => w log.LogError(ex, w => w

2
frontend/app/features/content/pages/comments/comments-page.component.html

@ -1 +1 @@
<sqx-comments [commentsId]="commentsId"></sqx-comments> <sqx-comments [commentsId]="commentsId | async"></sqx-comments>

12
frontend/app/features/content/pages/comments/comments-page.component.ts

@ -5,24 +5,20 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, OnInit } from '@angular/core'; import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { allParams } from '@app/shared'; import { map } from 'rxjs/operators';
@Component({ @Component({
selector: 'sqx-comments-page', selector: 'sqx-comments-page',
styleUrls: ['./comments-page.component.scss'], styleUrls: ['./comments-page.component.scss'],
templateUrl: './comments-page.component.html' templateUrl: './comments-page.component.html'
}) })
export class CommentsPageComponent implements OnInit { export class CommentsPageComponent {
public commentsId: string; public commentsId = this.route.parent!.params.pipe(map(x => x['contentId']));
constructor( constructor(
private readonly route: ActivatedRoute private readonly route: ActivatedRoute
) { ) {
} }
public ngOnInit() {
this.commentsId = allParams(this.route)['contentId'];
}
} }

6
frontend/app/shared/components/comments/comments.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { ChangeDetectorRef, Component, ElementRef, Input, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; import { ChangeDetectorRef, Component, ElementRef, Input, OnChanges, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { AppsState, AuthService, CommentDto, CommentsService, CommentsState, ContributorsState, DialogService, ResourceOwner, UpsertCommentForm } from '@app/shared/internal'; import { AppsState, AuthService, CommentDto, CommentsService, CommentsState, ContributorsState, DialogService, ResourceOwner, UpsertCommentForm } from '@app/shared/internal';
@ -19,7 +19,7 @@ import { CommentComponent } from './comment.component';
styleUrls: ['./comments.component.scss'], styleUrls: ['./comments.component.scss'],
templateUrl: './comments.component.html' templateUrl: './comments.component.html'
}) })
export class CommentsComponent extends ResourceOwner implements OnInit { export class CommentsComponent extends ResourceOwner implements OnChanges {
@ViewChild('commentsList', { static: false }) @ViewChild('commentsList', { static: false })
public commentsList: ElementRef<HTMLDivElement>; public commentsList: ElementRef<HTMLDivElement>;
@ -52,7 +52,7 @@ export class CommentsComponent extends ResourceOwner implements OnInit {
this.userToken = authService.user!.token; this.userToken = authService.user!.token;
} }
public ngOnInit() { public ngOnChanges() {
this.contributorsState.load(); this.contributorsState.load();
this.commentsUrl = `apps/${this.appsState.appName}/comments/${this.commentsId}`; this.commentsUrl = `apps/${this.appsState.appName}/comments/${this.commentsId}`;

Loading…
Cancel
Save