latest updates @APR 20, 2022

This commit is contained in:
pritesh 2022-04-20 11:15:19 +05:30 committed by Pranav
parent 90b15f5e00
commit a0bdbc7c55
1657 changed files with 301942 additions and 0 deletions

View file

@ -0,0 +1,120 @@
<div class="container" style="padding-top: 5%;">
<div class="row" style="background: #5e669d; color: white; font-size: 20px; padding-top: 10px; padding-left: 30px;">
<div class="12">
<p>{{'REMINDER' | translate}}</p>
</div>
</div>
<div class="row" >
<div class="col-6">
<label style="width: inherit;margin-top: 11px;font-weight: 600; color: #727b84;">{{'Select Vehicle' | translate}}</label>
<!-- <div style="width: inherit; margin-top: 4px;text-align: left" *ngIf="vehicleOption">
<select id="select" multiple="multiple" style="text-align: left">
<option *ngFor="let option_1 of options" value={{option_1.id}}>{{ option_1.value }}</option>
</select>
</div> -->
<div style="width:inherit; margin-top: 4px;text-align: left">
<select id="select_1" multiple="multiple" style="text-align: left" >
<option *ngFor="let option_1 of options" value={{option_1.id}} [selected] = "option_1.id === device_id">{{ option_1.value }}</option>
</select>
</div>
</div>
<div class="col-6" style="padding-right: 8px;" >
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;">Date</label>
<input id="reminder_date" bsDatepicker class="form-control form-control-sm" style="margin-top: 4px;width: 75%;" [bsConfig]="bsConfig" name="reminder_date" [(ngModel)]="reminderDate" type="text">
</div>
</div>
<div *ngIf="UpdateTemplate === false" class="row" style="padding-top: 20px;">
<div class="col-6">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;">{{'Select no of Days to get reminder for your services' | translate}}</label>
<input [(ngModel)]="priorReminder" class="form-control form-control-sm" style="margin-top: 4px;width: 200px;"
name="minIdleTime" min="0" placeholder="00" type="number">
</div>
<div class="col-6">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;">Set Target Odometer</label>
<!-- <label style="margin-right: 20px; font-size: 13px; font-weight: 500; color: #727b84;">Set Target Odometer</label> -->
<input [(ngModel)]="odometer" placeholder="00" style="margin-top: 4px;width: 200px;"
class="form-control form-control-sm">
</div>
</div>
<div *ngIf="UpdateTemplate === true" class="row" style="padding-top: 20px;">
<div class="col-6" style="display: inherit;">
<label style="margin-right: 20px; font-size: 13px; font-weight: 500; color: #727b84;">{{'Select no of Days to get reminder for your services' | translate}}</label>
</div>
<div class="col-6" style="display: inherit;">
<input [(ngModel)]="priorReminder" class="form-control form-control-sm" style="width: 80px;height: 60%;" name="minIdleTime" min="0" placeholder="00" type="number">
</div>
</div>
<div class="row" style="padding-top: 20px">
<div class="col-6">
<!-- <label style="width: inherit;margin-top: 11px;margin-left: 10px;">Reminder Type</label> -->
<md-select style="padding-top: 0;width: 70%;" [(ngModel)]="reminder" placeholder="--{{'Job type' | translate}}--" ngDefaultControl>
<md-option *ngFor="let reminder of reminderType" [value]="reminder.viewValue">
{{reminder.value}}
</md-option>
</md-select>
</div>
<!-- <div class="col-6">
<label style="width: inherit;margin-top: 11px; font-weight: 600; color: #727b84;">Notification Type</label>
<div class="btn-group btn-group-toggle" data-toggle="buttons" (click)="notitype($event)">
<label class="btn btn-secondary btn-default blue" > <input type="radio" name="options" id="option1" > SMS </label>
<label class="btn btn-secondary btn-default blue" > <input type="radio" name="options" id="option2" > PUSH NOTIFICATION </label>
<label class="btn btn-secondary btn-default blue" > <input type="radio" name="options" id="option3" > EMAIL </label>
</div>
</div> -->
<div class="col-6">
<md-select [(ngModel)]="notificatinType" placeholder="--Notification type--" multiple style="padding-top:0px;width: 75%;" ngDefaultControl>
<md-option *ngFor="let notif of notifType" [value]="notif.value">
{{notif.view}}
</md-option>
</md-select>
</div>
</div>
<div class="row" *ngIf="UpdateTemplate === true" style="padding-top: 20px">
<div class="col-6" style="padding-top: 20px;">
<!-- <label style="width: inherit;margin-top: 11px;margin-left: 10px;">Reminder Type</label> -->
<md-select style="padding-top: 0;width: 70%;" [(ngModel)]="jobStatus" placeholder="--{{'Job status' | translate}}--" ngDefaultControl>
<md-option *ngFor="let Jstatus of typeStatus" [value]="Jstatus.viewValue">
{{Jstatus.value}}
</md-option>
</md-select>
</div>
<div class="col-6">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;margin:0px">{{'Updated On' | translate}}</label>
<input id="status_date" bsDatepicker class="form-control form-control-sm" style="margin-top: 4px;width: 75%;" [bsConfig]="bsConfig" name="status_Change_date" [(ngModel)]="statusChangeDate" type="text">
</div>
</div>
<div class="row" *ngIf="UpdateTemplate === true" style="padding-top: 20px">
<div class="col-6">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;margin:0px">ODO</label>
<input [(ngModel)]="totalodo" class="form-control form-control-sm" name="odo" placeholder="00" type="text">
</div>
<div class="col-6">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;margin:0px">{{'Date of service' | translate}}</label>
<input id="date_of_service" bsDatepicker class="form-control form-control-sm" style="margin-top: 4px;width: 75%;" [bsConfig]="bsConfig" name="service_date" [(ngModel)]="date_of_service" type="text">
</div>
</div>
<div class="row" *ngIf="UpdateTemplate === true">
<div class="col-6" >
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;margin:0px">Performed By</label>
<input [(ngModel)]="performed_by" class="form-control form-control-sm" name="performed_by" type="text">
</div>
</div>
<div class="row" >
<div class="col-12">
<label style="width: inherit; margin-top: 11px;font-weight: 600; color: #727b84;">{{'Additional Notes' | translate}}</label>
<textarea id="additional_notes" class="form-control form-control-sm" name="additional notes" [(ngModel)]="additionalNote" type="text"></textarea>
</div>
</div>
<div class="row" style="margin-top: 40px; text-align: center;">
<div class="col-12">
<button *ngIf="UpdateTemplate === false" md-raised-button style="background: #31428c; color: white;" (click)="save()">{{'Save' | translate}}</button>
<button *ngIf="UpdateTemplate === true" md-raised-button style="background: #31428c; color: white;" (click)="updateReminder()">{{'Update' | translate}}</button>
<button md-raised-button style="background: #1d8216; color: white;" (click)="cancel()">{{'Cancel' | translate}}</button>
</div>
</div>
</div>

