|
@@ -1,4 +1,12 @@
|
|
|
+import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
|
+import { NgxSpinnerService } from 'ngx-spinner';
|
|
|
+import { ActivatedRoute, Router, Params } from '@angular/router';
|
|
|
+import { DashboardService } from './../../../shared/dashboard.service';
|
|
|
+import { HttpClient } from '@angular/common/http';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
|
|
|
+import { UserService } from '../../../shared/user.service';
|
|
|
+import { ToastrService } from 'ngx-toastr';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-maintenance-communications-list',
|
|
@@ -7,9 +15,183 @@ import { Component, OnInit } from '@angular/core';
|
|
|
})
|
|
|
export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
|
|
|
|
- constructor() { }
|
|
|
+
|
|
|
+ constructor(private http: HttpClient,
|
|
|
+ private route: ActivatedRoute,
|
|
|
+ private router: Router,
|
|
|
+ private modal: Modal,
|
|
|
+ private userSer: UserService,
|
|
|
+ private spinner: NgxSpinnerService,
|
|
|
+ private authSer: AuthServiceService,
|
|
|
+ private toastr: ToastrService,
|
|
|
+ private dashboardSer: DashboardService) { }
|
|
|
+
|
|
|
+ dataList = [];
|
|
|
+ pages= [];
|
|
|
+ pageId: number;
|
|
|
+ Ids = [];
|
|
|
+ count: number;
|
|
|
+ perPagePagenation: number;
|
|
|
+ currentPage:number = 1;
|
|
|
+ filtterStatus = 'all';
|
|
|
+ selectedAll: any;
|
|
|
+ userLoginId:number;
|
|
|
+ serviceId:number;
|
|
|
+ dataTableNumber: number = 5;
|
|
|
+ absorpationListIds = [];
|
|
|
+ dataListIds = [];
|
|
|
|
|
|
ngOnInit() {
|
|
|
+
|
|
|
+ //init values of permisions
|
|
|
+ this.authSer.showAddBtn = false;
|
|
|
+ this.authSer.showDeleteBtn = false;
|
|
|
+ this.authSer.showEditBtn = false;
|
|
|
+ this.authSer.showPermissionsBtn = false;
|
|
|
+ //show / hide notification search in header
|
|
|
+ this.authSer.notificationLogin = true;
|
|
|
+ this.authSer.showSearchHeader = false;
|
|
|
+ this.authSer.showHeaderLogin = false;
|
|
|
+ this.authSer.showHeaderDashBoard = true;
|
|
|
+ this.authSer.showDashboardHeader = true;
|
|
|
+ this.authSer.internalHeader = false;
|
|
|
+
|
|
|
+ this.route.params.subscribe(
|
|
|
+ (parmas: Params) => {
|
|
|
+ this.pageId = +parmas['maintCommuicationPageId'];
|
|
|
+ localStorage.setItem('pageIdActive', parmas['maintCommuicationPageId']);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ this.route.parent.params.subscribe(
|
|
|
+ (params:Params) => {
|
|
|
+ this.userLoginId = params['userID'];
|
|
|
+ this.serviceId = params['serviceID'];
|
|
|
+
|
|
|
+
|
|
|
+ this.userSer.getPagesPermetiotns(this.userLoginId, this.serviceId).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.pages = responce['pages'];
|
|
|
+ for(let i = 0; i< this.pages.length; i++) {
|
|
|
+ if(this.pages[i].id == 58) {
|
|
|
+ if(this.pages[i]['permissions'][0].name == 'follow_up_communications_for_admin_maintenance') {
|
|
|
+ this.authSer.showAddBtn = true;
|
|
|
+ this.authSer.showEditBtn = true;
|
|
|
+ this.authSer.showDeleteBtn = true;
|
|
|
+ } else {
|
|
|
+ console.log('no permissions');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('no events');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {console.log(error)}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
+ console.log('current page',this.pageId)
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage ,this.dataTableNumber).subscribe(
|
|
|
+ (response) => {
|
|
|
+ console.log(response);
|
|
|
+ this.dataList = response['communications'];
|
|
|
+ this.count = response['count'];
|
|
|
+ this.perPagePagenation = response['per_page'];
|
|
|
+
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
+ filtterFunc(data) {
|
|
|
+ this.dataList =[];
|
|
|
+ this.absorpationListIds = [];
|
|
|
+ console.log(data.target.value);
|
|
|
+ const dataSearch = data.target.value;
|
|
|
+ this.currentPage = 1;
|
|
|
+ console.log('search curent page', this.currentPage);
|
|
|
+ console.log('search page id', this.pageId);
|
|
|
+
|
|
|
+ this.dashboardSer.getDataUSerSearchBar(dataSearch, this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.dataList = responce['communications'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ console.log('filtter count', this.count);
|
|
|
+ console.log('filtter perPagePAgenation', this.perPagePagenation);
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+onPageChange(pagenationNumber) {
|
|
|
+ this.spinner.show();
|
|
|
+ this.currentPage = pagenationNumber;
|
|
|
+ this.absorpationListIds = [];
|
|
|
+ console.log(pagenationNumber);
|
|
|
+ console.log(this.pageId);
|
|
|
+ this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.dataList = responce['communications'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ console.log('FFFFFF', this.absorpationListIds);
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ }
|
|
|
+ );
|
|
|
+}
|
|
|
+//determine the list count from select element
|
|
|
+onGetValue(event) {
|
|
|
+ this.spinner.show();
|
|
|
+ this.absorpationListIds = [];
|
|
|
+ this.dataTableNumber = event.target.value;
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.absorpationListIds = responce['communications'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ }
|
|
|
+ );
|
|
|
+};
|
|
|
+onGetValueFiltter(event) {
|
|
|
+ console.log(event.target.value)
|
|
|
+ this.spinner.show();
|
|
|
+ this.dataList = [];
|
|
|
+ const typeId = event.target.value;
|
|
|
+ this.filtterStatus = event.target.value;
|
|
|
+ console.log(this.filtterStatus);
|
|
|
+ this.http.get(this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.dataList = responce['communications'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ this.spinner.hide();
|
|
|
+ console.log('UrL>>', this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId)
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
}
|