|
@@ -1,3 +1,4 @@
|
|
|
|
+import { Observable } from 'rxjs/Observable';
|
|
import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
import { NgxSpinnerService } from 'ngx-spinner';
|
|
import { NgxSpinnerService } from 'ngx-spinner';
|
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
|
@@ -7,6 +8,9 @@ import { Component, OnInit } from '@angular/core';
|
|
import { Modal } from 'ngx-modialog/plugins/bootstrap';
|
|
import { Modal } from 'ngx-modialog/plugins/bootstrap';
|
|
import { UserService } from '../../../shared/user.service';
|
|
import { UserService } from '../../../shared/user.service';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
import { ToastrService } from 'ngx-toastr';
|
|
|
|
+import { timer } from 'rxjs';
|
|
|
|
+import { take, map } from 'rxjs/operators';
|
|
|
|
+
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-maintenance-communications-list',
|
|
selector: 'app-maintenance-communications-list',
|
|
@@ -24,7 +28,8 @@ export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
private spinner: NgxSpinnerService,
|
|
private spinner: NgxSpinnerService,
|
|
private authSer: AuthServiceService,
|
|
private authSer: AuthServiceService,
|
|
private toastr: ToastrService,
|
|
private toastr: ToastrService,
|
|
- private dashboardSer: DashboardService) { }
|
|
|
|
|
|
+ private dashboardSer: DashboardService) {
|
|
|
|
+ }
|
|
|
|
|
|
dataList = [];
|
|
dataList = [];
|
|
pages= [];
|
|
pages= [];
|
|
@@ -38,8 +43,11 @@ export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
userLoginId:number;
|
|
userLoginId:number;
|
|
serviceId:number;
|
|
serviceId:number;
|
|
dataTableNumber: number = 5;
|
|
dataTableNumber: number = 5;
|
|
- absorpationListIds = [];
|
|
|
|
|
|
+ //absorpationListIds = [];
|
|
dataListIds = [];
|
|
dataListIds = [];
|
|
|
|
+
|
|
|
|
+ counter$: Observable<number>;
|
|
|
|
+ counter = 180;
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
|
|
|
@@ -56,61 +64,209 @@ export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
this.authSer.showDashboardHeader = true;
|
|
this.authSer.showDashboardHeader = true;
|
|
this.authSer.internalHeader = false;
|
|
this.authSer.internalHeader = false;
|
|
|
|
|
|
|
|
+ //reload page every 10 seconds
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ location.reload();
|
|
|
|
+ },180000);
|
|
|
|
+
|
|
|
|
+ this.counter$ = timer(0,1000).pipe(
|
|
|
|
+ take(this.counter),
|
|
|
|
+ map(() => --this.counter)
|
|
|
|
+ );
|
|
|
|
+
|
|
this.route.params.subscribe(
|
|
this.route.params.subscribe(
|
|
(parmas: Params) => {
|
|
(parmas: Params) => {
|
|
- this.pageId = +parmas['maintCommuicationPageId'];
|
|
|
|
- localStorage.setItem('pageIdActive', parmas['maintCommuicationPageId']);
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ this.pageId = +parmas['listPageId'];
|
|
|
|
+ localStorage.setItem('pageIdActive', parmas['listPageId']);
|
|
|
|
|
|
- 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');
|
|
|
|
- }
|
|
|
|
|
|
+ if(this.pageId == 56) {
|
|
|
|
+
|
|
|
|
+ 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 == 56) {
|
|
|
|
+ if(this.pages[i]['permissions'][0].name == 'follow_up_communications') {
|
|
|
|
+ this.authSer.showEditBtn = true;
|
|
|
|
+ } else {
|
|
|
|
+ console.log('no permissions');
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ console.log('no events');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.spinner.hide();
|
|
|
|
+ },
|
|
|
|
+ (error) => {console.log(error)}
|
|
|
|
+ );
|
|
}
|
|
}
|
|
- 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);
|
|
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ console.log('current page',this.pageId)
|
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage ,this.dataTableNumber).subscribe(
|
|
|
|
+ (response) => {
|
|
|
|
+ this.dataList = response['communications'];
|
|
|
|
+ console.log('dataList', this.dataList);
|
|
|
|
+ this.count = response['count'];
|
|
|
|
+ this.perPagePagenation = response['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ );
|
|
|
|
+ } else if(this.pageId == 58) {
|
|
|
|
+
|
|
|
|
+ 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.showEditBtn = 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'];
|
|
|
|
+ this.returnEditData();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ );
|
|
|
|
+ } else if(this.pageId == 59) {
|
|
|
|
+
|
|
|
|
+ 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 == 59) {
|
|
|
|
+ if(this.pages[i]['permissions'][0].name == 'follow_up_communications_for_adminstration') {
|
|
|
|
+ this.authSer.showEditBtn = 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('beforre', response);
|
|
|
|
+ this.dataList = response['communications'];
|
|
|
|
+ this.count = response['count'];
|
|
|
|
+ this.perPagePagenation = response['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
|
|
+ console.log('afteeeeeer', response);
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ } else if(this.pageId == 60) {
|
|
|
|
+
|
|
|
|
+ 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 == 60) {
|
|
|
|
+ if(this.pages[i]['permissions'][0].name == 'follow_up_communications_for_department') {
|
|
|
|
+ this.authSer.showEditBtn = 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('beforre', response);
|
|
|
|
+ this.dataList = response['communications'];
|
|
|
|
+ this.count = response['count'];
|
|
|
|
+ this.perPagePagenation = response['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
|
|
+ console.log('afteeeeeer', response);
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
}
|
|
}
|
|
-
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
filtterFunc(data) {
|
|
filtterFunc(data) {
|
|
this.dataList =[];
|
|
this.dataList =[];
|
|
- this.absorpationListIds = [];
|
|
|
|
console.log(data.target.value);
|
|
console.log(data.target.value);
|
|
const dataSearch = data.target.value;
|
|
const dataSearch = data.target.value;
|
|
this.currentPage = 1;
|
|
this.currentPage = 1;
|
|
@@ -123,6 +279,7 @@ export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
this.dataList = responce['communications'];
|
|
this.dataList = responce['communications'];
|
|
this.count = responce['count'];
|
|
this.count = responce['count'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
console.log('filtter count', this.count);
|
|
console.log('filtter count', this.count);
|
|
console.log('filtter perPagePAgenation', this.perPagePagenation);
|
|
console.log('filtter perPagePAgenation', this.perPagePagenation);
|
|
},
|
|
},
|
|
@@ -133,18 +290,18 @@ export class MaintenanceCommunicationsListComponent implements OnInit {
|
|
};
|
|
};
|
|
|
|
|
|
onPageChange(pagenationNumber) {
|
|
onPageChange(pagenationNumber) {
|
|
|
|
+ this.dataList = [];
|
|
this.spinner.show();
|
|
this.spinner.show();
|
|
this.currentPage = pagenationNumber;
|
|
this.currentPage = pagenationNumber;
|
|
- this.absorpationListIds = [];
|
|
|
|
console.log(pagenationNumber);
|
|
console.log(pagenationNumber);
|
|
console.log(this.pageId);
|
|
console.log(this.pageId);
|
|
- this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
|
|
|
+ this.dashboardSer.searchFiltterPagenation(this.pageId, pagenationNumber, this.dataTableNumber, this.filtterStatus).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log(responce);
|
|
console.log(responce);
|
|
this.dataList = responce['communications'];
|
|
this.dataList = responce['communications'];
|
|
this.count = responce['count'];
|
|
this.count = responce['count'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
- console.log('FFFFFF', this.absorpationListIds);
|
|
|
|
|
|
+ this.returnEditData();
|
|
this.spinner.hide();
|
|
this.spinner.hide();
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -156,14 +313,15 @@ onPageChange(pagenationNumber) {
|
|
//determine the list count from select element
|
|
//determine the list count from select element
|
|
onGetValue(event) {
|
|
onGetValue(event) {
|
|
this.spinner.show();
|
|
this.spinner.show();
|
|
- this.absorpationListIds = [];
|
|
|
|
|
|
+ this.dataList = [];
|
|
this.dataTableNumber = event.target.value;
|
|
this.dataTableNumber = event.target.value;
|
|
this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log(responce);
|
|
console.log(responce);
|
|
- this.absorpationListIds = responce['communications'];
|
|
|
|
|
|
+ this.dataList = responce['communications'];
|
|
this.count = responce['count'];
|
|
this.count = responce['count'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
this.spinner.hide();
|
|
this.spinner.hide();
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
@@ -172,6 +330,7 @@ onGetValue(event) {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
+
|
|
onGetValueFiltter(event) {
|
|
onGetValueFiltter(event) {
|
|
console.log(event.target.value)
|
|
console.log(event.target.value)
|
|
this.spinner.show();
|
|
this.spinner.show();
|
|
@@ -185,6 +344,7 @@ onGetValueFiltter(event) {
|
|
this.dataList = responce['communications'];
|
|
this.dataList = responce['communications'];
|
|
this.count = responce['count'];
|
|
this.count = responce['count'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
this.perPagePagenation = responce['per_page'];
|
|
|
|
+ this.returnEditData();
|
|
this.spinner.hide();
|
|
this.spinner.hide();
|
|
console.log('UrL>>', this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId)
|
|
console.log('UrL>>', this.authSer.pathApi +'/page_list/' + this.pageId + '/' + this.currentPage + '/' + this.dataTableNumber + '/' + typeId)
|
|
},
|
|
},
|
|
@@ -194,4 +354,35 @@ onGetValueFiltter(event) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+//return substring of subject and check negaive and positive time
|
|
|
|
+returnEditData() {
|
|
|
|
+ for(let i = 0; i < this.dataList.length; i++) {
|
|
|
|
+ if(this.dataList[i].subject.length > 20) {
|
|
|
|
+ this.dataList[i].subject = this.dataList[i].subject.substring(0 , 15) + '...';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // const firstChar = this.dataList[i].total_count_down.substring(0,1);
|
|
|
|
+ // console.log('first char', firstChar);
|
|
|
|
+ // if(firstChar == '-') {
|
|
|
|
+ // this.dataList[i].total_count_down = '-' + this.dashboardSer.secondsToDhms(this.dataList[i].total_count_down);
|
|
|
|
+ // }
|
|
|
|
+ this.dataList[i].total_count_down = this.dataList[i].total_count_down ? this.dashboardSer.secondsToDhms(this.dataList[i].total_count_down) : '-';
|
|
|
|
+ console.log(this.dataList[i].total_count_down);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+ onEdit(id: number) {
|
|
|
|
+ console.log(id);
|
|
|
|
+ if(this.pageId == 58) {
|
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/maintenanceCommunicationEdit/' + id]);
|
|
|
|
+ } else if(this.pageId == 56){
|
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/followCommunicationEdit/' + id]);
|
|
|
|
+ } else if(this.pageId == 59){
|
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/followCommunicationAdminEdit/' + id]);
|
|
|
|
+ } else if(this.pageId == 60) {
|
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/followCommunicationSecEdit/' + id]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|