var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Communications; (function (Communications) { let AI; (function (AI) { let Components; (function (Components) { class BusinessCards extends Unibase.Platform.Core.BaseComponent { constructor() { super(); this.inputParameters = []; this.reportIdGallery = null; this.fileValue = null; this.reqType = 1; this.resumeType = ['pdf', 'doc', 'docx']; this.businessCardsType = ['png', 'jpg', 'jpeg', 'JPEG', 'pdf']; this.salesInvoiceType = ['pdf']; this.currFile = ''; this.moreFiles = []; this.lastLength = 0; this.contid = ''; this.navigationhelper = Unibase.Platform.Helpers.NavigationHelper.Instance(); } cssFiles() { return []; } jsFiles() { return ["apps/communications/events/managers/gallerymanager.js", "apps/communications/ai/components/resumeparsingmanager.js"]; } getMulupleBase64(event) { return __awaiter(this, void 0, void 0, function* () { let file = event.target.files; const promisesArr = []; for (let i = 0; i < file.length; i++) { const currFile = file[i]; const currp = new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(currFile); reader.onloadend = function () { var base64String = reader.result.toString().replace(/^data:.+;base64,/, ''); var fileReq = { FileData: base64String, FileName: currFile.name.split('.').slice(0, -1).join('.'), FileType: currFile.name.split('.').pop(), FilePath: '' }; resolve(fileReq); }; reader.onerror = function (e) { reject(e); }; }); promisesArr.push(currp); } const ans = yield Promise.all(promisesArr); return ans; }); } getCompressFiles(e) { return __awaiter(this, void 0, void 0, function* () { let instance = this; const compressArr = []; for (let i = 0; i < e.target.files.length; i++) { const currFile = e.target.files[i]; console.log(currFile); let baseString = yield instance.compressImgInputMoreHandler(currFile); compressArr.push(baseString); } let cardsBox = ''; return compressArr; }); } generateCardsHTML() { let instance = this; let cards = instance.moreFiles; if ($('.childContainerBusinessCard').length === 0) { $('.containerBusinessCards').append('
'); } let cardsHTML = ''; for (let i = instance.lastLength; i < cards.length; i++) { const currItem = cards[i]; cardsHTML += instance.cardbox(`data:image/png;base64, ${currItem.FileData}`, currItem.FileName, currItem.FileType); } $('.addMoreFiles').remove(); cardsHTML += instance.addMoreFileHTML(); $('.childContainerBusinessCard').append(cardsHTML); $('.deleteBcard').each(function (i, evt) { $(evt).off().click(function (el) { const elId = $(el.target).parents('.businessCardbox').data('id'); const newFilterArr = instance.moreFiles.filter((e) => { return e.FileName != elId; }); instance.moreFiles = newFilterArr; $(el.target).parents('.businessCardbox').remove(); if ($('.deleteBcard').length === 0) { $('.containerBusinessCards').html(''); $('.containerBusinessCards').append($(instance.getChildHTML())); instance.moreFiles = []; instance.loadEvents(instance); } }); }); instance.loadEvents(instance); } load(id, containerid, callback) { let instance = this; instance.contid = containerid; instance.loadEvents(instance); let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true); let addHTMLMOBILE = `
`; if (!isMoblie) { addHTMLMOBILE = ''; } $('.onlyValuesDisplayAI').append(addHTMLMOBILE); } checkAllValidition(uploadedFiles) { let files = uploadedFiles; for (let i = 0; i < files.length; i++) { const currFile = files[i]; if (this.checkIsValidFile(this.businessCardsType, currFile.FileType) === false) { return true; } } return false; } addMoreFileHTML() { let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true); let html = ``; if (isMoblie) { return `
`; } else { return `
`; } } getErrorHTML(message) { return `
${message}
`; } setErrorRes(mess) { $('.errorDivPlaceHere').removeClass('d-none'); let errorHTML = this.getErrorHTML(mess); $('.errorDivPlaceHere').html(errorHTML); document.querySelector('.errorDivPlaceHere').scrollIntoView(); } loadEvents(instance) { $('#businesscardInput, #addMoreFilesAfter,#formImgInputMobile,#formImgInput,#formAIInputId').off().change(function (e) { return __awaiter(this, void 0, void 0, function* () { debugger; if (e.currentTarget.files.length === 0) { return; } Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); const uploadedFiles = yield instance.getMulupleBase64(e); if (instance.checkAllValidition(uploadedFiles)) { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); $('.errorDivPlaceHere').removeClass('d-none'); let errorHTML = instance.getErrorHTML('File Not Supported'); $('.errorDivPlaceHere').html(errorHTML); console.log(instance.moreFiles); return; } instance.lastLength = instance.moreFiles.length - 1 === -1 ? 0 : instance.moreFiles.length; instance.moreFiles = [...instance.moreFiles, ...uploadedFiles]; const compressFiles = yield instance.getCompressFiles(e); let j = 0; for (let i = instance.lastLength; i < instance.moreFiles.length; i++) { instance.moreFiles[i]['FileData'] = compressFiles[j++]; } Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); if ($('.childContainerBusinessCard').length === 0) { $('.containerBusinessCards').html(''); } instance.generateCardsHTML(); $('#businesscardInput').val(''); $('#formAIInputId').val(''); $('#formImgInput').val(''); $('#formImgInputMobile').val(''); $('#addMoreFilesAfter').val(''); }); }); $('.resumeParsingButtonDelete').off().click(function (e) { }); $('.resumeParsingButton').off().click(function (e) { return __awaiter(this, void 0, void 0, function* () { debugger; let res = null; console.log(instance.moreFiles); try { Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); res = yield instance.postBusinessCard(instance.moreFiles); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); instance.moreFiles = []; } catch (err) { console.log(err); $('.errorDivPlaceHere').removeClass('d-none'); const responseText = JSON.parse(err.responseText); instance.setErrorRes(responseText.title); return; } if (res === null) { instance.setErrorRes('Something Went wrong'); return; } if (res.code != '0') { instance.setErrorRes(res.message); return; } if (res.message == 'Email Already Exists, Mobile Number Already Exists' || res.message == 'Phone Number Already Exists, Email Already Exists') { instance.setErrorRes(res.message); return; } if (res.result === 'Invalid image') { instance.setErrorRes('Invalid image'); return; } $('#' + instance.contid).modal('hide'); $('#' + instance.contid).remove(); Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(Unibase.Platform.Helpers.NavigationHelper.installedAppId, null); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; }); }); $('.labelInputWhite').off(); $('.labelInputWhite').on('dragstart', function (e) { debugger; $('.onlyValuesDisplayAI').addClass('.clickEventDisabled'); }); $('.labelInputWhite').on('dragenter', function (e) { e.stopPropagation(); e.preventDefault(); debugger; $('.labelInputWhite').addClass('dragEnterResume'); $('.onlyValuesDisplayAI').addClass('clickEventDisabled'); }); $('.labelInputWhite').on('dragleave', function (e) { e.stopPropagation(); e.preventDefault(); $('.labelInputWhite').removeClass('dragEnterResume'); }); $('.labelInputWhite').on('dragstop', function (e) { $('.labelInputWhite').removeClass('dragEnterResume'); $('.onlyValuesDisplayAI').removeClass('.clickEventDisabled'); }); $('.labelInputWhite').on('dragover', function (e) { e.stopPropagation(); e.preventDefault(); }); $('.labelInputWhite').on('drop', function (e) { return __awaiter(this, void 0, void 0, function* () { e.stopPropagation(); e.preventDefault(); try { $('.labelInputWhite').removeClass('dragEnterResume'); debugger; Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); let event = { target: { files: e.originalEvent.dataTransfer.files } }; const uploadedFiles = yield instance.getMulupleBase64(event); if (instance.checkAllValidition(uploadedFiles)) { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); $('.errorDivPlaceHere').removeClass('d-none'); let errorHTML = instance.getErrorHTML('File Not Supported'); $('.errorDivPlaceHere').html(errorHTML); console.log(instance.moreFiles); return; } instance.lastLength = instance.moreFiles.length - 1 === -1 ? 0 : instance.moreFiles.length; instance.moreFiles = [...instance.moreFiles, ...uploadedFiles]; const compressFiles = yield instance.getCompressFiles(event); let j = 0; for (let i = instance.lastLength; i < instance.moreFiles.length; i++) { instance.moreFiles[i]['FileData'] = compressFiles[j++]; } Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); if ($('.childContainerBusinessCard').length === 0) { $('.containerBusinessCards').html(''); } instance.generateCardsHTML(); } catch (err) { console.log(err); } }); }); $('.bsClose').off().click(function () { instance.moreFiles = []; Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp(); }); } cardbox(img, filename, filetype) { if (filetype === 'pdf') { img = '/tenants/themes/compact/imgs/pdfimgdoc.png'; } return `
${filename}
${filename}
`; } createLead() { let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_stagename").Value != "Lead") { $(detailContainer).find('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').click(function () { if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_stagename").Value != "Lead") { var postData = { CONTACTPERSONNAME: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_contactpersonname").Value, Designation: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_designation").Value, PhoneNumber: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_phonenumber").Value), Email: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_email").Value, ADDRESS: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_address").Value, PinCode1: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pincode1").Value), country_code: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_countrycode").Value, LandMark1: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_landmark1").Value, state_name: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_statename").Value, state_code: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_statecode").Value, CityName1: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_cityname1").Value, Urls: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_urls").Value, OrganizationName: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationname").Value, OrganizationNumber: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationnumber").Value), OrganizationEmail: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationemail").Value }; var installedappid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_installedappid").Value; Unibase.Apps.Collaboration.ResumeParsingManager.Instance().createLead(postData).then(function (res) { if (res.message == "Lead Saved Successfully") { Unibase.Platform.Apps.Managers.StageManager.Instance().getStageByStageName(installedappid, "Lead").then(function (response) { Unibase.Themes.Compact.Components.Details.Instance().change(response.result.StageId, installedappid); $('.li_DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').hide(); }); MessageHelper.Instance().showSuccess(res.message, "Unibase_ValidationSummary"); } else $('.li_DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').show(); MessageHelper.Instance().showSuccess(res.message, "Unibase_ValidationSummary"); }); } else $("#div_App_DefaultWidgetSettings").hide(); }); } else $("#div_App_DefaultWidgetSettings").hide(); } postBusinessCard(payload) { return __awaiter(this, void 0, void 0, function* () { let res = yield Unibase.Apps.Collaboration.ResumeParsingManager.Instance().postbusinessCard(payload); return res; }); } compressImgInputMoreHandler(doc) { let instance = this; let imageFormat = 'jpeg'; return new Promise((reslove, reject) => { const MAX_WIDTH = 1000; const MAX_HEIGHT = 1000; const MIME_TYPE = 'image/' + imageFormat; const QUALITY = 1; const file = doc; const blobURL = URL.createObjectURL(file); const img = new Image(); img.src = blobURL; img.onerror = function () { reject("Cannot load image"); URL.revokeObjectURL(this.src); console.log("Cannot load image"); }; img.onload = function () { const [newWidth, newHeight] = instance.calculateSize(img, MAX_WIDTH, MAX_HEIGHT); const canvas = document.createElement("canvas"); canvas.width = newWidth; canvas.height = newHeight; const ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0, newWidth, newHeight); canvas.toBlob((blob) => { const formData = new FormData(); formData.append('file', blob); for (let [name, value] of formData) { if (name === 'file') { let reader = new FileReader(); reader.onloadend = function () { let base64String = `${reader.result}`.replace(/^data:.+;base64,/, ""); reslove(base64String); }; reader.readAsDataURL(blob); } } }, MIME_TYPE, QUALITY); }; }); } compressImgInputHandler(ev) { let instance = this; let imageFormat = 'jpeg'; return new Promise((reslove, reject) => { const MAX_WIDTH = 1000; const MAX_HEIGHT = 1000; const MIME_TYPE = 'image/' + imageFormat; const QUALITY = 1; const file = ev.target.files[0]; const blobURL = URL.createObjectURL(file); const img = new Image(); img.src = blobURL; img.onerror = function () { reject("Cannot load image"); URL.revokeObjectURL(this.src); console.log("Cannot load image"); }; img.onload = function () { const [newWidth, newHeight] = instance.calculateSize(img, MAX_WIDTH, MAX_HEIGHT); const canvas = document.createElement("canvas"); canvas.width = newWidth; canvas.height = newHeight; const ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0, newWidth, newHeight); canvas.toBlob((blob) => { const formData = new FormData(); formData.append('file', blob); for (let [name, value] of formData) { if (name === 'file') { let reader = new FileReader(); reader.onloadend = function () { let base64String = `${reader.result}`.replace(/^data:.+;base64,/, ""); reslove(base64String); }; reader.readAsDataURL(blob); } } }, MIME_TYPE, QUALITY); }; }); } calculateSize(img, maxWidth, maxHeight) { let width = img.width; let height = img.height; if (width > height) { if (width > maxWidth) { height = Math.round((height * maxWidth) / width); width = maxWidth; } } else { if (height > maxHeight) { width = Math.round((width * maxHeight) / height); height = maxHeight; } } return [width, height]; } checkIsValidFile(values, type) { const twoLower = type.toLowerCase(); for (let i = 0; i < values.length; i++) { if (twoLower == values[i]) { return true; } } return false; } init(containerid) { } getChildHTML() { return `
Click To Browse PDF, PNG, JPEJ, JPG to Upload
`; } html(id, containerid) { let html = ` `; return html; } callBusinessCards() { let instances = this; instances.navigationHelper.popup(0, '', this, null, Unibase.Platform.Helpers.Size.Medium); } static Instance() { if (this.instance === undefined) { this.instance = new BusinessCards(); } return this.instance; } } Components.BusinessCards = BusinessCards; })(Components = AI.Components || (AI.Components = {})); })(AI = Communications.AI || (Communications.AI = {})); })(Communications = Apps.Communications || (Apps.Communications = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));