From a746c9221579400bc27deca2593d7e63ca4f9846 Mon Sep 17 00:00:00 2001 From: Vitalii Lakatosh Date: Tue, 10 Feb 2026 22:40:59 +0200 Subject: [PATCH 1/4] Use ChangeDetectionStrategy.OnPush to reload Dom on cnange in Angular --- .../admin-comments-list.component.ts | 9 ++++++--- .../admin-comments-table.component.ts | 11 ++++++----- .../comments-activity/comments-activity.component.ts | 9 ++++++--- .../admin-posts-list/admin-posts-list.component.ts | 5 +++-- .../admin-posts-table/admin-posts-table.component.ts | 9 ++++++--- .../change-status/change-status.component.ts | 5 +++-- .../posts-activity-chart.component.ts | 9 ++++++--- .../admin-tags-list/admin-tags-list.component.ts | 5 +++-- .../admin-tags-table/admin-tags-table.component.ts | 9 ++++++--- .../tags-activity-chart.component.ts | 9 ++++++--- .../users-activity-chart.component.ts | 9 ++++++--- .../icons-cards/icons-cards.component.ts | 5 +++-- .../default-pages/index/index.component.ts | 5 +++-- .../app/shared/posts/add-post/add-post.component.ts | 9 ++++++--- .../comments/add-comment/add-comment.component.ts | 9 ++++++--- .../comments-list/comments-list.component.ts | 9 ++++++--- .../comments/edit-comment/edit-comment.component.ts | 9 ++++++--- .../shared/posts/edit-post/edit-post.component.ts | 9 ++++++--- .../app/shared/posts/my-posts/my-posts.component.ts | 9 ++++++--- .../posts/popular-posts/popular-posts.component.ts | 9 ++++++--- .../shared/posts/posts-list/posts-list.component.ts | 12 +++++++----- .../posts/posts-table/posts-table.component.ts | 10 ++++++---- .../posts/right-sidebar/right-sidebar.component.ts | 5 +++-- .../src/app/shared/posts/show/show.component.ts | 9 ++++++--- .../src/app/shared/tags/add-tag/add-tag.component.ts | 5 +++-- .../app/shared/tags/edit-tag/edit-tag.component.ts | 9 ++++++--- .../tags/popular-tags/popular-tags.component.ts | 9 ++++++--- .../app/shared/tags/tags-list/tags-list.component.ts | 5 +++-- .../default-pages/about/about.component.ts | 5 +++-- .../default-pages/contacts/contacts.component.ts | 5 +++-- .../layout-component/layout-component.component.ts | 5 +++-- .../change-email/change-email.component.ts | 9 ++++++--- .../change-password/change-password.component.ts | 9 ++++++--- .../change-phone-number.component.ts | 9 ++++++--- .../profile/edit-profile/edit-profile.component.ts | 9 ++++++--- .../profile/profile-page/profile-page.component.ts | 8 +++++--- .../user/authorization/authorization.component.ts | 5 +++-- .../user/registration/registration.component.ts | 6 +++--- 38 files changed, 189 insertions(+), 107 deletions(-) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts index d45c86b0..5b7e8288 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { User } from '../../../core/models/User'; import { Comment } from '../../../core/models/Comment'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -11,7 +11,8 @@ import { Messages } from '../../../core/data/Mesages'; selector: 'app-admin-comments-list', templateUrl: './admin-comments-list.component.html', styleUrls: ['./admin-comments-list.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminCommentsListComponent implements OnInit { /** @@ -51,10 +52,12 @@ export class AdminCommentsListComponent implements OnInit { /** * @param _commentService CommentService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentsService: CommentsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts index 384758d7..07d53d63 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts @@ -1,11 +1,9 @@ import { GlobalService } from '../../../core/services/global-service/global-service.service'; import { UsersService } from '../../../core/services/users-services/users-service.service'; import { CommentsService } from '../../../core/services/posts-services/comments.service'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Comment } from '../../../core/models/Comment'; import { User } from '../../../core/models/User'; -import { GeneralServiceService } from '../../../core'; -import { ActivatedRoute } from '@angular/router'; import { Messages } from '../../../core/data/Mesages'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { PageInfo } from '../../../core/models/PageInfo'; @@ -15,7 +13,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-admin-comments-table', templateUrl: './admin-comments-table.component.html', styleUrls: ['./admin-comments-table.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminCommentsTableComponent implements OnInit { /** @@ -55,10 +54,12 @@ export class AdminCommentsTableComponent implements OnInit { /** * @param _commentsService CommentsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentsService: CommentsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts index f270f3bc..68e0ada7 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { ChartOptions } from './../../../core/models/chart/ChartOptions'; import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -9,7 +9,8 @@ import { CommentsService } from '../../../core/services/posts-services/comments. selector: 'app-comments-activity', templateUrl: './comments-activity.component.html', styleUrls: ['./comments-activity.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class CommentsActivityComponent implements OnInit { /** @@ -45,10 +46,12 @@ export class CommentsActivityComponent implements OnInit { /** * @param _commentService CommentService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentService: CommentsService, - private _customToastrService: CustomToastrService) { + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-list/admin-posts-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-list/admin-posts-list.component.ts index c38fb1c6..73923100 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-list/admin-posts-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-list/admin-posts-list.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-admin-posts-list', templateUrl: './admin-posts-list.component.html', styleUrls: ['./admin-posts-list.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminPostsListComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts index c4130c51..f2682569 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from "@angular/core"; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from "@angular/core"; import { PageInfo } from "../../../core/models/PageInfo"; import { Post } from "../../../core/models/Post"; import { CustomToastrService } from "../../../core/services/custom-toastr.service"; @@ -11,7 +11,8 @@ import { Router } from "@angular/router"; selector: 'app-admin-posts-table', templateUrl: './admin-posts-table.component.html', styleUrls: ['./admin-posts-table.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminPostsTableComponent implements OnInit { /** @@ -39,11 +40,13 @@ export class AdminPostsTableComponent implements OnInit { * @param _router Router * @param _customToastrService CustomToastrService * @param _postsService: PostsService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _router: Router, private _customToastrService: CustomToastrService, - private _postsService: PostsService + private _postsService: PostsService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/change-status/change-status.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/change-status/change-status.component.ts index 41bf2b04..c99a4c19 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/change-status/change-status.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/change-status/change-status.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, ContentChild, ElementRef, Output, EventEmitter } from '@angular/core'; +import { Component, OnInit, Input, ContentChild, ElementRef, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { Messages } from './../../../../core/data/Mesages'; import { CustomToastrService } from './../../../../core/services/custom-toastr.service'; @@ -6,7 +6,8 @@ import { CustomToastrService } from './../../../../core/services/custom-toastr.s selector: 'app-change-status', templateUrl: './change-status.component.html', styleUrls: ['./change-status.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ChangeStatusComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts index 45fc5862..f8209452 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts @@ -3,13 +3,14 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { PostsService } from '../../../core/services/posts-services/posts.service'; import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; @Component({ selector: 'app-posts-activity-chart', templateUrl: './posts-activity-chart.component.html', styleUrls: ['./posts-activity-chart.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class PostsActivityChartComponent implements OnInit { /** @@ -45,10 +46,12 @@ export class PostsActivityChartComponent implements OnInit { /** * @param _postService PostService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _postsService: PostsService, - private _customToastrService: CustomToastrService) { + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-list/admin-tags-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-list/admin-tags-list.component.ts index 24ee85ec..1e6ce908 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-list/admin-tags-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-list/admin-tags-list.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-admin-tags-list', templateUrl: './admin-tags-list.component.html', styleUrls: ['./admin-tags-list.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminTagsListComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts index 0a61c0d2..452f191c 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts @@ -1,5 +1,5 @@ import { TagsService } from '../../../core/services/posts-services/tags.service'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Tag } from '../../../core/models/Tag'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -8,7 +8,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-admin-tags-table', templateUrl: './admin-tags-table.component.html', styleUrls: ['./admin-tags-table.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AdminTagsTableComponent implements OnInit { public tags: Tag[] = []; @@ -21,10 +22,12 @@ export class AdminTagsTableComponent implements OnInit { /** * @param _tagsService TagsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _tagsService: TagsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts index 5ac31dd5..c4cef9e3 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { ChartOptions } from './../../../core/models/chart/ChartOptions'; import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -9,7 +9,8 @@ import { TagsService } from '../../../core/services/posts-services/tags.service' selector: 'app-tags-activity-chart', templateUrl: './tags-activity-chart.component.html', styleUrls: ['./tags-activity-chart.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class TagsActivityChartComponent implements OnInit { /** @@ -45,10 +46,12 @@ export class TagsActivityChartComponent implements OnInit { /** * @param _tagsService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _tagsService: TagsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts index 1fe2c71a..b10e8546 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { ChartOptions } from './../../../core/models/chart/ChartOptions'; import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -9,7 +9,8 @@ import { UsersService } from '../../../core/services/users-services/users-servic selector: 'app-users-activity-chart', templateUrl: './users-activity-chart.component.html', styleUrls: ['./users-activity-chart.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class UsersActivityChartComponent implements OnInit { /** @@ -45,10 +46,12 @@ export class UsersActivityChartComponent implements OnInit { /** * @param _usersService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _usersService: UsersService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/icons-cards/icons-cards.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/icons-cards/icons-cards.component.ts index 4aa20273..bfc23396 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/icons-cards/icons-cards.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/icons-cards/icons-cards.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-icons-cards', templateUrl: './icons-cards.component.html', styleUrls: ['./icons-cards.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class IconsCardsComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/index/index.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/index/index.component.ts index bdeb2195..5aac3a55 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/index/index.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/default-pages/index/index.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-index', templateUrl: './index.component.html', styleUrls: ['./index.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class IndexComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts index 04aa6da2..1f83f35e 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts @@ -1,6 +1,6 @@ import { TagsService } from './../../../core/services/posts-services/tags.service'; import { PostsService } from './../../../core/services/posts-services/posts.service'; -import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; +import { Component, OnInit, ElementRef, ViewChild, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { PostForm } from '../../../core/forms/posts/PostForm'; import { Router } from '@angular/router'; @@ -18,7 +18,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-add-post', templateUrl: './add-post.component.html', styleUrls: ['./add-post.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AddPostComponent implements OnInit { /** @@ -81,6 +82,7 @@ export class AddPostComponent implements OnInit { * @param _postsService PostsService, * @param _tagsService TagsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ public constructor( private _router: Router, @@ -88,7 +90,8 @@ export class AddPostComponent implements OnInit { private _globalService: GlobalService, private _postsService: PostsService, private _tagsService: TagsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts index faeffbe8..431a898a 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts @@ -1,5 +1,5 @@ import { CommentsService } from './../../../../core/services/posts-services/comments.service'; -import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, Input, EventEmitter, Output, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { CommentForm } from './../../../../core/forms/posts/CommentForm'; import { Comment } from '../../../../core/models/Comment'; @@ -13,7 +13,8 @@ import { UsersService } from '../../../../core/services/users-services/users-ser selector: 'app-add-comment', templateUrl: './add-comment.component.html', styleUrls: ['./add-comment.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AddCommentComponent implements OnInit { /** @@ -41,11 +42,13 @@ export class AddCommentComponent implements OnInit { * @param _commentsService CommentsService * @param _usersService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentsService: CommentsService, private _usersService: UsersService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts index dc5c831f..d3b6745e 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts @@ -1,5 +1,5 @@ import { CommentsService } from './../../../../core/services/posts-services/comments.service'; -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { Comment } from './../../../../core/models/Comment'; import { UsersService } from '../../../../core/services/users-services/users-service.service'; import { GlobalService } from './../../../../core/services/global-service/global-service.service'; @@ -13,7 +13,8 @@ import { PageInfo } from '../../../../core/models/PageInfo'; selector: 'app-comments-list', templateUrl: './comments-list.component.html', styleUrls: ['./comments-list.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class CommentsListComponent implements OnInit { /** @@ -67,12 +68,14 @@ export class CommentsListComponent implements OnInit { * @param _usersService UsersService * @param _globalService GlobalService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentsService: CommentsService, private _usersService: UsersService, private _globalService: GlobalService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts index 024a33e4..2d65f288 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts @@ -1,5 +1,5 @@ import { CommentsService } from './../../../../core/services/posts-services/comments.service'; -import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, Input, EventEmitter, Output, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { CommentForm } from './../../../../core/forms/posts/CommentForm'; import { Comment } from '../../../../core/models/Comment'; @@ -14,7 +14,8 @@ import { ErrorResponse } from '../../../../core/responses/ErrorResponse'; selector: 'app-edit-comment', templateUrl: './edit-comment.component.html', styleUrls: ['./edit-comment.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class EditCommentComponent implements OnInit { /** @@ -47,12 +48,14 @@ export class EditCommentComponent implements OnInit { * @param _usersService UsersService * @param _globalService GlobalService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _commentsService: CommentsService, private _usersService: UsersService, private _globalService: GlobalService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts index 5f325e16..ecbf7712 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts @@ -1,5 +1,5 @@ import { PostsService } from './../../../core/services/posts-services/posts.service'; -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormGroup } from '@angular/forms'; import { PostForm } from '../../../core/forms/posts/PostForm'; @@ -20,7 +20,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-edit-post', templateUrl: './edit-post.component.html', styleUrls: ['./edit-post.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class EditPostComponent implements OnInit { /** @@ -99,6 +100,7 @@ export class EditPostComponent implements OnInit { * @param _globalService GlobalService * @param _tagsService TagsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _activatedRoute: ActivatedRoute, @@ -107,7 +109,8 @@ export class EditPostComponent implements OnInit { private _usersService: UsersService, private _globalService: GlobalService, private _tagsService: TagsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts index b9bf8e06..cfead42e 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts @@ -1,7 +1,7 @@ import { GeneralServiceService } from './../../../core/services/general-service.service'; import { PostsService } from './../../../core/services/posts-services/posts.service'; import { PageInfo } from './../../../core/models/PageInfo'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { GlobalService } from './../../../core/services/global-service/global-service.service'; import { SearchForm } from './../../../core/forms/SearchForm'; import { FormGroup } from '@angular/forms'; @@ -17,7 +17,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-my-posts', templateUrl: './my-posts.component.html', styleUrls: ['./my-posts.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class MyPostsComponent implements OnInit { /** @@ -91,6 +92,7 @@ export class MyPostsComponent implements OnInit { * @param _usersService UsersService * @param _customToastrService CustomToastrService * @param _generalService GeneralServiceService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _globalService: GlobalService, @@ -99,7 +101,8 @@ export class MyPostsComponent implements OnInit { private _postsService: PostsService, private _usersService: UsersService, private _customToastrService: CustomToastrService, - private _generalService: GeneralServiceService + private _generalService: GeneralServiceService, + private _changeDetectorRef: ChangeDetectorRef ) { } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts index dacd42f1..3fc39bfc 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Post } from './../../../core/models/Post'; import { PostsService } from './../../../core/services/posts-services/posts.service'; import { PageViewDto } from '../../../core/Dto/PageViewDto'; @@ -10,7 +10,8 @@ import { CustomToastrService } from '../../../core/services/custom-toastr.servic selector: 'app-popular-posts', templateUrl: './popular-posts.component.html', styleUrls: ['./popular-posts.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class PopularPostsComponent implements OnInit { /** @@ -40,10 +41,12 @@ export class PopularPostsComponent implements OnInit { /** * @param _postsService PostsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _postsService: PostsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts index a180c1bb..3b7e9cde 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts @@ -1,7 +1,7 @@ import { PostsService } from './../../../core/services/posts-services/posts.service'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { GeneralServiceService } from './../../../core'; -import { ActivatedRoute, Params } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { Post } from './../../../core/models/Post'; import { User } from './../../../core/models/User'; import { GlobalService } from './../../../core/services/global-service/global-service.service'; @@ -11,14 +11,14 @@ import { SearchForm } from './../../../core/forms/SearchForm'; import { PageInfo } from './../../../core/models/PageInfo'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { Messages } from './../../../core/data/Mesages'; -import { PageViewDto } from '../../../core/Dto/PageViewDto'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @Component({ selector: 'app-posts-list', templateUrl: './posts-list.component.html', styleUrls: ['./posts-list.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class PostsListComponent implements OnInit { /** @@ -87,6 +87,7 @@ export class PostsListComponent implements OnInit { * @param _usersService UsersService * @param _postsService: PostsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _globalService: GlobalService, @@ -94,7 +95,8 @@ export class PostsListComponent implements OnInit { private _activatedRoute: ActivatedRoute, private _usersService: UsersService, private _postsService: PostsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts index cadca71e..c333621d 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts @@ -1,5 +1,4 @@ -import { Component, OnInit, Input, Output, output } from "@angular/core"; -import EventEmitter from "events"; +import { Component, OnInit, Input, Output, output, ChangeDetectionStrategy, ChangeDetectorRef } from "@angular/core"; import { PageViewDto } from "../../../core/Dto/PageViewDto"; import { PageInfo } from "../../../core/models/PageInfo"; import { Post } from "../../../core/models/Post"; @@ -11,7 +10,8 @@ import { PostsService } from "../../../core/services/posts-services/posts.servic selector: 'app-posts-table', templateUrl: './posts-table.component.html', styleUrls: ['./posts-table.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class PostsTableComponent implements OnInit { /** @@ -46,10 +46,12 @@ export class PostsTableComponent implements OnInit { /** * @param _postsService PostsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _postsService: PostsService, - private _customToastrService: CustomToastrService) { } + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef) { } /** @inheritdoc */ ngOnInit() { diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/right-sidebar/right-sidebar.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/right-sidebar/right-sidebar.component.ts index 5f7facf0..c55bb98b 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/right-sidebar/right-sidebar.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/right-sidebar/right-sidebar.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-right-sidebar', templateUrl: './right-sidebar.component.html', styleUrls: ['./right-sidebar.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class RightSidebarComponent implements OnInit { diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts index 6c453d7b..cadcd898 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts @@ -1,5 +1,5 @@ import { PostsService } from './../../../core/services/posts-services/posts.service'; -import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { GeneralServiceService } from './../../../core'; import { UsersService } from '../../../core/services/users-services/users-service.service'; @@ -14,7 +14,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-show', templateUrl: './show.component.html', styleUrls: ['./show.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ShowComponent implements OnInit { /** @@ -64,6 +65,7 @@ export class ShowComponent implements OnInit { * @param _globalService GlobalService * @param _router Router * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _generalService: GeneralServiceService, @@ -72,7 +74,8 @@ export class ShowComponent implements OnInit { private _usersService: UsersService, private _globalService: GlobalService, private _router: Router, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts index 45332673..442a1fec 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts @@ -1,6 +1,6 @@ import { TagsService } from './../../../core/services/posts-services/tags.service'; import { Tag } from './../../../core/models/Tag'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { TagForm } from './../../../core/forms/posts/TagForm'; import { User } from './../../../core/models/User'; @@ -14,7 +14,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-add-tag', templateUrl: './add-tag.component.html', styleUrls: ['./add-tag.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AddTagComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts index 79a1b6b4..12680dbe 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { TagForm } from './../../../core/forms/posts/TagForm'; import { User } from './../../../core/models/User'; @@ -15,7 +15,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-edit-tag', templateUrl: './edit-tag.component.html', styleUrls: ['./edit-tag.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class EditTagComponent implements OnInit { /** @@ -50,6 +51,7 @@ export class EditTagComponent implements OnInit { * @param _globalService GlobalService * @param _tagsService TagsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _activatedRoute: ActivatedRoute, @@ -57,7 +59,8 @@ export class EditTagComponent implements OnInit { private _usersService: UsersService, private _globalService: GlobalService, private _tagsService: TagsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts index 10e69d97..fe229e64 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Tag } from './../../../core/models/Tag'; import { TagsService } from './../../../core/services/posts-services/tags.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @@ -8,13 +8,16 @@ import { CustomToastrService } from '../../../core/services/custom-toastr.servic selector: 'app-popular-tags', templateUrl: './popular-tags.component.html', styleUrls: ['./popular-tags.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class PopularTagsComponent implements OnInit { public tags: Tag[] = []; + constructor( private _tagsService: TagsService, - private _customToastrService: CustomToastrService) { + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef) { } ngOnInit() { diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/tags-list/tags-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/tags-list/tags-list.component.ts index d19b8b36..150a08f8 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/tags-list/tags-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/tags-list/tags-list.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-tags-list', templateUrl: './tags-list.component.html', styleUrls: ['./tags-list.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class TagsListComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/about/about.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/about/about.component.ts index 13824cb9..201057f5 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/about/about.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/about/about.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; @Component({ selector: 'app-about', templateUrl: './about.component.html', styleUrls: ['./about.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AboutComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts index 1378eb94..ddf52660 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { MessageForm } from '../../../core/forms/MessageForm'; import { Messages } from '../../../core/data/Mesages'; @@ -14,7 +14,8 @@ import { UsersService } from '../../../core/services/users-services/users-servic selector: 'app-contacts', templateUrl: './contacts.component.html', styleUrls: ['./contacts.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ContactsComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/layout-component/layout-component.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/layout-component/layout-component.component.ts index 0fab8a3b..47aa70d6 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/layout-component/layout-component.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/layout-component/layout-component.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { GlobalService } from './../../core/services/global-service/global-service.service'; import { UsersService } from '../../core/services/users-services/users-service.service'; import { User } from './../../core/models/User'; @@ -7,7 +7,8 @@ import { User } from './../../core/models/User'; selector: 'app-layout-component', templateUrl: './layout-component.component.html', styleUrls: ['./layout-component.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class LayoutComponentComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts index b5f934a1..bcf06afc 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { User } from './../../../core/models/User'; import { FormGroup } from '@angular/forms'; import { ProfileForm } from './../../../core/forms/user/ProfileForm'; @@ -17,7 +17,8 @@ import { AccountsService } from '../../../core/services/users-services/account.s selector: 'app-change-email', templateUrl: './change-email.component.html', styleUrls: ['./change-email.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ChangeEmailComponent implements OnInit { /** @@ -46,13 +47,15 @@ export class ChangeEmailComponent implements OnInit { * @param _usersService UsersService * @param _accountsService: AccountsService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _router: Router, private _globalService: GlobalService, private _usersService: UsersService, private _accountsService: AccountsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts index 1c32c387..eca9c206 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { User } from './../../../core/models/User'; import { FormGroup } from '@angular/forms'; import { TinyMCEOptionsObject } from './../../../core/models/TinyMCEOptionsObject'; @@ -16,7 +16,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-change-password', templateUrl: './change-password.component.html', styleUrls: ['./change-password.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ChangePasswordComponent implements OnInit { /** @@ -44,12 +45,14 @@ export class ChangePasswordComponent implements OnInit { * @param _globalService GlobalService * @param _usersService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _router: Router, private _globalService: GlobalService, private _usersService: UsersService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts index 19ddcebc..c55938c2 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { User } from './../../../core/models/User'; import { FormGroup } from '@angular/forms'; import { ProfileForm } from './../../../core/forms/user/ProfileForm'; @@ -16,7 +16,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-change-phone-number', templateUrl: './change-phone-number.component.html', styleUrls: ['./change-phone-number.component.scss'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ChangePhoneNumberComponent implements OnInit { /** @@ -44,12 +45,14 @@ export class ChangePhoneNumberComponent implements OnInit { * @param _globalService GlobalService * @param _usersService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _router: Router, private _globalService: GlobalService, private _usersService: UsersService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts index e959ddae..d909d5b0 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { User } from './../../../core/models/User'; import { Router } from '@angular/router'; import { GlobalService } from './../../../core/services/global-service/global-service.service'; @@ -16,7 +16,8 @@ import { ErrorResponse } from '../../../core/responses/ErrorResponse'; selector: 'app-edit-profile', templateUrl: './edit-profile.component.html', styleUrls: ['./edit-profile.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class EditProfileComponent implements OnInit { /** @@ -44,12 +45,14 @@ export class EditProfileComponent implements OnInit { * @param _globalService GlobalService * @param _usersService UsersService * @param _customToastrService CustomToastrService + * @param _changeDetectorRef: ChangeDetectorRef */ constructor( private _router: Router, private _globalService: GlobalService, private _usersService: UsersService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts index 7ba64d32..db10380a 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { GeneralServiceService } from './../../../core'; import { ActivatedRoute, Router } from '@angular/router'; import { User } from './../../../core/models/User'; @@ -13,7 +13,8 @@ import { AccountsService } from '../../../core/services/users-services/account.s selector: 'app-profile-page', templateUrl: './profile-page.component.html', styleUrls: ['./profile-page.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class ProfilePageComponent implements OnInit { /** @@ -70,7 +71,8 @@ export class ProfilePageComponent implements OnInit { private _globalService: GlobalService, private _usersService: UsersService, private _accountsService: AccountsService, - private _customToastrService: CustomToastrService + private _customToastrService: CustomToastrService, + private _changeDetectorRef: ChangeDetectorRef ) { } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts index 9b21cdf2..c4041d46 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { AuthorizationForm } from './../../../core/forms/user/AuthorizationForm'; import { Router } from '@angular/router'; @@ -14,7 +14,8 @@ import { AccountsService } from '../../../core/services/users-services/account.s selector: 'app-authorization', templateUrl: './authorization.component.html', styleUrls: ['./authorization.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class AuthorizationComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts index ed388ca1..8d8a84e4 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts @@ -1,9 +1,8 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Messages } from './../../../core/data/Mesages'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { RegistrationForm } from '../../../core/forms/user/RegistrationForm'; -import { GlobalService } from '../../../core/services/global-service/global-service.service'; import { UsersService } from '../../../core/services/users-services/users-service.service'; import { Router } from '@angular/router'; @@ -11,7 +10,8 @@ import { Router } from '@angular/router'; selector: 'app-registration', templateUrl: './registration.component.html', styleUrls: ['./registration.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class RegistrationComponent implements OnInit { /** From b1ccbfcdfd4970d7e7ebdb9c9e02c1b605ea3464 Mon Sep 17 00:00:00 2001 From: Vitalii Lakatosh Date: Tue, 10 Feb 2026 23:16:15 +0200 Subject: [PATCH 2/4] Use async Promices for Api requests --- .../admin-comments-list.component.ts | 15 ++-- .../admin-comments-table.component.ts | 16 ++-- .../comments-activity.component.ts | 11 +-- .../admin-posts-table.component.ts | 15 ++-- .../posts-activity-chart.component.ts | 11 +-- .../admin-tags-table.component.ts | 13 ++-- .../tags-activity-chart.component.ts | 11 +-- .../users-activity-chart.component.ts | 12 +-- .../layout-component.component.ts | 5 +- .../posts/add-post/add-post.component.ts | 20 +++-- .../add-comment/add-comment.component.ts | 10 ++- .../comments-list/comments-list.component.ts | 20 +++-- .../edit-comment/edit-comment.component.ts | 18 +++-- .../posts/edit-post/edit-post.component.ts | 41 ++++++---- .../posts/my-posts/my-posts.component.ts | 67 +++++++++------- .../popular-posts/popular-posts.component.ts | 9 ++- .../posts/posts-list/posts-list.component.ts | 77 ++++++++++--------- .../posts-table/posts-table.component.ts | 21 +++-- .../app/shared/posts/show/show.component.ts | 42 ++++++---- .../shared/tags/add-tag/add-tag.component.ts | 22 +++--- .../tags/edit-tag/edit-tag.component.ts | 19 ++--- .../popular-tags/popular-tags.component.ts | 10 ++- .../contacts/contacts.component.ts | 16 ++-- .../change-email/change-email.component.ts | 32 +++++--- .../change-password.component.ts | 20 +++-- .../change-phone-number.component.ts | 20 +++-- .../edit-profile/edit-profile.component.ts | 23 ++++-- .../profile-page/profile-page.component.ts | 20 +++-- .../authorization/authorization.component.ts | 59 +++++++------- .../registration/registration.component.ts | 12 ++- 30 files changed, 392 insertions(+), 295 deletions(-) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts index 5b7e8288..8a73602f 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts @@ -90,7 +90,7 @@ export class AdminCommentsListComponent implements OnInit { * @param page number * @returns void */ - private _getComments(page: number = 0): void { + private async _getComments(page: number = 0): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -103,14 +103,15 @@ export class AdminCommentsListComponent implements OnInit { tag: null, sortParameters: sortParameters }; - this._commentsService.list(null, model).subscribe( - (response: any) => { - this.comments = response.comments; - this.isLoaded = true; + + this._commentsService.list(null, model) + .subscribe({ + next: (response: any) => { + this.comments = [...response.comments]; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); /*!isNaN(postId) ? this._commentService.getCommentsByPostId(postId) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts index 07d53d63..49032e1c 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts @@ -91,7 +91,7 @@ export class AdminCommentsTableComponent implements OnInit { * @param page number * @returns void */ - private _getComments(page: number = 0): void { + private async _getComments(page: number = 0): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -104,14 +104,16 @@ export class AdminCommentsTableComponent implements OnInit { tag: null, sortParameters: sortParameters }; - this._commentsService.list(null, model).subscribe( - (response: any) => { - this.comments = response.comments; - this.isLoaded = true; + + this._commentsService.list(null, model) + .subscribe({ + next: (response: any) => { + this.comments = [...response.comments]; + this.pageInfo = { ...response.pageInfo }; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); /*!isNaN(postId) ? this._commentService.getCommentsByPostId(postId) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts index 68e0ada7..50d53c59 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts @@ -31,15 +31,16 @@ export class CommentsActivityComponent implements OnInit { /** * @inheritdoc */ - ngOnInit(): void { - this._commentService.commentsActivity().subscribe( - (response: any) => { + async ngOnInit(): Promise { + this._commentService.commentsActivity() + .subscribe({ + next: (response: any) => { this.chartOptions.Data[0] = response; this.chartOptions = this.chartOptions; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts index f2682569..066090e6 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts @@ -84,7 +84,7 @@ export class AdminPostsTableComponent implements OnInit { /** * Get all posts */ - private _getPosts(page = 1): void { + private async _getPosts(page = 1): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -99,15 +99,14 @@ export class AdminPostsTableComponent implements OnInit { }; this._postsService.list(model) - .subscribe( - (response: PageViewDto) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - this.isLoaded = true; + .subscribe({ + next: (response: any) => { + this.posts = [...response.posts]; + this.pageInfo = { ...response.pageInfo }; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts index f8209452..24457fb4 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts @@ -31,15 +31,16 @@ export class PostsActivityChartComponent implements OnInit { /** * @inheritdoc */ - ngOnInit(): void { - this._postsService.postsActivity().subscribe( - (response: any) => { + async ngOnInit(): Promise { + this._postsService.postsActivity() + .subscribe({ + next: (response: any) => { this.chartOptions.Data[0] = response; this.chartOptions = this.chartOptions; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts index 452f191c..984ceb7f 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts @@ -41,7 +41,7 @@ export class AdminTagsTableComponent implements OnInit { * Get all tags. * @param page number */ - private _getTags(page: number = 0): void { + private async _getTags(page: number = 0): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -55,15 +55,14 @@ export class AdminTagsTableComponent implements OnInit { sortParameters: sortParameters }; this._tagsService.list(model) - .subscribe( - (response: any) => { + .subscribe({ + next: (response: any) => { this.tags = response.tags; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; - });; + } + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts index c4cef9e3..ee46d6ed 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts @@ -31,15 +31,16 @@ export class TagsActivityChartComponent implements OnInit { /** * @inheritdoc */ - ngOnInit(): void { - this._tagsService.tagsActivity().subscribe( - (response: any) => { + async ngOnInit(): Promise { + this._tagsService.tagsActivity() + .subscribe({ + next: (response: any) => { this.chartOptions.Data[0] = response; this.chartOptions = this.chartOptions; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts index b10e8546..9e35b8c1 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts @@ -31,15 +31,17 @@ export class UsersActivityChartComponent implements OnInit { /** * @inheritdoc */ - ngOnInit(): void { - this._usersService.usersActivity().subscribe( - (response: any) => { + async ngOnInit(): Promise { + this._usersService.usersActivity() + + .subscribe({ + next: (response: any) => { this.chartOptions.Data[0] = response; this.chartOptions = this.chartOptions; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/layout-component/layout-component.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/layout-component/layout-component.component.ts index 78423011..616cacf5 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/layout-component/layout-component.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/layout-component/layout-component.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { GlobalService } from './../../core/services/global-service/global-service.service'; import { User } from './../../core/models/User'; import { UsersService } from '../../core/services/users-services/users-service.service'; @@ -7,7 +7,8 @@ import { UsersService } from '../../core/services/users-services/users-service.s selector: 'app-layout-component', templateUrl: './layout-component.component.html', styleUrls: ['./layout-component.component.css'], - standalone: false + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush }) export class LayoutComponentComponent implements OnInit { /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts index 1f83f35e..69ed362b 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts @@ -185,20 +185,21 @@ export class AddPostComponent implements OnInit { * * @param post Post */ - add() { + async add(): Promise { if (this.postForm.valid) { this.postForm.value.id = 0; this.postForm.value.tags = this.tagsList; this.postForm.value.authorId = this.user?.id; this._postsService.add({ ...this.postForm.value - }).subscribe( - () => { + }).subscribe({ + next: () => { this._customToastrService.displaySuccessMessage(Messages.POST_CREATED_SUCCESSFULLY); this._router.navigate(['/']); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -214,13 +215,16 @@ export class AddPostComponent implements OnInit { * Get available tags. * @returns void */ - private _getTags(): void { - this._tagsService.list().subscribe( - (response: Tag[]) => { + private async _getTags(): Promise { + this._tagsService.list() + + .subscribe({ + next: (response: Tag[]) => { this.availableTags = response; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts index 431a898a..b4051aa2 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts @@ -65,7 +65,7 @@ export class AddCommentComponent implements OnInit { * Add Comment * @returns void */ - addComment(): void { + async addComment(): Promise { if (this._usersService.isLoggedIn() && this.commentForm.valid) { const comment: Comment = new Comment (); comment.postId = this.postId; @@ -78,13 +78,15 @@ export class AddCommentComponent implements OnInit { comment.name = this.commentForm.get('name')?.value; } - this._commentsService.add(comment).subscribe( - (response: any) => { + this._commentsService.add(comment) + .subscribe({ + next: (response: any) => { this.onAdd.emit(response.json()); this._customToastrService.displaySuccessMessage(Messages.COMMENT_CREATED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); this.onAdd.emit(null); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts index d3b6745e..25accfd7 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts @@ -81,7 +81,7 @@ export class CommentsListComponent implements OnInit { /** * @inheritdoc */ - ngOnInit() { + async ngOnInit(): Promise { // this._getCommentsForCurrentPost(); this.loggedIn = this._usersService.isLoggedIn(); @@ -100,14 +100,18 @@ export class CommentsListComponent implements OnInit { pageSize: 10, displayType: null }; + if(this.postId) { this._commentsService.list(this.postId, sortParameters) - .subscribe((response: any) => { + + .subscribe({ + next: (response: any) => { this.comments = response.comments; this.pageInfo = response.pageInfo; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -165,14 +169,16 @@ export class CommentsListComponent implements OnInit { * @param comment Comment * @returns void */ - deleteAction(comment: Comment): void { - this._commentsService.delete(comment.id).subscribe( - (response: any) => { + async deleteAction(comment: Comment): Promise { + this._commentsService.delete(comment.id) + .subscribe({ + next: (response: any) => { this.onDeleteCommentAction(response.id); this._customToastrService.displaySuccessMessage(Messages.COMMENT_DELETED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts index 2d65f288..7eaea4c3 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/edit-comment/edit-comment.component.ts @@ -88,18 +88,20 @@ export class EditCommentComponent implements OnInit { * @param comment Comment * @returns void */ - public edit(): void { + public async edit(): Promise { if (this.user?.id === this.comment?.userId && this.commentForm.valid && this.comment) { this.comment.commentBody = this.commentForm.get('content')?.value; - this._commentsService.edit(this.comment.id, this.comment).subscribe( - (response: any) => { - this.onEdit.emit(response); - this._customToastrService.displaySuccessMessage(Messages.COMMENT_EDITED_SUCCESSFULLY); - }, - (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._commentsService.edit(this.comment.id, this.comment) + .subscribe({ + next: (response: any) => { + this.onEdit.emit(response); + this._customToastrService.displaySuccessMessage(Messages.COMMENT_EDITED_SUCCESSFULLY); + }, + error: (error: ErrorResponse) => { + this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts index ecbf7712..428aa694 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts @@ -157,7 +157,7 @@ export class EditPostComponent implements OnInit { * @param post Post * @returns void */ - edit(post: Post): void { + async edit(post: Post): Promise { if (this.isCurrentUserPost && this.postForm.valid && this._postId @@ -165,13 +165,15 @@ export class EditPostComponent implements OnInit { post.id = this._postId; post.tags = this.post?.tags; post.authorId = this.user?.id; - this._postsService.edit(this._postId, post).subscribe( - () => { + this._postsService.edit(this._postId, post) + .subscribe({ + next: (response: any) => { this._customToastrService.displaySuccessMessage(Messages.POST_EDITED_SUCCESSFULLY); this._router.navigate(['/blog/post/' + this._postId]); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -179,15 +181,17 @@ export class EditPostComponent implements OnInit { /** * Delete post action. */ - deleteAction(): void { + async deleteAction(): Promise { if (this.isCurrentUserPost && this._postId && this._globalService._currentUser) { - this._postsService.delete(this._postId, this._globalService._currentUser.id).subscribe( - () => { + this._postsService.delete(this._postId, this._globalService._currentUser.id) + .subscribe({ + next: () => { this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); this._router.navigate(['/blog']); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -266,10 +270,11 @@ export class EditPostComponent implements OnInit { * Get post. * @returns void */ - private _getPost(): void { + private async _getPost(): Promise { if(this._postId) { - this._postsService.showPost(this._postId).subscribe( - (response: any) => { + this._postsService.showPost(this._postId) + .subscribe({ + next: (response: any) => { this.post = response.post; if(this.post) { this.post.tags = response.tags; @@ -282,8 +287,9 @@ export class EditPostComponent implements OnInit { this._setFormData(); } }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -292,13 +298,16 @@ export class EditPostComponent implements OnInit { * Get available tags. * @returns void */ - private _getTags(): void { - this._tagsService.list().subscribe( - (response: Tag[]) => { + private async _getTags(): Promise { + this._tagsService.list() + + .subscribe({ + next: (response: Tag[]) => { this.availableTags = response; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts index cfead42e..b9e54b00 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts @@ -139,16 +139,18 @@ export class MyPostsComponent implements OnInit { * @param postId number * @returns void */ - public deleteAction(postId: number): void { + public async deleteAction(postId: number): Promise { const post = this.posts.find(p => p.id === postId); if (this.isLoggedIn && this.posts[postId].author.id === this.user?.id && this._globalService._currentUser) { - this._postsService.delete(postId, this._globalService._currentUser.id).subscribe( - (response: any) => { + this._postsService.delete(postId, this._globalService._currentUser.id) + .subscribe({ + next: (response: any) => { this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); this._onDeleteCommentAction(response.id); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -158,16 +160,18 @@ export class MyPostsComponent implements OnInit { * @param id number * @returns void */ - public like(id: number): void { + public async like(id: number): Promise { if (this.isLoggedIn) { - this._postsService.like(id).subscribe( - (response: any) => { + this._postsService.like(id) + .subscribe({ + next: (response: any) => { const ind = this.posts.findIndex(post => post.id === id); this.posts[ind] = response; this.posts = this.posts; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -177,16 +181,18 @@ export class MyPostsComponent implements OnInit { * @param id number * @returns void */ - public dislike(id: number): void { + public async dislike(id: number): Promise { if (this.isLoggedIn) { - this._postsService.dislike(id).subscribe( - (response: any) => { + this._postsService.dislike(id) + .subscribe({ + next: (response: any) => { const ind = this.posts.findIndex(post => post.id === id); this.posts[ind] = response; this.posts = this.posts; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -205,7 +211,7 @@ export class MyPostsComponent implements OnInit { * @param search string * @returns void */ - search(search: string): void { + async search(search: string): Promise { this.isLoaded = false; const model = { search: search, @@ -213,15 +219,15 @@ export class MyPostsComponent implements OnInit { sortParameters: null, }; if(this._userId) { - this._postsService.userPosts(this._userId, model).subscribe( - (response: any) => { + this._postsService.userPosts(this._userId, model) + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = this.pageInfo; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } } @@ -230,7 +236,7 @@ export class MyPostsComponent implements OnInit { * Sort posts by parameter. * @returns void */ - sort() { + async sort(): Promise { const sortParameters = { sortBy: this.sortBy, orderBy: this.orderBy, @@ -244,14 +250,16 @@ export class MyPostsComponent implements OnInit { sortParameters: sortParameters, }; if(this._userId) { - this._postsService.userPosts(this._userId, model).subscribe( - (response: any) => { + this._postsService.userPosts(this._userId, model) + + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = response.pageInfo; - }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -260,7 +268,7 @@ export class MyPostsComponent implements OnInit { * Get all posts. * @returns void */ - private _getPosts(page = 1): void { + private async _getPosts(page = 1): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -273,15 +281,18 @@ export class MyPostsComponent implements OnInit { tag: this._searchFilter, sortParameters: sortParameters, }; + if(this._userId) { - this._postsService.userPosts(this._userId, model).subscribe( - (response: any) => { + this._postsService.userPosts(this._userId, model) + + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = response.pageInfo; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts index 3fc39bfc..bd9576b5 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts @@ -60,7 +60,7 @@ export class PopularPostsComponent implements OnInit { * Get all posts. * @returns void */ - private _getPosts(page = 1): void { + private async _getPosts(page = 1): Promise { const sortParameters = { sortBy: this.sortBy, orderBy: this.orderBy, @@ -74,13 +74,14 @@ export class PopularPostsComponent implements OnInit { }; this._postsService.list(model) - .subscribe( - (response: PageViewDto) => { + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = response.pageInfo; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts index 3b7e9cde..be16401d 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts @@ -119,16 +119,18 @@ export class PostsListComponent implements OnInit { * @param postId number * @returns void */ - deleteAction(postId: number): void { + async deleteAction(postId: number): Promise { const postItem = this.posts.find(post => post.id === postId); if (this.loggedIn && this._globalService._currentUser && postItem?.authorId === this._globalService._currentUser?.id) { - this._postsService.delete(postId, this._globalService._currentUser.id).subscribe( - (response: any) => { + this._postsService.delete(postId, this._globalService._currentUser.id) + .subscribe({ + next: (response: any) => { this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); this._onDeleteCommentAction(response.id); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -138,16 +140,18 @@ export class PostsListComponent implements OnInit { * @param id number * @returns void */ - public like(id: number): void { + public async like(id: number): Promise { if (this.loggedIn) { - this._postsService.like(id).subscribe( - (response: any) => { + this._postsService.like(id) + .subscribe({ + next: (response: any) => { const ind = this.posts.findIndex(post => post.id === id); this.posts[ind] = response; this.posts = this.posts; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -157,16 +161,18 @@ export class PostsListComponent implements OnInit { * @param id number * @returns void */ - public dislike(id: number): void { + public async dislike(id: number): Promise { if (this.loggedIn) { - this._postsService.dislike(id).subscribe( - (response: any) => { + this._postsService.dislike(id) + .subscribe({ + next: (response: any) => { const ind = this.posts.findIndex(post => post.id === id); this.posts[ind] = response; this.posts = this.posts; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -186,22 +192,22 @@ export class PostsListComponent implements OnInit { * @param search string * @returns void */ - public search(search: string): void { + public async search(search: string): Promise { this.isLoaded = false; const model = { search: search, tag: this._searchFilter, sortParameters: null, }; - this._postsService.list(model).subscribe( - (response: any) => { - this.posts = response.posts; - this.pageInfo = this.pageInfo; - this.isLoaded = true; + this._postsService.list(model) + .subscribe({ + next: (response: any) => { + this.posts = [...response.posts]; + this.pageInfo = { ...response.pageInfo }; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } @@ -209,7 +215,7 @@ export class PostsListComponent implements OnInit { * Sort posts by parameter. * @returns void */ - public sort(): void { + public async sort(): Promise { const sortParameters = { sortBy: this.sortBy, orderBy: this.orderBy, @@ -222,23 +228,23 @@ export class PostsListComponent implements OnInit { tag: this._searchFilter, sortParameters: sortParameters, }; - this._postsService.list(model).subscribe( - (response: any) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - + this._postsService.list(model) + .subscribe({ + next: (response: any) => { + this.posts = [...response.posts]; + this.pageInfo = { ...response.pageInfo }; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); - } /** * Get all posts. * @returns void */ - private _getPosts(page = 1): void { + private async _getPosts(page = 1): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -253,15 +259,14 @@ export class PostsListComponent implements OnInit { }; this._postsService.list(model) - .subscribe( - (response: PageViewDto) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - this.isLoaded = true; + .subscribe({ + next: (response: any) => { + this.posts = [...response.posts]; + this.pageInfo = { ...response.pageInfo }; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts index c333621d..f65b1bdf 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts @@ -63,7 +63,7 @@ export class PostsTableComponent implements OnInit { * @param page number * @returns void */ - private _getPosts(page: number = 1): void { + private async _getPosts(page: number = 1): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -76,29 +76,28 @@ export class PostsTableComponent implements OnInit { sortParameters: sortParameters, }; if (this.userId != null) { - this._postsService.userPosts(this.userId, model).subscribe( - (response: any) => { + this._postsService.userPosts(this.userId, model) + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = response.pageInfo; this.postsCount.emit(this.pageInfo.totalItems); - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } else { this._postsService.list(model) - .subscribe( - (response: PageViewDto) => { + .subscribe({ + next: (response: any) => { this.posts = response.posts; this.pageInfo = response.pageInfo; this.postsCount.emit(this.pageInfo.totalItems); - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - this.isLoaded = true; + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts index cadcd898..1f29d6f4 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts @@ -96,14 +96,16 @@ export class ShowComponent implements OnInit { * @param id number * @returns void */ - public like(id: number): void { + public async like(id: number): Promise { if(this.postId) { - this._postsService.like(this.postId).subscribe( - (response: any) => { + this._postsService.like(this.postId) + .subscribe({ + next: (response: any) => { this.post = response; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -113,14 +115,16 @@ export class ShowComponent implements OnInit { * @param id number * @returns void */ - public dislike(id: number): void { + public async dislike(id: number): Promise { if(this.postId) { - this._postsService.dislike(this.postId).subscribe( - (response: any) => { + this._postsService.dislike(this.postId) + .subscribe({ + next: (response: any) => { this.post = response; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -128,14 +132,16 @@ export class ShowComponent implements OnInit { /** * Delete post. */ - public deleteAction() { + public async deleteAction(): Promise { if (this.loggedIn && this.post && this.post?.authorId === this.user?.id) { - this._postsService.delete(this.post.id, this.user.id).subscribe( - () => { + this._postsService.delete(this.post.id, this.user.id) + .subscribe({ + next: (response: any) => { this._router.navigateByUrl('/blog'); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -150,20 +156,22 @@ export class ShowComponent implements OnInit { /** * Get post by id. */ - private _getPost() { + private async _getPost(): Promise { if(this.postId) { - this._postsService.showPost(this.postId).subscribe( - (response: any) => { + this._postsService.showPost(this.postId) + + .subscribe({ + next: (response: any) => { this.post = response.post; if(this.post) { this.post.tags = response.tags; this.post.comments = response.comments.comments; } this.pageInfo = response.comments.pageInfo; - this.isLoaded = true; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts index 442a1fec..ec862cf3 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/add-tag/add-tag.component.ts @@ -66,18 +66,18 @@ export class AddTagComponent implements OnInit { * * @param tag Tag */ - public add(tag: Tag): void { + public async add(tag: Tag): Promise { if (this.tagForm.valid) { - this._tagsService.add(...this.tagForm.value).subscribe( - () => { - //this._customToastrService.displaySuccessMessage(Messages.TAG_CREATED_SUCCESSFULLY); - this._router.navigate(['/admin/tags']); - }, - (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); - }); - - + this._tagsService.add(...this.tagForm.value) + .subscribe({ + next: (response: any) => { + //this._customToastrService.displaySuccessMessage(Messages.TAG_CREATED_SUCCESSFULLY); + this._router.navigate(['/admin/tags']); + }, + error: (error: ErrorResponse) => { + this._customToastrService.displayErrorMessage(error); + } + }); } } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts index 12680dbe..1193fce0 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts @@ -8,7 +8,6 @@ import { GlobalService } from './../../../core/services/global-service/global-se import { TagsService } from './../../../core/services/posts-services/tags.service'; import { Tag } from './../../../core/models/Tag'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; -import { Messages } from './../../../core/data/Mesages'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @Component({ @@ -89,17 +88,18 @@ export class EditTagComponent implements OnInit { * * @param tag Tag */ - public edit(tag: Tag): void { + public async edit(tag: Tag): Promise { if (this.tagForm.valid && this.tag && this._tagId) { this.tag.title = tag['title']; this._tagsService.edit(this._tagId, this.tag) - .subscribe( - () => { + .subscribe({ + next: (response: any) => { //this._customToastrService.displaySuccessMessage(Messages.TAG_EDITED_SUCCESSFULLY); this._router.navigate(['/admin/tags']); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -114,16 +114,17 @@ export class EditTagComponent implements OnInit { /** * Get tag by id. */ - private _getTag(): void { + private async _getTag(): Promise { if(this._tagId) { this._tagsService.getTag(this._tagId) - .subscribe( - (response: any) => { + .subscribe({ + next: (response: any) => { this.tag = response; this._setFormData(); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts index fe229e64..836f5a47 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts @@ -28,7 +28,7 @@ export class PopularTagsComponent implements OnInit { * Get all tags. * @returns void */ - private _getTags(page = 1): void { + private async _getTags(page = 1): Promise { const sortParameters = { sortBy: null, orderBy: null, @@ -40,13 +40,15 @@ export class PopularTagsComponent implements OnInit { search: null, sortParameters: sortParameters }; + this._tagsService.list(model) - .subscribe( - (response: any) => { + .subscribe({ + next: (response: any) => { this.tags = response.tags; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts index ddf52660..75e70c0a 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.ts @@ -62,14 +62,16 @@ export class ContactsComponent implements OnInit { * @param message any * @returns void */ - public sendMessage(message: any): void { + public async sendMessage(message: any): Promise { message['messageType'] = MessageType.MessageForAdmins; - this._messagesService.sendMessage(message).subscribe( - () => { - this._customToastrService.displaySuccessMessage(Messages.MESSAGE_SENDED_SUCCESSFULLY); - }, - (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._messagesService.sendMessage(message) + .subscribe({ + next: (response: any) => { + this._customToastrService.displaySuccessMessage(Messages.MESSAGE_SENDED_SUCCESSFULLY); + }, + error: (error: ErrorResponse) => { + this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts index bcf06afc..4b8c9c2a 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts @@ -79,14 +79,16 @@ export class ChangeEmailComponent implements OnInit { * @param id number * @returns void */ - private _getProfile(id: number): void { - this._usersService.getProfile(id).subscribe( - (response: any) => { + private async _getProfile(id: number): Promise { + this._usersService.getProfile(id) + .subscribe({ + next: (response: any) => { this.user = response; this._setFormData(); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } @@ -94,7 +96,7 @@ export class ChangeEmailComponent implements OnInit { * Change user email. * @param profileModel any */ - edit(profileModel: any): void { + async edit(profileModel: any): Promise { if(this.user && this._globalService._currentUser && this._globalService._currentUser?.profile) { const profile = new ProfileViewDto( profileModel.email, @@ -103,8 +105,11 @@ export class ChangeEmailComponent implements OnInit { this.user.phoneNumber, this._globalService._currentUser?.password, this.user.profile?.about); - this._usersService.updateProfile(this._globalService._currentUser?.profile?.id, profile).subscribe( - (result: any) => { + + this._usersService.updateProfile(this._globalService._currentUser?.profile?.id, profile) + + .subscribe({ + next: (result: any) => { if(this._globalService._currentUser && this._globalService._currentUser.profile) { this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; this._globalService._currentUser.email = result.email; @@ -116,8 +121,9 @@ export class ChangeEmailComponent implements OnInit { // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ this._customToastrService.displaySuccessMessage(Messages.EMAIL_CHANGED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } @@ -126,13 +132,15 @@ export class ChangeEmailComponent implements OnInit { * Verify email. * @returns void. */ - public verifyEmail(): void { - this._accountsService.sendConfirmationEmail().subscribe( - () => { + public async verifyEmail(): Promise { + this._accountsService.sendConfirmationEmail() + .subscribe({ + next: () => { this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts index eca9c206..1924d0c7 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts @@ -76,14 +76,16 @@ export class ChangePasswordComponent implements OnInit { * @param id number * @returns void */ - private _getProfile(id: number): void { - this._usersService.getProfile(id).subscribe( - (response: any) => { + private async _getProfile(id: number): Promise { + this._usersService.getProfile(id) + .subscribe({ + next: (response: any) => { this.user = response; this._setFormData(); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } @@ -91,7 +93,7 @@ export class ChangePasswordComponent implements OnInit { * Change user email. * @param profileModel any */ - edit(profileModel: any): void { + async edit(profileModel: any): Promise { if (profileModel.oldPassword !== null && profileModel.newPassword !== null && profileModel.confirmPassword != null @@ -102,13 +104,15 @@ export class ChangePasswordComponent implements OnInit { const profile = new ChangePasswordDto( profileModel.oldPassword, profileModel.newPassword); - this._usersService.changePassword(profile).subscribe( - () => { + this._usersService.changePassword(profile) + .subscribe({ + next: (response: any) => { // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ this._customToastrService.displaySuccessMessage(Messages.PASSWORD_CHANGED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts index c55938c2..dd657ebd 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts @@ -77,13 +77,15 @@ export class ChangePhoneNumberComponent implements OnInit { * @returns void */ private _getProfile(id: number): void { - this._usersService.getProfile(id).subscribe( - (response: any) => { + this._usersService.getProfile(id) + .subscribe({ + next: (response: any) => { this.user = response; this._setFormData(); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } @@ -92,7 +94,7 @@ export class ChangePhoneNumberComponent implements OnInit { * @param profileModel any * @returns void */ - edit(profileModel: any): void { + async edit(profileModel: any): Promise { if(this.user && this._globalService._currentUser?.profile) { const profile = new ProfileViewDto( this.user.email ?? '', @@ -101,8 +103,11 @@ export class ChangePhoneNumberComponent implements OnInit { profileModel.phoneNumber, undefined, this.user.profile?.about); - this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile).subscribe( - (result: any) => { + + this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile) + + .subscribe({ + next: (result: any) => { if(this._globalService._currentUser?.profile) { this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; this._globalService._currentUser.email = result.email; @@ -114,8 +119,9 @@ export class ChangePhoneNumberComponent implements OnInit { // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ this._customToastrService.displaySuccessMessage(Messages.PHONE_NUMBER_CHANGED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts index d909d5b0..395a992b 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts @@ -77,13 +77,15 @@ export class EditProfileComponent implements OnInit { * @returns void */ private _getProfile(id: number): void { - this._usersService.getProfile(id).subscribe( - (response: any) => { + this._usersService.getProfile(id) + .subscribe({ + next: (response: any) => { this.user = response; this._setFormData(); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } @@ -92,7 +94,7 @@ export class EditProfileComponent implements OnInit { * @param profileModel any * @returns void */ - edit(profileModel: any): void { + async edit(profileModel: any): Promise { if(this.user && this._globalService._currentUser?.profile) { const profile = new ProfileViewDto( this.user.email ?? '', @@ -101,8 +103,14 @@ export class EditProfileComponent implements OnInit { this.user.phoneNumber, undefined, profileModel.about); - this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile).subscribe( - (result: any) => { + this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile) + + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) + .subscribe({ + next: (result: any) => { if(this._globalService._currentUser?.profile) { this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; this._globalService._currentUser.email = result.email; @@ -114,8 +122,9 @@ export class EditProfileComponent implements OnInit { // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ this._customToastrService.displaySuccessMessage(Messages.PROFILE_EDITED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts index db10380a..088cde5c 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts @@ -107,13 +107,15 @@ export class ProfilePageComponent implements OnInit { * @param id number * @returns void */ - private _getProfile(id: number): void { - this._usersService.getProfile(id).subscribe( - (response: any) => { + private async _getProfile(id: number): Promise { + this._usersService.getProfile(id) + .subscribe({ + next: (response: any) => { this.user = response; }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } @@ -137,13 +139,15 @@ export class ProfilePageComponent implements OnInit { * Verify email. * @returns void. */ - public verifyEmail(): void { - this._accountsService.sendConfirmationEmail().subscribe( - () => { + public async verifyEmail(): Promise { + this._accountsService.sendConfirmationEmail() + .subscribe({ + next: () => { this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); + } }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts index c4041d46..309e5c36 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/authorization/authorization.component.ts @@ -52,18 +52,19 @@ export class AuthorizationComponent implements OnInit { * @param dataForAuthorize any * @returns void */ - authorization(dataForAuthorize: any): void { + async authorization(dataForAuthorize: any): Promise { if (this.authorizationForm.valid) { this._usersService.login(dataForAuthorize) - .subscribe( - (jwt: JwtToken) => { + .subscribe({ + next: (jwt: JwtToken) => { if (jwt) { this.succesLogin(jwt); } }, - (error: ErrorResponse) => { + error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); - }); + } + }); } } @@ -71,29 +72,31 @@ export class AuthorizationComponent implements OnInit { * Save user data if login success * @param jwt JwtToken */ - public succesLogin(jwt: JwtToken | null): void { - if(typeof jwt === 'string') { - const jwtString = jwt; - jwt = null; - const parsedJwtString = JSON.parse(jwtString); - jwt = new JwtToken(parsedJwtString['auth_token'], parsedJwtString['refresh_token'], parsedJwtString['expires_in']); - } - if(jwt) { - this._usersService.saveToken(jwt.AccessToken, jwt.RefreshToken); - if(this._globalService._currentUser) { - this._accountService.initialize(this._globalService._currentUser.id).subscribe( - (initializationData: any) => { - this._customToastrService.displaySuccessMessage(Messages.AUTHORIZED_SUCCESSFULLY); - this._router.navigate(['/']) - .then(() => { - this._globalService.initializeData(initializationData); - });; - }, - (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); - }); - } - } + public async succesLogin(jwt: JwtToken | null): Promise { + if(typeof jwt === 'string') { + const jwtString = jwt; + jwt = null; + const parsedJwtString = JSON.parse(jwtString); + jwt = new JwtToken(parsedJwtString['auth_token'], parsedJwtString['refresh_token'], parsedJwtString['expires_in']); + } + if(jwt) { + this._usersService.saveToken(jwt.AccessToken, jwt.RefreshToken); + if(this._globalService._currentUser) { + this._accountService.initialize(this._globalService._currentUser.id) + .subscribe({ + next: (initializationData: any) => { + this._customToastrService.displaySuccessMessage(Messages.AUTHORIZED_SUCCESSFULLY); + this._router.navigate(['/']) + .then(() => { + this._globalService.initializeData(initializationData); + }); + }, + error: (error: ErrorResponse) => { + this._customToastrService.displayErrorMessage(error); + } + }); + } + } // this._subscription.add(initializeSubscription); // this._globalService.setIsLoadedData(false); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts index 8d8a84e4..b33d21f6 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/user/registration/registration.component.ts @@ -5,6 +5,7 @@ import { CustomToastrService } from './../../../core/services/custom-toastr.serv import { RegistrationForm } from '../../../core/forms/user/RegistrationForm'; import { UsersService } from '../../../core/services/users-services/users-service.service'; import { Router } from '@angular/router'; +import { ErrorResponse } from '../../../core/responses/ErrorResponse'; @Component({ selector: 'app-registration', @@ -42,7 +43,7 @@ export class RegistrationComponent implements OnInit { /** * Register user. */ - register() { + async register(): Promise { if ( this.registrationForm.valid && this.registrationForm.value.password === this.registrationForm.value.confirmPassword) { @@ -50,13 +51,16 @@ export class RegistrationComponent implements OnInit { roles.push('User'); this.registrationForm.value.roles = roles; this._usersService.registration(this.registrationForm.value) - .subscribe( - (response) => { + .subscribe({ + next: () => { // this._logIn(registerModel); // this.isLoginRequestSend = false; this._customToastrService.displaySuccessMessage(Messages.REGISTERED_SUCCESSFULLY); }, - (errorMessage) => {}); + error: (error: ErrorResponse) => { + this._customToastrService.displayErrorMessage(error); + } + }); } } } From 40aa335ce10fd8f5fe266ab865ff53261fa64305 Mon Sep 17 00:00:00 2001 From: Vitalii Lakatosh Date: Tue, 10 Feb 2026 23:23:49 +0200 Subject: [PATCH 3/4] Use finalize pipeline for HTTP GET requests --- .../admin-comments-list.component.ts | 9 ++- .../admin-comments-table.component.ts | 11 ++- .../comments-activity.component.ts | 15 ++-- .../admin-posts-table.component.ts | 9 ++- .../posts-activity-chart.component.ts | 9 ++- .../admin-tags-table.component.ts | 13 +++- .../tags-activity-chart.component.ts | 17 +++-- .../users-activity-chart.component.ts | 10 ++- .../posts/add-post/add-post.component.ts | 11 ++- .../add-comment/add-comment.component.ts | 6 +- .../comments-list/comments-list.component.ts | 23 +++--- .../posts/edit-post/edit-post.component.ts | 58 ++++++++------- .../posts/my-posts/my-posts.component.ts | 72 +++++++++++-------- .../popular-posts/popular-posts.component.ts | 8 ++- .../posts/posts-list/posts-list.component.ts | 57 ++++++++++----- .../posts-table/posts-table.component.ts | 25 +++++-- .../app/shared/posts/show/show.component.ts | 42 ++++++----- .../tags/edit-tag/edit-tag.component.ts | 10 ++- .../popular-tags/popular-tags.component.ts | 8 ++- .../change-email/change-email.component.ts | 50 +++++++------ .../change-password.component.ts | 22 +++--- .../change-phone-number.component.ts | 44 +++++++----- .../edit-profile/edit-profile.component.ts | 40 ++++++----- .../profile-page/profile-page.component.ts | 18 +++-- 24 files changed, 385 insertions(+), 202 deletions(-) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts index 8a73602f..e177637c 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-list/admin-comments-list.component.ts @@ -6,6 +6,7 @@ import { CustomToastrService } from '../../../core/services/custom-toastr.servic import { PageInfo } from '../../..//core/models/PageInfo'; import { CommentsService } from '../../../core/services/posts-services/comments.service'; import { Messages } from '../../../core/data/Mesages'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-admin-comments-list', @@ -105,6 +106,12 @@ export class AdminCommentsListComponent implements OnInit { }; this._commentsService.list(null, model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.comments = [...response.comments]; @@ -112,7 +119,7 @@ export class AdminCommentsListComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); /*!isNaN(postId) ? this._commentService.getCommentsByPostId(postId) : this._commentService.list(nu);*/ diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts index 49032e1c..d003b6b9 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments-table/admin-comments-table.component.ts @@ -1,5 +1,3 @@ -import { GlobalService } from '../../../core/services/global-service/global-service.service'; -import { UsersService } from '../../../core/services/users-services/users-service.service'; import { CommentsService } from '../../../core/services/posts-services/comments.service'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Comment } from '../../../core/models/Comment'; @@ -8,6 +6,7 @@ import { Messages } from '../../../core/data/Mesages'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { PageInfo } from '../../../core/models/PageInfo'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-admin-comments-table', @@ -106,6 +105,12 @@ export class AdminCommentsTableComponent implements OnInit { }; this._commentsService.list(null, model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.comments = [...response.comments]; @@ -114,7 +119,7 @@ export class AdminCommentsTableComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); /*!isNaN(postId) ? this._commentService.getCommentsByPostId(postId) : this._commentService.list(nu);*/ diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts index 50d53c59..37430569 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/comments-activity/comments-activity.component.ts @@ -4,6 +4,7 @@ import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { CommentsService } from '../../../core/services/posts-services/comments.service'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-comments-activity', @@ -33,13 +34,19 @@ export class CommentsActivityComponent implements OnInit { */ async ngOnInit(): Promise { this._commentService.commentsActivity() + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.chartOptions.Data[0] = response; - this.chartOptions = this.chartOptions; - }, + this.chartOptions.Data[0] = response; + this.chartOptions = this.chartOptions; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts index 066090e6..a681a07e 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/admin-posts-table/admin-posts-table.component.ts @@ -6,6 +6,7 @@ import { PageViewDto } from "../../../core/Dto/PageViewDto"; import { ErrorResponse } from "../../../core/responses/ErrorResponse"; import { PostsService } from "../../../core/services/posts-services/posts.service"; import { Router } from "@angular/router"; +import { finalize } from "rxjs"; @Component({ selector: 'app-admin-posts-table', @@ -99,6 +100,12 @@ export class AdminPostsTableComponent implements OnInit { }; this._postsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = [...response.posts]; @@ -107,7 +114,7 @@ export class AdminPostsTableComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts index 24457fb4..3e434186 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-posts/posts-activity-chart/posts-activity-chart.component.ts @@ -1,3 +1,4 @@ +import { finalize } from 'rxjs'; import { ChartOptions } from '../../../core/models/chart/ChartOptions'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; @@ -33,6 +34,12 @@ export class PostsActivityChartComponent implements OnInit { */ async ngOnInit(): Promise { this._postsService.postsActivity() + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.chartOptions.Data[0] = response; @@ -41,7 +48,7 @@ export class PostsActivityChartComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts index 984ceb7f..57b93ed7 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/admin-tags-table/admin-tags-table.component.ts @@ -3,6 +3,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@ import { Tag } from '../../../core/models/Tag'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-admin-tags-table', @@ -55,12 +56,18 @@ export class AdminTagsTableComponent implements OnInit { sortParameters: sortParameters }; this._tagsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.tags = response.tags; - }, + this.tags = response.tags; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts index ee46d6ed..7ee06a54 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-tags/tags-activity-chart/tags-activity-chart.component.ts @@ -4,6 +4,7 @@ import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { TagsService } from '../../../core/services/posts-services/tags.service'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-tags-activity-chart', @@ -33,15 +34,21 @@ export class TagsActivityChartComponent implements OnInit { */ async ngOnInit(): Promise { this._tagsService.tagsActivity() + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.chartOptions.Data[0] = response; - this.chartOptions = this.chartOptions; - }, + this.chartOptions.Data[0] = response; + this.chartOptions = this.chartOptions; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts index 9e35b8c1..fcb41f7f 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-users/users-activity-chart/users-activity-chart.component.ts @@ -4,6 +4,7 @@ import { ChartOptionsData } from './../../../core/data/chart/ChartOptionsData'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; import { UsersService } from '../../../core/services/users-services/users-service.service'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-users-activity-chart', @@ -33,7 +34,12 @@ export class UsersActivityChartComponent implements OnInit { */ async ngOnInit(): Promise { this._usersService.usersActivity() - + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.chartOptions.Data[0] = response; @@ -42,7 +48,7 @@ export class UsersActivityChartComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts index 69ed362b..4e5fda45 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/add-post/add-post.component.ts @@ -13,6 +13,7 @@ import { Tag } from './../../../core/models/Tag'; import { Messages } from './../../../core/data/Mesages'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-add-post', @@ -200,7 +201,7 @@ export class AddPostComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } } @@ -217,7 +218,11 @@ export class AddPostComponent implements OnInit { */ private async _getTags(): Promise { this._tagsService.list() - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: Tag[]) => { this.availableTags = response; @@ -225,7 +230,7 @@ export class AddPostComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts index b4051aa2..4898ff7f 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/add-comment/add-comment.component.ts @@ -81,11 +81,11 @@ export class AddCommentComponent implements OnInit { this._commentsService.add(comment) .subscribe({ next: (response: any) => { - this.onAdd.emit(response.json()); + this.onAdd.emit(response.json()); this._customToastrService.displaySuccessMessage(Messages.COMMENT_CREATED_SUCCESSFULLY); - }, + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); this.onAdd.emit(null); diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts index 25accfd7..f4406110 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/comments/comments-list/comments-list.component.ts @@ -8,6 +8,7 @@ import { Messages } from './../../../../core/data/Mesages'; import { CustomToastrService } from './../../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../../core/responses/ErrorResponse'; import { PageInfo } from '../../../../core/models/PageInfo'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-comments-list', @@ -103,14 +104,18 @@ export class CommentsListComponent implements OnInit { if(this.postId) { this._commentsService.list(this.postId, sortParameters) - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.comments = response.comments; - this.pageInfo = response.pageInfo; - }, + this.comments = response.comments; + this.pageInfo = response.pageInfo; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -173,11 +178,11 @@ export class CommentsListComponent implements OnInit { this._commentsService.delete(comment.id) .subscribe({ next: (response: any) => { - this.onDeleteCommentAction(response.id); - this._customToastrService.displaySuccessMessage(Messages.COMMENT_DELETED_SUCCESSFULLY); - }, + this.onDeleteCommentAction(response.id); + this._customToastrService.displaySuccessMessage(Messages.COMMENT_DELETED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts index 428aa694..57a556e9 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/edit-post/edit-post.component.ts @@ -15,6 +15,7 @@ import { CustomToastrService } from './../../../core/services/custom-toastr.serv import { Messages } from './../../../core/data/Mesages'; import { SelectedTag } from '../../../core/models/SelectedTag'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-edit-post', @@ -168,11 +169,11 @@ export class EditPostComponent implements OnInit { this._postsService.edit(this._postId, post) .subscribe({ next: (response: any) => { - this._customToastrService.displaySuccessMessage(Messages.POST_EDITED_SUCCESSFULLY); - this._router.navigate(['/blog/post/' + this._postId]); - }, + this._customToastrService.displaySuccessMessage(Messages.POST_EDITED_SUCCESSFULLY); + this._router.navigate(['/blog/post/' + this._postId]); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -186,11 +187,11 @@ export class EditPostComponent implements OnInit { this._postsService.delete(this._postId, this._globalService._currentUser.id) .subscribe({ next: () => { - this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); - this._router.navigate(['/blog']); - }, + this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); + this._router.navigate(['/blog']); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -273,22 +274,27 @@ export class EditPostComponent implements OnInit { private async _getPost(): Promise { if(this._postId) { this._postsService.showPost(this._postId) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.post = response.post; - if(this.post) { - this.post.tags = response.tags; - if (! this.isLoggedIn || this.user?.id !== this.post.authorId) { - this._router.navigateByUrl('/'); - } - if (this.user?.id === this.post.authorId) { - this.isCurrentUserPost = true; + this.post = response.post; + if(this.post) { + this.post.tags = response.tags; + if (! this.isLoggedIn || this.user?.id !== this.post.authorId) { + this._router.navigateByUrl('/'); + } + if (this.user?.id === this.post.authorId) { + this.isCurrentUserPost = true; + } + this._setFormData(); } - this._setFormData(); - } - }, + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -300,13 +306,17 @@ export class EditPostComponent implements OnInit { */ private async _getTags(): Promise { this._tagsService.list() - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: Tag[]) => { - this.availableTags = response; - }, + this.availableTags = response; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts index b9e54b00..91300b8d 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/my-posts/my-posts.component.ts @@ -12,6 +12,7 @@ import { Post } from './../../../core/models/Post'; import { Messages } from './../../../core/data/Mesages'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-my-posts', @@ -145,11 +146,11 @@ export class MyPostsComponent implements OnInit { this._postsService.delete(postId, this._globalService._currentUser.id) .subscribe({ next: (response: any) => { - this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); - this._onDeleteCommentAction(response.id); - }, + this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); + this._onDeleteCommentAction(response.id); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -165,12 +166,12 @@ export class MyPostsComponent implements OnInit { this._postsService.like(id) .subscribe({ next: (response: any) => { - const ind = this.posts.findIndex(post => post.id === id); - this.posts[ind] = response; - this.posts = this.posts; - }, + const ind = this.posts.findIndex(post => post.id === id); + this.posts[ind] = response; + this.posts = this.posts; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -186,12 +187,12 @@ export class MyPostsComponent implements OnInit { this._postsService.dislike(id) .subscribe({ next: (response: any) => { - const ind = this.posts.findIndex(post => post.id === id); - this.posts[ind] = response; - this.posts = this.posts; - }, + const ind = this.posts.findIndex(post => post.id === id); + this.posts[ind] = response; + this.posts = this.posts; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -220,13 +221,19 @@ export class MyPostsComponent implements OnInit { }; if(this._userId) { this._postsService.userPosts(this._userId, model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.posts = response.posts; - this.pageInfo = this.pageInfo; - }, + this.posts = response.posts; + this.pageInfo = this.pageInfo; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -251,14 +258,18 @@ export class MyPostsComponent implements OnInit { }; if(this._userId) { this._postsService.userPosts(this._userId, model) - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - }, + this.posts = response.posts; + this.pageInfo = response.pageInfo; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -284,14 +295,19 @@ export class MyPostsComponent implements OnInit { if(this._userId) { this._postsService.userPosts(this._userId, model) - + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - }, + this.posts = response.posts; + this.pageInfo = response.pageInfo; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts index bd9576b5..845fcbb8 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/popular-posts/popular-posts.component.ts @@ -5,6 +5,7 @@ import { PageViewDto } from '../../../core/Dto/PageViewDto'; import { PageInfo } from '../../../core/models/PageInfo'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-popular-posts', @@ -74,6 +75,11 @@ export class PopularPostsComponent implements OnInit { }; this._postsService.list(model) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = response.posts; @@ -82,6 +88,6 @@ export class PopularPostsComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts index be16401d..54725c15 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-list/posts-list.component.ts @@ -12,6 +12,7 @@ import { PageInfo } from './../../../core/models/PageInfo'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { Messages } from './../../../core/data/Mesages'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-posts-list', @@ -125,11 +126,11 @@ export class PostsListComponent implements OnInit { this._postsService.delete(postId, this._globalService._currentUser.id) .subscribe({ next: (response: any) => { - this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); - this._onDeleteCommentAction(response.id); - }, + this._customToastrService.displaySuccessMessage(Messages.POST_DELETED_SUCCESSFULLY); + this._onDeleteCommentAction(response.id); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -145,12 +146,12 @@ export class PostsListComponent implements OnInit { this._postsService.like(id) .subscribe({ next: (response: any) => { - const ind = this.posts.findIndex(post => post.id === id); - this.posts[ind] = response; - this.posts = this.posts; - }, + const ind = this.posts.findIndex(post => post.id === id); + this.posts[ind] = response; + this.posts = this.posts; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -166,12 +167,12 @@ export class PostsListComponent implements OnInit { this._postsService.dislike(id) .subscribe({ next: (response: any) => { - const ind = this.posts.findIndex(post => post.id === id); - this.posts[ind] = response; - this.posts = this.posts; - }, + const ind = this.posts.findIndex(post => post.id === id); + this.posts[ind] = response; + this.posts = this.posts; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -200,13 +201,19 @@ export class PostsListComponent implements OnInit { sortParameters: null, }; this._postsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = [...response.posts]; this.pageInfo = { ...response.pageInfo }; - }, + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -229,13 +236,19 @@ export class PostsListComponent implements OnInit { sortParameters: sortParameters, }; this._postsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = [...response.posts]; this.pageInfo = { ...response.pageInfo }; - }, + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -259,6 +272,12 @@ export class PostsListComponent implements OnInit { }; this._postsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = [...response.posts]; @@ -267,7 +286,7 @@ export class PostsListComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } /** diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts index f65b1bdf..eb47f35e 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/posts-table/posts-table.component.ts @@ -5,6 +5,7 @@ import { Post } from "../../../core/models/Post"; import { ErrorResponse } from "../../../core/responses/ErrorResponse"; import { CustomToastrService } from "../../../core/services/custom-toastr.service"; import { PostsService } from "../../../core/services/posts-services/posts.service"; +import { finalize } from "rxjs"; @Component({ selector: 'app-posts-table', @@ -77,18 +78,30 @@ export class PostsTableComponent implements OnInit { }; if (this.userId != null) { this._postsService.userPosts(this.userId, model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.posts = response.posts; - this.pageInfo = response.pageInfo; - this.postsCount.emit(this.pageInfo.totalItems); - }, + this.posts = response.posts; + this.pageInfo = response.pageInfo; + this.postsCount.emit(this.pageInfo.totalItems); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } else { this._postsService.list(model) + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.posts = response.posts; @@ -98,7 +111,7 @@ export class PostsTableComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } this.pageInfo.totalItems = this.posts.length; diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts index 1f29d6f4..8dee114a 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/posts/show/show.component.ts @@ -9,6 +9,7 @@ import { Post } from './../../../core/models/Post'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { PageInfo } from '../../../core/models/PageInfo'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-show', @@ -101,10 +102,10 @@ export class ShowComponent implements OnInit { this._postsService.like(this.postId) .subscribe({ next: (response: any) => { - this.post = response; - }, + this.post = response; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -120,10 +121,10 @@ export class ShowComponent implements OnInit { this._postsService.dislike(this.postId) .subscribe({ next: (response: any) => { - this.post = response; - }, + this.post = response; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -137,10 +138,10 @@ export class ShowComponent implements OnInit { this._postsService.delete(this.post.id, this.user.id) .subscribe({ next: (response: any) => { - this._router.navigateByUrl('/blog'); - }, + this._router.navigateByUrl('/blog'); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -159,18 +160,23 @@ export class ShowComponent implements OnInit { private async _getPost(): Promise { if(this.postId) { this._postsService.showPost(this.postId) - + .pipe( + finalize(() => { + this.isLoaded = true; + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.post = response.post; - if(this.post) { - this.post.tags = response.tags; - this.post.comments = response.comments.comments; - } - this.pageInfo = response.comments.pageInfo; - }, + this.post = response.post; + if(this.post) { + this.post.tags = response.tags; + this.post.comments = response.comments.comments; + } + this.pageInfo = response.comments.pageInfo; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts index 1193fce0..c5959f3d 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/edit-tag/edit-tag.component.ts @@ -9,6 +9,7 @@ import { TagsService } from './../../../core/services/posts-services/tags.servic import { Tag } from './../../../core/models/Tag'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-edit-tag', @@ -100,7 +101,7 @@ export class EditTagComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } } @@ -117,6 +118,11 @@ export class EditTagComponent implements OnInit { private async _getTag(): Promise { if(this._tagId) { this._tagsService.getTag(this._tagId) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.tag = response; @@ -125,7 +131,7 @@ export class EditTagComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts index 836f5a47..280aaf29 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/shared/tags/popular-tags/popular-tags.component.ts @@ -3,6 +3,7 @@ import { Tag } from './../../../core/models/Tag'; import { TagsService } from './../../../core/services/posts-services/tags.service'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { CustomToastrService } from '../../../core/services/custom-toastr.service'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-popular-tags', @@ -42,6 +43,11 @@ export class PopularTagsComponent implements OnInit { }; this._tagsService.list(model) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { this.tags = response.tags; @@ -49,6 +55,6 @@ export class PopularTagsComponent implements OnInit { error: (error: ErrorResponse) => { this._customToastrService.displayErrorMessage(error); } - }); + }); } } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts index 4b8c9c2a..7970c76b 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-email/change-email.component.ts @@ -12,6 +12,7 @@ import { Messages } from './../../../core/data/Mesages'; import { ProfileViewDto } from '../../../core/Dto/ProfileViewDto'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { AccountsService } from '../../../core/services/users-services/account.sevice'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-change-email', @@ -81,13 +82,18 @@ export class ChangeEmailComponent implements OnInit { */ private async _getProfile(id: number): Promise { this._usersService.getProfile(id) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.user = response; - this._setFormData(); - }, + this.user = response; + this._setFormData(); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -107,22 +113,26 @@ export class ChangeEmailComponent implements OnInit { this.user.profile?.about); this._usersService.updateProfile(this._globalService._currentUser?.profile?.id, profile) - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (result: any) => { - if(this._globalService._currentUser && this._globalService._currentUser.profile) { - this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; - this._globalService._currentUser.email = result.email; - this._globalService._currentUser.firstName = result.firstName; - this._globalService._currentUser.lastName = result.lastName; - this._globalService._currentUser.phoneNumber = result.phoneNumber; - this._globalService._currentUser.profile.about = result.about; - } - // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ - this._customToastrService.displaySuccessMessage(Messages.EMAIL_CHANGED_SUCCESSFULLY); - }, + if(this._globalService._currentUser && this._globalService._currentUser.profile) { + this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; + this._globalService._currentUser.email = result.email; + this._globalService._currentUser.firstName = result.firstName; + this._globalService._currentUser.lastName = result.lastName; + this._globalService._currentUser.phoneNumber = result.phoneNumber; + this._globalService._currentUser.profile.about = result.about; + } + // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ + this._customToastrService.displaySuccessMessage(Messages.EMAIL_CHANGED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -136,10 +146,10 @@ export class ChangeEmailComponent implements OnInit { this._accountsService.sendConfirmationEmail() .subscribe({ next: () => { - this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); - }, + this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts index 1924d0c7..eb5ce5c8 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-password/change-password.component.ts @@ -11,6 +11,7 @@ import { CustomToastrService } from './../../../core/services/custom-toastr.serv import { ChangePasswordDto } from '../../../core/Dto/ChangePasswordDto'; import { ChangePasswordForm } from '../../../core/forms/user/ChangePasswordForm'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-change-password', @@ -78,13 +79,18 @@ export class ChangePasswordComponent implements OnInit { */ private async _getProfile(id: number): Promise { this._usersService.getProfile(id) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.user = response; - this._setFormData(); - }, + this.user = response; + this._setFormData(); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -107,11 +113,11 @@ export class ChangePasswordComponent implements OnInit { this._usersService.changePassword(profile) .subscribe({ next: (response: any) => { - // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ - this._customToastrService.displaySuccessMessage(Messages.PASSWORD_CHANGED_SUCCESSFULLY); - }, + // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ + this._customToastrService.displaySuccessMessage(Messages.PASSWORD_CHANGED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts index dd657ebd..5f443bff 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/personal-info/change-phone-number/change-phone-number.component.ts @@ -11,6 +11,7 @@ import { CustomToastrService } from './../../../core/services/custom-toastr.serv import { Messages } from './../../../core/data/Mesages'; import { ProfileViewDto } from '../../../core/Dto/ProfileViewDto'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-change-phone-number', @@ -78,13 +79,18 @@ export class ChangePhoneNumberComponent implements OnInit { */ private _getProfile(id: number): void { this._usersService.getProfile(id) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.user = response; - this._setFormData(); - }, + this.user = response; + this._setFormData(); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -105,22 +111,26 @@ export class ChangePhoneNumberComponent implements OnInit { this.user.profile?.about); this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile) - + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (result: any) => { - if(this._globalService._currentUser?.profile) { - this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; - this._globalService._currentUser.email = result.email; - this._globalService._currentUser.firstName = result.firstName; - this._globalService._currentUser.lastName = result.lastName; - this._globalService._currentUser.phoneNumber = result.phoneNumber; - this._globalService._currentUser.profile.about = result.about; - } - // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ - this._customToastrService.displaySuccessMessage(Messages.PHONE_NUMBER_CHANGED_SUCCESSFULLY); - }, + if(this._globalService._currentUser?.profile) { + this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; + this._globalService._currentUser.email = result.email; + this._globalService._currentUser.firstName = result.firstName; + this._globalService._currentUser.lastName = result.lastName; + this._globalService._currentUser.phoneNumber = result.phoneNumber; + this._globalService._currentUser.profile.about = result.about; + } + // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ + this._customToastrService.displaySuccessMessage(Messages.PHONE_NUMBER_CHANGED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts index 395a992b..967afbca 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/edit-profile/edit-profile.component.ts @@ -11,6 +11,7 @@ import { Messages } from './../../../core/data/Mesages'; import { CustomToastrService } from './../../../core/services/custom-toastr.service'; import { ProfileViewDto } from '../../../core/Dto/ProfileViewDto'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-edit-profile', @@ -78,13 +79,18 @@ export class EditProfileComponent implements OnInit { */ private _getProfile(id: number): void { this._usersService.getProfile(id) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.user = response; - this._setFormData(); - }, + this.user = response; + this._setFormData(); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -104,26 +110,26 @@ export class EditProfileComponent implements OnInit { undefined, profileModel.about); this._usersService.updateProfile(this._globalService._currentUser.profile.id, profile) - + .pipe( finalize(() => { this._changeDetectorRef.markForCheck(); }) ) .subscribe({ next: (result: any) => { - if(this._globalService._currentUser?.profile) { - this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; - this._globalService._currentUser.email = result.email; - this._globalService._currentUser.firstName = result.firstName; - this._globalService._currentUser.lastName = result.lastName; - this._globalService._currentUser.phoneNumber = result.phoneNumber; - this._globalService._currentUser.profile.about = result.about; - } - // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ - this._customToastrService.displaySuccessMessage(Messages.PROFILE_EDITED_SUCCESSFULLY); - }, + if(this._globalService._currentUser?.profile) { + this._globalService._currentUser.userName = result.firstName + ' ' + result.lastName; + this._globalService._currentUser.email = result.email; + this._globalService._currentUser.firstName = result.firstName; + this._globalService._currentUser.lastName = result.lastName; + this._globalService._currentUser.phoneNumber = result.phoneNumber; + this._globalService._currentUser.profile.about = result.about; + } + // this._usersService.saveUser(JSON.stringify(this._globalService._currentUser));*/ + this._customToastrService.displaySuccessMessage(Messages.PROFILE_EDITED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts index 088cde5c..294d11a7 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/profile/profile-page/profile-page.component.ts @@ -8,6 +8,7 @@ import { CustomToastrService } from './../../../core/services/custom-toastr.serv import { Messages } from './../../../core/data/Mesages'; import { ErrorResponse } from '../../../core/responses/ErrorResponse'; import { AccountsService } from '../../../core/services/users-services/account.sevice'; +import { finalize } from 'rxjs'; @Component({ selector: 'app-profile-page', @@ -109,12 +110,17 @@ export class ProfilePageComponent implements OnInit { */ private async _getProfile(id: number): Promise { this._usersService.getProfile(id) + .pipe( + finalize(() => { + this._changeDetectorRef.markForCheck(); + }) + ) .subscribe({ next: (response: any) => { - this.user = response; - }, + this.user = response; + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } @@ -143,10 +149,10 @@ export class ProfilePageComponent implements OnInit { this._accountsService.sendConfirmationEmail() .subscribe({ next: () => { - this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); - }, + this._customToastrService.displaySuccessMessage(Messages.EMAIL_VERIFIED_SUCCESSFULLY); + }, error: (error: ErrorResponse) => { - this._customToastrService.displayErrorMessage(error); + this._customToastrService.displayErrorMessage(error); } }); } From a7e62d0d93d6549ba6946a8b4834e379ea47cbec Mon Sep 17 00:00:00 2001 From: Vitalii Lakatosh Date: Tue, 10 Feb 2026 00:42:30 +0200 Subject: [PATCH 4/4] Fix issues in Angular --- .../app/admin-portal/admin-comments/admin-comments.module.ts | 4 +++- .../default-pages/contacts/contacts.component.html | 2 +- .../src/app/user-portal/default-pages/default-pages.module.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments.module.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments.module.ts index 6e326ae7..27efcbf2 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments.module.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/admin-portal/admin-comments/admin-comments.module.ts @@ -7,6 +7,7 @@ import { CommentsActivityComponent } from './comments-activity/comments-activity import { NgxChartsModule } from '@swimlane/ngx-charts'; import { AdminCommentsListComponent } from './admin-comments-list/admin-comments-list.component'; import { AdminCommentsTableComponent } from './admin-comments-table/admin-comments-table.component'; +import { DefaultPagesModule } from '../../user-portal/default-pages/default-pages.module'; @NgModule({ declarations: [ @@ -19,7 +20,8 @@ import { AdminCommentsTableComponent } from './admin-comments-table/admin-commen AdminCommentsRoutingModule, NgxChartsModule, CommentsModule, - CoreModule + CoreModule, + DefaultPagesModule ], exports: [ CommentsActivityComponent, diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.html b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.html index 58eeb30b..3c609c43 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.html +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/contacts/contacts.component.html @@ -27,7 +27,7 @@

Контактна інформація!

Форма зворотнього звязку

-
+
@if(!isLoggedIn) { diff --git a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/default-pages.module.ts b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/default-pages.module.ts index d210b85b..025a4f28 100644 --- a/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/default-pages.module.ts +++ b/BlogWebApp/Blog.Web/ClientApp/src/app/user-portal/default-pages/default-pages.module.ts @@ -12,6 +12,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; FormsModule, ReactiveFormsModule, ], - declarations: [AboutComponent, ContactsComponent] + declarations: [AboutComponent, ContactsComponent], + exports: [AboutComponent, ContactsComponent] }) export class DefaultPagesModule { }