View file

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddReminderComponent } from './add-reminder.component';
describe('AddReminderComponent', () => {
let component: AddReminderComponent;
let fixture: ComponentFixture<AddReminderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddReminderComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddReminderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,340 @@
import { Component, OnInit,Inject } from '@angular/core';
import { MdDialogRef,MD_DIALOG_DATA, MdSnackBar } from '@angular/material';
import { ContactService } from '../../contact.service';
import { BsDatepickerConfig } from 'ngx-bootstrap';
declare var $:any;
@Component({
selector: 'app-add-reminder',
templateUrl: './add-reminder.component.html',
styleUrls: ['./add-reminder.component.scss']
})
export class AddReminderComponent implements OnInit {
useridd: any;
reminderDate = new Date();
bsConfig: Partial<BsDatepickerConfig>;
colorTheme = 'theme-dark-blue';
priorReminder:number=0;
device_id :any;
statusChangeDate : any = new Date() ;
date_of_service:any=new Date();
totalodo:any=0;
odometer
jobStatus :any ;
selectedDevice
typeStatus = [{viewValue:"Pending", value:"Pending"},{viewValue:"In Progress", value:"In Progress"},{viewValue:"Completed", value:"Completed"}]
reminderType :any=[
{ viewValue:"Service", value:"Service", },
{ viewValue:"Oil Change", value:"Oil Change", },
{ viewValue:"Tyres", value:"Tyres", },
{ viewValue:"Maintenance", value:"Maintenance", },
{ viewValue:"Auto Repair", value:"Auto Repair" },
{ viewValue:"Body Work", value:"Body Work" },
{ viewValue:"Diagnostics", value:"Diagnostics" },
{ viewValue:"Tune Up", value:"Tune Up" },
{ viewValue:"Brake Job", value:"Brake Job" },
{ viewValue:"Oil & Oil Filter Change", value:"Oil & Oil Filter Change" },
{ viewValue:"Tire Care", value:"Tire Care" },
{ viewValue:"Towing", value:"Towing" },
{ viewValue:"Wheel balance & Alignment", value:"Wheel balance & Alignment" },
{ viewValue:"Fleet", value:"Fleet" },
{ viewValue:"Auto Tracking", value:"Auto Tracking" },
{ viewValue:"A/C Repair", value:"A/C Repair" },
{ viewValue:"Others", value:"Others", }
]
notifType = [
{view:"SMS",value:"SMS"},{view:"EMAIL",value:"EMAIL"},{view:"PUSH NOTIFICATION",value:"PUSH_NOTIFICATION"}
];
notificatinType:any;
emailid: any;
devicesss: any;
finall: any;
options :any=[];
vehicleOption:boolean=false;
reminder: any;
additionalNote:any;
deviceObject: any = [];
UpdateTemplate: boolean = false ;
performed_by: any;
vehicleName
constructor(public dialogRef: MdDialogRef<AddReminderComponent>,
@Inject(MD_DIALOG_DATA) public data: any,private contactService: ContactService,public snackBar: MdSnackBar) {
$('#select_1').hide();
this.bsConfig = Object.assign({ dateInputFormat: 'DD-MM-YYYY, h:mm:ss a' }, { containerClass: this.colorTheme });
this.useridd = JSON.parse(window.atob(window.localStorage.token.split('.')[1]))._id;
this.emailid = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).email;
console.log('this.data',this.data);
if(this.data.identifier === 'edit'){
console.log('edit is working fine');
this.UpdateTemplate = true ;
this.jobStatus = this.data.status ;
this.reminderDate = (this.data.reminder_date)?new Date(this.data.reminder_date):new Date();
this.date_of_service = (this.data.date_of_service)?new Date(this.data.date_of_service):new Date();
this.priorReminder = this.data.prior_reminder ;
this.reminder = this.data.reminder_type ;
this.performed_by= this.data.performed_by;
this.totalodo = this.data.odo ;
this.vehicleName=this.data.Device_Name
// this.notificatinType = this.data.notification_type ;
this.additionalNote = this.data.note ;
this.device_id = this.data.device._id ;
console.log("this.device_id",this.device_id);
// notificatinType
}
}
ngOnInit() {
this.getDevices();
}
getDevices(){
this.contactService.getDevice(this.emailid,this.useridd).subscribe(
data => {
this.devicesss = data
this.finall = (this.devicesss.devices);
for(let i=0;i<this.devicesss.devices.length;i++){
// if(this.devicesss.devices[i].type_of_device =="Tracker"){
let a ={
value : this.devicesss.devices[i].Device_Name,
viewValue:this.devicesss.devices[i].Device_Name,
did:this.devicesss.devices[i].Device_ID,
id:this.devicesss.devices[i]._id,
user:this.devicesss.devices[i].user,
// email: this.devicesss.devices[i].Email_ID,
// deviceType: this.devicesss.devices[i].type_of_device
}
this.options.push(a);
}
// }
console.log(this.options);
let that = this;
setTimeout(()=>{
// if(that.data.identifier === 'edit'){
// that.device_id = that.data.device._id ;
// }
that.loadropdown();
},100)
});
}
loadropdown() {
let that = this;
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "https://unpkg.com/multiple-select@1.3.1/dist/multiple-select.min.js");
document.getElementsByTagName("head")[0].appendChild(script);
setTimeout(() => {
$('#select_1').multipleSelect({
width: 200,
placeholder: 'Select device.....',
filter: true,
single: true,
selectAll: false
})
// $('#select').show();
}, 100);
}
testss:any;
deviceArr:any;
save(){
var that= this;
this.deviceArr = $('#select_1').multipleSelect('getSelects','value');
console.log('this.deviceArr',this.deviceArr);
that.deviceObject = that.options.filter(function(devobj) {
if(devobj.id == that.deviceArr[0]){
return devobj;
}
})
for(var i=0;i<this.options.length;i++){
if(that.deviceArr[0]==this.options[i].id){
this.vehicleName=this.options[i].value
}
}
console.log('this.options',this.options);
console.log('this.deviceObj=>',this.deviceObject);
console.log('this.deviceArr=>',this.deviceArr);
function showErr(msg){
let message1;
(msg=='nodevice')?message1="Please select device":(msg=='reminder')?message1="Please select reminder type":(msg=='notif')?message1="Please select notification type":''
let action:any;
return that.snackBar.open(message1, action, {
duration: 5000,
});
}
(this.deviceArr.length==0)?showErr('nodevice'):(this.reminder==undefined)?showErr('reminder'):(this.notificatinType==undefined)?showErr('notif'):saveReminder();
function saveReminder(){
var notifObj={
"SMS" : false,
"EMAIL": false,
"PUSH_NOTIFICATION":false
};
for(var i=0;i<that.notificatinType.length;i++){
if(that.notificatinType[i]=="SMS"){
notifObj.SMS = true ;
}else if(that.notificatinType[i]=="EMAIL"){
notifObj.EMAIL = true ;
}else{
notifObj.PUSH_NOTIFICATION = true;
}
}
// that.reminderDate
var reminderPayload = {
created_by : that.useridd,
user : that.deviceObject[0].user,
device : that.deviceArr[0],
reminder_type : that.reminder,
notification_type : notifObj,
reminder_date: that.reminderDate.toISOString(),
prior_reminder :that.priorReminder,
status :'Pending',
vehicleName:that.vehicleName
}
if(that.additionalNote != undefined){
reminderPayload['note'] = that.additionalNote ;
}
if(that.odometer){
reminderPayload['odo'] = that.odometer ;
}
console.log(reminderPayload);
that.contactService.savereminder(reminderPayload).subscribe(res=>{
if(res){
let msg = "Reminder set for the vehicle";
let action:any;
that.snackBar.open(msg, action, {
duration: 5000,
});
that.dialogRef.close('reminder Saved');
}
},err=>{
let msg = "Please Try Again";
let action:any;
return that.snackBar.open(msg, action, {
duration: 5000,
});
})
}
}
updateReminder(){
this.deviceArr = $('#select_1').multipleSelect('getSelects','value');
console.log(this.deviceArr,this.options,this.selectedDevice);
if(this.deviceArr){
for(var i=0;i<this.options.length;i++){
if(this.deviceArr[0]==this.options[i].id){
this.vehicleName=this.options[i].value
}
}
}else{
for(var i=0;i<this.options.length;i++){
if(this.device_id==this.options[i].id){
this.vehicleName=this.options[i].value
}
// this.device_id
}
}
var data={
rid: this.data._id,
status : this.jobStatus,
status_changed_on : this.statusChangeDate.toISOString(),
};
if(this.deviceArr){
data['device']=this.deviceArr[0]
}else{
data['device']=this.device_id
}
if(this.vehicleName){
data['vehicleName']=this.vehicleName
}
if(this.priorReminder != undefined){
data['prior_reminder'] = this.priorReminder ;
}
if(this.additionalNote != undefined){
data['note'] = this.additionalNote ;
}
if(this.reminder != undefined){
data['reminder'] = this.reminder ;
}
if(this.performed_by != undefined){
data['performed_by'] = this.performed_by ;
}
if(this.totalodo != undefined){
data['odo'] = this.totalodo ;
}
if(this.date_of_service != undefined){
var dos = new Date(this.date_of_service);
data['date_of_service'] = dos.toISOString() ;
}
console.log(data);
this.contactService.updateReminder(data).subscribe(res=>{
console.log(res);
if(res){
let msg = "Reminder Updated";
let action:any;
this.snackBar.open(msg, action, {
duration: 5000,
});
this.dialogRef.close('Reminder updated');
}
},err=>{
let msg = "Please Try Again";
let action:any;
return this.snackBar.open(msg, action, {
duration: 5000,
});
})
}
cancel(){
this.dialogRef.close('cancel');
}
}

