Skip to content

Commit

Permalink
sms template and sms component(wip) changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Diamond Khanna (Digital) authored and Diamond Khanna (Digital) committed Jul 9, 2018
1 parent c9c64c9 commit 08ba79a
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 26 deletions.
1 change: 0 additions & 1 deletion .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/tether/dist/js/tether.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
// "../node_modules/jspdf/dist/jspdf.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down
7 changes: 5 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ import { AgentForceLogoutComponent } from './agent-force-logout/agent-force-logo

import { SmsTemplateComponent } from './sms-template/sms-template.component';
import { SmsTemplateService } from './services/supervisorServices/sms-template-service.service';
import { CommonSmsDialogComponent } from './common-sms-dialog/common-sms-dialog.component';

//for text mask
// import { TextMaskModule } from 'angular2-text-mask';
Expand Down Expand Up @@ -235,7 +236,8 @@ import { SmsTemplateService } from './services/supervisorServices/sms-template-s
EmergencyContactsViewModalComponent,
CaseSheetSummaryDialogComponent,
AgentForceLogoutComponent,
SmsTemplateComponent
SmsTemplateComponent,
CommonSmsDialogComponent

],
imports: [
Expand Down Expand Up @@ -335,7 +337,8 @@ import { SmsTemplateService } from './services/supervisorServices/sms-template-s
CoAlternateNumberComponent,
EmergencyContactsViewModalComponent,
CaseSheetSummaryDialogComponent,
AgentForceLogoutComponent],
AgentForceLogoutComponent,
CommonSmsDialogComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [loginService, ClearFormService, dataService, DashboardHttpServices, SPService, RegisterService,
UserService, LanguageService, RoleService, ServicemasterService, ScreenService, HttpServices, HttpClientModule,
Expand Down
125 changes: 118 additions & 7 deletions src/app/beneficiary-registration/beneficiary-registration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { OutboundService } from './../services/common/outbound.services';
import { ReloadService } from './../services/common/reload.service';
import { Subscription } from 'rxjs/Subscription';
import { NgForm } from '@angular/forms';
import { CommonSmsDialogComponent } from '../common-sms-dialog/common-sms-dialog.component';
import { SmsTemplateService } from './../services/supervisorServices/sms-template-service.service';

import * as moment from 'moment';

declare var jQuery: any;
Expand Down Expand Up @@ -153,12 +156,22 @@ export class BeneficiaryRegistrationComponent implements OnInit {

//public mobileNumberMask = [ /[^0-9]/, /\d/];

constructor(private _util: RegisterService, private _router: Router,
private _userBeneficiaryData: UserBeneficiaryData, private _locationService: LocationService,
private updateBen: UpdateService, private saved_data: dataService, private renderer: Renderer,
private message: Message, public dialog: MdDialog, private alertMaessage: ConfirmationDialogsService,
constructor(private _util: RegisterService,
private _router: Router,
private _userBeneficiaryData: UserBeneficiaryData,
private _locationService: LocationService,
private updateBen: UpdateService,
private saved_data: dataService,
private renderer: Renderer,
private message: Message,
public dialog: MdDialog,
private alertMaessage: ConfirmationDialogsService,
private pass_data: CommunicationService,
private outboundService: OutboundService, private czentrixService: CzentrixServices, private reload_call: ReloadService) {
private outboundService: OutboundService,
private czentrixService: CzentrixServices,
private reload_call: ReloadService,
private _smsService: SmsTemplateService
) {

// this.subcriptionOutbound = this.outboundService.getOutboundData()
// .subscribe(benOutboundData => { this.startOutBoundCall(benOutboundData) });
Expand Down Expand Up @@ -600,7 +613,7 @@ export class BeneficiaryRegistrationComponent implements OnInit {
this.updatedObj.lastName = this.LastName;
this.updatedObj.genderID = this.GenderID;
if (this.DOB) {
this.updatedObj.dOB = new Date((this.DOB) - 1 * (this.DOB.getTimezoneOffset() * 60 * 1000)).toJSON().slice(0,  10)+'T00:00:00.000Z';
this.updatedObj.dOB = new Date((this.DOB) - 1 * (this.DOB.getTimezoneOffset() * 60 * 1000)).toJSON().slice(0, 10) + 'T00:00:00.000Z';
} else {
this.updatedObj.dOB = undefined;
}
Expand Down Expand Up @@ -732,7 +745,30 @@ export class BeneficiaryRegistrationComponent implements OnInit {

showAlert() {
this.BeneficaryForm.resetForm();
this.alertMaessage.alert('Beneficiary registered with ID :' + this.benRegistrationResponse.beneficiaryID, 'success');
// this.alertMaessage.alert('Beneficiary registered with ID :' + this.benRegistrationResponse.beneficiaryID, 'success');
let dialogReff = this.dialog.open(CommonSmsDialogComponent, {
disableClose: true,
width: '420px',
data: {
'statement': 'Beneficiary registered with ID ',
'generatedID': this.benRegistrationResponse.beneficiaryID
}
});

dialogReff.afterClosed().subscribe(result => {
let mobile_number;
mobile_number = result;

if (mobile_number != 'close' && (mobile_number === undefined || mobile_number === '')) {
// mobile no is undefined
console.log('Registered number will be used'); // Registered number will be used
// ** code to send SMS **
this.sendSMS(this.benRegistrationResponse.beneficiaryRegID);
} else {
// ** code to send SMS **
this.sendSMS(this.benRegistrationResponse.beneficiaryRegID, mobile_number);
}
});
}

retrieveRegHistoryByPhoneNo(PhoneNo: any) {
Expand Down Expand Up @@ -1516,4 +1552,79 @@ export class BeneficiaryRegistrationComponent implements OnInit {
// }
/** Purpose: function to retrive beneficiaries based on the fileds entered */



/* 3 July,2018
Author:Diamond Khanna
Purpose: SMS sending */
sendSMS(generated_ben_id, alternate_Phone_No?) {

let sms_template_id = '';
let smsTypeID = '';
let currentServiceID = this.saved_data.current_serviceID;

this._smsService.getSMStypes(currentServiceID)
.subscribe(response => {
if (response != undefined) {
if (response.length > 0) {
for (let i = 0; i < response.length; i++) {
if (response[i].smsType.toLowerCase() === 'Registration SMS'.toLowerCase()) {
smsTypeID = response[i].smsTypeID;
break;
}
}
}
}

if (smsTypeID != '') {
this._smsService.getSMStemplates(this.saved_data.current_service.serviceID,
smsTypeID).subscribe(res => {
if (res != undefined) {
if (res.length > 0) {
for (let j = 0; j < res.length; j++) {
if (res[j].deleted === false) {
sms_template_id = res[j].smsTemplateID;
break;
}
}

}

if (smsTypeID != '') {
let reqObj = {
'alternateNo': alternate_Phone_No,
'beneficiaryRegID': generated_ben_id,
'createdBy': this.saved_data.uname,
'is1097': false,
'providerServiceMapID': this.saved_data.current_service.serviceID,
'smsTemplateID': sms_template_id,
'smsTemplateTypeID': smsTypeID
// "userID": 0
}

let arr = [];
arr.push(reqObj);

this._smsService.sendSMS(arr)
.subscribe(ressponse => {
console.log(ressponse, 'SMS Sent');
alert('SMS sent');
}, err => {
console.log(err, 'SMS not sent Error');
})
}
}
}, err => {
console.log(err, 'Error in fetching sms templates');
})
}



}, err => {
console.log(err, 'error while fetching sms types');
})

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h4>Referral Services</h4>
<div class=" height-120 border-1-g overflow-auto" for="subCategoryDetails">
<div *ngIf="showresult">
<span *ngFor="let detail of detailsList">
<md-checkbox color="primary" (change)="toggleSms($event)" class="m-l-10" name={{detail.institutionDetails.institutionID}}>
<md-checkbox color="primary" (change)="toggleSms($event,detail.institutionDetails.institutionID)" class="m-l-10" name={{detail.institutionDetails.institutionID}}>
</md-checkbox>
{{detail.institutionDetails?.institutionName}}
<span *ngIf="detail.institutionDetails?.address">, {{detail.institutionDetails?.address}}</span>
Expand Down
Empty file.
34 changes: 34 additions & 0 deletions src/app/common-sms-dialog/common-sms-dialog.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="successHeaderDiv">
<h4 class="popupHeader">Success</h4>
</div>
<div class="col-xs-12 col-sm-12">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h4>{{data.statement}}:{{data.generatedID}}</h4>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<md-checkbox color="primary" name="altNum" [(ngModel)]="altNum">
Alternate Number
</md-checkbox>
<div *ngIf="altNum">
<md-input-container myMobileNumber>
<input mdInput autocomplete="off" minlength="10" maxlength="10" (keyup)="mobileNum(mobileNumber)" placeholder="Mobile Number"
required name="mobileNumber" [(ngModel)]="mobileNumber" #phnNum="ngModel">
<md-hint *ngIf=" phnNum.errors && ( phnNum.touched)" class="errorText">
<span>
Enter 10 digit mobile number
</span>
</md-hint>
</md-input-container>
</div>
</div>

<div class="col-xs-12 col-sm-12">
<button md-raised-button color="primary" class="pull-right font-regular m-t-8" (click)="dialogReff.close('close')">Close</button>
<button md-raised-button color="accent" [disabled]="altNum && !validNumber" class="pull-right font-regular m-t-8 m-r-5"
(click)="dialogReff.close(mobileNumber)">Send SMS
</button>
</div>
</div>

</div>
25 changes: 25 additions & 0 deletions src/app/common-sms-dialog/common-sms-dialog.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CommonSmsDialogComponent } from './common-sms-dialog.component';

describe('CommonSmsDialogComponent', () => {
let component: CommonSmsDialogComponent;
let fixture: ComponentFixture<CommonSmsDialogComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CommonSmsDialogComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CommonSmsDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
33 changes: 33 additions & 0 deletions src/app/common-sms-dialog/common-sms-dialog.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Component, OnInit, Inject } from '@angular/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { MD_DIALOG_DATA } from '@angular/material';
import { dataService } from '../services/dataService/data.service';

@Component({
selector: 'app-common-sms-dialog',
templateUrl: './common-sms-dialog.component.html',
styleUrls: ['./common-sms-dialog.component.css']
})
export class CommonSmsDialogComponent implements OnInit {

altNum = false;
mobileNumber: any;
validNumber = false;

constructor( @Inject(MD_DIALOG_DATA) public data: any,
public dialog: MdDialog,
public dialogReff: MdDialogRef<CommonSmsDialogComponent>,
public getCommonData: dataService) { }

ngOnInit() {
}

mobileNum(value) {
if (value.length == 10) {
this.validNumber = true;
} else {
this.validNumber = false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SmsTemplateService {
getSMSparameters_url: any;

getFullSMSTemplate_url: any;

sendSMS_url: any;

constructor(
private _config: ConfigService,
Expand All @@ -33,13 +33,17 @@ export class SmsTemplateService {
this.getSMStypes_url = this.commonBaseURL + 'sms/getSMSTypes';
this.getSMSparameters_url = this.commonBaseURL + 'sms/getSMSParameters';
this.getFullSMSTemplate_url = this.commonBaseURL + 'sms/getFullSMSTemplate';
this.sendSMS_url = this.commonBaseURL + 'sms/sendSMS';


}

getSMStemplates(providerServiceMapID) {
getSMStemplates(providerServiceMapID, smsTypeID?) {
return this.httpIntercept.post(this.getSMStemplates_url,
{ 'providerServiceMapID': providerServiceMapID })
{
'providerServiceMapID': providerServiceMapID,
'smsTypeID': smsTypeID ? smsTypeID : undefined
})
.map(this.handleSuccess)
.catch(this.handleError);
}
Expand Down Expand Up @@ -81,6 +85,12 @@ export class SmsTemplateService {
.catch(this.handleError);
}

sendSMS(obj) {
return this.httpIntercept.post(this.sendSMS_url, obj)
.map(this.handleSuccess)
.catch(this.handleError);
}



handleSuccess(response: Response) {
Expand Down
7 changes: 5 additions & 2 deletions src/app/sms-template/sms-template.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ <h4 class="f-s-b m-t-20 m-b-20">Create SMS Template</h4>

</div>

<div class="row" *ngIf="viewTemplate">
<div class="row" [hidden]="!viewTemplate">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h4 class="f-s-b m-t-20 m-b-20">View SMS Template</h4>
</div>

<form #smsViewForm="ngForm" autocomplete="off">
<form #vf="ngForm" autocomplete="off">
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<md-input-container [style.width]="'100%'">
<input mdInput required placeholder="Template Name" ngModel name="templateName" readonly>
Expand Down Expand Up @@ -225,6 +225,9 @@ <h4 class="f-s-b m-t-20 m-b-20">View SMS Template</h4>
</tfoot>
</table>
</div>
<div class="col-xs-12 col-sm-12" *ngIf="viewSMSparameterTable.length===0">
<button md-raised-button color="primary" type="button" class="pull-right m-r-0" (click)="showTable()">Back</button>
</div>
</form>
</div>

6 changes: 3 additions & 3 deletions src/app/sms-template/sms-template.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export class SmsTemplateComponent implements OnInit {
smsParameterMaps = [];

@ViewChild('smsForm') Smsform1: NgForm;
@ViewChild('smsViewForm') smsViewForm: NgForm;
@ViewChild('vf') viewform: NgForm;


constructor(public commonData: dataService,
public sms_service: SmsTemplateService,
Expand Down Expand Up @@ -246,7 +246,7 @@ export class SmsTemplateComponent implements OnInit {
this.viewTemplate = true;
this.showTableFlag = false;

this.smsViewForm.form.patchValue({
this.viewform.form.patchValue({
'templateName': response.smsTemplateName,
'smsType': response.smsType.smsType,
'smsTemplate': response.smsTemplate
Expand Down
Loading

0 comments on commit 08ba79a

Please sign in to comment.