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 Unibase; (function (Unibase) { let Forms; (function (Forms) { let Controls; (function (Controls) { class ImagePicker { constructor() { this.fileData = []; } jsFiles() { return ["apps/communications/ai/components/resumeparsingmanager.js"]; } init(formpropertyid, prop, callback) { var instance = this; var errormsg = $(".bizgaze_FormErrorMessages:visible").attr("id"); if ($("#img_" + prop.FormPropertyId).val() == "") { instance.fileData[formpropertyid] = []; } $('#browse_' + prop.FormPropertyId).click(function () { $("#img_" + prop.FormPropertyId).click(); }); instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); $("#img_" + formpropertyid).change(function (e) { $("#editFileName_" + formpropertyid).addClass("hidden"); if (!$("#editFileName_" + formpropertyid).hasClass("hidden") && instance.fileData[formpropertyid] != []) { var fileReq = { FileId: 1, FilePath: instance.fileData[formpropertyid].FilePath, }; instance.fileData[formpropertyid] = fileReq; } $("#img_" + formpropertyid).removeAttr("style"); var file = $("#img_" + formpropertyid).get(0); var files = file.files; if (!files[0].type.match('image.*')) { $("#img_" + formpropertyid).val(''); MessageHelper.Instance().showError("Please Select Image File.", errormsg); } else { instance.selectImageFile(files[0], prop.DocPropertyName, formpropertyid, null); var item = { Files: files[0] }; instance.getBase64(item).then(function (response) { var filePath = null; if (instance.fileData[formpropertyid].FilePath != null) { filePath = instance.fileData[formpropertyid].FilePath; } instance.fileData[formpropertyid] = response; instance.fileData[formpropertyid].FilePath = filePath; }); } }); if (callback != null) { callback(); } } selectImageFile(file, DocPropertyName, formpropertyid, imgurl) { var instance = this; $("#fileCount").addClass('hidden'); var html = ""; var imgShow = ""; var filename = ""; if (file != null) { var tmppath = URL.createObjectURL(file); imgShow = tmppath; filename = file.name; $("#requiredImgInput_" + formpropertyid).val(filename); instance.fileHtml(filename, formpropertyid, DocPropertyName, imgShow); } else { filename = DocPropertyName; $("#requiredImgInput_" + formpropertyid).val(filename); DocPropertyName = ""; var src = ""; var path = 'apis/v4/Documents/GetFile?path=' + imgurl; Unibase.Platform.Analytics.Managers.ReportManager.Instance().dataHelper().getAsync(path).then(function (response) { src = 'data:image/png;base64,' + response.file; }).then(function () { instance.fileHtml(filename, formpropertyid, DocPropertyName, src); }); } } fileHtml(filename, formpropertyid, DocPropertyName, imgShow) { if (filename.length > 15) { var File_Extension = filename.substr(filename.lastIndexOf(".")); filename = filename.substr(0, 15) + '...' + File_Extension; } var html = '