View file

@ -0,0 +1,60 @@
<app-all-menus></app-all-menus>
<div class="container-fluid" style="padding-top: 5%;">
<div class="headerStyle">
<span>{{'MAINTENANCE REMINDERS' | translate}}</span>
<div class="loading" *ngIf="Load">Loading&#8230;</div>
</div>
<div class="filterDiv">
<div class="row">
<div class="col-12" style="padding-left: 0;padding-right: 0">
<button md-tooltip="Add Reminder" style="border:1px solid transparent;float:left; background-color: transparent;" (click)="reminderComponent()" ><md-icon style="float: right;width:30px;height:30px;">add</md-icon></button>
</div>
</div>
<div class="row" style="width: 100%; padding-bottom: 25px; background: #efefef;">
<div class="col-12" style="text-align: center;margin-top: 30px;">
<div style="display: inline-flex; width: 95%;padding-bottom: 3px;">
<!-- <label style="width: inherit;margin-top: 11px;margin-left: 10px;">Reminder Type</label> -->
<md-select style="padding-top: 0;width: 70%;" [(ngModel)]="reminder" placeholder="--{{'Job type' | translate}}--" ngDefaultControl>
<md-option *ngFor="let reminder of reminderType" [value]="reminder.viewValue">
{{reminder.value}}
</md-option>
</md-select>
<label style="margin-top: 11px;width: inherit;">{{'Select Vehicle' | translate}}</label>
<div style="width: inherit; margin-top: 9px;text-align: left">
<select id="select" multiple="multiple" style="text-align: left">
<option *ngFor="let option_1 of options" value={{option_1.id}} >{{ option_1.value }}</option>
</select>
</div>
<label style="width: inherit;margin-top: 11px">{{'From Date' | translate}}</label>
<input id="from_date" bsDatepicker class="form-control form-control-sm" style="margin-top: 4px;"
[bsConfig]="bsConfig" [(ngModel)]="from_date" type="text">
<label style="width: inherit;margin-top: 11px">{{'To Date' | translate}}</label>
<input id="to_date" bsDatepicker class="form-control form-control-sm" style="margin-top: 4px;" [bsConfig]="bsConfig" name="todate" [(ngModel)]="to_date" type="text">
<button md-raised-button style="width: 190px; background: #31428c; color: white;margin-left: 20px;" (click)="callfunction()"> {{'SEARCH' | translate}} </button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<table id="deviceTable" class="display" cellspacing="0" style="width:100%;font-size:15px;text-align: center">
<thead style="background-color:#A2C523;color: white;">
<tr>
<th style="text-align:center;">{{'Device Name' | translate}}</th>
<th style="text-align:center;">{{'Reminder Date' | translate}}</th>
<th style="text-align:center;">{{'Notification Type' | translate}}</th>
<th style="text-align:center;">{{'Reminder Type' | translate}}</th>
<th style="text-align:center;">{{'Prior Notification (Days)' | translate}}</th>
<th style="text-align:center;">{{'Odo' | translate}}</th>
<th style="text-align:center;">{{'Additional notes' | translate}}</th>
<th style="text-align:center;">{{'Status' | translate}}</th>
<th style="text-align:center;">{{'Edit' | translate}}</th>
<th style="text-align:center;">{{'Deleted' | translate}}</th>
</tr>
</thead>
</table>
</div>
</div>
</div>

