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,666 @@
<app-all-menus></app-all-menus>
<div id="toast">
<div id="desc">{{ data_descip }}</div>
</div>
<div class="loading" *ngIf="Load">Loading&#8230;</div>
<div class="topDiv">
<div class="card">
<div class="card-header">
<h4>
Add Device
<button type="button" class="close pull-right" (click)="back()">
<i class="fas fa-arrow-circle-left"></i>
</button>
</h4>
</div>
<div class="card-body">
<form [formGroup]="deviceForm" (ngSubmit)="submit()">
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputPassword4">Contact No.</label> <span>*</span>
<input
(input)="onSearchChange($event.target.value)"
formControlName="contactNo"
type="text"
class="form-control"
id="inputPassword4"
placeholder="Enter Contact number"
[ngClass]="{ 'is-invalid': submitted && f.contactNo.errors }"
/>
<small *ngIf="message">{{ message }}</small>
<div
*ngIf="submitted && f.contactNo.errors"
class="invalid-feedback"
>
<div *ngIf="f.contactNo.errors.required">
Contact Number is required
</div>
<div *ngIf="f.contactNo.errors.pattern">
Please enter valid Contact No
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4">Owner Name</label> <span>*</span>
<input
formControlName="ownerName"
type="text"
class="form-control"
id="inputEmail4"
placeholder="Please Enter Owner Name"
[ngClass]="{ 'is-invalid': submitted && f.ownerName.errors }"
/>
<div
*ngIf="submitted && f.ownerName.errors"
class="invalid-feedback"
>
<div *ngIf="f.ownerName.errors.required">
Owner Name is required
</div>
<div *ngIf="f.ownerName.errors.pattern">
Please enter valid name
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputCity">Email</label>
<!-- <span>*</span> -->
<input
formControlName="email"
type="text"
class="form-control"
id="inputCity"
placeholder="Please Enter Email"
/>
<!-- <div *ngIf="submitted && f.email.errors.email" class="invalid-feedback">
<div *ngIf="f.email.errors.email">Please Enter valid email id</div>
</div> -->
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputCity">Dealer Followup Mobile</label> <span>*</span>
<input
formControlName="dealerFollowup"
type="text"
class="form-control"
id="inputCity"
[ngClass]="{ 'is-invalid': submitted && f.dealerFollowup.errors }"
/>
<div
*ngIf="submitted && f.dealerFollowup.errors"
class="invalid-feedback"
>
<div *ngIf="f.dealerFollowup.errors.required">
Dealer Followup is required
</div>
<div *ngIf="f.dealerFollowup.errors.pattern">
Please Enter Valid number
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputCity">Address</label> <span>*</span>
<input
formControlName="address"
type="text"
class="form-control"
id="inputCity"
[ngClass]="{ 'is-invalid': submitted && f.dealerFollowup.errors }"
/>
<div *ngIf="submitted && f.address.errors" class="invalid-feedback">
<div *ngIf="f.address.errors.required">Address is required</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="pin">Pin Code</label> <span>*</span>
<input
formControlName="pin"
type="text"
class="form-control"
id="pin"
[ngClass]="{ 'is-invalid': submitted && f.dealerFollowup.errors }"
/>
<div *ngIf="submitted && f.pin.errors" class="invalid-feedback">
<div *ngIf="f.pin.errors.required">Pin Code is required</div>
<div *ngIf="f.pin.errors.pattern">
Please Enter valid Pin code
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState">State</label>
<select
formControlName="state"
(change)="onStateChange($event)"
id="inputState"
class="form-control"
>
<option value="" selected disabled>Choose state</option>
<option *ngFor="let item of states" [value]="item">
{{ item }}
</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputCity">City</label>
<select
formControlName="city"
(change)="onCityChange($event)"
id="inputState"
class="form-control"
>
<option value="" selected disabled>Choose City</option>
<option *ngFor="let item of cityList" [value]="item.city">
{{ item.city }}
</option>
</select>
<!-- <input formControlName="city" type="text" class="form-control" id="inputCity"> -->
</div>
<div class="form-group col-md-4">
<label for="inputZip">RTO Office</label>
<select
formControlName="rtoOffice"
id="inputState"
class="form-control"
>
<option value="" selected disabled>Choose RTO</option>
<option *ngFor="let item of RTO" [value]="item.RTO_Name">
{{ item.RTO_Name }}
</option>
</select>
<!-- <input formControlName="rtoOffice" type="text" class="form-control" id="inputZip"> -->
</div>
</div>
<div class="form-row">
<div *ngIf="!inventoryManagement" class="form-group col-md-4">
<label for="inputCity">Device ID (IMEI)</label><span>*</span>
<input
formControlName="device_id"
type="text"
class="form-control"
id="inputCity"
[ngClass]="{ 'is-invalid': submitted && f.email.errors }"
/>
<div
*ngIf="submitted && f.device_id.errors"
class="invalid-feedback"
>
<div *ngIf="f.device_id.errors.required">
Device Id is required
</div>
</div>
</div>
<div *ngIf="inventoryManagement" class="form-group col-md-4">
<label for="inputCity">Device ID (IMEI)</label><span>*</span>
<div>
<select id="inventory" multiple="multiple">
<option
*ngFor="let option_1 of inventory"
[value]="option_1.IMEI"
>
{{ option_1.IMEI }}
</option>
</select>
</div>
<div
*ngIf="submitted && f.device_id.errors"
class="invalid-feedback"
>
<div *ngIf="f.device_id.errors.required">
Device Id is required
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4">Vehicle No.</label><span>*</span>
<input
formControlName="vehicleNo"
type="text"
class="form-control"
id="inputPassword4"
placeholder="Enter Vehicle number"
[ngClass]="{ 'is-invalid': submitted && f.vehicleNo.errors }"
/>
<div
*ngIf="submitted && f.vehicleNo.errors"
class="invalid-feedback"
>
<div *ngIf="f.vehicleNo.errors.required">
Vehicle number is required
</div>
<div *ngIf="f.vehicleNo.errors.maxLength">
Vehicle number accepts max 10 digits
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4">Vehicle Type</label><span>*</span>
<div>
<select id="vehicleType" multiple="multiple">
<option *ngFor="let option_1 of vehData" [value]="option_1._id">
{{ option_1.vehicle_name }}
</option>
</select>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="iccid">ICCID</label>
<input
formControlName="iccid"
type="text"
class="form-control"
id="iccid"
placeholder="Enter ICCID No number"
/>
</div>
<div class="form-group col-md-4">
<label for="sim1">SIM 1</label> <span>*</span>
<input
formControlName="sim1"
type="text"
class="form-control"
id="sim1"
placeholder="Enter SIM number"
[ngClass]="{ 'is-invalid': submitted && f.sim1.errors }"
/>
<div *ngIf="submitted && f.sim1.errors" class="invalid-feedback">
<div *ngIf="f.sim1.errors.required">SIM 1 is required</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4">SIM 2</label>
<div>
<input
formControlName="sim2"
type="text"
class="form-control"
id="sim1"
placeholder="Enter SIM number"
/>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4">Chassis No.</label><span>*</span>
<input
formControlName="chasisNo"
type="text"
class="form-control"
id="inputEmail4"
placeholder="Enter Chasis No."
[ngClass]="{ 'is-invalid': submitted && f.chasisNo.errors }"
/>
<div
*ngIf="submitted && f.chasisNo.errors"
class="invalid-feedback"
>
<div *ngIf="f.chasisNo.errors.required">
Chassis No is required
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputPassword4">Engine No.</label><span>*</span>
<input
formControlName="engineNo"
type="text"
class="form-control"
id="inputPassword4"
placeholder="Enter Engine number"
[ngClass]="{ 'is-invalid': submitted && f.engineNo.errors }"
/>
<div
*ngIf="submitted && f.engineNo.errors"
class="invalid-feedback"
>
<div *ngIf="f.engineNo.errors.required">
Engine No is required
</div>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4">Panic Button Quality.</label>
<select formControlName="panic" class="form-control">
<option value="" selected disabled>Select Panic Button</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<!-- <input formControlName="panic" type="text" class="form-control" id="inputEmail4"
placeholder="Enter Panic Button Quality."> -->
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputCity">Vehicle Manufacture</label>
<select
class="form-control"
formControlName="vehicleManufacture"
(change)="selectModel($event)"
>
<option value="" selected disabled>Choose Manufacturer</option>
<option *ngFor="let item of manufacturingData" [value]="item">
{{ item }}
</option>
</select>
<!-- <input formControlName="vehicleManufacture" type="text" class="form-control" id="inputCity"> -->
</div>
<div class="form-group col-md-4">
<label for="inputZip">Model</label>
<select class="form-control" formControlName="model">
<option value="" selected disabled>Choose Model</option>
<option *ngFor="let item of modelData" [value]="item.ModelName">
{{ item.ModelName }}
</option>
</select>
<!-- <input formControlName="vehicleCategory" type="text" class="form-control" id="inputZip"> -->
</div>
<div class="form-group col-md-4">
<lable>{{ "Vehicle Category" | translate }} :</lable>
<select formControlName="vehicleCategory" class="form-control">
<option *ngFor="let license of vehicleCat" [value]="license">
{{ license }}
</option>
</select>
<!-- <label for="inputZip">Type Of Vehicle</label>
<input formControlName="vehicleCategory" type="text" class="form-control" id="inputZip"> -->
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputState">Device Model</label><span>*</span>
<div>
<select id="dbselect" multiple="multiple">
<option
*ngFor="let option_1 of device_Model"
[value]="option_1._id"
>
{{ option_1.modelName }}
</option>
</select>
</div>
</div>
<div class="form-group col-md-4">
<label for="inputZip">Tracking Expiry</label>
<input
formControlName="trackingExp"
bsDatepicker
[bsConfig]="bsConfig"
type="text"
class="form-control"
id="inputZip"
/>
</div>
<div class="form-group col-md-4">
<label for="inputZip">E sim Expiry</label>
<input
formControlName="eSimExpiry"
bsDatepicker
[bsConfig]="bsConfig"
type="text"
class="form-control"
id="inputZip"
/>
</div>
</div>
<div class="row"></div>
</form>
<div
style="overflow: auto; overflow-x: hidden; min-height: 200px"
[ngClass]="{ rowHeight: docRow }"
>
<div class="row" *ngFor="let data of imageuploadObject; let i = index">
<div class="col-sm-6" style="padding-top: 8px">
<div class="row">
<div class="col-md-4">
<span>{{ data.doctype }} : </span>
</div>
<div class="col-md-6">
<input
type="text"
[(ngModel)]="data.phone"
placeholder="{{ 'Doc number' | translate }}"
/>
</div>
<div class="col-md-2">
<img
*ngIf="data.image"
style="width: 50px"
[src]="'https://www.oneqlik.in' + data.image.substring(6)"
(click)="openModal(template, data)"
/>
</div>
</div>
</div>
<div class="col-sm-6">
<span
><input
type="file"
class="btn btn btn-success"
style="background: #f1f1f1; border: none; color: black"
(change)="onFileChanged($event, i)"
/></span>
<!-- <span>
<button class="btn btn btn-success" (click)="onUpload(i)">
{{ uploadStatus }}
</button></span
> -->
</div>
</div>
</div>
<div class="accordion" id="accordionExample">
<div
class="card"
style="margin-left: 61px; margin-top: 23px; margin-right: 151px"
>
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button
class="btn btn-link"
type="button"
data-toggle="collapse"
data-target="#collapseOne"
aria-expanded="true"
aria-controls="collapseOne"
>
Upload Device Image
</button>
</h2>
</div>
<div
id="collapseOne"
class="collapse collapse"
aria-labelledby="headingOne"
data-parent="#accordionExample"
>
<div class="card-body">
<div class="row">
<div class="col-md-2">
<span>Device Image 1: </span>
</div>
<div class="col-md-2">
<img
*ngIf="deviceImg[0]"
style="width: 50px"
[src]="'https://www.oneqlik.in' + deviceImg[0].substring(6)"
(click)="openModal(template, deviceImg[0])"
/>
</div>
<div class="col-md-4">
<input
style="
background: #ececec;
width: 80%;
margin-left: 5px;
border: 1px solid #c1c1c1;
"
type="file"
(change)="onDeviceImageChanged($event, 0)"
/>
</div>
<!-- <div class="col-md-4">
<i
class="fas fa-cloud-upload-alt"
style="
color: #4c6ef5;
float: left;
font-size: 23px;
line-height: 2.1rem;
cursor: pointer;
"
title="Upload Image"
(click)="onDeviceImageUploadUpload(0)"
></i>
</div> -->
</div>
<div class="row">
<div class="col-md-2">
<span>Device Image 2: </span>
</div>
<div class="col-md-2">
<img
*ngIf="deviceImg[1]"
style="width: 50px"
[src]="'https://www.oneqlik.in' + deviceImg[1].substring(6)"
(click)="openModal(template, deviceImg[1])"
/>
</div>
<div class="col-md-4">
<input
style="
background: #ececec;
width: 80%;
margin-left: 5px;
border: 1px solid #c1c1c1;
"
type="file"
(change)="onDeviceImageChanged($event, 1)"
/>
</div>
<!-- <div class="col-md-4">
<i
class="fas fa-cloud-upload-alt"
style="
color: #4c6ef5;
float: left;
font-size: 23px;
line-height: 2.1rem;
cursor: pointer;
"
title="Upload Image"
(click)="onDeviceImageUploadUpload(1)"
></i>
</div> -->
</div>
<div class="row">
<div class="col-md-2">
<span>Device Image 3: </span>
</div>
<div class="col-md-2">
<img
*ngIf="deviceImg[2]"
style="width: 50px"
[src]="'https://www.oneqlik.in' + deviceImg[2].substring(6)"
(click)="openModal(template, deviceImg[2])"
/>
</div>
<div class="col-md-4">
<input
style="
background: #ececec;
width: 80%;
margin-left: 5px;
border: 1px solid #c1c1c1;
"
type="file"
(change)="onDeviceImageChanged($event, 2)"
/>
</div>
<!-- <div class="col-md-4">
<i
class="fas fa-cloud-upload-alt"
style="
color: #4c6ef5;
float: left;
font-size: 23px;
line-height: 2.1rem;
cursor: pointer;
"
title="Upload Image"
(click)="onDeviceImageUploadUpload(2)"
></i>
</div> -->
</div>
<div id="toast">
<div id="desc">{{ data_descip }}</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer text-center">
<button type="submit" class="btn btn-primary" (click)="submit()">
Add Device
</button>
</div>
</div>
</div>
</div>
<ng-template #template>
<div class="modal-header">
<h4 class="modal-title pull-left">{{ docName }}</h4>
<button
type="button"
class="close pull-right"
aria-label="Close"
(click)="modalRef.hide()"
>
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body row">
<div class="col-md-12">
<img style="width: -webkit-fill-available" src="{{ image }}" />
</div>
</div>
</ng-template>

