auto cut cutome

This commit is contained in:
venbainfotech 2021-08-14 20:18:12 +05:30
parent e7a4f89a0f
commit 512697c99b
5 changed files with 13393 additions and 99 deletions

13294
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"staging":"ng build --configuration=staging",
"production":"ng build --prod"
"staging": "ng build --configuration=staging",
"production": "ng build --prod"
},
"private": true,
"dependencies": {
@ -36,9 +36,9 @@
"@angular/cli": "~8.3.20",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { DatePipe } from '@angular/common';
import * as watermark from 'watermarkjs';
// import * as watermark from 'watermarkjs';
@Injectable({
@ -17,81 +17,81 @@ pipe = new DatePipe('en-US')
})
},2000)
}
addWatermarks(base64Img,geoCords?) {
// addWatermarks(base64Img,geoCords?) {
return new Promise((resolve, reject) => {
// return new Promise((resolve, reject) => {
// this.constant.getGeoTag().then(geoCoordinates => {
// this.getPosition().then(geoCords=>{
// console.log(geoCords);
// this.geoCords = geoCoordinates
// });
// this.geoCords=localStorage.getItem('current_coordinates')
// console.log("corrds",this.geoCords)
let raw_img = base64Img
var today = new Date();
// let today_loc = today.toLocaleString('en-US', { timeZone: "Asia/Kolkata" })
let today_loc=this.pipe.transform(today, 'yyyy-MM-dd, h:mm a')
var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
// var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = 'Date : ' + today_loc;
// // this.constant.getGeoTag().then(geoCoordinates => {
// // this.getPosition().then(geoCords=>{
// // console.log(geoCords);
// // this.geoCords = geoCoordinates
// // });
// // this.geoCords=localStorage.getItem('current_coordinates')
// // console.log("corrds",this.geoCords)
// let raw_img = base64Img
// var today = new Date();
// // let today_loc = today.toLocaleString('en-US', { timeZone: "Asia/Kolkata" })
// let today_loc=this.pipe.transform(today, 'yyyy-MM-dd, h:mm a')
// var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
// // var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
// var dateTime = 'Date : ' + today_loc;
console.log(date)
// console.log(date)
// fetch(raw_img)
// .then(res => res.blob())
// .then(blob => {
watermark([raw_img, 'assets/images/PD_watermark.png'])
.image(watermark.image.upperRight())
.then(img => {
raw_img = img.src;
// // fetch(raw_img)
// // .then(res => res.blob())
// // .then(blob => {
// watermark([raw_img, 'assets/images/PD_watermark.png'])
// .image(watermark.image.upperRight())
// .then(img => {
// raw_img = img.src;
let text = watermark.text
watermark([raw_img])
.image(text.upperLeft(dateTime, '19px sans-serif', '#ff0000', 1.0))
// .image(text.upperLeft(dateTime, '20px sans-serif', '#ff0000', 1.0))
.then(img => {
raw_img = img.src;
console.log("2d", raw_img)
// resolve(img.src)
console.log(geoCords)
// let geoCoordinates = geoCords ? geoCords : '-'
if(geoCords) {
let Location = `Location : ` + geoCords
watermark([raw_img])
.image(text.upperLeft(Location, '19px sans-serif', '#ff0000', 1.0, 40 ))
.then(img => {
raw_img = img.src
console.log("3rd", raw_img)
resolve(img.src)
// localStorage.removeItem('current_coordinates')
});
}
else {
resolve(img.src)
}
});
});
// let text = watermark.text
// watermark([raw_img])
// .image(text.upperLeft(dateTime, '19px sans-serif', '#ff0000', 1.0))
// // .image(text.upperLeft(dateTime, '20px sans-serif', '#ff0000', 1.0))
// .then(img => {
// raw_img = img.src;
// console.log("2d", raw_img)
// // resolve(img.src)
// console.log(geoCords)
// // let geoCoordinates = geoCords ? geoCords : '-'
// if(geoCords) {
// let Location = `Location : ` + geoCords
// watermark([raw_img])
// .image(text.upperLeft(Location, '19px sans-serif', '#ff0000', 1.0, 40 ))
// .then(img => {
// raw_img = img.src
// console.log("3rd", raw_img)
// resolve(img.src)
// // localStorage.removeItem('current_coordinates')
// });
// }
// else {
// resolve(img.src)
// }
// });
// });
// },err=>{
// console.log("Error in geo",err);
// switch(err.code) {
// case 1:
// alert("Geolocation permission is denied. Please allow the permission to capture");
// break;
// case 2:
// alert("Do not get the geolocation of your place");
// break;
// case 2:
// alert("Something went wrong");
// break;
// }
// reject(err);
// })
})
// });
}
// // },err=>{
// // console.log("Error in geo",err);
// // switch(err.code) {
// // case 1:
// // alert("Geolocation permission is denied. Please allow the permission to capture");
// // break;
// // case 2:
// // alert("Do not get the geolocation of your place");
// // break;
// // case 2:
// // alert("Something went wrong");
// // break;
// // }
// // reject(err);
// // })
// })
// // });
// }
getPosition(): Promise<any>
{
return new Promise((resolve, reject) => {

View File

@ -28,7 +28,7 @@ export class TwilioService {
switch_camera_option: boolean = false;
shouldFaceUser:boolean = true;
mediaTracks:any;
user_data:any={};
user_data:any={};
constructor(
private http: HttpClient,
private router: Router,
@ -123,8 +123,8 @@ export class TwilioService {
this.previewing = true;
// }
this.roomParticipants = room.participants;
console.log(room.participants.size,room.participants)
this.roomParticipants = room.participants;
// if(room.participants.size) {
// if(room.participants.size >0 && room.participants.size <= 1) {
room.participants.forEach(participant => {
@ -132,13 +132,23 @@ export class TwilioService {
this.openSnackBar(participant.identity+' joined the call','')
this.msgSubject.next("Already in Room: '" + participant.identity + "'");
this.attachParticipantTracks(participant);
});
let withoutcustomer = this.getWithOutCustomer(this.roomParticipants)
console.log('getWithOutCustomer',withoutcustomer)
if(this.user_data.type == '2') {
console.log("User type in service",this.user_data)
let params = {"fk_pd_id":this.user_data.pd_id,"room_id":this.roomObj.sid,"is_call_ended":"0"}
console.log("connected api",params)
this.sendRoomandStatus(params).subscribe(rr=>{})
}
});
else if(this.user_data.type == '3' && withoutcustomer == '0'){
console.log("User type in service",this.user_data)
let params = {"fk_pd_id":this.user_data.pd_id,"room_id":this.roomObj.sid,"is_call_ended":"0"}
console.log("connected api",params)
this.sendRoomandStatus(params).subscribe(rr=>{})
}
// }
// else {
// this.openSnackBar("Call is already connected",'')
@ -187,6 +197,12 @@ export class TwilioService {
console.log("connected api",params)
this.sendRoomandStatus(params).subscribe(rr=>{})
}
// else if(this.user_data.type == '3' && withoutcustomer == '0'){
// console.log("User type in service",this.user_data)
// let params = {"fk_pd_id":this.user_data.pd_id,"room_id":this.roomObj.sid,"is_call_ended":"0"}
// console.log("connected api",params)
// this.sendRoomandStatus(params).subscribe(rr=>{})
// }
});
// When a Participant adds a Track, attach it to the DOM.
@ -237,7 +253,14 @@ export class TwilioService {
console.log("Participant Disconnected",participant,participant.sid);
this.openSnackBar(participant.identity+' left the call','')
this.msgSubject.next("Participant '" + participant.identity + "' left the call");
// this.disconnect();
// this.roomParticipants = room.participants;
let withoutcustomer = this.getWithOutCustomer(this.roomParticipants)
if(this.user_data.type == '1' && withoutcustomer == '0'){
this.disconnect();
this.msgSubject.next('')
}
// this.detachParticipantTracks(participant);
// $(`div#${participant.sid}`, participant).remove();
let parent = document.getElementById('peervideo')
@ -246,7 +269,7 @@ export class TwilioService {
console.log(parent,"new",this.remoteVideo.nativeElement,this.remoteVideo.nativeElement.children.length,"Room participants size",this.roomParticipants.size)
this.detachParticipantTracks(participant)
if(this.roomParticipants.size == 0) {
if(this.roomParticipants.size == 0 && this.user_data.type != 1) {
this.msgSubject.next("Waiting for participant...")
this.btnSubject.next({name:"peerVideoEnable",value:false})
}
@ -272,6 +295,17 @@ export class TwilioService {
})
}
getWithOutCustomer(participant){
let participantWOC: any = []
participant.forEach(element => {
if(element.identity != 'CUSTOMER'){
participantWOC.push(element)
}
});
return participantWOC.length
}
detachParticipantTracks(participant) {
for (let track of participant.tracks) {
Array.from(this.remoteVideo.nativeElement.children).forEach((child:any) => {
@ -494,6 +528,8 @@ getTracks(participant) {
// }});}
disconnect(){
let withoutcustomer = this.getWithOutCustomer(this.roomParticipants)
console.log('roomObj',this.roomObj,this.user_data.type, withoutcustomer)
if (this.roomObj && this.roomObj !== null) {
console.log("User type in service",this.user_data,this.remoteVideo)
if(this.user_data.type == '2' && this.remoteVideo.nativeElement.firstChild != null) {
@ -501,6 +537,12 @@ disconnect(){
console.log("disconnected api",params)
this.sendRoomandStatus(params).subscribe(rr=>{})
}
else if(this.user_data.type == '3' && withoutcustomer == '0'){
console.log("User type in service",this.user_data)
let params = {"fk_pd_id":this.user_data.pd_id,"room_id":this.roomObj.sid,"is_call_ended":"1"}
console.log("disconnected api",params)
this.sendRoomandStatus(params).subscribe(rr=>{})
}
this.roomObj.disconnect();
this.roomObj = null;
} else {