View file

@ -0,0 +1,36 @@
.container-fluid .headerStyle{
text-align: center;
padding-bottom: 10px;
padding-top: 10px;
font-size: 20px;
font-weight: 500;
background: white;
color: black;
border-radius: 4px;
}
/deep/ .mat-menu-panel.test{
background-color: #b7b7b7;
width: 160px;
text-align: left;
color: #fff;
a{
display: block;
padding: 9px 10px;
margin: 0;
border-bottom: 1px solid #999;
}
}
/deep/ .mat-menu-panel.test_1{
background-color: #b7b7b7;
width: 160px;
text-align: left;
color: #fff;
margin-top:48px;
}

View file

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { VehicleReminderComponent } from './vehicle-reminder.component';
describe('VehicleReminderComponent', () => {
let component: VehicleReminderComponent;
let fixture: ComponentFixture<VehicleReminderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ VehicleReminderComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(VehicleReminderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,492 @@
import { Component, OnInit } from '@angular/core';
declare var $:any;
import * as moment from 'moment';
import { BsDatepickerConfig } from 'ngx-bootstrap';
import { ContactService } from '../contact.service';
import { MdDialog, MdSnackBar } from '@angular/material';
import { AddReminderComponent } from './add-reminder/add-reminder.component';
declare var swal: any;
@Component({
selector: 'app-vehicle-reminder',
templateUrl: './vehicle-reminder.component.html',
styleUrls: ['./vehicle-reminder.component.scss']
})
export class VehicleReminderComponent implements OnInit {
Load:boolean=false;
options: any=[];
devicesss: any;
superAdmin: any;
supAdmin: any;
fs: any;
minIdleTime:any= 5;
ls: any;
emailid: any;
or: any;
useridd: any;
mb: any;
custtype: any;
Dealer: any;
finall: any;
from_date=new Date();
to_date=new Date();
colorTheme = 'theme-dark-blue';
reminder:any;
reminderType :any=[
{ viewValue:"Service", value:"Service", },
{ viewValue:"Oil Change", value:"Oil Change", },
{ viewValue:"Tyres", value:"Tyres", },
{ viewValue:"Maintenance", value:"Maintenance", },
{ viewValue:"Auto Repair", value:"Auto Repair", },
{ viewValue:"Body Work", value:"Body Work" },
{ viewValue:"Diagnostics", value:"Diagnostics" },
{ viewValue:"Tune Up", value:"Tune Up" },
{ viewValue:"Brake Job", value:"Brake Job" },
{ viewValue:"Oil & Oil Filter Change", value:"Oil & Oil Filter Change" },
{ viewValue:"Tire Care", value:"Tire Care" },
{ viewValue:"Towing", value:"Towing" },
{ viewValue:"Wheel balance & Alignment", value:"Wheel balance & Alignment" },
{ viewValue:"Fleet", value:"Fleet" },
{ viewValue:"Auto Tracking", value:"Auto Tracking" },
{ viewValue:"A/C Repair", value:"A/C Repair" },
{ viewValue:"Others", value:"Others", }
]
bsConfig: Partial<BsDatepickerConfig>;
constructor(private contactService: ContactService, public dialog: MdDialog, public snackBar: MdSnackBar) {
this.bsConfig = Object.assign({ dateInputFormat: 'DD-MM-YYYY, h:mm:ss a' }, { containerClass: this.colorTheme });
this.from_date.setHours(0,0,0,0);
this.from_date.setMonth(this.from_date.getMonth()-1);
// $('#select').hide();
console.log("loginDetails=>",JSON.parse(window.atob(window.localStorage.token.split(".")[1])));
this.superAdmin = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).isSuperAdmin;
this.supAdmin = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).supAdmin;
this.fs = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).fn;
this.ls = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).ln;
this.emailid = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).email;
this.or = JSON.parse(window.atob(window.localStorage.token.split(".")[1]))._orgName;
this.useridd = JSON.parse(window.atob(window.localStorage.token.split('.')[1]))._id;
this.mb = JSON.parse(window.atob(window.localStorage.token.split('.')[1])).phn;
this.custtype = JSON.parse(window.atob(window.localStorage.token.split('.')[1])).isDealer;
this.Dealer = JSON.parse(window.atob(window.localStorage.token.split('.')[1])).Dealer;
}
ngOnInit() {
this.getDevices();
this.testTable();
}
getDevices(){
this.contactService.getDevice(this.emailid,this.useridd).subscribe(
data => {
this.devicesss = data
this.finall = (this.devicesss.devices);
for(let i=0;i<this.devicesss.devices.length;i++){
// if(this.devicesss.devices[i].type_of_device =="Tracker"){
let a ={
value : this.devicesss.devices[i].Device_Name,
viewValue:this.devicesss.devices[i].Device_Name,
did:this.devicesss.devices[i].Device_ID,
id:this.devicesss.devices[i]._id,
user:this.devicesss.devices[i].user,
// email: this.devicesss.devices[i].Email_ID,
// deviceType: this.devicesss.devices[i].type_of_device
}
this.options.push(a);
// }
}
console.log(this.options);
let that = this;
setTimeout(()=>{
that.loadropdown();
},100)
});
}
loadropdown() {
let that = this;
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "https://unpkg.com/multiple-select@1.3.1/dist/multiple-select.min.js");
document.getElementsByTagName("head")[0].appendChild(script);
setTimeout(() => {
$('#select').multipleSelect({
width: 200,
placeholder: 'Select device.....',
filter: true,
// single: true,
// selectAll: false
})
// $('#select').show();
that.callfunction();
}, 100);
}
tabelObj: any;
dtOptions:any={};
repCount = 0 ;
vCount = 0;
deviceArr:any=[];
callfunction(): void {
this.Load = true;
this.deviceArr = $('#select').multipleSelect('getSelects','value');
this.tabelObj.draw();
}
testTable() {
const that = this;
console.log("inside function");
this.Load = true;
$(document).ready(function() {
that.tabelObj = $('#deviceTable').DataTable({
dom: 'lBftip',
buttons: [
'copy',
'print',
'excel'
],
"processing": true,
"searching": false,
pagingType: 'full_numbers',
pageLength: 25,
serverSide: true,
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
ajax: (dataTablesParameters: any, callback) => {
dataTablesParameters.op = {};
dataTablesParameters.select = [];
dataTablesParameters.find = {};
dataTablesParameters.find['$and'] = [];
var userFilter = {};
userFilter['$or'] =[ {user : that.useridd}, {created_by :that.useridd} ]
dataTablesParameters.find['$and'].push(userFilter);
// dataTablesParameters.find['$or'] = [currUser,admin]
dataTablesParameters.columns = [
{data:"_id"},
{data:'user.first_name'},
{data:'user.last_name'},
{data:'device.Device_Name'},
{data:'reminder_date'},
{data:'notification_type.SMS'},
{data:'notification_type.EMAIL'},
{data:'notification_type.PUSH_NOTIFICATION'},
{data : 'reminder_type'},
{data : 'prior_reminder'},
{data:'note'},
{data:'vehicleName'},
{data:'odo'},
{data:'status'},
]
if(that.repCount != 0){
var reminder_date={};
console.log(that.repCount);
// dataTablesParameters.find.user = that.useridd;
if(that.deviceArr.length != 0){
console.log('that.deviceArr',that.deviceArr);
var dev_in = {device : {'$in': that.deviceArr}};
// dataTablesParameters.find.device = dev_in;
dataTablesParameters.find['$and'].push(dev_in);
}
if (that.from_date) {
var fdate = new Date(that.from_date).toISOString()
reminder_date['$gte']=fdate
};
if (that.to_date) {
var tdate = new Date(that.to_date).toISOString()
reminder_date['$lte'] = tdate ;
};
var r_d ={};
r_d['reminder_date'] = reminder_date ;
dataTablesParameters.find['$and'].push(r_d);
if(that.reminder != undefined){
console.log(that.reminder);
var r_t = {};
r_t['reminder_type'] = that.reminder ;
dataTablesParameters.find['$and'].push(r_t);
}
// dataTablesParameters.find.user = that.useridd ;
console.log('dataTablesParameters.find=>',dataTablesParameters.find);
// that.minIdleTime =
var suburl = "";
suburl += "/reminder/reminderdatatable";
that.contactService.post(suburl, dataTablesParameters).subscribe(resp => {
console.log("Response from datatable=>",resp);
that.Load= false;
callback(resp);
}, err => {
that.Load= false;
let message1="Server Error, Please try again ";
let action:any;
that.snackBar.open(message1, action, {
duration: 5000,
});
console.log("error",err) ;
});
// }else{
// that.Load= false;
// let message1="Please Select Device";
// let action:any;
// that.snackBar.open(message1, action, {
// duration: 5000,
// });
// return;
// }
}else{
that.repCount = that.repCount + 1 ;
that.Load= false;
}
},
"rowCallback": function(row: Node, data: any | Object, index: number){
// var ddoption = $('body .dropdown-toggle').dropdown();
// console.log('ddoption',ddoption);
$('#edit', row).bind('click', (e) => {
// var name = document.getElementById('cars');
// console.log('name',name['value']);
// var selectedVal = name ;
data['identifier'] = 'edit' ;
console.log('data',data);
let dialogRef = that.dialog.open(AddReminderComponent, {
width:"700px",
data: data
});
dialogRef.afterClosed().subscribe(result => {
if(result == "Reminder updated"){
that.to_date = new Date();
that.callfunction();
console.log("Updated");
// console.log("Updated");
}
});
});
$('#delete', row).bind('click', (e) => {
console.log('delete');
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result: { value: boolean; }) => {
if (result) {
that.Load =true;
var pld = {rid : data._id};
that.contactService.deleteReminder(pld)
.subscribe(
data => {
that.Load= false;
swal(
'Deleted',
'Reminder Deleted',
'success'
)
that.callfunction();
},err=>{
that.Load = false;
swal(
'Error',
'Internal Server Error, Please try after sometime !!!',
'success'
)
})
}
})
});
},
"columns": [
{
"data": "device.Device_Name",
"visible" :true,
"render": function(data, type, row) {
return data?data:'NA';
}
},
{
"data": "reminder_date",
"visible" :true,
render: function(data, type, row) {
return moment(data).format('llll');
}
},
{
"data": "notification_type",
"visible" :true,
render: function(data, type, row) {
console.log('data',data);
if(data != undefined){
var sms:any='';
var email:any='';
var push:any='';
console.log("data.SMS,data.EMAIL,data.PUSH_NOTIFICATION=>",data.SMS,data.EMAIL,data.PUSH_NOTIFICATION);
if(data.SMS == true){
sms = '<img src="../../assets/image/sms.png" title="SMS" alt="sms" style="width:30px;height:23px;margin-right:5px">';
}
if(data.EMAIL == true){
email = '<img src="../../assets/image/email.png" title="Email" alt="email" style="width:20px;height:20px;margin-right:5px">';
}
if(data.PUSH_NOTIFICATION == true){
push = '<img src="../../assets/image/pushN.png" title="Push Notification" alt="Push Notification" style="width:30px;height:24px;margin-right:5px">';
}
}
var combinedStr = sms + email + push ;
return (combinedStr != NaN)?combinedStr : '<p></p>';
}
},
{
"data": "reminder_type",
"visible" : true,
render: function(data, type, row) {
return data?data:"NA";
}
},
{
"data": "prior_reminder",
"visible" :true,
render: function(data, type, row) {
return data?data:0;
}
},
{
"data": "odo",
"visible" :true,
render: function(data, type, row) {
return data?data:0;
}
},
{
"data": "note",
"visible" :true,
render: function(data, type, row) {
return data?data:''
}
},
{
"data": "status",
"visible" :true,
render: function(data, type, row) {
return data?data:''
}
},
{
"data": "_id",
"visible" :true,
render: function(data, type, row) {
// var option_status = '<div class="dropdown" >' +
// '<button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Status </button>'+
// '<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id = "reminder_s">' +
// '<a class="dropdown-item" style="cursor : pointer" value="Pending" >Pending</a>' +
// '<a class="dropdown-item" style="cursor : pointer" value="Completed" >Completed' +
// '<a class="dropdown-item" style="cursor : pointer" value="In Progress" >In Progress'+
// '</div>' +
// '</div>';
// var curr_status = 'pending';
var option_edit ="<i class='material-icons' style='cursor : pointer' title='Update Reminder' id='edit'> edit </i>";
// var option_status = '<select id="cars">' +
// '<option value="pending" selected ='+curr_status === "pending"+'>Pending</option>' +
// '<option value="in_Progress" selected ='+ curr_status === "in_Progress" +'>In Progress</option>' +
// '<option value="completed" selected = "curr_status === completed">Completed</option>' +
// '</select>'
return option_edit ;
}
},
{
"data": "_id",
"visible" :true,
render: function(data, type, row) {
var option_delete ="<i class='material-icons' style='cursor : pointer' title='Update Reminder' id='delete'> delete </i>";
return option_delete ;
}
},
],
});
});
}
reminderComponent(){
let dialogRef = this.dialog.open(AddReminderComponent, {
width:"800px",
data: {identifier : 'add'}
});
dialogRef.afterClosed().subscribe(result => {
if(result == "reminder Saved"){
this.to_date = new Date();
this.callfunction();
console.log("Updated")
}
});
}
}