Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

import { User } from '../../../core/models/User';
import { Comment } from '../../../core/models/Comment';
import { ErrorResponse } from '../../../core/responses/ErrorResponse';
import { CustomToastrService } from '../../../core/services/custom-toastr.service';
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',
templateUrl: './admin-comments-list.component.html',
styleUrls: ['./admin-comments-list.component.css'],
standalone: false
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AdminCommentsListComponent implements OnInit {
/**
Expand Down Expand Up @@ -51,10 +53,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
) { }

/**
Expand Down Expand Up @@ -87,7 +91,7 @@ export class AdminCommentsListComponent implements OnInit {
* @param page number
* @returns void
*/
private _getComments(page: number = 0): void {
private async _getComments(page: number = 0): Promise<void> {
const sortParameters = {
sortBy: null,
orderBy: null,
Expand All @@ -100,15 +104,22 @@ 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)
.pipe(
finalize(() => {
this.isLoaded = true;
this._changeDetectorRef.markForCheck();
})
)
.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)
: this._commentService.list(nu);*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
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';
import { ErrorResponse } from '../../../core/responses/ErrorResponse';
import { finalize } from 'rxjs';

@Component({
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 {
/**
Expand Down Expand Up @@ -55,10 +53,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
) { }

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ export class AdminCommentsTableComponent implements OnInit {
* @param page number
* @returns void
*/
private _getComments(page: number = 0): void {
private async _getComments(page: number = 0): Promise<void> {
const sortParameters = {
sortBy: null,
orderBy: null,
Expand All @@ -103,15 +103,23 @@ 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)
.pipe(
finalize(() => {
this.isLoaded = true;
this._changeDetectorRef.markForCheck();
})
)
.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)
: this._commentService.list(nu);*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -19,7 +20,8 @@ import { AdminCommentsTableComponent } from './admin-comments-table/admin-commen
AdminCommentsRoutingModule,
NgxChartsModule,
CommentsModule,
CoreModule
CoreModule,
DefaultPagesModule
],
exports: [
CommentsActivityComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
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';
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',
templateUrl: './comments-activity.component.html',
styleUrls: ['./comments-activity.component.css'],
standalone: false
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CommentsActivityComponent implements OnInit {
/**
Expand All @@ -30,25 +32,34 @@ export class CommentsActivityComponent implements OnInit {
/**
* @inheritdoc
*/
ngOnInit(): void {
this._commentService.commentsActivity().subscribe(
(response: any) => {
this.chartOptions.Data[0] = response;
this.chartOptions = this.chartOptions;
this.isLoaded = true;
},
(error: ErrorResponse) => {
this._customToastrService.displayErrorMessage(error);
async ngOnInit(): Promise<void> {
this._commentService.commentsActivity()
.pipe(
finalize(() => {
this.isLoaded = true;
this._changeDetectorRef.markForCheck();
})
)
.subscribe({
next: (response: any) => {
this.chartOptions.Data[0] = response;
this.chartOptions = this.chartOptions;
},
error: (error: ErrorResponse) => {
this._customToastrService.displayErrorMessage(error);
}
});
}

/**
* @param _commentService CommentService
* @param _customToastrService CustomToastrService
* @param _changeDetectorRef: ChangeDetectorRef
*/
constructor(
private _commentService: CommentsService,
private _customToastrService: CustomToastrService) {
private _customToastrService: CustomToastrService,
private _changeDetectorRef: ChangeDetectorRef) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
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";
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',
templateUrl: './admin-posts-table.component.html',
styleUrls: ['./admin-posts-table.component.css'],
standalone: false
standalone: false,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AdminPostsTableComponent implements OnInit {
/**
Expand Down Expand Up @@ -39,11 +41,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
) { }

/**
Expand Down Expand Up @@ -81,7 +85,7 @@ export class AdminPostsTableComponent implements OnInit {
/**
* Get all posts
*/
private _getPosts(page = 1): void {
private async _getPosts(page = 1): Promise<void> {
const sortParameters = {
sortBy: null,
orderBy: null,
Expand All @@ -96,16 +100,21 @@ export class AdminPostsTableComponent implements OnInit {
};

this._postsService.list(model)
.subscribe(
(response: PageViewDto) => {
this.posts = response.posts;
this.pageInfo = response.pageInfo;
.pipe(
finalize(() => {
this.isLoaded = true;
this._changeDetectorRef.markForCheck();
})
)
.subscribe({
next: (response: any) => {
this.posts = [...response.posts];
this.pageInfo = { ...response.pageInfo };
},
(error: ErrorResponse) => {
error: (error: ErrorResponse) => {
this._customToastrService.displayErrorMessage(error);
this.isLoaded = true;
});
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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';

@Component({
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 {
/**
Expand Down
Loading
Loading