@eqproject/eqp-attachments 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/eqproject-eqp-attachments.umd.js +15 -1
- package/bundles/eqproject-eqp-attachments.umd.js.map +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js.map +1 -1
- package/eqproject-eqp-attachments.metadata.json +1 -1
- package/esm2015/lib/eqp-attachments.component.js +16 -2
- package/esm5/lib/eqp-attachments.component.js +16 -2
- package/fesm2015/eqproject-eqp-attachments.js +15 -1
- package/fesm2015/eqproject-eqp-attachments.js.map +1 -1
- package/fesm5/eqproject-eqp-attachments.js +15 -1
- package/fesm5/eqproject-eqp-attachments.js.map +1 -1
- package/lib/eqp-attachments.component.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms"),require("ngx-image-cropper"),require("browser-image-compression"),require("@eqproject/eqp-table"),require("@angular/material/dialog"),require("sweetalert2"),require("@angular/platform-browser"),require("@angular/common/http"),require("@angular/common"),require("@angular/material/checkbox"),require("@angular/material/button"),require("@angular/material/input"),require("@angular/material/autocomplete"),require("@angular/material/datepicker"),require("@angular/material/form-field"),require("@angular/material/radio"),require("@angular/material/select"),require("@angular/material/slider"),require("@angular/material/slide-toggle"),require("@angular/material/menu"),require("@angular/material/sidenav"),require("@angular/material/toolbar"),require("@angular/material/list"),require("@angular/material/grid-list"),require("@angular/material/card"),require("@angular/material/stepper"),require("@angular/material/tabs"),require("@angular/material/expansion"),require("@angular/material/button-toggle"),require("@angular/material/chips"),require("@angular/material/icon"),require("@angular/material/progress-spinner"),require("@angular/material/progress-bar"),require("@angular/material/tooltip"),require("@angular/material/snack-bar"),require("@angular/material/table"),require("@angular/material/sort"),require("@angular/material/paginator"),require("@angular/material/core")):"function"==typeof define&&define.amd?define("@eqproject/eqp-attachments",["exports","@angular/core","@angular/forms","ngx-image-cropper","browser-image-compression","@eqproject/eqp-table","@angular/material/dialog","sweetalert2","@angular/platform-browser","@angular/common/http","@angular/common","@angular/material/checkbox","@angular/material/button","@angular/material/input","@angular/material/autocomplete","@angular/material/datepicker","@angular/material/form-field","@angular/material/radio","@angular/material/select","@angular/material/slider","@angular/material/slide-toggle","@angular/material/menu","@angular/material/sidenav","@angular/material/toolbar","@angular/material/list","@angular/material/grid-list","@angular/material/card","@angular/material/stepper","@angular/material/tabs","@angular/material/expansion","@angular/material/button-toggle","@angular/material/chips","@angular/material/icon","@angular/material/progress-spinner","@angular/material/progress-bar","@angular/material/tooltip","@angular/material/snack-bar","@angular/material/table","@angular/material/sort","@angular/material/paginator","@angular/material/core"],e):e(((t=t||self).eqproject=t.eqproject||{},t.eqproject["eqp-attachments"]={}),t.ng.core,t.ng.forms,t.ngxImageCropper,t.imageCompression,t.eqpTable,t.ng.material.dialog,t.Swal,t.ng.platformBrowser,t.ng.common.http,t.ng.common,t.ng.material.checkbox,t.ng.material.button,t.ng.material.input,t.ng.material.autocomplete,t.ng.material.datepicker,t.ng.material.formField,t.ng.material.radio,t.ng.material.select,t.ng.material.slider,t.ng.material.slideToggle,t.ng.material.menu,t.ng.material.sidenav,t.ng.material.toolbar,t.ng.material.list,t.ng.material.gridList,t.ng.material.card,t.ng.material.stepper,t.ng.material.tabs,t.ng.material.expansion,t.ng.material.buttonToggle,t.ng.material.chips,t.ng.material.icon,t.ng.material.progressSpinner,t.ng.material.progressBar,t.ng.material.tooltip,t.ng.material.snackBar,t.ng.material.table,t.ng.material.sort,t.ng.material.paginator,t.ng.material.core)}(this,(function(t,e,a,n,i,r,o,l,s,m,c,h,d,p,u,g,f,b,v,y,w,A,I,M,T,F,L,x,C,q,E,k,D,P,B,S,N,W,H,O,j){"use strict";i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,l=l&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l;var R;function U(t,e,a,n){var i,r=arguments.length,o=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,a):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,a,n);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(o=(r<3?i(o):r>3?i(e,a,o):i(e,a))||o);return r>3&&o&&Object.defineProperty(e,a,o),o}function z(t,e,a,n){return new(a||(a=Promise))((function(i,r){function o(t){try{s(n.next(t))}catch(t){r(t)}}function l(t){try{s(n.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(o,l)}s((n=n.apply(t,e||[])).next())}))}function _(t,e){var a,n,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){o=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(6===r[0]&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(t){r=[6,t],n=0}finally{a=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function K(t){var e="function"==typeof Symbol&&Symbol.iterator,a=e&&t[e],n=0;if(a)return a.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(R=t.AttachmentType||(t.AttachmentType={}))[R.FILE=1]="FILE",R[R.LINK=2]="LINK";var V=function(){function t(){}return t.checkImageFromMimeType=function(t){return null!=this.imageMimeTypes.find((function(e){return e==t}))},t.getIconFromFileExtensione=function(t){var e=this.fileExtensionIcon[t];return null!=e?e:"fas fa-file"},t.imageMimeTypes=["image/bmp","image/gif","image/jpeg","image/tiff","image/png"],t.fileExtensionIcon={txt:"fas fa-file-text",pdf:"fas fa-file-pdf",doc:"fas fa-file-word",docx:"fas fa-file-word",xls:"fas fa-file-excel",xlsx:"fas fa-file-excel",jpg:"fas fa-file-image",jpeg:"fas fa-file-image",png:"fas fa-file-image",bmp:"fas fa-file-image",mkv:"fas fa-file-video",flv:"fas fa-file-video",gif:"fas fa-file-video",gifv:"fas fa-file-video",avi:"fas fa-file-video",wmv:"fas fa-file-video",mp4:"fas fa-file-video",m4p:"fas fa-file-video",m4v:"fas fa-file-video",mpg:"fas fa-file-video",mp2:"fas fa-file-video",mpeg:"fas fa-file-video",mpe:"fas fa-file-video",mpv:"fas fa-file-video",m2v:"fas fa-file-video","3gp":"fas fa-file-video","3g2":"fas fa-file-video",mp3:"fas fa-file-audio"},t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t=U([e.Injectable({providedIn:"root"})],t)}(),G=function(){function t(){}return t.Error=function(t,e){void 0===e&&(e=null);var a=null!=e?e:"Errore";if(Array.isArray(t)){a=null!=e?e:"Errore";var n=t.join("<br>");l.fire({title:a,html:n,icon:"error"})}else l.fire(a,t,"error")},t.Confirm=function(t,e,a,n,i){void 0===a&&(a=!1),void 0===n&&(n=null),void 0===i&&(i=null);var r=null!=n?n:"Sei sicuro di voler procedere?";if(Array.isArray(t)){var o=t.join("<br>");l.fire({title:r,html:o,width:i||"32rem",icon:a?"warning":"question",showCancelButton:!0,allowOutsideClick:!1,allowEscapeKey:!1}).then((function(t){t.value&&e&&e()}))}else l.fire({title:r,text:t,width:i||"32rem",icon:a?"warning":"question",showCancelButton:!0,allowOutsideClick:!1,allowEscapeKey:!1}).then((function(t){t.value&&e&&e()}))},t.Info=function(t,e,a){void 0===e&&(e=null),void 0===a&&(a=null);var n=null!=e?e:"Informazione:";l.fire(n,t,"info")},t.Warning=function(t,e,a){void 0===e&&(e=null),void 0===a&&(a=null);var n=null!=e?e:"Attenzione!";if(Array.isArray(t)){var i=t.join("<br>");l.fire({title:n,html:i,icon:"warning"})}else l.fire(n,t,"warning")},t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t=U([e.Injectable({providedIn:"root"})],t)}(),J=function(t){return new Promise((function(e,a){var n=new FileReader;n.readAsDataURL(t),n.onload=function(){return e(n.result.toString())},n.onerror=function(t){return a(t)}}))},$=J,Q=function(){function l(a,n,i,o){this.dialog=a,this.formBuilder=n,this.sanitizer=i,this.http=o,this.disableAction=!1,this.showHeader=!0,this.headerTitle="Elenco allegati",this.attachmentsList=null,this.showMatCard=!0,this.multipleAttachment=!0,this.attachmentsColumns=null,this.emptyTableMessage="Nessun dato trovato",this.allowOnlyImages=!1,this.isDisabled=!1,this.showInlinePreview=!1,this.getAttachmentEndpoint=null,this.productionBaseUrl=null,this.compressionOptions={maxSizeMB:.5,maxWidthOrHeight:1920,useWebWorker:!0},this.downloadTooltipPosition=r.TooltipPositionType.Below,this.openLinkLabel="Apri link",this.addButtonLabel="Aggiungi",this.downloadLabel="Download",this.deleteLabel="Elimina",this.fileNameLabel="Nome file",this.previewLabel="Anteprima",this.uploadFileLabel="Carica file",this.confirmLabel="Conferma",this.abortLabel="Annulla",this.saveLabel="Salva",this.exitLabel="Esci",this.eqpTableSearchText="Cerca",this.deleteDialogTitle=null,this.deleteDialogMessage="Sei sicuro di voler cancellare quest'allegato?",this.noImageSelectedErrorMessage="Non è possibile selezionare un file che non sia un'immagine.",this.wrongTypeSelectedErrorMessage="Non è possibile caricare il file selezionato.",this.videoPreviewErrorMessage="Impossibile aprire l'anteprima di un file video.",this.audioPreviewErrorMessage="Impossibile aprire l'anteprima di un file audio.",this.localEditedAttachments=new e.EventEmitter,this.downloadAttachment=new e.EventEmitter,this.onDeleteAttachment=new e.EventEmitter,this.newAttachment={},this.attachmentType=t.AttachmentType,this.selectedFile=null,this.showCropImage=!1,this.imageChangedEvent="",this.croppedImage="",this.transform={},this.AttachmentType=t.AttachmentType}return l.prototype.ngOnInit=function(){this.acceptedFileTypes||(1==this.allowOnlyImages?this.acceptedFileTypes="image/*":this.acceptedFileTypes="*"),1!=this.multipleAttachment||this.attachmentsColumns&&0!=this.attachmentsColumns.length||this.configureColumns(),null==this.attachmentsList&&(this.attachmentsList=new Array),this.checkAttachmentImage()},l.prototype.reloadData=function(){this.attachmentTable&&this.attachmentTable.reloadDatatable()},l.prototype.checkAttachmentImage=function(){this.attachmentsList.forEach((function(t){t.IsImage=V.checkImageFromMimeType(t.FileContentType)}))},l.prototype.configureColumns=function(){var e=this;this.attachmentsColumns=[],1!=this.disableAction&&this.attachmentsColumns.push({key:"action",display:"",type:r.TypeColumn.MenuAction,buttonMenuIcon:"more_vert",styles:{flex:"0 0 6%"},actions:[{name:this.deleteLabel,icon:"delete",fn:function(t,a,n){return e.deleteAttachment(t)}}]});var a={key:"attachment",display:"",type:r.TypeColumn.SimpleAction,styles:{flex:"0 0 6%"},actions:[{name:"",fontawesome:!0,icon:function(a){return e.showInlinePreview?a.AttachmentType==t.AttachmentType.FILE?"fas fa-cloud-download-alt":"fas fa-external-link-alt":e.getAttachmentIcon(a)},fn:function(t,a,n){return e.viewAttachment(t)},tooltip:{tooltipText:function(a){return a.AttachmentType==t.AttachmentType.FILE?e.downloadLabel:e.openLinkLabel},tooltipPosition:this.downloadTooltipPosition}}]},n={key:"InlinePreview",display:this.previewLabel,type:r.TypeColumn.ExternalTemplate,externalTemplate:this.inlinePreviewTemplate,styles:{flex:"0 0 10%"}},i={key:"FileName",display:this.fileNameLabel};this.showInlinePreview?(this.attachmentsColumns.push(n),this.attachmentsColumns.push(i),this.attachmentsColumns.push(a)):(this.attachmentsColumns.push(a),this.attachmentsColumns.push(i))},l.prototype.deleteAttachment=function(t){var e=this;G.Confirm(this.deleteDialogMessage,(function(){e.removeAttachmentFromList(e.attachmentsList.indexOf(t))}),!0,this.deleteDialogTitle)},l.prototype.removeAttachmentFromList=function(t){this.onDeleteAttachment.emit(this.attachmentsList[t]),this.attachmentsList.splice(t,1),this.attachmentTable&&this.attachmentTable.reloadDatatable(),this.localEditedAttachments.emit(this.attachmentsList)},l.prototype.viewAttachment=function(e){if(e.AttachmentType!=t.AttachmentType.LINK)if(e.FileDataBase64&&e.FileContentType&&e.FileName){var a="data:"+e.FileContentType+";base64,"+e.FileDataBase64,n=document.createElement("a");n.href=a,n.download=""+e.FileName,n.click()}else this.downloadAttachment.emit(e);else window.open(e.FilePath,"_blank")},l.prototype.getAttachmentIcon=function(e){return e.AttachmentType==t.AttachmentType.LINK?"fas fa-link":V.getIconFromFileExtensione(e.FileExtension)},l.prototype.openModalAddAttachment=function(t){this.newAttachment={},this.newAttachment.IsImage=!1,this.newAttachment.AttachmentType=t,this.newAttachmentForm=this.formBuilder.group({type:[this.newAttachment.AttachmentType,a.Validators.required],name:[this.newAttachment.FileName],path:[this.newAttachment.FilePath],customHeight:[this.customHeight],customWidth:[this.customWidth]}),this.dialofRefAddAttachment=this.dialog.open(this.dialogAddAttachment,{disableClose:!0,hasBackdrop:!0,width:"60%",maxHeight:"80%"})},l.prototype.close=function(){this.newAttachment={},this.abortFile(),this.newAttachmentForm.reset(),this.dialofRefAddAttachment.close()},l.prototype.disableSave=function(){return this.newAttachment.AttachmentType==t.AttachmentType.FILE?!this.newAttachment.FileDataBase64:!this.newAttachment.FilePath},l.prototype.confirmAddAttachment=function(){this.newAttachment.AttachmentType!=t.AttachmentType.LINK||this.newAttachment.FileName||(this.newAttachment.FileName=this.newAttachment.FilePath),null==this.attachmentsList&&(this.attachmentsList=new Array),this.attachmentsList.push(this.newAttachment),this.attachmentTable&&this.attachmentTable.reloadDatatable(),this.localEditedAttachments.emit(this.attachmentsList),this.dialofRefAddAttachment.close()},l.prototype.openPreviewDialog=function(e){return z(this,void 0,void 0,(function(){var a=this;return _(this,(function(n){switch(n.label){case 0:if(this.selectedAttachment=JSON.parse(JSON.stringify(e)),this.selectedAttachment.AttachmentType==t.AttachmentType.FILE){if(this.selectedAttachment.FileContentType.startsWith("video"))return G.Warning(this.videoPreviewErrorMessage),[2];if(this.selectedAttachment.FileContentType.startsWith("audio"))return G.Warning(this.audioPreviewErrorMessage),[2]}return this.getAttachmentEndpoint&&this.selectedAttachment.IsImage&&!this.selectedAttachment.FileDataBase64?[4,this.getAttachmentByID().then((function(t){a.selectedAttachment.FileDataBase64=t.FileDataBase64})).catch((function(t){G.Error(t)}))]:[3,2];case 1:n.sent(),n.label=2;case 2:if(this.selectedAttachment.AttachmentType==t.AttachmentType.LINK)this.selectedAttachment.TrustedUrl=this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);else{if(this.selectedAttachment.IsImage&&!this.selectedAttachment.FileDataBase64&&!this.selectedAttachment.FileThumbnailBase64)return G.Info("Impossibile aprire l'anteprima dell'allegato, file mancante."),[2];if(!this.selectedAttachment.IsImage){if(!this.selectedAttachment.FilePath||!this.productionBaseUrl)return G.Info("Impossibile aprire l'anteprima del documento!"),[2];this.selectedAttachment.TrustedUrl=this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/gview?url="+this.productionBaseUrl+"/"+this.selectedAttachment.FilePath+"&embedded=true")}}return this.dialog.open(this.dialogPreview,{disableClose:!0,hasBackdrop:!0}),[2]}}))}))},l.prototype.getAttachmentByID=function(){return z(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.http.post(this.getAttachmentEndpoint,this.selectedAttachment).toPromise()]}))}))},l.prototype.onFileInputChange=function(t){return z(this,void 0,void 0,(function(){var e;return _(this,(function(a){switch(a.label){case 0:return this.showCropImage=!1,this.selectedFile=t.target.files[0],this.selectedFile?(this.newAttachment.FileContentType=this.selectedFile.type,this.newAttachment.FileName=this.selectedFile.name,this.newAttachment.FileExtension=this.selectedFile.name.substr(this.selectedFile.name.lastIndexOf(".")+1),this.newAttachment.IsImage=V.checkImageFromMimeType(this.selectedFile.type),1==this.allowOnlyImages&&1!=this.newAttachment.IsImage?(G.Error(this.noImageSelectedErrorMessage),this.abortFile(),[2]):this.checkAcceptedFiles()?1!=this.newAttachment.IsImage?[3,1]:(this.getImageDimensions(t.target.files[0]),this.newAttachmentForm.disable(),this.newAttachmentForm.controls.customWidth.enable(),this.newAttachmentForm.controls.customHeight.enable(),this.showCropImage=!0,this.imageChangedEvent=t,[3,3]):(G.Error(this.wrongTypeSelectedErrorMessage),this.abortFile(),[2])):[2];case 1:return this.showCropImage=!1,[4,J(this.selectedFile)];case 2:(e=a.sent())&&(this.newAttachment.FileContentType=this.newAttachment.FileContentType?this.newAttachment.FileContentType:e.split(",")[0].split(":")[1].split(";")[0],this.newAttachment.FileDataBase64=e.split(",")[1]),a.label=3;case 3:return[2]}}))}))},l.prototype.checkAcceptedFiles=function(){var t,e;if(this.selectedFile.type.startsWith("video"))return!1;if("*"==this.acceptedFileTypes)return!0;var a=this.acceptedFileTypes.includes(this.selectedFile.type);if(!a)try{for(var n=K(this.acceptedFileTypes.split(",").filter((function(t){return t.includes("*")}))),i=n.next();!i.done;i=n.next()){var r=i.value;if(a=this.selectedFile.type.startsWith(r.split("*")[0]))break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return a},l.prototype.getImageDimensions=function(t){var e=this,a=new FileReader;a.onload=function(t){var a=new Image;a.src=t.target.result,a.onload=function(t){e.originalHeight=t.currentTarget.height,e.originalWidth=t.currentTarget.width,e.originalWidth>1280?(e.customWidth=1280,e.customHeight=Math.round(1280*e.originalHeight/e.originalWidth)):(e.customHeight=t.currentTarget.height,e.customWidth=t.currentTarget.width)}},a.readAsDataURL(t)},l.prototype.restoreOriginalDimensions=function(){this.customWidth=this.originalWidth,this.customHeight=this.originalHeight},l.prototype.onDimensionsChange=function(t){"H"==t?this.customWidth=Math.round(this.customHeight*this.originalWidth/this.originalHeight):"W"==t&&(this.customHeight=Math.round(this.customWidth*this.originalHeight/this.originalWidth))},l.prototype.imageCropped=function(t){this.croppedImage=t.base64,this.getCroppedAndUpload(this.croppedImage)},l.prototype.getCroppedAndUpload=function(t){var e=this,a=(t=n.base64ToFile(t),this.compressionOptions);i(t,a).then((function(t){var a=new FileReader;a.onload=function(){var t=a.result;e.newAttachment.FileDataBase64=t.substring(t.indexOf(";base64,")+";base64,".length),e.showCropImage=!1,e.newAttachmentForm.enable()},a.readAsDataURL(t)}))},l.prototype.confirmCrop=function(){this.imageCropper.crop()},l.prototype.abortFile=function(){this.imageChangedEvent="",this.imageInput&&(this.imageInput.nativeElement.value=""),this.selectedFile=null,this.showCropImage=!1,this.newAttachment.IsImage=!1,this.newAttachment.FileDataBase64=null,this.newAttachment.FileName=null,this.newAttachment.FileExtension=null,this.newAttachment.FileContentType=null,this.customHeight=null,this.customWidth=null,this.originalHeight=null,this.originalWidth=null},l.ctorParameters=function(){return[{type:o.MatDialog},{type:a.FormBuilder},{type:s.DomSanitizer},{type:m.HttpClient}]},U([e.Input("disableAction")],l.prototype,"disableAction",void 0),U([e.Input("showHeader")],l.prototype,"showHeader",void 0),U([e.Input("headerTitle")],l.prototype,"headerTitle",void 0),U([e.Input("attachmentsList")],l.prototype,"attachmentsList",void 0),U([e.Input("showMatCard")],l.prototype,"showMatCard",void 0),U([e.Input("multipleAttachment")],l.prototype,"multipleAttachment",void 0),U([e.Input("attachmentsColumns")],l.prototype,"attachmentsColumns",void 0),U([e.Input("emptyTableMessage")],l.prototype,"emptyTableMessage",void 0),U([e.Input("allowOnlyImages")],l.prototype,"allowOnlyImages",void 0),U([e.Input("acceptedFileTypes")],l.prototype,"acceptedFileTypes",void 0),U([e.Input("isDisabled")],l.prototype,"isDisabled",void 0),U([e.Input("showInlinePreview")],l.prototype,"showInlinePreview",void 0),U([e.Input("getAttachmentEndpoint")],l.prototype,"getAttachmentEndpoint",void 0),U([e.Input("productionBaseUrl")],l.prototype,"productionBaseUrl",void 0),U([e.Input("compressionOptions")],l.prototype,"compressionOptions",void 0),U([e.Input("downloadTooltipPosition")],l.prototype,"downloadTooltipPosition",void 0),U([e.Input("openLinkLabel")],l.prototype,"openLinkLabel",void 0),U([e.Input("addButtonLabel")],l.prototype,"addButtonLabel",void 0),U([e.Input("downloadLabel")],l.prototype,"downloadLabel",void 0),U([e.Input("deleteLabel")],l.prototype,"deleteLabel",void 0),U([e.Input("fileNameLabel")],l.prototype,"fileNameLabel",void 0),U([e.Input("previewLabel")],l.prototype,"previewLabel",void 0),U([e.Input("uploadFileLabel")],l.prototype,"uploadFileLabel",void 0),U([e.Input("confirmLabel")],l.prototype,"confirmLabel",void 0),U([e.Input("abortLabel")],l.prototype,"abortLabel",void 0),U([e.Input("saveLabel")],l.prototype,"saveLabel",void 0),U([e.Input("exitLabel")],l.prototype,"exitLabel",void 0),U([e.Input("eqpTableSearchText")],l.prototype,"eqpTableSearchText",void 0),U([e.Input("deleteDialogTitle")],l.prototype,"deleteDialogTitle",void 0),U([e.Input("deleteDialogMessage")],l.prototype,"deleteDialogMessage",void 0),U([e.Input("noImageSelectedErrorMessage")],l.prototype,"noImageSelectedErrorMessage",void 0),U([e.Input("wrongTypeSelectedErrorMessage")],l.prototype,"wrongTypeSelectedErrorMessage",void 0),U([e.Input("videoPreviewErrorMessage")],l.prototype,"videoPreviewErrorMessage",void 0),U([e.Input("videoPreviewErrorMessage")],l.prototype,"audioPreviewErrorMessage",void 0),U([e.Output()],l.prototype,"localEditedAttachments",void 0),U([e.Output("downloadAttachment")],l.prototype,"downloadAttachment",void 0),U([e.Output("onDeleteAttachment")],l.prototype,"onDeleteAttachment",void 0),U([e.ViewChild("dialogAddAttachment",{static:!0})],l.prototype,"dialogAddAttachment",void 0),U([e.ViewChild(n.ImageCropperComponent)],l.prototype,"imageCropper",void 0),U([e.ViewChild("imageInput")],l.prototype,"imageInput",void 0),U([e.ViewChild("attachmentTable",{static:!1})],l.prototype,"attachmentTable",void 0),U([e.ViewChild("inlinePreviewTemplate",{static:!0})],l.prototype,"inlinePreviewTemplate",void 0),U([e.ViewChild("dialogPreview",{static:!0})],l.prototype,"dialogPreview",void 0),l=U([e.Component({selector:"eqp-attachments",template:'\x3c!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l\'elenco allegati --\x3e\r\n<div *ngIf="multipleAttachment == true">\r\n <mat-card [ngStyle]="{ \'box-shadow\': showMatCard == false ? \'none\' : null }">\r\n <mat-card-header>\r\n <div class="col-md-6">\r\n <div class="text-nowrap eqp-attachments-header-title" *ngIf="showHeader == true">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class="col-md-6 text-right">\r\n <div class="row justify-content-end">\r\n <button class="btn btn-primary mb-4 mr-5 eqp-attachments-add-btn" mat-raised-button color="primary"\r\n type="button" [matMenuTriggerFor]="attachmentTypeMenu" [disabled]="isDisabled">\r\n <mat-icon>add</mat-icon><span> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu="matMenu">\r\n <button mat-menu-item (click)="openModalAddAttachment(1)" class="eqp-attachments-file-btn">\r\n <i class="fas fa-file"></i>\r\n <span style="margin-left: 10px;">File</span>\r\n </button>\r\n <button mat-menu-item (click)="openModalAddAttachment(2)" class="eqp-attachments-link-btn">\r\n <i class="fas fa-link"></i>\r\n <span style="margin-left: 10px;">Link</span>\r\n </button>\r\n </mat-menu>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]="false" #table [columns]="attachmentsColumns"\r\n [data]="attachmentsList" [emptyTableMessage]="emptyTableMessage" [searchText]="eqpTableSearchText">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n\x3c!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file --\x3e\r\n<div *ngIf="multipleAttachment != true">\r\n <button class="btn btn-primary mb-4 mr-5 eqp-attachments-add-btn" mat-raised-button color="primary" type="button"\r\n [matMenuTriggerFor]="attachmentTypeMenu" [disabled]="isDisabled"\r\n *ngIf="!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])">\r\n <mat-icon>cloud_upload</mat-icon><span> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu="matMenu">\r\n <button mat-menu-item (click)="openModalAddAttachment(1)" class="eqp-attachments-file-btn">\r\n <i class="fas fa-file"></i>\r\n <span style="margin-left: 10px;">File</span>\r\n </button>\r\n <button mat-menu-item (click)="openModalAddAttachment(2)" class="eqp-attachments-link-btn">\r\n <i class="fas fa-link"></i>\r\n <span style="margin-left: 10px;">Link</span>\r\n </button>\r\n </mat-menu>\r\n\r\n <button class="mb-2 mr-2 eqp-attachments-download-btn" (click)="viewAttachment(attachmentsList[0])" type="button"\r\n mat-raised-button *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0]" color="primary">\r\n <mat-icon *ngIf="attachmentsList[0].AttachmentType == AttachmentType.FILE">download</mat-icon>\r\n <mat-icon *ngIf="attachmentsList[0].AttachmentType != AttachmentType.FILE">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class="mb-2 mr-2 eqp-attachments-preview-btn" (click)="openPreviewDialog(attachmentsList[0])" type="button"\r\n mat-raised-button color="primary"\r\n *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith(\'video\') && !attachmentsList[0].FileContentType.startsWith(\'audio\')))">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class="mb-2 eqp-attachments-delete-btn" (click)="deleteAttachment(attachmentsList[0])" type="button"\r\n mat-raised-button *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0]"\r\n [disabled]="isDisabled">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class="row" style="margin-top: 10px;"\r\n *ngIf="attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true">\r\n <div class="col-sm-12">\r\n <div class="single-attachment-inline-preview-container">\r\n <img src="data:image/png;base64,{{attachmentsList[0].FileDataBase64}}">\r\n </div>\r\n </div>\r\n </div>\r\n <div class="row" *ngIf="attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true">\r\n <div class="col-sm-12">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]="attachmentsList[0].FileName">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class="container-fluid eqp-attachments-dialog-add-container" style="max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;">\r\n <form [formGroup]="newAttachmentForm" (ngSubmit)="confirmAddAttachment()" *ngIf="newAttachmentForm">\r\n <div class="row">\r\n <div class="header-title-standard"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n \'File\' : \'Link\'}} </div>\r\n </div>\r\n <div class="row" style="margin-top: 20px;">\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == attachmentType.FILE">\r\n <input #imageInput style="display:none;" id="file_attachment" name="file_attachment" type="file"\r\n (change)="onFileInputChange($event)" [accept]="acceptedFileTypes" />\r\n <button (click)="imageInput.click()" type="button" style="margin-left: 10px;" id="file_attachment"\r\n mat-raised-button color="primary" [disabled]="showCropImage == true"\r\n class="mb-2 btn btn-primary eqp-attachments-upload-btn" *ngIf="!newAttachment.FileDataBase64">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)="abortFile()" type="button" style="margin-left: 10px;" mat-raised-button\r\n *ngIf="newAttachment.FileDataBase64" class="mb-2 eqp-attachments-delete-btn">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == 2 || selectedFile">\r\n <mat-form-field>\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName="name" matInput [(ngModel)]="newAttachment.FileName">\r\n </mat-form-field>\r\n </div>\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == 2">\r\n <mat-form-field>\r\n <mat-label> Link </mat-label>\r\n <input formControlName="path" required matInput [(ngModel)]="newAttachment.FilePath">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n <div class="row"\r\n *ngIf="showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true"\r\n style="margin-top: 10px;">\r\n <div class="col-4">\r\n <div class="single-attachment-inline-preview-container">\r\n <img src="data:image/png;base64,{{newAttachment.FileDataBase64}}">\r\n </div>\r\n </div>\r\n </div>\r\n <div class="row mt-2 mb-2" *ngIf="showCropImage == true">\r\n <div class="col-md-12 d-flex align-items-center justify-content-center">\r\n <span class="mr-1">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName="customHeight" type="number" matInput [(ngModel)]="customHeight"\r\n (change)="onDimensionsChange(\'H\')">\r\n </mat-form-field>\r\n\r\n <span class="ml-2 mr-1">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName="customWidth" type="number" matInput [(ngModel)]="customWidth"\r\n (change)="onDimensionsChange(\'W\')">\r\n </mat-form-field>\r\n\r\n <button class="btn btn-primary mat-raised-button ml-2" (click)="restoreOriginalDimensions()"\r\n [disabled]="customWidth == originalWidth && customHeight == originalHeight">\r\n <mat-icon style="vertical-align: middle;">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class="row justify-content-center" *ngIf="showCropImage == true">\r\n <div style="max-height: 450px; max-width: 450px;">\r\n <image-cropper [imageChangedEvent]="imageChangedEvent" [maintainAspectRatio]="false"\r\n [autoCrop]="false" [containWithinAspectRatio]="false" [aspectRatio]="4/3"\r\n [cropperMinWidth]="128" [onlyScaleDown]="true" [roundCropper]="false" [canvasRotation]="0"\r\n [transform]="transform" [alignImage]="\'left\'" format="png" (imageCropped)="imageCropped($event)"\r\n [resizeToWidth]="customWidth" [resizeToHeight]="customHeight">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class="row justify-content-center mt-2" *ngIf="showCropImage == true">\r\n <div style="max-height: 450px; max-width: 450px;">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2" type="button"\r\n (click)="confirmCrop()">\r\n {{confirmLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-abort-btn" type="button" (click)="abortFile()">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-2">\r\n <div class="col-sm-12 text-right">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2" type="submit"\r\n [disabled]="showCropImage == true || newAttachmentForm?.disabled == true || disableSave()">\r\n {{saveLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-exit-btn" (click)="close()"\r\n [disabled]="showCropImage == true" type="button">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row="row">\r\n <div class="inline-preview-container" *ngIf="row.IsImage" (click)="openPreviewDialog(row)">\r\n <img src="data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}">\r\n </div>\r\n <div class="inline-preview-container" *ngIf="!row.IsImage" (click)="openPreviewDialog(row)">\r\n <i [ngClass]="getAttachmentIcon(row)"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class="container-fluid" style="max-height: 70vh !important;" *ngIf="selectedAttachment">\r\n <div class="row">\r\n <div class="header-title-standard">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? \'File\' : \'Link\'}}\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-2">\r\n \x3c!-- ANTEPRIMA IMMAGINE --\x3e\r\n <div class="col-12 text-center preview-container" *ngIf="selectedAttachment.IsImage">\r\n <img class="image-preview"\r\n src="data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}">\r\n </div>\r\n\r\n \x3c!-- ANTEPRIMA LINK --\x3e\r\n <div class="col-12 preview-container" *ngIf="!selectedAttachment.IsImage">\r\n <iframe class="link-preview" [src]="selectedAttachment.TrustedUrl"\r\n [title]="selectedAttachment.FileName"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-3">\r\n <div class="col-sm-12 text-right">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2" type="submit"\r\n (click)="viewAttachment(selectedAttachment)"\r\n *ngIf="selectedAttachment.AttachmentType != AttachmentType.LINK">\r\n {{downloadLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-exit-btn" mat-dialog-close type="button"\r\n (click)="selectedAttachment = null">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>',styles:[".eqp-attachments-header-title{font-weight:700;font-size:19px;line-height:24px;margin-bottom:auto}.single-attachment-inline-preview-container{max-height:400px;max-width:400px;display:flex;align-items:center}.single-attachment-inline-preview-container img{max-width:100%;max-height:120px}.inline-preview-container{max-height:100px;max-width:100px;display:flex;align-items:center;justify-content:center;width:100%;cursor:pointer}.inline-preview-container img{max-width:100%;max-height:100px}.inline-preview-container i{font-size:25px;margin:auto}.preview-container{max-height:60vh;max-width:100%}.preview-container .image-preview{max-width:100%;max-height:100%}.preview-container .link-preview{width:70vw;height:55vh}"]})],l)}(),X=function(){function t(){}return t=U([e.NgModule({imports:[h.MatCheckboxModule,d.MatButtonModule,p.MatInputModule,u.MatAutocompleteModule,g.MatDatepickerModule,f.MatFormFieldModule,b.MatRadioModule,v.MatSelectModule,y.MatSliderModule,w.MatSlideToggleModule,A.MatMenuModule,I.MatSidenavModule,M.MatToolbarModule,T.MatListModule,F.MatGridListModule,L.MatCardModule,x.MatStepperModule,C.MatTabsModule,q.MatExpansionModule,E.MatButtonToggleModule,k.MatChipsModule,D.MatIconModule,P.MatProgressSpinnerModule,B.MatProgressBarModule,o.MatDialogModule,S.MatTooltipModule,N.MatSnackBarModule,W.MatTableModule,H.MatSortModule,O.MatPaginatorModule,g.MatDatepickerModule,j.MatNativeDateModule],exports:[h.MatCheckboxModule,d.MatButtonModule,p.MatInputModule,u.MatAutocompleteModule,g.MatDatepickerModule,f.MatFormFieldModule,b.MatRadioModule,v.MatSelectModule,y.MatSliderModule,w.MatSlideToggleModule,A.MatMenuModule,I.MatSidenavModule,M.MatToolbarModule,T.MatListModule,F.MatGridListModule,L.MatCardModule,x.MatStepperModule,C.MatTabsModule,q.MatExpansionModule,E.MatButtonToggleModule,k.MatChipsModule,D.MatIconModule,P.MatProgressSpinnerModule,B.MatProgressBarModule,o.MatDialogModule,S.MatTooltipModule,N.MatSnackBarModule,W.MatTableModule,H.MatSortModule,O.MatPaginatorModule]})],t)}(),Y=function(){function t(){}return t=U([e.NgModule({declarations:[Q],imports:[X,a.FormsModule,c.CommonModule,a.ReactiveFormsModule,n.ImageCropperModule,r.EqpTableModule],exports:[Q]})],t)}();t.AttachmentHelperService=V,t.EqpAttachmentDialogService=G,t.EqpAttachmentsComponent=Q,t.EqpAttachmentsModule=Y,t.ɵ0=$,t.ɵa=X,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms"),require("ngx-image-cropper"),require("browser-image-compression"),require("@eqproject/eqp-table"),require("@angular/material/dialog"),require("sweetalert2"),require("@angular/platform-browser"),require("@angular/common/http"),require("@angular/common"),require("@angular/material/checkbox"),require("@angular/material/button"),require("@angular/material/input"),require("@angular/material/autocomplete"),require("@angular/material/datepicker"),require("@angular/material/form-field"),require("@angular/material/radio"),require("@angular/material/select"),require("@angular/material/slider"),require("@angular/material/slide-toggle"),require("@angular/material/menu"),require("@angular/material/sidenav"),require("@angular/material/toolbar"),require("@angular/material/list"),require("@angular/material/grid-list"),require("@angular/material/card"),require("@angular/material/stepper"),require("@angular/material/tabs"),require("@angular/material/expansion"),require("@angular/material/button-toggle"),require("@angular/material/chips"),require("@angular/material/icon"),require("@angular/material/progress-spinner"),require("@angular/material/progress-bar"),require("@angular/material/tooltip"),require("@angular/material/snack-bar"),require("@angular/material/table"),require("@angular/material/sort"),require("@angular/material/paginator"),require("@angular/material/core")):"function"==typeof define&&define.amd?define("@eqproject/eqp-attachments",["exports","@angular/core","@angular/forms","ngx-image-cropper","browser-image-compression","@eqproject/eqp-table","@angular/material/dialog","sweetalert2","@angular/platform-browser","@angular/common/http","@angular/common","@angular/material/checkbox","@angular/material/button","@angular/material/input","@angular/material/autocomplete","@angular/material/datepicker","@angular/material/form-field","@angular/material/radio","@angular/material/select","@angular/material/slider","@angular/material/slide-toggle","@angular/material/menu","@angular/material/sidenav","@angular/material/toolbar","@angular/material/list","@angular/material/grid-list","@angular/material/card","@angular/material/stepper","@angular/material/tabs","@angular/material/expansion","@angular/material/button-toggle","@angular/material/chips","@angular/material/icon","@angular/material/progress-spinner","@angular/material/progress-bar","@angular/material/tooltip","@angular/material/snack-bar","@angular/material/table","@angular/material/sort","@angular/material/paginator","@angular/material/core"],e):e(((t=t||self).eqproject=t.eqproject||{},t.eqproject["eqp-attachments"]={}),t.ng.core,t.ng.forms,t.ngxImageCropper,t.imageCompression,t.eqpTable,t.ng.material.dialog,t.Swal,t.ng.platformBrowser,t.ng.common.http,t.ng.common,t.ng.material.checkbox,t.ng.material.button,t.ng.material.input,t.ng.material.autocomplete,t.ng.material.datepicker,t.ng.material.formField,t.ng.material.radio,t.ng.material.select,t.ng.material.slider,t.ng.material.slideToggle,t.ng.material.menu,t.ng.material.sidenav,t.ng.material.toolbar,t.ng.material.list,t.ng.material.gridList,t.ng.material.card,t.ng.material.stepper,t.ng.material.tabs,t.ng.material.expansion,t.ng.material.buttonToggle,t.ng.material.chips,t.ng.material.icon,t.ng.material.progressSpinner,t.ng.material.progressBar,t.ng.material.tooltip,t.ng.material.snackBar,t.ng.material.table,t.ng.material.sort,t.ng.material.paginator,t.ng.material.core)}(this,(function(t,e,a,n,i,r,o,l,s,c,m,p,d,h,u,g,f,b,v,y,w,A,I,M,T,L,F,x,C,E,q,k,D,P,B,S,N,W,O,H,j){"use strict";i=i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,l=l&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l;var R;function U(t,e,a,n){var i,r=arguments.length,o=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,a):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,a,n);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(o=(r<3?i(o):r>3?i(e,a,o):i(e,a))||o);return r>3&&o&&Object.defineProperty(e,a,o),o}function z(t,e,a,n){return new(a||(a=Promise))((function(i,r){function o(t){try{s(n.next(t))}catch(t){r(t)}}function l(t){try{s(n.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(o,l)}s((n=n.apply(t,e||[])).next())}))}function K(t,e){var a,n,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){o=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(6===r[0]&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(t){r=[6,t],n=0}finally{a=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function _(t){var e="function"==typeof Symbol&&Symbol.iterator,a=e&&t[e],n=0;if(a)return a.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(R=t.AttachmentType||(t.AttachmentType={}))[R.FILE=1]="FILE",R[R.LINK=2]="LINK";var G=function(){function t(){}return t.checkImageFromMimeType=function(t){return null!=this.imageMimeTypes.find((function(e){return e==t}))},t.getIconFromFileExtensione=function(t){var e=this.fileExtensionIcon[t];return null!=e?e:"fas fa-file"},t.imageMimeTypes=["image/bmp","image/gif","image/jpeg","image/tiff","image/png"],t.fileExtensionIcon={txt:"fas fa-file-text",pdf:"fas fa-file-pdf",doc:"fas fa-file-word",docx:"fas fa-file-word",xls:"fas fa-file-excel",xlsx:"fas fa-file-excel",jpg:"fas fa-file-image",jpeg:"fas fa-file-image",png:"fas fa-file-image",bmp:"fas fa-file-image",mkv:"fas fa-file-video",flv:"fas fa-file-video",gif:"fas fa-file-video",gifv:"fas fa-file-video",avi:"fas fa-file-video",wmv:"fas fa-file-video",mp4:"fas fa-file-video",m4p:"fas fa-file-video",m4v:"fas fa-file-video",mpg:"fas fa-file-video",mp2:"fas fa-file-video",mpeg:"fas fa-file-video",mpe:"fas fa-file-video",mpv:"fas fa-file-video",m2v:"fas fa-file-video","3gp":"fas fa-file-video","3g2":"fas fa-file-video",mp3:"fas fa-file-audio"},t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t=U([e.Injectable({providedIn:"root"})],t)}(),V=function(){function t(){}return t.Error=function(t,e){void 0===e&&(e=null);var a=null!=e?e:"Errore";if(Array.isArray(t)){a=null!=e?e:"Errore";var n=t.join("<br>");l.fire({title:a,html:n,icon:"error"})}else l.fire(a,t,"error")},t.Confirm=function(t,e,a,n,i){void 0===a&&(a=!1),void 0===n&&(n=null),void 0===i&&(i=null);var r=null!=n?n:"Sei sicuro di voler procedere?";if(Array.isArray(t)){var o=t.join("<br>");l.fire({title:r,html:o,width:i||"32rem",icon:a?"warning":"question",showCancelButton:!0,allowOutsideClick:!1,allowEscapeKey:!1}).then((function(t){t.value&&e&&e()}))}else l.fire({title:r,text:t,width:i||"32rem",icon:a?"warning":"question",showCancelButton:!0,allowOutsideClick:!1,allowEscapeKey:!1}).then((function(t){t.value&&e&&e()}))},t.Info=function(t,e,a){void 0===e&&(e=null),void 0===a&&(a=null);var n=null!=e?e:"Informazione:";l.fire(n,t,"info")},t.Warning=function(t,e,a){void 0===e&&(e=null),void 0===a&&(a=null);var n=null!=e?e:"Attenzione!";if(Array.isArray(t)){var i=t.join("<br>");l.fire({title:n,html:i,icon:"warning"})}else l.fire(n,t,"warning")},t.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t=U([e.Injectable({providedIn:"root"})],t)}(),J=function(t){return new Promise((function(e,a){var n=new FileReader;n.readAsDataURL(t),n.onload=function(){return e(n.result.toString())},n.onerror=function(t){return a(t)}}))},$=J,Q=function(){function l(a,n,i,o){this.dialog=a,this.formBuilder=n,this.sanitizer=i,this.http=o,this.disableAction=!1,this.showHeader=!0,this.headerTitle="Elenco allegati",this.attachmentsList=null,this.showMatCard=!0,this.multipleAttachment=!0,this.attachmentsColumns=null,this.emptyTableMessage="Nessun dato trovato",this.allowOnlyImages=!1,this.isDisabled=!1,this.showInlinePreview=!1,this.getAttachmentEndpoint=null,this.productionBaseUrl=null,this.compressionOptions={maxSizeMB:.5,maxWidthOrHeight:1920,useWebWorker:!0},this.allowedTypes=[t.AttachmentType.FILE,t.AttachmentType.LINK],this.downloadTooltipPosition=r.TooltipPositionType.Below,this.openLinkLabel="Apri link",this.addButtonLabel="Aggiungi",this.downloadLabel="Download",this.deleteLabel="Elimina",this.fileNameLabel="Nome file",this.previewLabel="Anteprima",this.uploadFileLabel="Carica file",this.confirmLabel="Conferma",this.abortLabel="Annulla",this.saveLabel="Salva",this.exitLabel="Esci",this.eqpTableSearchText="Cerca",this.deleteDialogTitle=null,this.deleteDialogMessage="Sei sicuro di voler cancellare quest'allegato?",this.noImageSelectedErrorMessage="Non è possibile selezionare un file che non sia un'immagine.",this.wrongTypeSelectedErrorMessage="Non è possibile caricare il file selezionato.",this.videoPreviewErrorMessage="Impossibile aprire l'anteprima di un file video.",this.audioPreviewErrorMessage="Impossibile aprire l'anteprima di un file audio.",this.localEditedAttachments=new e.EventEmitter,this.downloadAttachment=new e.EventEmitter,this.onDeleteAttachment=new e.EventEmitter,this.newAttachment={},this.attachmentType=t.AttachmentType,this.selectedFile=null,this.showCropImage=!1,this.imageChangedEvent="",this.croppedImage="",this.transform={},this.AttachmentType=t.AttachmentType}return l.prototype.ngOnInit=function(){this.acceptedFileTypes||(1==this.allowOnlyImages?this.acceptedFileTypes="image/*":this.acceptedFileTypes="*"),this.allowedTypes&&0!=this.allowedTypes.length?this.allowedTypes.find((function(e){return e!=t.AttachmentType.FILE&&e!=t.AttachmentType.LINK}))&&(V.Warning('Almeno uno degli AttachmentType selezionati nel parametro "allowedTypes" non esiste.'),this.allowedTypes=[t.AttachmentType.FILE,t.AttachmentType.LINK]):this.allowedTypes=[t.AttachmentType.FILE,t.AttachmentType.LINK],1!=this.multipleAttachment||this.attachmentsColumns&&0!=this.attachmentsColumns.length||this.configureColumns(),null==this.attachmentsList&&(this.attachmentsList=new Array),this.checkAttachmentImage()},l.prototype.reloadData=function(){this.attachmentTable&&this.attachmentTable.reloadDatatable()},l.prototype.checkAttachmentImage=function(){this.attachmentsList.forEach((function(t){t.IsImage=G.checkImageFromMimeType(t.FileContentType)}))},l.prototype.configureColumns=function(){var e=this;this.attachmentsColumns=[],1!=this.disableAction&&this.attachmentsColumns.push({key:"action",display:"",type:r.TypeColumn.MenuAction,buttonMenuIcon:"more_vert",styles:{flex:"0 0 6%"},actions:[{name:this.deleteLabel,icon:"delete",fn:function(t,a,n){return e.deleteAttachment(t)}}]});var a={key:"attachment",display:"",type:r.TypeColumn.SimpleAction,styles:{flex:"0 0 6%"},actions:[{name:"",fontawesome:!0,icon:function(a){return e.showInlinePreview?a.AttachmentType==t.AttachmentType.FILE?"fas fa-cloud-download-alt":"fas fa-external-link-alt":e.getAttachmentIcon(a)},fn:function(t,a,n){return e.viewAttachment(t)},tooltip:{tooltipText:function(a){return a.AttachmentType==t.AttachmentType.FILE?e.downloadLabel:e.openLinkLabel},tooltipPosition:this.downloadTooltipPosition}}]},n={key:"InlinePreview",display:this.previewLabel,type:r.TypeColumn.ExternalTemplate,externalTemplate:this.inlinePreviewTemplate,styles:{flex:"0 0 10%"}},i={key:"FileName",display:this.fileNameLabel};this.showInlinePreview?(this.attachmentsColumns.push(n),this.attachmentsColumns.push(i),this.attachmentsColumns.push(a)):(this.attachmentsColumns.push(a),this.attachmentsColumns.push(i))},l.prototype.deleteAttachment=function(t){var e=this;V.Confirm(this.deleteDialogMessage,(function(){e.removeAttachmentFromList(e.attachmentsList.indexOf(t))}),!0,this.deleteDialogTitle)},l.prototype.removeAttachmentFromList=function(t){this.onDeleteAttachment.emit(this.attachmentsList[t]),this.attachmentsList.splice(t,1),this.attachmentTable&&this.attachmentTable.reloadDatatable(),this.localEditedAttachments.emit(this.attachmentsList)},l.prototype.viewAttachment=function(e){if(e.AttachmentType!=t.AttachmentType.LINK)if(e.FileDataBase64&&e.FileContentType&&e.FileName){var a="data:"+e.FileContentType+";base64,"+e.FileDataBase64,n=document.createElement("a");n.href=a,n.download=""+e.FileName,n.click()}else this.downloadAttachment.emit(e);else window.open(e.FilePath,"_blank")},l.prototype.getAttachmentIcon=function(e){return e.AttachmentType==t.AttachmentType.LINK?"fas fa-link":G.getIconFromFileExtensione(e.FileExtension)},l.prototype.openModalAddAttachment=function(t){this.newAttachment={},this.newAttachment.IsImage=!1,this.newAttachment.AttachmentType=t,this.newAttachmentForm=this.formBuilder.group({type:[this.newAttachment.AttachmentType,a.Validators.required],name:[this.newAttachment.FileName],path:[this.newAttachment.FilePath],customHeight:[this.customHeight],customWidth:[this.customWidth]}),this.dialofRefAddAttachment=this.dialog.open(this.dialogAddAttachment,{disableClose:!0,hasBackdrop:!0,width:"60%",maxHeight:"80%"})},l.prototype.close=function(){this.newAttachment={},this.abortFile(),this.newAttachmentForm.reset(),this.dialofRefAddAttachment.close()},l.prototype.disableSave=function(){return this.newAttachment.AttachmentType==t.AttachmentType.FILE?!this.newAttachment.FileDataBase64:!this.newAttachment.FilePath},l.prototype.confirmAddAttachment=function(){this.newAttachment.AttachmentType!=t.AttachmentType.LINK||this.newAttachment.FileName||(this.newAttachment.FileName=this.newAttachment.FilePath),null==this.attachmentsList&&(this.attachmentsList=new Array),this.attachmentsList.push(this.newAttachment),this.attachmentTable&&this.attachmentTable.reloadDatatable(),this.localEditedAttachments.emit(this.attachmentsList),this.dialofRefAddAttachment.close()},l.prototype.openPreviewDialog=function(e){return z(this,void 0,void 0,(function(){var a=this;return K(this,(function(n){switch(n.label){case 0:if(this.selectedAttachment=JSON.parse(JSON.stringify(e)),this.selectedAttachment.AttachmentType==t.AttachmentType.FILE){if(this.selectedAttachment.FileContentType.startsWith("video"))return V.Warning(this.videoPreviewErrorMessage),[2];if(this.selectedAttachment.FileContentType.startsWith("audio"))return V.Warning(this.audioPreviewErrorMessage),[2]}return this.getAttachmentEndpoint&&this.selectedAttachment.IsImage&&!this.selectedAttachment.FileDataBase64?[4,this.getAttachmentByID().then((function(t){a.selectedAttachment.FileDataBase64=t.FileDataBase64})).catch((function(t){V.Error(t)}))]:[3,2];case 1:n.sent(),n.label=2;case 2:if(this.selectedAttachment.AttachmentType==t.AttachmentType.LINK)this.selectedAttachment.TrustedUrl=this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);else{if(this.selectedAttachment.IsImage&&!this.selectedAttachment.FileDataBase64&&!this.selectedAttachment.FileThumbnailBase64)return V.Info("Impossibile aprire l'anteprima dell'allegato, file mancante."),[2];if(!this.selectedAttachment.IsImage){if(!this.selectedAttachment.FilePath||!this.productionBaseUrl)return V.Info("Impossibile aprire l'anteprima del documento!"),[2];this.selectedAttachment.TrustedUrl=this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/gview?url="+this.productionBaseUrl+"/"+this.selectedAttachment.FilePath+"&embedded=true")}}return this.dialog.open(this.dialogPreview,{disableClose:!0,hasBackdrop:!0}),[2]}}))}))},l.prototype.getAttachmentByID=function(){return z(this,void 0,void 0,(function(){return K(this,(function(t){return[2,this.http.post(this.getAttachmentEndpoint,this.selectedAttachment).toPromise()]}))}))},l.prototype.onFileInputChange=function(t){return z(this,void 0,void 0,(function(){var e;return K(this,(function(a){switch(a.label){case 0:return this.showCropImage=!1,this.selectedFile=t.target.files[0],this.selectedFile?(this.newAttachment.FileContentType=this.selectedFile.type,this.newAttachment.FileName=this.selectedFile.name,this.newAttachment.FileExtension=this.selectedFile.name.substr(this.selectedFile.name.lastIndexOf(".")+1),this.newAttachment.IsImage=G.checkImageFromMimeType(this.selectedFile.type),1==this.allowOnlyImages&&1!=this.newAttachment.IsImage?(V.Error(this.noImageSelectedErrorMessage),this.abortFile(),[2]):this.checkAcceptedFiles()?1!=this.newAttachment.IsImage?[3,1]:(this.getImageDimensions(t.target.files[0]),this.newAttachmentForm.disable(),this.newAttachmentForm.controls.customWidth.enable(),this.newAttachmentForm.controls.customHeight.enable(),this.showCropImage=!0,this.imageChangedEvent=t,[3,3]):(V.Error(this.wrongTypeSelectedErrorMessage),this.abortFile(),[2])):[2];case 1:return this.showCropImage=!1,[4,J(this.selectedFile)];case 2:(e=a.sent())&&(this.newAttachment.FileContentType=this.newAttachment.FileContentType?this.newAttachment.FileContentType:e.split(",")[0].split(":")[1].split(";")[0],this.newAttachment.FileDataBase64=e.split(",")[1]),a.label=3;case 3:return[2]}}))}))},l.prototype.checkAcceptedFiles=function(){var t,e;if(this.selectedFile.type.startsWith("video"))return!1;if("*"==this.acceptedFileTypes)return!0;var a=this.acceptedFileTypes.includes(this.selectedFile.type);if(!a)try{for(var n=_(this.acceptedFileTypes.split(",").filter((function(t){return t.includes("*")}))),i=n.next();!i.done;i=n.next()){var r=i.value;if(a=this.selectedFile.type.startsWith(r.split("*")[0]))break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return a},l.prototype.getImageDimensions=function(t){var e=this,a=new FileReader;a.onload=function(t){var a=new Image;a.src=t.target.result,a.onload=function(t){e.originalHeight=t.currentTarget.height,e.originalWidth=t.currentTarget.width,e.originalWidth>1280?(e.customWidth=1280,e.customHeight=Math.round(1280*e.originalHeight/e.originalWidth)):(e.customHeight=t.currentTarget.height,e.customWidth=t.currentTarget.width)}},a.readAsDataURL(t)},l.prototype.restoreOriginalDimensions=function(){this.customWidth=this.originalWidth,this.customHeight=this.originalHeight},l.prototype.onDimensionsChange=function(t){"H"==t?this.customWidth=Math.round(this.customHeight*this.originalWidth/this.originalHeight):"W"==t&&(this.customHeight=Math.round(this.customWidth*this.originalHeight/this.originalWidth))},l.prototype.imageCropped=function(t){this.croppedImage=t.base64,this.getCroppedAndUpload(this.croppedImage)},l.prototype.getCroppedAndUpload=function(t){var e=this,a=(t=n.base64ToFile(t),this.compressionOptions);i(t,a).then((function(t){var a=new FileReader;a.onload=function(){var t=a.result;e.newAttachment.FileDataBase64=t.substring(t.indexOf(";base64,")+";base64,".length),e.showCropImage=!1,e.newAttachmentForm.enable()},a.readAsDataURL(t)}))},l.prototype.confirmCrop=function(){this.imageCropper.crop()},l.prototype.abortFile=function(){this.imageChangedEvent="",this.imageInput&&(this.imageInput.nativeElement.value=""),this.selectedFile=null,this.showCropImage=!1,this.newAttachment.IsImage=!1,this.newAttachment.FileDataBase64=null,this.newAttachment.FileName=null,this.newAttachment.FileExtension=null,this.newAttachment.FileContentType=null,this.customHeight=null,this.customWidth=null,this.originalHeight=null,this.originalWidth=null},l.ctorParameters=function(){return[{type:o.MatDialog},{type:a.FormBuilder},{type:s.DomSanitizer},{type:c.HttpClient}]},U([e.Input("disableAction")],l.prototype,"disableAction",void 0),U([e.Input("showHeader")],l.prototype,"showHeader",void 0),U([e.Input("headerTitle")],l.prototype,"headerTitle",void 0),U([e.Input("attachmentsList")],l.prototype,"attachmentsList",void 0),U([e.Input("showMatCard")],l.prototype,"showMatCard",void 0),U([e.Input("multipleAttachment")],l.prototype,"multipleAttachment",void 0),U([e.Input("attachmentsColumns")],l.prototype,"attachmentsColumns",void 0),U([e.Input("emptyTableMessage")],l.prototype,"emptyTableMessage",void 0),U([e.Input("allowOnlyImages")],l.prototype,"allowOnlyImages",void 0),U([e.Input("acceptedFileTypes")],l.prototype,"acceptedFileTypes",void 0),U([e.Input("isDisabled")],l.prototype,"isDisabled",void 0),U([e.Input("showInlinePreview")],l.prototype,"showInlinePreview",void 0),U([e.Input("getAttachmentEndpoint")],l.prototype,"getAttachmentEndpoint",void 0),U([e.Input("productionBaseUrl")],l.prototype,"productionBaseUrl",void 0),U([e.Input("compressionOptions")],l.prototype,"compressionOptions",void 0),U([e.Input("allowedTypes")],l.prototype,"allowedTypes",void 0),U([e.Input("downloadTooltipPosition")],l.prototype,"downloadTooltipPosition",void 0),U([e.Input("openLinkLabel")],l.prototype,"openLinkLabel",void 0),U([e.Input("addButtonLabel")],l.prototype,"addButtonLabel",void 0),U([e.Input("downloadLabel")],l.prototype,"downloadLabel",void 0),U([e.Input("deleteLabel")],l.prototype,"deleteLabel",void 0),U([e.Input("fileNameLabel")],l.prototype,"fileNameLabel",void 0),U([e.Input("previewLabel")],l.prototype,"previewLabel",void 0),U([e.Input("uploadFileLabel")],l.prototype,"uploadFileLabel",void 0),U([e.Input("confirmLabel")],l.prototype,"confirmLabel",void 0),U([e.Input("abortLabel")],l.prototype,"abortLabel",void 0),U([e.Input("saveLabel")],l.prototype,"saveLabel",void 0),U([e.Input("exitLabel")],l.prototype,"exitLabel",void 0),U([e.Input("eqpTableSearchText")],l.prototype,"eqpTableSearchText",void 0),U([e.Input("deleteDialogTitle")],l.prototype,"deleteDialogTitle",void 0),U([e.Input("deleteDialogMessage")],l.prototype,"deleteDialogMessage",void 0),U([e.Input("noImageSelectedErrorMessage")],l.prototype,"noImageSelectedErrorMessage",void 0),U([e.Input("wrongTypeSelectedErrorMessage")],l.prototype,"wrongTypeSelectedErrorMessage",void 0),U([e.Input("videoPreviewErrorMessage")],l.prototype,"videoPreviewErrorMessage",void 0),U([e.Input("videoPreviewErrorMessage")],l.prototype,"audioPreviewErrorMessage",void 0),U([e.Output()],l.prototype,"localEditedAttachments",void 0),U([e.Output("downloadAttachment")],l.prototype,"downloadAttachment",void 0),U([e.Output("onDeleteAttachment")],l.prototype,"onDeleteAttachment",void 0),U([e.ViewChild("dialogAddAttachment",{static:!0})],l.prototype,"dialogAddAttachment",void 0),U([e.ViewChild(n.ImageCropperComponent)],l.prototype,"imageCropper",void 0),U([e.ViewChild("imageInput")],l.prototype,"imageInput",void 0),U([e.ViewChild("attachmentTable",{static:!1})],l.prototype,"attachmentTable",void 0),U([e.ViewChild("inlinePreviewTemplate",{static:!0})],l.prototype,"inlinePreviewTemplate",void 0),U([e.ViewChild("dialogPreview",{static:!0})],l.prototype,"dialogPreview",void 0),l=U([e.Component({selector:"eqp-attachments",template:'\x3c!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l\'elenco allegati --\x3e\r\n<div *ngIf="multipleAttachment == true">\r\n <mat-card [ngStyle]="{ \'box-shadow\': showMatCard == false ? \'none\' : null }">\r\n <mat-card-header>\r\n <div class="col-md-6">\r\n <div class="text-nowrap eqp-attachments-header-title" *ngIf="showHeader == true">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class="col-md-6 text-right">\r\n <div class="row justify-content-end">\r\n \x3c!-- Template del button per l\'aggiunta di un allegato --\x3e\r\n <ng-container *ngTemplateOutlet="addAttachmentButton"></ng-container>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]="false" #table [columns]="attachmentsColumns"\r\n [data]="attachmentsList" [emptyTableMessage]="emptyTableMessage" [searchText]="eqpTableSearchText">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n\x3c!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file --\x3e\r\n<div *ngIf="multipleAttachment != true">\r\n \x3c!-- Template del button per l\'aggiunta di un allegato --\x3e\r\n <ng-container *ngTemplateOutlet="addAttachmentButton"></ng-container>\r\n\r\n <button class="mb-2 mr-2 eqp-attachments-download-btn" (click)="viewAttachment(attachmentsList[0])" type="button"\r\n mat-raised-button *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0]" color="primary">\r\n <mat-icon *ngIf="attachmentsList[0].AttachmentType == AttachmentType.FILE">download</mat-icon>\r\n <mat-icon *ngIf="attachmentsList[0].AttachmentType != AttachmentType.FILE">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class="mb-2 mr-2 eqp-attachments-preview-btn" (click)="openPreviewDialog(attachmentsList[0])" type="button"\r\n mat-raised-button color="primary"\r\n *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith(\'video\') && !attachmentsList[0].FileContentType.startsWith(\'audio\')))">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class="mb-2 eqp-attachments-delete-btn" (click)="deleteAttachment(attachmentsList[0])" type="button"\r\n mat-raised-button *ngIf="attachmentsList && attachmentsList.length > 0 && attachmentsList[0]"\r\n [disabled]="isDisabled">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class="row" style="margin-top: 10px;"\r\n *ngIf="attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true">\r\n <div class="col-sm-12">\r\n <div class="single-attachment-inline-preview-container">\r\n <img src="data:image/png;base64,{{attachmentsList[0].FileDataBase64}}">\r\n </div>\r\n </div>\r\n </div>\r\n <div class="row" *ngIf="attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true">\r\n <div class="col-sm-12">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]="attachmentsList[0].FileName">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class="container-fluid eqp-attachments-dialog-add-container"\r\n style="max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;">\r\n <form [formGroup]="newAttachmentForm" (ngSubmit)="confirmAddAttachment()" *ngIf="newAttachmentForm">\r\n <div class="row">\r\n <div class="header-title-standard"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n \'File\' : \'Link\'}} </div>\r\n </div>\r\n <div class="row" style="margin-top: 20px;">\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == attachmentType.FILE">\r\n <input #imageInput style="display:none;" id="file_attachment" name="file_attachment" type="file"\r\n (change)="onFileInputChange($event)" [accept]="acceptedFileTypes" />\r\n <button (click)="imageInput.click()" type="button" style="margin-left: 10px;" id="file_attachment"\r\n mat-raised-button color="primary" [disabled]="showCropImage == true"\r\n class="mb-2 btn btn-primary eqp-attachments-upload-btn" *ngIf="!newAttachment.FileDataBase64">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)="abortFile()" type="button" style="margin-left: 10px;" mat-raised-button\r\n *ngIf="newAttachment.FileDataBase64" class="mb-2 eqp-attachments-delete-btn">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == 2 || selectedFile">\r\n <mat-form-field>\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName="name" matInput [(ngModel)]="newAttachment.FileName">\r\n </mat-form-field>\r\n </div>\r\n <div class="col-sm-12" *ngIf="newAttachment.AttachmentType == 2">\r\n <mat-form-field>\r\n <mat-label> Link </mat-label>\r\n <input formControlName="path" required matInput [(ngModel)]="newAttachment.FilePath">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n <div class="row"\r\n *ngIf="showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true"\r\n style="margin-top: 10px;">\r\n <div class="col-4">\r\n <div class="single-attachment-inline-preview-container">\r\n <img src="data:image/png;base64,{{newAttachment.FileDataBase64}}">\r\n </div>\r\n </div>\r\n </div>\r\n <div class="row mt-2 mb-2" *ngIf="showCropImage == true">\r\n <div class="col-md-12 d-flex align-items-center justify-content-center">\r\n <span class="mr-1">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName="customHeight" type="number" matInput [(ngModel)]="customHeight"\r\n (change)="onDimensionsChange(\'H\')">\r\n </mat-form-field>\r\n\r\n <span class="ml-2 mr-1">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName="customWidth" type="number" matInput [(ngModel)]="customWidth"\r\n (change)="onDimensionsChange(\'W\')">\r\n </mat-form-field>\r\n\r\n <button class="btn btn-primary mat-raised-button ml-2" (click)="restoreOriginalDimensions()"\r\n [disabled]="customWidth == originalWidth && customHeight == originalHeight">\r\n <mat-icon style="vertical-align: middle;">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class="row justify-content-center" *ngIf="showCropImage == true">\r\n <div style="max-height: 450px; max-width: 450px;">\r\n <image-cropper [imageChangedEvent]="imageChangedEvent" [maintainAspectRatio]="false"\r\n [autoCrop]="false" [containWithinAspectRatio]="false" [aspectRatio]="4/3"\r\n [cropperMinWidth]="128" [onlyScaleDown]="true" [roundCropper]="false" [canvasRotation]="0"\r\n [transform]="transform" [alignImage]="\'left\'" format="png" (imageCropped)="imageCropped($event)"\r\n [resizeToWidth]="customWidth" [resizeToHeight]="customHeight">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class="row justify-content-center mt-2" *ngIf="showCropImage == true">\r\n <div style="max-height: 450px; max-width: 450px;">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2" type="button"\r\n (click)="confirmCrop()">\r\n {{confirmLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-abort-btn" type="button" (click)="abortFile()">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-2">\r\n <div class="col-sm-12 text-right">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2" type="submit"\r\n [disabled]="showCropImage == true || newAttachmentForm?.disabled == true || disableSave()">\r\n {{saveLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-exit-btn" (click)="close()"\r\n [disabled]="showCropImage == true" type="button">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row="row">\r\n <div class="inline-preview-container" *ngIf="row.IsImage" (click)="openPreviewDialog(row)">\r\n <img src="data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}">\r\n </div>\r\n <div class="inline-preview-container" *ngIf="!row.IsImage" (click)="openPreviewDialog(row)">\r\n <i [ngClass]="getAttachmentIcon(row)"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class="container-fluid" style="max-height: 70vh !important;" *ngIf="selectedAttachment">\r\n <div class="row">\r\n <div class="header-title-standard">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? \'File\' : \'Link\'}}\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-2">\r\n \x3c!-- ANTEPRIMA IMMAGINE --\x3e\r\n <div class="col-12 text-center preview-container" *ngIf="selectedAttachment.IsImage">\r\n <img class="image-preview"\r\n src="data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}">\r\n </div>\r\n\r\n \x3c!-- ANTEPRIMA LINK --\x3e\r\n <div class="col-12 preview-container" *ngIf="!selectedAttachment.IsImage">\r\n <iframe class="link-preview" [src]="selectedAttachment.TrustedUrl"\r\n [title]="selectedAttachment.FileName"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class="row mt-3">\r\n <div class="col-sm-12 text-right">\r\n <button class="btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2" type="submit"\r\n (click)="viewAttachment(selectedAttachment)"\r\n *ngIf="selectedAttachment.AttachmentType != AttachmentType.LINK">\r\n {{downloadLabel}}\r\n </button>\r\n <button class="btn mat-raised-button eqp-attachments-exit-btn" mat-dialog-close type="button"\r\n (click)="selectedAttachment = null">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n\x3c!-- TEMPLATE PER IL PULSANTE DI AGGIUNTA NUOVO ALLEGATO --\x3e\r\n<ng-template #addAttachmentButton>\r\n\r\n \x3c!-- \r\n Pulsanti per l\'aggiunta di un file o un link. Ne viene visualizzato uno se:\r\n - gli allowedTypes sono stati specificati, nell\'array ne è presente uno solo, quello inserito è AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di più allegati (multipleAttachment == true)\r\n OPPURE\r\n - gli allowedTypes sono stati specificati, nell\'array ne è presente uno solo, quello inserito è AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di un singolo allegato (multipleAttachment == true) e non ne è ancora stato selezionato uno (ovvero attachmentsList non esiste o non ha elementi)\r\n --\x3e\r\n <button class="btn btn-primary mb-4 mr-5 eqp-attachments-add-btn" mat-raised-button color="primary" type="button"\r\n *ngIf="allowedTypes && allowedTypes.length == 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))"\r\n (click)="openModalAddAttachment(allowedTypes[0])">\r\n \x3c!-- Per l\'aggiunta dei file mostro un\'icona diversa dall\'aggiunta dei link --\x3e\r\n <mat-icon *ngIf="allowedTypes[0] == 1">cloud_upload</mat-icon>\r\n <i class="fas fa-link" *ngIf="allowedTypes[0] == 2"></i>\r\n <span style="margin-left: 10px;">{{addButtonLabel}} {{allowedTypes[0] == 1 ? "file" : "link"}}</span>\r\n </button>\r\n\r\n\r\n \x3c!-- Pulsante per aprire il menu per la scelta del tipo di Attachment da creare --\x3e\r\n <button class="btn btn-primary mb-4 mr-5 eqp-attachments-add-btn" mat-raised-button color="primary" type="button"\r\n [matMenuTriggerFor]="attachmentTypeMenu" [disabled]="isDisabled"\r\n *ngIf="allowedTypes && allowedTypes.length > 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))">\r\n <mat-icon *ngIf="multipleAttachment != true">cloud_upload</mat-icon>\r\n <mat-icon *ngIf="multipleAttachment == true">add</mat-icon>\r\n <span style="margin-left: 0px;"> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu="matMenu">\r\n <button mat-menu-item (click)="openModalAddAttachment(1)" class="eqp-attachments-file-btn">\r\n <i class="fas fa-file"></i>\r\n <span style="margin-left: 10px;">File</span>\r\n </button>\r\n <button mat-menu-item (click)="openModalAddAttachment(2)" class="eqp-attachments-link-btn">\r\n <i class="fas fa-link"></i>\r\n <span style="margin-left: 10px;">Link</span>\r\n </button>\r\n </mat-menu>\r\n</ng-template>',styles:[".eqp-attachments-header-title{font-weight:700;font-size:19px;line-height:24px;margin-bottom:auto}.single-attachment-inline-preview-container{max-height:400px;max-width:400px;display:flex;align-items:center}.single-attachment-inline-preview-container img{max-width:100%;max-height:120px}.inline-preview-container{max-height:100px;max-width:100px;display:flex;align-items:center;justify-content:center;width:100%;cursor:pointer}.inline-preview-container img{max-width:100%;max-height:100px}.inline-preview-container i{font-size:25px;margin:auto}.preview-container{max-height:60vh;max-width:100%}.preview-container .image-preview{max-width:100%;max-height:100%}.preview-container .link-preview{width:70vw;height:55vh}"]})],l)}(),X=function(){function t(){}return t=U([e.NgModule({imports:[p.MatCheckboxModule,d.MatButtonModule,h.MatInputModule,u.MatAutocompleteModule,g.MatDatepickerModule,f.MatFormFieldModule,b.MatRadioModule,v.MatSelectModule,y.MatSliderModule,w.MatSlideToggleModule,A.MatMenuModule,I.MatSidenavModule,M.MatToolbarModule,T.MatListModule,L.MatGridListModule,F.MatCardModule,x.MatStepperModule,C.MatTabsModule,E.MatExpansionModule,q.MatButtonToggleModule,k.MatChipsModule,D.MatIconModule,P.MatProgressSpinnerModule,B.MatProgressBarModule,o.MatDialogModule,S.MatTooltipModule,N.MatSnackBarModule,W.MatTableModule,O.MatSortModule,H.MatPaginatorModule,g.MatDatepickerModule,j.MatNativeDateModule],exports:[p.MatCheckboxModule,d.MatButtonModule,h.MatInputModule,u.MatAutocompleteModule,g.MatDatepickerModule,f.MatFormFieldModule,b.MatRadioModule,v.MatSelectModule,y.MatSliderModule,w.MatSlideToggleModule,A.MatMenuModule,I.MatSidenavModule,M.MatToolbarModule,T.MatListModule,L.MatGridListModule,F.MatCardModule,x.MatStepperModule,C.MatTabsModule,E.MatExpansionModule,q.MatButtonToggleModule,k.MatChipsModule,D.MatIconModule,P.MatProgressSpinnerModule,B.MatProgressBarModule,o.MatDialogModule,S.MatTooltipModule,N.MatSnackBarModule,W.MatTableModule,O.MatSortModule,H.MatPaginatorModule]})],t)}(),Y=function(){function t(){}return t=U([e.NgModule({declarations:[Q],imports:[X,a.FormsModule,m.CommonModule,a.ReactiveFormsModule,n.ImageCropperModule,r.EqpTableModule],exports:[Q]})],t)}();t.AttachmentHelperService=G,t.EqpAttachmentDialogService=V,t.EqpAttachmentsComponent=Q,t.EqpAttachmentsModule=Y,t.ɵ0=$,t.ɵa=X,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=eqproject-eqp-attachments.umd.min.js.map
|