View file

@ -0,0 +1,58 @@
.topDiv {
padding-top: 59px;
background: whitesmoke;
height: 100vh;
padding-left: 4px;
padding-right: 3px;
}
#toast {
visibility: hidden;
max-width: 250px;
height: 50px;
/*margin-left: -125px;*/
margin: auto;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
position: fixed;
z-index: 1;
left: 60%;
right: 0;
bottom: 80%;
font-size: 13px;
white-space: nowrap;
}
#toast #img {
width: 250px;
height: 50px;
float: left;
padding-top: 16px;
padding-bottom: 16px;
box-sizing: border-box;
background-color: #111;
color: #fff;
}
#toast #desc {
color: #fff;
padding: 16px;
overflow: hidden;
white-space: nowrap;
}
#toast.show {
visibility: visible;
-webkit-animation: fadein 0.5s, expand 0.5s 0.5s, stay 3s 1s, shrink 0.5s 2s,
fadeout 0.5s 2.5s;
animation: fadein 0.5s, expand 0.5s 0.5s, stay 3s 1s, shrink 0.5s 4s,
fadeout 0.5s 4.5s;
}

View file

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

View file

@ -0,0 +1,985 @@
import { Component, OnInit, TemplateRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { FlashMessagesService } from 'angular2-flash-messages';
import { BsDatepickerConfig, BsModalRef, BsModalService } from 'ngx-bootstrap';
import { ContactService } from '../../contact.service';
import {Location} from '@angular/common';
declare var $:any;
declare var swal: any;
@Component({
selector: 'app-add-new-device',
templateUrl: './add-new-device.component.html',
styleUrls: ['./add-new-device.component.scss']
})
export class AddNewDeviceComponent implements OnInit {
DeviceModelValue: any;
modalRef: BsModalRef;
submitted = false;
date=new Date()
expDate:any = new Date(this.date.getFullYear() + 1, this.date.getMonth(), this.date.getDate()).toLocaleString();
Indianstate = [ "Andhra Pradesh",
"Arunachal Pradesh",
"Assam",
"Bihar",
"Chhattisgarh",
"Goa",
"Gujarat",
"Haryana",
"Himachal Pradesh",
"Jammu and Kashmir",
"Jharkhand",
"Karnataka",
"Kerala",
"Madhya Pradesh",
"Maharashtra",
"Manipur",
"Meghalaya",
"Mizoram",
"Nagaland",
"Odisha",
"Punjab",
"Rajasthan",
"Sikkim",
"Tamil Nadu",
"Telangana",
"Tripura",
"Uttarakhand",
"Uttar Pradesh",
"West Bengal",
"Andaman and Nicobar Islands",
"Chandigarh",
"Dadra and Nagar Haveli",
"Daman and Diu",
"Delhi",
"Lakshadweep",
"Puducherry"]
custtype: any;
DealerId: any;
constructor(private modalService: BsModalService,private location:Location,private fb:FormBuilder,private contactService:ContactService,private router:Router,private _flashMessagesService: FlashMessagesService,) { }
deviceForm:FormGroup;
userId
deviceModel
vehicleCat=[
"Luxury Cab",
"Three wheeled vehicles for transport of passengers/goods",
"Goods carrier trucks or tankers or mail carriers",
"Power tiller and Tractors using public roads",
"Mobile clinic or X-Ray van or library vans",
"Mobile Workshops",
"Mobile canteens",
"Private Service Vehicle",
"maxi cab",
"motor cab",
"stage cariage",
"contract carriage",
"Tourist",
"Educational Institution buses",
"Ambulances",
"Animal Ambulances",
"Camper vans or trailers",
"Cash vans",
"Fire tenders, snorked ladders,auxiliary trailers and fire fighting vehicles",
"Articulated vehicles",
"Hearses",
"Motor car",
"Crane mounted vehicle",
"Agricultural Tractor and Power Tiller",
"Tow Trucks, Breakdown Van and Recovery Vehicles",
"Construction Equipment Vehicles",]
// vehicleCat=['Truck','Bus','Car','School Van'];
Load:boolean=false;
bsConfig: Partial<BsDatepickerConfig>;
dataDevModel: any[];
vehicle_Type: any[];
imageuploadObject = [{doctype:'Adhar card1 *',image:'',phone:'',docdate:new Date(),fill:false},
{doctype:'Adhar card2 *',image:'',phone:'',docdate:new Date(),fill:false},
{doctype:'Warrenty Card *',image:'',phone:'',docdate:new Date(),fill:false},
{doctype:'vehicle sales invoice *',image:'',phone:'',docdate:new Date(),fill:false},
{doctype:'vehicle RC',image:'',phone:'',docdate:new Date(),fill:true},
{doctype:'vehicle Photo',image:'',phone:'',docdate:new Date(),fill:true},
];
dealerId
sup_admin
hrdwr
hrdwr2
custId
vahanID
documentList = [
{
"docId": "Adhar card1",
"docName": "Adhar Card Front"
},
{
"docId": "Adhar card2",
"docName": "Adhar Card Back"
},
{
"docId": "vehicle sales invoice",
"docName": "vehicle sales invoice"
},
{
"docId": "voter Id",
"docName": "Voter Id"
},
{
"docId": "vehicle RC",
"docName": "vehicle RC"
},
{
"docId": "vehicle Photo",
"docName": "vehicle Photo"
},
{
"docId": "PAN card",
"docName": "Pan Card"
},
{
"docId": "Driving License",
"docName": "Driving License"
},
{
"docId": "RC Book",
"docName": "RC Book"
},
{
"docId": "Device Image",
"docName": "Device Image"
},
{
"docId": "Co.registered Card",
"docName": "Co.registered Card"
},
{
"docId": "Nepal Citizenship",
"docName": "Nepal Citizenship"
},
{
"docId": "Blue Book",
"docName": "Blue Book"
},
{
"docId": "Warrenty Card",
"docName": "Warrenty Card"
},
{
"docId": "Other",
"docName": "Other"
}
];
ngOnInit() {
this.bsConfig = Object.assign({ dateInputFormat: 'DD-MM-YYYY' }, { containerClass: 'theme-dark-blue' });
this.userId = JSON.parse(window.atob(window.localStorage.token.split('.')[1]))._id;
this.dealerId=JSON.parse(window.atob(window.localStorage.token.split('.')[1])).Dealer_ID;
if(JSON.parse(window.atob(window.localStorage.token.split(".")[1])).isSuperAdmin){
this.sup_admin = JSON.parse(window.atob(window.localStorage.token.split(".")[1]))._id;
}else{
this.sup_admin = JSON.parse(window.atob(window.localStorage.token.split(".")[1])).supAdmin;
}
console.log("SUPPPERADMIN-----,",this.sup_admin);
this.custtype = JSON.parse(window.atob(window.localStorage.token.split('.')[1])).isDealer;
this.custId = localStorage.getItem('custId');
if((this.custtype == false)&&(window.localStorage['Custumer'] == 'ON')){
this.DealerId = JSON.parse(window.atob(window.localStorage.Dealer_token.split(".")[1]))._id;
}
this.deviceForm=this.fb.group({
ownerName:['',[Validators.required,Validators.pattern("[a-zA-Z][a-zA-Z ]+")]],
contactNo:['',[Validators.required,Validators.pattern('[0-9 ]{10}')]],
device_id:[''],
address:['',Validators.required],
state:[''],
rtoOffice:[''],
vehicleManufacture:[''],
vehicleModel:[''],
vehicleCategory:[''],
vehicleType:[''],
vehicleNo:['',[Validators.required,Validators.maxLength(10)]],
chasisNo:['',Validators.required],
engineNo:['',Validators.required],
panic:[''],
bsnlPlan:[''],
hostingPlan:[''],
SMSPlan:[''],
city:[''],
deviceModel:[''],
trackingExp:new Date(this.expDate),
eSimExpiry:[''],
model:[''],
email:[""],
dealerFollowup:['',[Validators.required,Validators.pattern('[0-9 ]{10}')]],
sim1:['',Validators.required],
sim2:[''],
iccid:[''],
pin:['',[Validators.required,Validators.pattern('[0-9 ]{6}')]]
})
this.loadropdown()
this.getDeviceModel();
this.getvehDetail()
this.getUserSetting(this.userId);
this.getModelData()
this. getAllState()
var that=this
$(document).on('change','#inventory',function() {
var value = $('#inventory').val();
for(var i=0;i<that.inventory.length;i++){
if(value==that.inventory[i].IMEI){
var date=new Date()
var exp
if(that.inventory[i].eSIMValidaity=="One Year"){
exp= new Date(date.getFullYear() + 1, date.getMonth(), date.getDate()).toLocaleString();
}else if(that.inventory[i].eSIMValidaity=="Two Year"){
exp= new Date(date.getFullYear() + 2, date.getMonth(), date.getDate()).toLocaleString();
}else{
exp= new Date(date.getFullYear() + 1, date.getMonth(), date.getDate()).toLocaleString();
}
that.deviceForm.patchValue({
iccid:that.inventory[i].IccidNo,
sim1:that.inventory[i].Mob1,
sim2:that.inventory[i].Mob2,
eSimExpiry:new Date(exp),
device_id:value,
})
that.vahanID=that.inventory[i]['SerialNo']
that.hrdwr=that.inventory[i].Mob1
that.hrdwr2=that.inventory[i].Mob2
}
}
});
}
get f() { return this.deviceForm.controls; }
states=[]
getAllState(){
this.contactService.get('/RTO_master/getAllState').subscribe((res:any)=>{
for(var i=0;i<res.length;i++){
this.states.push(res[i]._id.state)
}
// this.states=res;
})
}
submit(){
this.submitted = true;
// stop here if form is invalid
if (this.deviceForm.invalid) {
const controls = this.deviceForm.controls;
for (const name in controls) {
if (controls[name].invalid) {
// invalid.push(name);
this.data_descip = "please enter valid "+name ;
this.launch_toast();
return;
}
}
}
for(var i=0;i<this.imageuploadObject.length;i++){
if(!this.imageuploadObject[i].fill){
swal(
'Upload Error',
'Please upload required documnets !!!',
'error'
)
return;
}
if(i<=3 && this.imageuploadObject[i].phone==''){
var err
if(i==0 || i==1){
err="Please Enter Adhar card number"
}else if(i==2){
err="Please Enter Warrenty card number"
}else{
err="Please Enter vehicle sales invoice number"
}
swal(
'Upload Error',
err,
'error'
)
return;
}
}
if(this.userFound){
var data1={
contactid:this.user._id
}
if(this.deviceForm.value.pin){
data1['pin']=this.deviceForm.value.pin
}
this.contactService.post('/users/editUserDetails',data1).subscribe((res:any)=>{
console.log(res);
if(res.message=="Saved"){
this.addDevice(this.user)
// this.addDevice(res._id)
// this.router.navigateByUrl('/dashboard');
}
})
}else{
var expDate = new Date();
expDate.setFullYear(expDate.getFullYear()+1);
var name=this.deviceForm.value.ownerName.split(' ')
var data={
// Dealer:this.reactiveForm.value.manager,
custumer: true,
expdate:new Date(expDate).toISOString(),
first_name:name[0]?name[0]:'',
last_name:name[1]?name[1]:'',
isDealer: false,
phone:this.deviceForm.value.contactNo,
user_id:"",
org_name: null,
password:this.generatePassword(6),
supAdmin:this.sup_admin,
Dealer:this.userId,
timezone: "Asia/Kolkata",
std_code: {countryCode: "in", dialcode: "91"},
}
if(this.deviceForm.value.pin){
data['pin']=this.deviceForm.value.pin
}
if(this.deviceForm.value.email){
data['email']=this.deviceForm.value.email
}
if(this.deviceForm.value.address){
data['address']=this.deviceForm.value.address
}
console.log(data);
this.contactService.post('/users/signUp',data).subscribe((res:any)=>{
console.log(res);
if(res.message=="Registered Sucessfully" || res.message=="Registered and Message Sent Successfuly" || res.message=="Registered"){
this.addDevice(res._id)
// this.router.navigateByUrl('/dashboard');
}
})
}
}
addDevice(data){
var model= $('#dbselect').multipleSelect('getSelects','value');
var type= $('#vehicleType').multipleSelect('getSelects','value');
var deviceid
if(this.inventoryManagement){
var id=$('#inventory').multipleSelect('getSelects','value');
deviceid=id[0]
}else{
deviceid=this.deviceForm.value.device_id
}
var newDevice = {
devicename: this.deviceForm.value.vehicleNo,
deviceid: deviceid,
// des: this.des,
model: model[0],
typdev: "Tracker",
// emailid: this.emailid,
Mileage : "10",
phn: this.deviceForm.value.contactNo,
sim_number: this.deviceForm.value.contactNo,
created_by: this.userId,
supAdmin: this.sup_admin,
// driver_name: this.driver,
// contact_number: this.dcontact,
device_model: model[0],
expdate: new Date(this.expDate),
user:data._id,
bussinessType:1
// License : this.licenseVal,
// deviceDistanceVariation:this.selcetedSign+(this.deviceDistanceVariation?this.deviceDistanceVariation:'0')
// Dealer:this.dealerObj?this.dealerObj:this.sup_admin
}
// if (this.custtype) {
// newDevice['Dealer'] = this.userId;
// } else if((this.custtype == false)&&(window.localStorage['Custumer'] == 'ON') ) {
newDevice['Dealer'] = this.userId
// }
// hrdwr: this.deviceForm.value.sim1,
// hrdwr1: this.deviceForm.value.sim1,
if(this.deviceForm.value.sim1){
newDevice['hrdwr'] = this.deviceForm.value.sim1
}
if(this.deviceForm.value.sim1){
newDevice['sim_number'] = this.deviceForm.value.sim1
}
if(this.deviceForm.value.sim2){
newDevice['sim_number2'] = this.deviceForm.value.sim2
}
if(this.deviceForm.value.eSimExpiry){
newDevice['esim_validity'] = this.deviceForm.value.eSimExpiry
}
if(this.deviceForm.value.model){
newDevice['model'] = this.deviceForm.value.model
}
if(this.deviceForm.value.dealerFollowup){
newDevice['CID_No'] = this.deviceForm.value.dealerFollowup;
}
if(this.hrdwr){
newDevice['hrdwr']=this.hrdwr
}
if(this.deviceForm.value.engineNo){
newDevice['engineNo'] = this.deviceForm.value.engineNo;
}
if(this.deviceForm.value.city){
newDevice['transportOfficeCity'] = this.deviceForm.value.city;
}
if(this.deviceForm.value.state){
newDevice['transportOfficeState'] = this.deviceForm.value.state;
}
if(this.deviceForm.value.chasisNo){
newDevice['ChassisNo'] = this.deviceForm.value.chasisNo
}
if(this.deviceForm.value.vehicleManufacture){
newDevice['manufacturingCompany'] = this.deviceForm.value.vehicleManufacture;
}
if(type){
newDevice['typeOfVehicle'] = type[0];
}
if(type){
newDevice['vehicleType'] = type[0];
}
// if(this.transportOfficeCity){
// newDevice['transportOfficeCity'] = this.transportOfficeCity;
// }
if(this.deviceForm.value.state){
newDevice['transportOfficeState'] = this.deviceForm.value.state;
}
if(this.deviceForm.value.iccid){
newDevice['IccidNo'] = this.deviceForm.value.iccid;
}
if(this.vahanID){
newDevice['vahanID'] = this.vahanID;
}
if(this.deviceForm.value.panic){
newDevice['numberOfSOS'] = this.deviceForm.value.panic;
}
if(this.deviceImg != undefined){
newDevice['deviceImage'] = this.deviceImg;
}
if(this.deviceForm.value.vehicleCategory){
newDevice['vehicleCategory'] = this.deviceForm.value.vehicleCategory;
}
if(this.deviceForm.value.rtoOffice){
newDevice['rto'] = this.deviceForm.value.rtoOffice;
}
console.log("imageuploadDocument",this.imageuploadObject);
if((this.imageuploadObject.length !=0)){
newDevice['imageDoc'] = this.imageuploadObject ;
}
console.log("=======>",newDevice)
this.Load = false;
this.contactService.addKycDevice(newDevice)
.subscribe((device) => {
console.log(device);
window.localStorage['DataUpdate'] = 'True';
this.data_descip = "Device Added Successfully";
launch_toast();
this.router.navigateByUrl("dashboard");
}
// this.Load = false
, (err: any) => {
console.log(err.status);
console.log(err);
var that = this;
if (err.status == 400) {
console.log(JSON.parse(err._body).deviceObj);
var dupObj = JSON.parse(err._body).deviceObj ;
// this.Load = false;
that.data_descip = "Duplicate Device ID (IMEI)";
that.launch_toast();
var devicesupAdmin = dupObj.supAdmin;
var deviceDealer = dupObj.Dealer;
var devOwner = dupObj.user;
// debugger;
}
else {
var message
if(err.status==401){
message="Access Denied !!!"
this.data_descip = "Access Denied !!!";
launch_toast();
}else{
message="Network Error !!!"
this.data_descip = "Network Error !!!";
launch_toast();
}
console.log(err);
this._flashMessagesService.show(message, { cssClass: 'alert-danger', timeout: 2000 });
// this.Load = false
}
}
)
function launch_toast() {
// console.log(divid);
var x = document.getElementById("toast")
//console.log(x);
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 1500);
}
}
generatePassword(passwordLength) {
var numberChars = "0123456789";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var allChars = numberChars + upperChars + lowerChars;
var randPasswordArray = Array(passwordLength);
randPasswordArray[0] = numberChars;
randPasswordArray[1] = upperChars;
randPasswordArray[2] = lowerChars;
randPasswordArray = randPasswordArray.fill(allChars, 3);
return this.shuffleArray(randPasswordArray.map(function(x) { return x[Math.floor(Math.random() * x.length)] })).join('');
}
shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
message
user
userFound:boolean=false;
onSearchChange(value){
this.userFound=false
this.message=undefined
console.log(value);
var phone=this.deviceForm.value.contactNo
if(phone.length==10){
console.log("KLDJNDKjk");
this.contactService.get('/users/searchUserByPhone?user='+this.userId+'&phone='+phone).subscribe((res:any)=>{
console.log(res);
if(res.message=="User already Present"){
this.deviceForm.patchValue({
ownerName:res.data[0].first_name?res.data[0].first_name:""+" "+res.data[0].last_name?res.data[0].first_name:'',
email:res.data[0].email?res.data[0].email:""
})
this.user=res.data[0]
this.userFound=true;
this.deviceForm.controls.ownerName.disable();
this.deviceForm.controls.email.disable();
}else{
this.userFound=false
this.message=res.message
}
},err=>{
console.log(err);
this.message=err.error.message
})
}
}
device_Model: any;
getDeviceModel() {
this.contactService.get("/deviceModel/getDeviceModel?input=Nippon")
// this.contactService.getDevModel()
.subscribe(res => {
this.device_Model = res;
var devname = [];
console.log("Device_Model",this.device_Model);
for(var i = 0 ; i<this.device_Model.length;i++){
var a = {
model :this.device_Model[i].device_type,
id : this.device_Model[i]._id
}
var modelName;
if(this.device_Model[i].deviceport != undefined){
modelName = this.device_Model[i].device_type + " " + "(Port : " + this.device_Model[i].deviceport + ")";
}else{
modelName = this.device_Model[i].device_type;
}
this.device_Model[i].modelName = modelName ;
devname.push(a);
}
console.log('this.device_Model',this.device_Model);
console.log(devname);
this.loadropdown()
})
}
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);
// ||(this.componentIdentifier === 'notification_master')
setTimeout(() => {
$('#dbselect').multipleSelect({
width: 470,
placeholder:"Select model",
filter: true,
single: true,
selectAll: false
})
$('#vehicleType').multipleSelect({
width: 470,
placeholder: "Select Type",
filter: true,
single: true,
selectAll: false
})
$('#inventory').multipleSelect({
width: 470,
placeholder: 'Select IMEI',
filter: true,
single: true,
selectAll: false
})
}, 100);
}
vehData:any;
getvehDetail(){
this.contactService.getvehType(this.userId)
.subscribe(res=>{
// console.log(res);
this.vehData=res;
var vdata = res;
for(var a = 0;a<this.vehData.length;a++){
var vehtypename = vdata[a].brand + " " + vdata[a].model;
this.vehData[a].vehicle_name = vehtypename;
}
console.log("allveh",this.vehData);
this.loadropdown()
})
}
docRow:boolean=false;
// AddDocumentsField(addedRow:any){
// console.log("Inside function !!!");
// if(addedRow){
// this.docRow = true;
// }
// var obj={doctype:'',image:'',phone:'',docdate:''};
// this.imageuploadObject.push(obj);
// console.log(this.imageuploadObject);
// // console.log("ImageuploadObject=>",this.imageuploadObject);
// }
showUpload:boolean=true;
DeleteDocumentsField(index){
console.log(this.imageuploadObject.length);
if(this.imageuploadObject.length == 1){
this.docRow = false;
this.showUpload = false;
}
this.imageuploadObject.splice(index, 1);
}
selectedFile: File;
index
onFileChanged(event,i) {
this.index=i
this.selectedFile = <File>event.target.files[0];
console.log(this.selectedFile);
this.imageuploadObject[this.index].fill=true;
console.log(this.imageuploadObject);
const fd = new FormData();
fd.append('photo',this.selectedFile,this.selectedFile.name)
console.log("imgURL=>",fd) ;
this.Load = true;
this.contactService.imageupload(fd)
.subscribe(res=>{
this.Load = false;
this.ifuploadArr = true;
// this.uploadStatus = 'Uploaded';
this.data_descip = "Image Uploaded";
this.launch_toast();
console.log(res);
var resImage ='';
resImage = res['_body'];
console.log(res['_body']);
this.imageuploadObject[this.index].image = resImage;
console.log(this.imageuploadObject);
// console.log(res);
this.selectedFile=undefined
},err=>{
this.selectedFile=undefined
this.Load= false;
this.data_descip = "Internal server error , try again";
this.launch_toast();
this._flashMessagesService.show('Internal server error , try again', { cssClass: 'alert-success', timeout: 2000 });
})
}
ifuploadArr: boolean ;
uploadStatus: any = 'Upload';
onUpload(imgIndex) {
console.log(imgIndex);
// console.log("selected file name =>",this.selectedFile.name);
if(!this.selectedFile){
swal(
'Upload Error',
'Please choose file before upload !!!',
'error'
)
}else{
this.imageuploadObject[this.index].fill=true;
console.log(this.imageuploadObject);
const fd = new FormData();
fd.append('photo',this.selectedFile,this.selectedFile.name)
console.log("imgURL=>",fd) ;
this.Load = true;
this.contactService.imageupload(fd)
.subscribe(res=>{
this.Load = false;
this.ifuploadArr = true;
// this.uploadStatus = 'Uploaded';
this.data_descip = "Image Uploaded";
this.launch_toast();
console.log(res);
var resImage ='';
resImage = res['_body'];
console.log(res['_body']);
this.imageuploadObject[this.index].image = resImage;
console.log(this.imageuploadObject);
// console.log(res);
this.selectedFile=undefined
},err=>{
this.selectedFile=undefined
this.Load= false;
this.data_descip = "Internal server error , try again";
this.launch_toast();
this._flashMessagesService.show('Internal server error , try again', { cssClass: 'alert-success', timeout: 2000 });
})
}
}
documentType(docType){
console.log("doctypeObject=>",docType);
}
inventoryManagement:Boolean=false;
inventory=[]
getUserSetting(userId){
this.contactService.post('/users/get_user_setting',{uid: userId}).subscribe((res:any)=>{
this.inventoryManagement=res.inventoryManagement;
if(this.inventoryManagement){
console.log(this.userId,this.dealerId=JSON.parse(window.atob(window.localStorage.token.split('.')[1])).isDealer);
var isDealer=JSON.parse(window.atob(window.localStorage.token.split('.')[1])).isDealer
var isSuperAdmin=JSON.parse(window.atob(window.localStorage.token.split('.')[1])).isSuperAdmin
// var user
// if(isSuperAdmin){
// var user
// }else if(isDealer){
// }
var user=isSuperAdmin?this.userId:this.sup_admin?this.sup_admin:this.userId
console.log(user);
this.contactService.get('/Device_inventory/getInventoryDropdown?user='+this.userId).subscribe((res:any)=>{
this.inventory=res;
this.loadropdown()
})
}
})
}
manufacturingData
getModelData(){
this.contactService.get('/model_master/GetNames').subscribe((res:any)=>{
this.manufacturingData=res
})
}
modelData
selectModel(event){
console.log(event.target.value);
this.contactService.get('/model_master/getModel?name='+event.target.value).subscribe((res:any)=>{
this.modelData=res
})
}
cityList
onStateChange(event){
this.contactService.get('/RTO_master/getCity?state='+event.target.value).subscribe((res:any)=>{
this.cityList=res
})
}
RTO
onCityChange(event){
this.contactService.get('/RTO_master/getRTO?city='+event.target.value).subscribe((res:any)=>{
this.RTO=res
})
}
back(){
this.location.back()
}
imageURL:any;
index2
selectedDeviceFile:File;
data_descip : any;
onDeviceImageChanged(event,index) {
this.index2=index
this.selectedDeviceFile = <File>event.target.files[0];
if(this.selectedDeviceFile){
this.Load = true;
const fdDevice = new FormData();
fdDevice.append('photo',this.selectedDeviceFile,this.selectedDeviceFile.name)
console.log("Binaryimage = > ",fdDevice );
this.contactService.deviceImageupload(fdDevice)
.subscribe(res=>{
console.log(res);
if(res){
// if(this.deviceImg[this.index2]){
this.deviceImg[this.index2]=res['_body']
// }else{
// this.deviceImg.push(res['_body'])
// }
}
this.selectedDeviceFile=undefined;
console.log('this.deviceImg',this.deviceImg);
this.data_descip = "Image Uploaded";
launch_toast();
this.Load = false;
},err=>{
this.data_descip = "Internal Server Error";
launch_toast();
this.selectedDeviceFile=undefined;
console.log(err);
this.Load = false;
})
}
function launch_toast() {
// console.log(divid);
var x = document.getElementById("toast")
//console.log(x);
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 1500);
}
}
deviceImg=['','',''];
onDeviceImageUploadUpload(index){
if(!this.selectedDeviceFile){
swal(
'Upload Error',
'Please choose file before upload !!!',
'error'
)
}else{
this.Load = true;
const fdDevice = new FormData();
fdDevice.append('photo',this.selectedDeviceFile,this.selectedDeviceFile.name)
console.log("Binaryimage = > ",fdDevice );
this.contactService.deviceImageupload(fdDevice)
.subscribe(res=>{
console.log(res);
if(res){
// if(this.deviceImg[this.index2]){
this.deviceImg[this.index2]=res['_body']
// }else{
// this.deviceImg.push(res['_body'])
// }
}
this.selectedDeviceFile=undefined;
console.log('this.deviceImg',this.deviceImg);
this.data_descip = "Image Uploaded";
launch_toast();
this.Load = false;
},err=>{
this.data_descip = "Internal Server Error";
launch_toast();
this.selectedDeviceFile=undefined;
console.log(err);
this.Load = false;
})
}
function launch_toast() {
// console.log(divid);
var x = document.getElementById("toast")
//console.log(x);
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 1500);
}
}
launch_toast() {
console.log("ihjgdfds");
var x = document.getElementById("toast")
//console.log(x);
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 1500);
}
image;
docName
openModal(template: TemplateRef<any>,doc){
console.log(doc);
this.modalRef = this.modalService.show(template,{'backdrop':'static',class:'modal-lg modal-dialog-centered'});
this.docName=doc.doctype
this.image="https://www.oneqlik.in"+doc.image.substring(6)
}
}