Built files from Bizgaze WebServer
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

businesscards.js 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Bizgaze;
  11. (function (Bizgaze) {
  12. let Apps;
  13. (function (Apps) {
  14. let Communications;
  15. (function (Communications) {
  16. let AI;
  17. (function (AI) {
  18. let Components;
  19. (function (Components) {
  20. class BusinessCards extends Unibase.Platform.Core.BaseComponent {
  21. constructor() {
  22. super();
  23. this.inputParameters = [];
  24. this.reportIdGallery = null;
  25. this.fileValue = null;
  26. this.reqType = 1;
  27. this.resumeType = ['pdf', 'doc', 'docx'];
  28. this.businessCardsType = ['png', 'jpg', 'jpeg', 'JPEG', 'pdf'];
  29. this.salesInvoiceType = ['pdf'];
  30. this.currFile = '';
  31. this.moreFiles = [];
  32. this.lastLength = 0;
  33. this.contid = '';
  34. this.navigationhelper = Unibase.Platform.Helpers.NavigationHelper.Instance();
  35. }
  36. cssFiles() {
  37. return [];
  38. }
  39. jsFiles() {
  40. return ["apps/communications/events/managers/gallerymanager.js", "apps/communications/ai/components/resumeparsingmanager.js"];
  41. }
  42. getMulupleBase64(event) {
  43. return __awaiter(this, void 0, void 0, function* () {
  44. let file = event.target.files;
  45. const promisesArr = [];
  46. for (let i = 0; i < file.length; i++) {
  47. const currFile = file[i];
  48. const currp = new Promise((resolve, reject) => {
  49. const reader = new FileReader();
  50. reader.readAsDataURL(currFile);
  51. reader.onloadend = function () {
  52. var base64String = reader.result.toString().replace(/^data:.+;base64,/, '');
  53. var fileReq = {
  54. FileData: base64String,
  55. FileName: currFile.name.split('.').slice(0, -1).join('.'),
  56. FileType: currFile.name.split('.').pop(),
  57. FilePath: ''
  58. };
  59. resolve(fileReq);
  60. };
  61. reader.onerror = function (e) {
  62. reject(e);
  63. };
  64. });
  65. promisesArr.push(currp);
  66. }
  67. const ans = yield Promise.all(promisesArr);
  68. return ans;
  69. });
  70. }
  71. getCompressFiles(e) {
  72. return __awaiter(this, void 0, void 0, function* () {
  73. let instance = this;
  74. const compressArr = [];
  75. for (let i = 0; i < e.target.files.length; i++) {
  76. const currFile = e.target.files[i];
  77. console.log(currFile);
  78. let baseString = yield instance.compressImgInputMoreHandler(currFile);
  79. compressArr.push(baseString);
  80. }
  81. let cardsBox = '';
  82. return compressArr;
  83. });
  84. }
  85. generateCardsHTML() {
  86. let instance = this;
  87. let cards = instance.moreFiles;
  88. if ($('.childContainerBusinessCard').length === 0) {
  89. $('.containerBusinessCards').append('<div style="gap:20px; display:grid; align-items: start; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-content: flex-start;" class="childContainerBusinessCard w-100 h-100 py-4"></div>');
  90. }
  91. let cardsHTML = '';
  92. for (let i = instance.lastLength; i < cards.length; i++) {
  93. const currItem = cards[i];
  94. cardsHTML += instance.cardbox(`data:image/png;base64, ${currItem.FileData}`, currItem.FileName, currItem.FileType);
  95. }
  96. $('.addMoreFiles').remove();
  97. cardsHTML += instance.addMoreFileHTML();
  98. $('.childContainerBusinessCard').append(cardsHTML);
  99. $('.deleteBcard').each(function (i, evt) {
  100. $(evt).off().click(function (el) {
  101. const elId = $(el.target).parents('.businessCardbox').data('id');
  102. const newFilterArr = instance.moreFiles.filter((e) => {
  103. return e.FileName != elId;
  104. });
  105. instance.moreFiles = newFilterArr;
  106. $(el.target).parents('.businessCardbox').remove();
  107. if ($('.deleteBcard').length === 0) {
  108. $('.containerBusinessCards').html('');
  109. $('.containerBusinessCards').append($(instance.getChildHTML()));
  110. instance.moreFiles = [];
  111. instance.loadEvents(instance);
  112. }
  113. });
  114. });
  115. instance.loadEvents(instance);
  116. }
  117. load(id, containerid, callback) {
  118. let instance = this;
  119. instance.contid = containerid;
  120. instance.loadEvents(instance);
  121. let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true);
  122. let addHTMLMOBILE = `<div class="text-center"><label for="formImgInput"><button class="w-150p btn btn-primary btn-sm clickEventDisabled">Browse Images</button></label></div>`;
  123. if (!isMoblie) {
  124. addHTMLMOBILE = '';
  125. }
  126. $('.onlyValuesDisplayAI').append(addHTMLMOBILE);
  127. }
  128. checkAllValidition(uploadedFiles) {
  129. let files = uploadedFiles;
  130. for (let i = 0; i < files.length; i++) {
  131. const currFile = files[i];
  132. if (this.checkIsValidFile(this.businessCardsType, currFile.FileType) === false) {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. addMoreFileHTML() {
  139. let isMoblie = !(Unibase.Themes.Compact.Components.Index.Instance().desktopMode == true);
  140. let html = ``;
  141. if (isMoblie) {
  142. return `
  143. <div data-name="addmore" class="addMoreFiles d-flex justify-content-end align-items-center border p-4 overflow-hide position-relative" style="min-height:100%;max-height:max-content;">
  144. <div class="w-sm-100p h-100p p-2 text-center d-flex justify-content-end align-items-center flex-column" >
  145. <input multiple id="addMoreFilesAfter" type="file" class="d-none" />
  146. <label for="addMoreFilesAfter" class="d-flex flex-center flex-column w-100p btn btn-primary">
  147. Files
  148. </label>
  149. <input id="formImgInputMobile" multiple class="m-0 d-none" accept="image/*" type="file">
  150. <label for="formImgInputMobile" class="btn bg-primary w-100p text-white">Images</label>
  151. </div>
  152. </div>
  153. `;
  154. }
  155. else {
  156. return `
  157. <div data-name="addmore" class="addMoreFiles border p-4 overflow-hide position-relative d-flex justify-content-center align-items-center" style="min-height:100%;max-height:max-content;">
  158. <div class="w-sm-100p h-100p p-2 text-center" >
  159. <input multiple id="addMoreFilesAfter" type="file" class="d-none" />
  160. <label for="addMoreFilesAfter" class="d-flex flex-center flex-column">
  161. <span class="font-50 cursor-pointer"> <i class="fa fa-paperclip"> </i></span >
  162. <span>Add more </span>
  163. </label>
  164. </div>
  165. </div>
  166. `;
  167. }
  168. }
  169. getErrorHTML(message) {
  170. return `<div class="errorDiv py-10 d-flex justify-content-center align-items-center" style="
  171. background: #ff000024;
  172. "><span class="fa fa-info-circle pr-1 pt-1 text-danger"></span><span> ${message} </span></div>`;
  173. }
  174. setErrorRes(mess) {
  175. $('.errorDivPlaceHere').removeClass('d-none');
  176. let errorHTML = this.getErrorHTML(mess);
  177. $('.errorDivPlaceHere').html(errorHTML);
  178. document.querySelector('.errorDivPlaceHere').scrollIntoView();
  179. }
  180. loadEvents(instance) {
  181. $('#businesscardInput, #addMoreFilesAfter,#formImgInputMobile,#formImgInput,#formAIInputId').off().change(function (e) {
  182. return __awaiter(this, void 0, void 0, function* () {
  183. debugger;
  184. if (e.currentTarget.files.length === 0) {
  185. return;
  186. }
  187. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  188. const uploadedFiles = yield instance.getMulupleBase64(e);
  189. if (instance.checkAllValidition(uploadedFiles)) {
  190. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  191. $('.errorDivPlaceHere').removeClass('d-none');
  192. let errorHTML = instance.getErrorHTML('File Not Supported');
  193. $('.errorDivPlaceHere').html(errorHTML);
  194. console.log(instance.moreFiles);
  195. return;
  196. }
  197. instance.lastLength = instance.moreFiles.length - 1 === -1 ? 0 : instance.moreFiles.length;
  198. instance.moreFiles = [...instance.moreFiles, ...uploadedFiles];
  199. const compressFiles = yield instance.getCompressFiles(e);
  200. let j = 0;
  201. for (let i = instance.lastLength; i < instance.moreFiles.length; i++) {
  202. instance.moreFiles[i]['FileData'] = compressFiles[j++];
  203. }
  204. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  205. if ($('.childContainerBusinessCard').length === 0) {
  206. $('.containerBusinessCards').html('');
  207. }
  208. instance.generateCardsHTML();
  209. $('#businesscardInput').val('');
  210. $('#formAIInputId').val('');
  211. $('#formImgInput').val('');
  212. $('#formImgInputMobile').val('');
  213. $('#addMoreFilesAfter').val('');
  214. });
  215. });
  216. $('.resumeParsingButtonDelete').off().click(function (e) {
  217. });
  218. $('.resumeParsingButton').off().click(function (e) {
  219. return __awaiter(this, void 0, void 0, function* () {
  220. debugger;
  221. let res = null;
  222. console.log(instance.moreFiles);
  223. try {
  224. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  225. res = yield instance.postBusinessCard(instance.moreFiles);
  226. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  227. instance.moreFiles = [];
  228. }
  229. catch (err) {
  230. console.log(err);
  231. $('.errorDivPlaceHere').removeClass('d-none');
  232. const responseText = JSON.parse(err.responseText);
  233. instance.setErrorRes(responseText.title);
  234. return;
  235. }
  236. if (res === null) {
  237. instance.setErrorRes('Something Went wrong');
  238. return;
  239. }
  240. if (res.code != '0') {
  241. instance.setErrorRes(res.message);
  242. return;
  243. }
  244. if (res.message == 'Email Already Exists, Mobile Number Already Exists' || res.message == 'Phone Number Already Exists, Email Already Exists') {
  245. instance.setErrorRes(res.message);
  246. return;
  247. }
  248. if (res.result === 'Invalid image') {
  249. instance.setErrorRes('Invalid image');
  250. return;
  251. }
  252. $('#' + instance.contid).modal('hide');
  253. $('#' + instance.contid).remove();
  254. Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(Unibase.Platform.Helpers.NavigationHelper.installedAppId, null);
  255. Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true;
  256. });
  257. });
  258. $('.labelInputWhite').off();
  259. $('.labelInputWhite').on('dragstart', function (e) {
  260. debugger;
  261. $('.onlyValuesDisplayAI').addClass('.clickEventDisabled');
  262. });
  263. $('.labelInputWhite').on('dragenter', function (e) {
  264. e.stopPropagation();
  265. e.preventDefault();
  266. debugger;
  267. $('.labelInputWhite').addClass('dragEnterResume');
  268. $('.onlyValuesDisplayAI').addClass('clickEventDisabled');
  269. });
  270. $('.labelInputWhite').on('dragleave', function (e) {
  271. e.stopPropagation();
  272. e.preventDefault();
  273. $('.labelInputWhite').removeClass('dragEnterResume');
  274. });
  275. $('.labelInputWhite').on('dragstop', function (e) {
  276. $('.labelInputWhite').removeClass('dragEnterResume');
  277. $('.onlyValuesDisplayAI').removeClass('.clickEventDisabled');
  278. });
  279. $('.labelInputWhite').on('dragover', function (e) {
  280. e.stopPropagation();
  281. e.preventDefault();
  282. });
  283. $('.labelInputWhite').on('drop', function (e) {
  284. return __awaiter(this, void 0, void 0, function* () {
  285. e.stopPropagation();
  286. e.preventDefault();
  287. try {
  288. $('.labelInputWhite').removeClass('dragEnterResume');
  289. debugger;
  290. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  291. let event = {
  292. target: {
  293. files: e.originalEvent.dataTransfer.files
  294. }
  295. };
  296. const uploadedFiles = yield instance.getMulupleBase64(event);
  297. if (instance.checkAllValidition(uploadedFiles)) {
  298. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  299. $('.errorDivPlaceHere').removeClass('d-none');
  300. let errorHTML = instance.getErrorHTML('File Not Supported');
  301. $('.errorDivPlaceHere').html(errorHTML);
  302. console.log(instance.moreFiles);
  303. return;
  304. }
  305. instance.lastLength = instance.moreFiles.length - 1 === -1 ? 0 : instance.moreFiles.length;
  306. instance.moreFiles = [...instance.moreFiles, ...uploadedFiles];
  307. const compressFiles = yield instance.getCompressFiles(event);
  308. let j = 0;
  309. for (let i = instance.lastLength; i < instance.moreFiles.length; i++) {
  310. instance.moreFiles[i]['FileData'] = compressFiles[j++];
  311. }
  312. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  313. if ($('.childContainerBusinessCard').length === 0) {
  314. $('.containerBusinessCards').html('');
  315. }
  316. instance.generateCardsHTML();
  317. }
  318. catch (err) {
  319. console.log(err);
  320. }
  321. });
  322. });
  323. $('.bsClose').off().click(function () {
  324. instance.moreFiles = [];
  325. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  326. });
  327. }
  328. cardbox(img, filename, filetype) {
  329. if (filetype === 'pdf') {
  330. img = '/tenants/themes/compact/imgs/pdfimgdoc.png';
  331. }
  332. return `
  333. <div data-id="${filename}" data-name="${filename}_bcards" class="businessCardbox border h-100 p-4 overflow-hide position-relative" style="height:min-content;">
  334. <div class="position-absolute" style="top:10px;right:10px;"><span class="w-30p bg-white cursor-pointer deleteBcard"><i style="pointer-events:none;" class="fa fa-trash-o text-danger font-18"></i> </span> </div>
  335. <div class="w-sm-100p w-md-100 h-100p p-2" >
  336. <img class="w-100 h-100" src="${img}" alt="${filename}"/>
  337. </div>
  338. <div class="word-break text-center">
  339. ${filename}
  340. </div>
  341. </div>
  342. `;
  343. }
  344. createLead() {
  345. let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  346. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_stagename").Value != "Lead") {
  347. $(detailContainer).find('.DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').click(function () {
  348. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_stagename").Value != "Lead") {
  349. var postData = {
  350. CONTACTPERSONNAME: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_contactpersonname").Value,
  351. Designation: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_designation").Value,
  352. PhoneNumber: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_phonenumber").Value),
  353. Email: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_email").Value,
  354. ADDRESS: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_address").Value,
  355. PinCode1: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_pincode1").Value),
  356. country_code: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_countrycode").Value,
  357. LandMark1: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_landmark1").Value,
  358. state_name: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_statename").Value,
  359. state_code: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_statecode").Value,
  360. CityName1: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_cityname1").Value,
  361. Urls: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_urls").Value,
  362. OrganizationName: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationname").Value,
  363. OrganizationNumber: Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationnumber").Value),
  364. OrganizationEmail: Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationemail").Value
  365. };
  366. var installedappid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_installedappid").Value;
  367. Unibase.Apps.Collaboration.ResumeParsingManager.Instance().createLead(postData).then(function (res) {
  368. if (res.message == "Lead Saved Successfully") {
  369. Unibase.Platform.Apps.Managers.StageManager.Instance().getStageByStageName(installedappid, "Lead").then(function (response) {
  370. Unibase.Themes.Compact.Components.Details.Instance().change(response.result.StageId, installedappid);
  371. $('.li_DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').hide();
  372. });
  373. MessageHelper.Instance().showSuccess(res.message, "Unibase_ValidationSummary");
  374. }
  375. else
  376. $('.li_DetailSetting_' + Unibase.Themes.Providers.DetailHelper.installedAppId + '_ConvertToLead').show();
  377. MessageHelper.Instance().showSuccess(res.message, "Unibase_ValidationSummary");
  378. });
  379. }
  380. else
  381. $("#div_App_DefaultWidgetSettings").hide();
  382. });
  383. }
  384. else
  385. $("#div_App_DefaultWidgetSettings").hide();
  386. }
  387. postBusinessCard(payload) {
  388. return __awaiter(this, void 0, void 0, function* () {
  389. let res = yield Unibase.Apps.Collaboration.ResumeParsingManager.Instance().postbusinessCard(payload);
  390. return res;
  391. });
  392. }
  393. compressImgInputMoreHandler(doc) {
  394. let instance = this;
  395. let imageFormat = 'jpeg';
  396. return new Promise((reslove, reject) => {
  397. const MAX_WIDTH = 1000;
  398. const MAX_HEIGHT = 1000;
  399. const MIME_TYPE = 'image/' + imageFormat;
  400. const QUALITY = 1;
  401. const file = doc;
  402. const blobURL = URL.createObjectURL(file);
  403. const img = new Image();
  404. img.src = blobURL;
  405. img.onerror = function () {
  406. reject("Cannot load image");
  407. URL.revokeObjectURL(this.src);
  408. console.log("Cannot load image");
  409. };
  410. img.onload = function () {
  411. const [newWidth, newHeight] = instance.calculateSize(img, MAX_WIDTH, MAX_HEIGHT);
  412. const canvas = document.createElement("canvas");
  413. canvas.width = newWidth;
  414. canvas.height = newHeight;
  415. const ctx = canvas.getContext("2d");
  416. ctx.drawImage(img, 0, 0, newWidth, newHeight);
  417. canvas.toBlob((blob) => {
  418. const formData = new FormData();
  419. formData.append('file', blob);
  420. for (let [name, value] of formData) {
  421. if (name === 'file') {
  422. let reader = new FileReader();
  423. reader.onloadend = function () {
  424. let base64String = `${reader.result}`.replace(/^data:.+;base64,/, "");
  425. reslove(base64String);
  426. };
  427. reader.readAsDataURL(blob);
  428. }
  429. }
  430. }, MIME_TYPE, QUALITY);
  431. };
  432. });
  433. }
  434. compressImgInputHandler(ev) {
  435. let instance = this;
  436. let imageFormat = 'jpeg';
  437. return new Promise((reslove, reject) => {
  438. const MAX_WIDTH = 1000;
  439. const MAX_HEIGHT = 1000;
  440. const MIME_TYPE = 'image/' + imageFormat;
  441. const QUALITY = 1;
  442. const file = ev.target.files[0];
  443. const blobURL = URL.createObjectURL(file);
  444. const img = new Image();
  445. img.src = blobURL;
  446. img.onerror = function () {
  447. reject("Cannot load image");
  448. URL.revokeObjectURL(this.src);
  449. console.log("Cannot load image");
  450. };
  451. img.onload = function () {
  452. const [newWidth, newHeight] = instance.calculateSize(img, MAX_WIDTH, MAX_HEIGHT);
  453. const canvas = document.createElement("canvas");
  454. canvas.width = newWidth;
  455. canvas.height = newHeight;
  456. const ctx = canvas.getContext("2d");
  457. ctx.drawImage(img, 0, 0, newWidth, newHeight);
  458. canvas.toBlob((blob) => {
  459. const formData = new FormData();
  460. formData.append('file', blob);
  461. for (let [name, value] of formData) {
  462. if (name === 'file') {
  463. let reader = new FileReader();
  464. reader.onloadend = function () {
  465. let base64String = `${reader.result}`.replace(/^data:.+;base64,/, "");
  466. reslove(base64String);
  467. };
  468. reader.readAsDataURL(blob);
  469. }
  470. }
  471. }, MIME_TYPE, QUALITY);
  472. };
  473. });
  474. }
  475. calculateSize(img, maxWidth, maxHeight) {
  476. let width = img.width;
  477. let height = img.height;
  478. if (width > height) {
  479. if (width > maxWidth) {
  480. height = Math.round((height * maxWidth) / width);
  481. width = maxWidth;
  482. }
  483. }
  484. else {
  485. if (height > maxHeight) {
  486. width = Math.round((width * maxHeight) / height);
  487. height = maxHeight;
  488. }
  489. }
  490. return [width, height];
  491. }
  492. checkIsValidFile(values, type) {
  493. const twoLower = type.toLowerCase();
  494. for (let i = 0; i < values.length; i++) {
  495. if (twoLower == values[i]) {
  496. return true;
  497. }
  498. }
  499. return false;
  500. }
  501. init(containerid) {
  502. }
  503. getChildHTML() {
  504. return `<div class="parsingForm m-0 p-0 w-400p h-450p w-md-500p justify-content-center align-items-center py-5 border-dashed d-flex flex-column"
  505. style="border: 4px #beccd6;">
  506. <div class="resumeParsingButtonDelete d-none"> <i class="fa fa-trash-o text-danger font-18"></i> </div>
  507. <div class="resumeDivImg d-none my-2 rounded overflow-hide">
  508. <img class="w-100 h-100" src="" />
  509. </div>
  510. <div for="formAIInputId"
  511. class=" d-flex flex-column align-items-center m-0 labelInputWhite h-100 w-100 rounded-10">
  512. <div class="d-flex flex-column justify-content-center align-items-center h-100 w-100">
  513. <div class="font-50 w-100p text-center clickEventDisabled">
  514. <img class="w-100" src="/tenants/themes/compact/imgs/cloudresume.png" />
  515. </div>
  516. <div class="onlyValuesDisplayAI ">
  517. <span>Click To Browse PDF, PNG, JPEJ, JPG to Upload</span>
  518. <div class="text-center">
  519. <input type="file" multiple id="businesscardInput" class="d-none" />
  520. <label for="businesscardInput" class="btn bg-primary w-150p text-white">Upload</label>
  521. </div>
  522. </div>
  523. <input id="formAIInputId" multiple class="resumeParsingInput m-0 d-none" type="file">
  524. <input id="formImgInput" multiple class="m-0 d-none" accept="image/*" type="file">
  525. </div>
  526. </div>
  527. </div>
  528. <div class="text-center py-30 d-none fileMessageDisplay"></div>`;
  529. }
  530. html(id, containerid) {
  531. let html = `
  532. <div id="img-modal" class="modal-content h-100">
  533. <div class="modal-body bg-white simple-scroll-bar edit-filters-body py-0 bg-cyan-light-5">
  534. <div class="text-danger errorDivPlaceHere d-none p-10"></div>
  535. <div
  536. class="align-items-center d-flex flex-column d-flex h-100 justify-content-center w-100 containerBusinessCards">
  537. ${this.getChildHTML()}
  538. </div>
  539. <div class="spinner-border" role="status">
  540. <span class="sr-only">Loading...</span>
  541. </div>
  542. </div>
  543. <div class="modal-footer pa-10"> <button type="button" id="btn_CloseForm_${id}"
  544. class="btn btn-light btn-sm mr-auto bsClose">Close</button>
  545. <button class="btn btn-primary resumeParsingButton btn-sm" type="button">Submit</button>
  546. </div>
  547. </div>`;
  548. return html;
  549. }
  550. callBusinessCards() {
  551. let instances = this;
  552. instances.navigationHelper.popup(0, '', this, null, Unibase.Platform.Helpers.Size.Medium);
  553. }
  554. static Instance() {
  555. if (this.instance === undefined) {
  556. this.instance = new BusinessCards();
  557. }
  558. return this.instance;
  559. }
  560. }
  561. Components.BusinessCards = BusinessCards;
  562. })(Components = AI.Components || (AI.Components = {}));
  563. })(AI = Communications.AI || (Communications.AI = {}));
  564. })(Communications = Apps.Communications || (Apps.Communications = {}));
  565. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  566. })(Bizgaze || (Bizgaze = {}));