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 ResumeParsing 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.navigationhelper = Unibase.Platform.Helpers.NavigationHelper.Instance(); } cssFiles() { return []; } jsFiles() { return ["apps/communications/events/managers/gallerymanager.js", "apps/communications/ai/components/resumeparsingmanager.js"]; } load(id, containerid, callback) { let instance = this; $('.resumeParsingInput, #formImgInput').change(function (e) { return __awaiter(this, void 0, void 0, function* () { if (e.currentTarget.files.length === 0) { return; } Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); let file = yield Unibase.Platform.Helpers.FileHelper.Instance().getBase64(e); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); let whichType = []; if (instance.reqType == 1) { whichType = instance.resumeType; } else if (instance.reqType == 2) { whichType = instance.businessCardsType; } else if (instance.reqType == 3) { whichType = instance.salesInvoiceType; } $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(`File Name: ${file.FileName} `); const lowercaseWords = whichType.map(word => word.toLowerCase()); if (instance.checkIsValidFile(lowercaseWords, file.FileType.toLowerCase()) === false) { $('.resumeParsingButton').prop('disabled', true); let idGen = Math.random() * 999; idGen = `${idGen}_selectedFile`; $('.fileMessageDisplay').html(`Wrong File Selected`); $('#formAIInputId').val(''); $('#formImgInput').val(''); setTimeout(function () { $('.fileMessageDisplay').addClass('d-none'); $('.fileMessageDisplay').html(''); }, 3000); return; } $('.resumeParsingButton').prop('disabled', false); $('.resumeParsingButtonDelete').removeClass('d-none'); $(`.resumeDivImg`).removeClass('d-none'); if (instance.reqType === 2) { if (file.FileType == 'pdf') { $(`.resumeDivImg img`).attr('src', `/tenants/themes/compact/imgs/fileuploaded.png`); } else { let baseString = yield instance.compressImgInputHandler(e); $(`.resumeDivImg img`).attr('src', `data:image/png;base64, ${file.FileData}`); file.FileData = `${baseString}`; } } else { $(`.resumeDivImg img`).attr('src', `/tenants/themes/compact/imgs/fileuploaded.png`); } $('.labelInputWhite').removeClass('d-flex').addClass('d-none'); instance.fileValue = file; }); }); $('.resumeParsingButtonDelete').click(function (e) { $('.resumeParsingButtonDelete').addClass('d-none'); $('.labelInputWhite').addClass('d-flex').removeClass('d-none'); $(`.resumeDivImg`).addClass('d-none'); $('.fileMessageDisplay').html(''); $('.fileMessageDisplay').addClass('d-none'); $('#formAIInputId').val(''); $('#formImgInput').val(''); }); $('.resumeParsingButton').click(function (e) { return __awaiter(this, void 0, void 0, function* () { e.preventDefault(); Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); if (instance.fileValue === null) { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); return; } ; let file = instance.fileValue; let payload = { "FileData": file.FileData, "FileName": file.FileName, "FilePath": "test", "FileType": instance.fileValue.FileType }; let message = ''; $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(file.FileName); try { if (instance.reqType == 1) { message = yield instance.postResume(payload); } else if (instance.reqType == 2) { message = yield instance.postBusinessCard(payload); } } catch (err) { console.log(err); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); MessageHelper.Instance().showError(err === null || err === void 0 ? void 0 : err.message, "div_message"); return; } let res = JSON.parse(message.result); if (message.result === 'Invalid image') { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); MessageHelper.Instance().showError("Invalid image", "div_message"); return; } if (res.status == 0) { $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(`Upload Successs`); } else { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); MessageHelper.Instance().showError(res.message, "div_message"); return; } if (message.message == 'Email Already Exists, Mobile Number Already Exists' || message.message == 'Phone Number Already Exists, Email Already Exists') { Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); MessageHelper.Instance().showError(message.message, "div_message"); return; } if (message.code != '0') { $('.fileMessageDisplay').removeClass('d-none'); if ((message === null || message === void 0 ? void 0 : message.message) == '') { $('.fileMessageDisplay').html(`${message === null || message === void 0 ? void 0 : message.code}`); } else { $('.fileMessageDisplay').html(`${message === null || message === void 0 ? void 0 : message.message}`); } Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); setTimeout(function () { $('.fileMessageDisplay').addClass('d-none'); $('.fileMessageDisplay').html(''); }, 3000); return; } if (res === null) { $('.fileMessageDisplay').removeClass('d-none'); if ((message === null || message === void 0 ? void 0 : message.message) == '') { $('.fileMessageDisplay').html(`${message === null || message === void 0 ? void 0 : message.code}`); } else { $('.fileMessageDisplay').html(`${message === null || message === void 0 ? void 0 : message.message}`); } Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); setTimeout(function () { $('.fileMessageDisplay').addClass('d-none'); $('.fileMessageDisplay').html(''); }, 3000); return; } Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(''); $('#' + containerid).modal('hide'); $('#' + containerid).remove(); Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(Number(res.result), Unibase.Platform.Helpers.NavigationHelper.installedAppId, null); Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true; }); }); if (instance.reqType == 1) { let htmlstr = instance.appendTextValuesValid(instance.resumeType); let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true); let addHTMLMOBILE = ``; let str = addHTMLMOBILE; $('.onlyValuesDisplayAI').html(str); } else if (instance.reqType == 2) { let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true); let addHTMLMOBILE = ``; if (!isMoblie) { addHTMLMOBILE = ''; } let str = `
Drag & Drop files here
or
${addHTMLMOBILE}
`; $('.onlyValuesDisplayAI').html(str); } $('.labelInputWhite').on('dragenter', function (e) { e.stopPropagation(); e.preventDefault(); $('.labelInputWhite').addClass('dragEnterResume'); }); $('.labelInputWhite').on('dragleave', function (e) { e.stopPropagation(); e.preventDefault(); $('.labelInputWhite').removeClass('dragEnterResume'); }); $('.labelInputWhite').on('dragstop', function (e) { $('.labelInputWhite').removeClass('dragEnterResume'); }); $('.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(); $('.labelInputWhite').removeClass('dragEnterResume'); Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading(); let event = { target: { files: e.originalEvent.dataTransfer.files } }; let file = yield Unibase.Platform.Helpers.FileHelper.Instance().getBase64(event); let whichType = []; if (instance.reqType == 1) { whichType = instance.resumeType; } else if (instance.reqType == 2) { whichType = instance.businessCardsType; } else if (instance.reqType == 3) { whichType = instance.salesInvoiceType; } if (instance.checkIsValidFile(whichType, file.FileType) === false) { $('.resumeParsingButton').prop('disabled', true); let idGen = Math.random() * 999; idGen = `${idGen}_selectedFile`; $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(`Wrong File Selected`); $('#formAIInputId').val(''); $('#formImgInput').val(''); setTimeout(function () { $('.fileMessageDisplay').addClass('d-none'); $('.fileMessageDisplay').html(''); }, 5000); Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); return; } if (instance.reqType === 2) { $(`.resumeDivImg img`).attr('src', `data:image/png;base64, ${file.FileData}`); let baseString = yield instance.compressImgInputHandler(e); file.FileData = `${baseString}`; } else { $(`.resumeDivImg img`).attr('src', `/tenants/themes/compact/imgs/fileuploaded.png`); } $('.labelInputWhite').addClass('d-none').removeClass('d-flex'); $(`.resumeDivImg`).removeClass('d-none'); $('.resumeParsingButton').prop('disabled', false); $('.resumeParsingButtonDelete').removeClass('d-none'); $('.fileMessageDisplay').removeClass('d-none'); $('.fileMessageDisplay').html(`File Name: ${file.FileName} `); instance.fileValue = file; Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading(); }); }); } 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(); } postResume(payload) { return __awaiter(this, void 0, void 0, function* () { let instance = this; let res = yield Unibase.Apps.Collaboration.ResumeParsingManager.Instance().postResume(payload); return res; }); } postBusinessCard(payload) { return __awaiter(this, void 0, void 0, function* () { let res = yield Unibase.Apps.Collaboration.ResumeParsingManager.Instance().postbusinessCard(payload); return res; }); } 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]; } appendTextValuesValid(arr) { let values = ''; for (let i = 0; i < arr.length; i++) { if (i != arr.length - 1) { values = values + `${arr[i]},`; } else { values = values + arr[i]; } } let str = `Click To Browse ${values} to Upload`; return str; } getLabelHTML() { return ``; } 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) { } html(id, containerid) { let html = ` `; return html; } callResumeParsing(type = 1) { let instances = this; instances.reqType = type; instances.navigationHelper.popup(0, '', this, null, Unibase.Platform.Helpers.Size.Medium); } static Instance() { if (this.instance === undefined) { this.instance = new ResumeParsing(); } return this.instance; } } Components.ResumeParsing = ResumeParsing; })(Components = AI.Components || (AI.Components = {})); })(AI = Communications.AI || (Communications.AI = {})); })(Communications = Apps.Communications || (Apps.Communications = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));