news-pages.component.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { AuthServiceService } from './../../shared/auth-service.service';
  2. import { HttpClient } from '@angular/common/http';
  3. import { Component, OnInit } from '@angular/core';
  4. import { Router } from '@angular/router';
  5. import { NgxSpinnerService } from 'ngx-spinner';
  6. @Component({
  7. selector: 'app-news-pages',
  8. templateUrl: './news-pages.component.html',
  9. styleUrls: ['./news-pages.component.css']
  10. })
  11. export class NewsPagesComponent implements OnInit {
  12. constructor(private http: HttpClient,
  13. private authSer: AuthServiceService,
  14. private spinner: NgxSpinnerService,
  15. private router: Router) { }
  16. myInnerHeight = window.innerHeight;
  17. dataPagesNews= [];
  18. perPagePagenation: number = 10;
  19. count: number;
  20. currentPage:number = 1;
  21. ngOnInit() {
  22. this.spinner.show();
  23. console.log(this.authSer.pathImg);
  24. this.http.get(this.authSer.pathApi + '/reports_list_gate/' + this.currentPage + '/' + this.perPagePagenation + '/internal').subscribe(
  25. (responce) => {
  26. console.log(responce);
  27. this.dataPagesNews = responce['reports'];
  28. this.count = responce['count'];
  29. for(let i = 0 ; i < this.dataPagesNews.length ; i++) {
  30. if(this.dataPagesNews[i].description.length > 60) {
  31. this.dataPagesNews[i].description = this.dataPagesNews[i].description.substring(0,200) + '........' ;
  32. this.dataPagesNews[i].description_en = this.dataPagesNews[i].description_en.substring(0,200) + '......';
  33. }
  34. }
  35. this.spinner.hide();
  36. },
  37. (error) => {
  38. console.log(error);
  39. }
  40. )
  41. }
  42. // /change page
  43. onPageChange(pagenationNumber) {
  44. this.spinner.show();
  45. this.http.get(this.authSer.pathApi + '/reports_list_gate/' + this.currentPage + '/' + this.perPagePagenation + '/internal').subscribe(
  46. (responce) => {
  47. console.log(responce);
  48. this.dataPagesNews = responce['reports'];
  49. this.count = responce['count'];
  50. for(let i = 0 ; i < this.dataPagesNews.length ; i++) {
  51. if(this.dataPagesNews[i].description.length > 60) {
  52. this.dataPagesNews[i].description = this.dataPagesNews[i].description.substring(0,200) + '........' ;
  53. this.dataPagesNews[i].description_en = this.dataPagesNews[i].description_en.substring(0,200) + '......';
  54. }
  55. }
  56. },
  57. (error) => {
  58. console.log(error);
  59. }
  60. )
  61. };
  62. onGetNew(id) {
  63. this.router.navigate(['InternalPage/news/' + id])
  64. }
  65. }