Files
doneit-web/.angular/cache/14.2.12/babel-webpack/4cbe84afc6800de742e62fc264ae6b69.json
T
Eudes Inácio 53b71ea16f its working
2023-06-30 09:54:21 +01:00

1 line
43 KiB
JSON

{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./new-publication.page.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./new-publication.page.scss?ngResource\";\nimport { Component } from '@angular/core';\nimport { ModalController, NavParams, Platform, LoadingController } from '@ionic/angular';\nimport { PublicationsService } from 'src/app/services/publications.service';\nimport { Publication } from 'src/app/models/publication';\nimport { Image } from 'src/app/models/image';\nimport { PhotoService } from 'src/app/services/photo.service';\n//Capacitor\nimport { ToastService } from 'src/app/services/toast.service';\nimport { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';\nimport { formatDate } from 'src/plugin/momentG.js';\nimport { ThemeService } from 'src/app/services/theme.service';\nimport { Camera, CameraResultType, CameraSource } from '@capacitor/camera';\nimport { Filesystem, Directory } from '@capacitor/filesystem';\nimport { NgxImageCompressService } from \"ngx-image-compress\";\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\nconst IMAGE_DIR = 'stored-images';\nlet NewPublicationPage = class NewPublicationPage {\n constructor(modalController, photoService, navParams, publications, toastService, ThemeService, platform, loadingCtrl, imageCompress, httpErrorHandle) {\n this.modalController = modalController;\n this.photoService = photoService;\n this.navParams = navParams;\n this.publications = publications;\n this.toastService = toastService;\n this.ThemeService = ThemeService;\n this.platform = platform;\n this.loadingCtrl = loadingCtrl;\n this.imageCompress = imageCompress;\n this.httpErrorHandle = httpErrorHandle;\n this.images = [];\n this.disabled = false;\n this.showSpinners = true;\n this.showSeconds = false;\n this.touchUi = false;\n this.enableMeridian = false;\n this.minDate = new Date().toISOString().slice(0, 10);\n this.endMinDate = new Date(new Date().getTime() + 15 * 60000);\n this.stepHour = 1;\n this.stepMinute = 15;\n this.stepSecond = 5;\n this.color = 'primary';\n this.validateFrom = false;\n this.pub = new Publication();\n this.image = new Image();\n this.Defaultimage = '';\n this.capturedImage = '';\n this.photos = [];\n this.convertBlobToBase64 = blob => new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = reject;\n reader.onload = () => {\n resolve(reader.result);\n };\n reader.readAsDataURL(blob);\n }).catch(error => {\n console.error(error);\n });\n this.publicationType = this.navParams.get('publicationType');\n this.folderId = this.navParams.get('folderId');\n this.publicationTitle = 'Nova Publicação';\n this.convertBlobToBase64Worker = new Worker(new URL('./convertBlobToBase64.worker.js', import.meta.url));\n }\n ngOnInit() {\n this.setTitle();\n Filesystem.mkdir({\n path: IMAGE_DIR,\n directory: Directory.Data,\n recursive: true\n });\n // this.takePicture();\n }\n\n takePicture() {\n var _this = this;\n return _asyncToGenerator(function* () {\n const capturedImage = yield Camera.getPhoto({\n quality: 50,\n // allowEditing: true,\n resultType: CameraResultType.Uri,\n source: CameraSource.Camera\n });\n const response = yield fetch(capturedImage.webPath);\n const blob = yield response.blob();\n _this.convertBlobToBase64Worker.postMessage(blob);\n _this.convertBlobToBase64Worker.onmessage = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(function* (oEvent) {\n _this.capturedImage = oEvent.data;\n });\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }();\n })();\n }\n imageSize(image) {\n var canvas = document.createElement('canvas');\n var ctx = canvas.getContext('2d');\n canvas.width = 100;\n canvas.height = 34;\n ctx.drawImage(image, 0, 0);\n document.body.appendChild(canvas);\n }\n /* async laodPicture() {\r\n const capturedImage = await Camera.getPhoto({\r\n resultType: CameraResultType.Uri,\r\n source: CameraSource.Photos,\r\n quality: 90,\r\n width: 1080,\r\n height: 720,\r\n });\r\n const response = await fetch(capturedImage.webPath!);\r\n const blob = await response.blob();\r\n this.photos.unshift({\r\n filepath: \"soon...\",\r\n webviewPath: capturedImage.webPath\r\n });\r\n this.capturedImage = await this.convertBlobToBase64(blob);\r\n this.capturedImageTitle = new Date().getTime() + '.jpeg';\r\n } */\n laodPicture() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n const capturedImage = yield Camera.getPhoto({\n quality: 90,\n // allowEditing: true,\n resultType: CameraResultType.Uri,\n source: CameraSource.Photos\n });\n const response = yield fetch(capturedImage.webPath);\n const blob = yield response.blob();\n _this2.convertBlobToBase64Worker.postMessage(blob);\n _this2.convertBlobToBase64Worker.onmessage = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(function* (oEvent) {\n _this2.capturedImage = oEvent.data;\n });\n return function (_x2) {\n return _ref2.apply(this, arguments);\n };\n }();\n })();\n }\n runValidation() {\n this.validateFrom = true;\n }\n injectValidation() {\n this.Form = new UntypedFormGroup({\n Subject: new UntypedFormControl(this.pub.Title, [Validators.required\n // Validators.minLength(4)\n ]),\n\n capturedImage: new UntypedFormControl(this.capturedImage, []),\n Message: new UntypedFormControl(this.pub.Message, [Validators.required, Validators.maxLength(1000)])\n });\n }\n save() {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n _this3.injectValidation();\n _this3.runValidation();\n if (_this3.Form.invalid) return false;\n if (_this3.publicationType == '3') {\n if (_this3.capturedImage != '') {\n _this3.publication = {\n DateIndex: _this3.publication.DateIndex,\n DocumentId: _this3.publication.DocumentId,\n ProcessId: _this3.publication.ProcessId,\n Title: _this3.pub.Title,\n Message: _this3.pub.Message,\n DatePublication: _this3.publication.DatePublication,\n OriginalFileName: _this3.capturedImageTitle,\n FileBase64: _this3.capturedImage,\n FileExtension: 'jpeg'\n };\n const loader = _this3.toastService.loading();\n try {\n yield _this3.publications.UpdatePublication(_this3.publication.ProcessId, _this3.publication).toPromise();\n _this3.httpErrorHandle.httpsSucessMessagge('Publicação Editada');\n _this3.close();\n } catch (error) {\n _this3.httpErrorHandle.httpStatusHandle(error);\n } finally {\n loader.remove();\n }\n } else if (!_this3.publication.OriginalFileName) {\n _this3.publication = {\n DateIndex: _this3.publication.DateIndex,\n DocumentId: _this3.publication.DocumentId,\n ProcessId: _this3.publication.ProcessId,\n Title: _this3.pub.Title,\n Message: _this3.pub.Message,\n DatePublication: _this3.publication.DatePublication\n // OriginalFileName: this.publication.OriginalFileName,\n // FileBase64: this.publication.FileBase64,\n // FileExtension: 'jpeg',\n };\n\n const loader = _this3.toastService.loading();\n try {\n yield _this3.publications.UpdatePublication(_this3.publication.ProcessId, _this3.publication).toPromise();\n _this3.httpErrorHandle.httpsSucessMessagge('Criar publicação');\n _this3.close();\n } catch (error) {\n _this3.httpErrorHandle.httpStatusHandle(error);\n } finally {\n loader.remove();\n }\n } else {\n _this3.publication = {\n DateIndex: _this3.publication.DateIndex,\n DocumentId: _this3.publication.DocumentId,\n ProcessId: _this3.publication.ProcessId,\n Title: _this3.pub.Title,\n Message: _this3.pub.Message,\n DatePublication: _this3.publication.DatePublication,\n OriginalFileName: _this3.capturedImageTitle,\n FileBase64: _this3.capturedImage,\n FileExtension: 'jpeg'\n };\n const loader = _this3.toastService.loading();\n try {\n yield _this3.publications.UpdatePublication(_this3.publication.ProcessId, _this3.publication).toPromise();\n _this3.httpErrorHandle.httpsSucessMessagge('Publicação Editada');\n _this3.close();\n } catch (error) {\n _this3.httpErrorHandle.httpStatusHandle(error);\n } finally {\n loader.remove();\n }\n }\n } else {\n const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');\n _this3.publication = {\n DateIndex: date,\n DocumentId: null,\n ProcessId: _this3.folderId,\n Title: _this3.pub.Title,\n Message: _this3.pub.Message,\n DatePublication: date,\n OriginalFileName: _this3.capturedImageTitle,\n FileBase64: _this3.capturedImage,\n FileExtension: 'jpeg'\n };\n const loader = _this3.toastService.loading();\n try {\n yield _this3.publications.CreatePublication(_this3.folderId, _this3.publication).toPromise();\n _this3.close();\n _this3.httpErrorHandle.httpsSucessMessagge('Criar publicação');\n _this3.close();\n } catch (error) {\n _this3.httpErrorHandle.httpStatusHandle(error);\n } finally {\n loader.remove();\n }\n }\n })();\n }\n close() {\n this.modalController.dismiss().then(() => {\n this.showLoader = true;\n });\n }\n clear() {\n this.capturedImage = '';\n }\n setTitle() {\n if (this.publicationType == '1') {\n this.publicationTitle = 'Nova Publicação Rápida';\n } else if (this.publicationType == '2') {\n this.publicationTitle = 'Nova Publicação';\n } else if (this.publicationType == '3') {\n this.publicationTitle = 'Editar Publicação';\n this.pub = this.navParams.get('publication');\n }\n }\n /* async openGallery() {\r\n const modal = await this.modalController.create({\r\n component: GalleryPage,\r\n componentProps:{\r\n },\r\n cssClass: 'new-publication',\r\n backdropDismiss: false\r\n });\r\n await modal.present();\r\n modal.onDidDismiss();\r\n } */\n /* async takePicture(){\r\n const image = await Plugins.Camera.getPhoto({\r\n quality: 100,\r\n allowEditing: false,\r\n resultType: CameraResultType.DataUrl,\r\n source: CameraSource.Camera\r\n });\r\n \r\n this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));\r\n } */\n selectImage() {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n const image = yield Camera.getPhoto({\n quality: 90,\n allowEditing: false,\n resultType: CameraResultType.Uri,\n source: CameraSource.Camera // Camera, Photos or Prompt!\n });\n\n if (image) {\n _this4.saveImage(image);\n }\n })();\n }\n // Create a new file from a capture image\n saveImage(photo) {\n var _this5 = this;\n return _asyncToGenerator(function* () {\n const base64Data = yield _this5.readAsBase64(photo);\n const fileName = new Date().getTime() + '.jpeg';\n const savedFile = yield Filesystem.writeFile({\n path: `${IMAGE_DIR}/${fileName}`,\n data: base64Data,\n directory: Directory.Data\n });\n //this.loadFiles(fileName);\n _this5.loadFileData(fileName);\n })();\n }\n readAsBase64(photo) {\n var _this6 = this;\n return _asyncToGenerator(function* () {\n if (_this6.platform.is('hybrid')) {\n const file = yield Filesystem.readFile({\n path: photo.path\n });\n return file.data;\n } else {\n // Fetch the photo, read as a blob, then convert to base64 format\n const response = yield fetch(photo.webPath);\n const blob = yield response.blob();\n return yield _this6.convertBlobToBase64(blob);\n }\n })();\n }\n loadFiles(fileName) {\n var _this7 = this;\n return _asyncToGenerator(function* () {\n _this7.images = [];\n const loading = yield _this7.loadingCtrl.create({\n message: 'Loading data...'\n });\n yield loading.present();\n /* Filesystem.readdir({\r\n path: `${IMAGE_DIR}/${fileName}`,\r\n directory: Directory.Data,\r\n }).then(result => {\r\n \r\n let lastphoto = result.files[result.files.length - 1]\r\n this.loadFileData(lastphoto);\r\n },\r\n async (err) => {\r\n \r\n // Folder does not yet exists!\r\n await Filesystem.mkdir({\r\n path: IMAGE_DIR,\r\n directory: Directory.Data,\r\n recursive: true\r\n });\r\n }\r\n ).then(_ => {\r\n loading.dismiss();\r\n }); */\n })();\n }\n\n loadFileData(fileName) {\n var _this8 = this;\n return _asyncToGenerator(function* () {\n const loading = yield _this8.loadingCtrl.create({\n message: 'Loading data...'\n });\n yield loading.present();\n const filePath = `${IMAGE_DIR}/${fileName}`;\n const readFile = yield Filesystem.readFile({\n path: filePath,\n directory: Directory.Data\n });\n _this8.images.push({\n name: fileName,\n path: filePath,\n data: `data:image/jpeg;base64,${readFile.data}`\n });\n _this8.capturedImage = _this8.images[0].data;\n _this8.compressFile();\n loading.dismiss();\n })();\n }\n /* compressImage() {\r\n let image = this.capturedImage;\r\n this.imageCompress.compressFile(image, orientation, 50, 50,).then(() => {\r\n this.imgResultBeforeCompress = image;\r\n \r\n this.imageCompress.compressFile(image, orientation, 50, 50).then(\r\n result => {\r\n this.imgResultAfterCompress = result;\r\n \r\n }\r\n );\r\n })\r\n } */\n compressFile() {\n //this.imgResultBeforeCompress = image;s\n this.imageCompress.getOrientation(this.capturedImage).then(orientation => {\n this.imageCompress.compressFile(this.capturedImage, orientation, 90, 90).then(result => {\n this.capturedImage = result;\n });\n });\n }\n};\nNewPublicationPage.ctorParameters = () => [{\n type: ModalController\n}, {\n type: PhotoService\n}, {\n type: NavParams\n}, {\n type: PublicationsService\n}, {\n type: ToastService\n}, {\n type: ThemeService\n}, {\n type: Platform\n}, {\n type: LoadingController\n}, {\n type: NgxImageCompressService\n}, {\n type: HttpErrorHandle\n}];\nNewPublicationPage = __decorate([Component({\n selector: 'app-new-publication',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], NewPublicationPage);\nexport { NewPublicationPage };","map":{"version":3,"mappings":";;;;AAAA,SAASA,SAAS,QAAgB,eAAe;AACjD,SAASC,eAAe,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,iBAAiB,QAAQ,gBAAgB;AAIxF,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SAASC,YAAY,QAAQ,gCAAgC;AAC7D;AAEA,SAASC,YAAY,QAAQ,gCAAgC;AAC7D,SAASC,kBAAkB,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ,gBAAgB;AAEjF,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,YAAY,QAAQ,gCAAgC;AAC7D,SAASC,MAAM,EAAEC,gBAAgB,EAAEC,YAAY,QAAe,mBAAmB;AAEjF,SAASC,UAAU,EAAEC,SAAS,QAAQ,uBAAuB;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,eAAe,QAAQ,4CAA4C;AAE5E,MAAMC,SAAS,GAAG,eAAe;AAY1B,IAAMC,kBAAkB,GAAxB,MAAMA,kBAAkB;EA4C7BC,YACUC,eAAgC,EACjCC,YAA0B,EACzBC,SAAoB,EACpBC,YAAiC,EACjCC,YAA0B,EAC3Bf,YAA0B,EACzBgB,QAAkB,EAClBC,WAA8B,EAC/BC,aAAsC,EACrCC,eAAgC;IAThC,oBAAe,GAAfR,eAAe;IAChB,iBAAY,GAAZC,YAAY;IACX,cAAS,GAATC,SAAS;IACT,iBAAY,GAAZC,YAAY;IACZ,iBAAY,GAAZC,YAAY;IACb,iBAAY,GAAZf,YAAY;IACX,aAAQ,GAARgB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AACmC,OAAO,EAAE;MAEvB,MAAME,QAAQ,GAAG,GAAGxI,SAAS,IAAIwH,QAAQ,EAAE;MAE3C,MAAMO,QAAQ,SAASnI,UAAU,CAACmI,QAAQ,CAAC;QACzCrF,IAAI,EAAE8F,QAAQ;QACd7F,SAAS,EAAE9C,SAAS,CAAC+C;OACtB,CAAC;MAEF2F,MAAI,CAACJ,MAAM,CAACM,IAAI,CAAC;QACfC,IAAI,EAAElB,QAAQ;QACd9E,IAAI,EAAE8F,QAAQ;QACd5E,IAAI,EAAE,0BAA0BmE,QAAQ,CAACnE,IAAI;OAC9C,CAAC;MAIF2E,MAAI,CAACxF,aAAa,GAAGwF,MAAI,CAACJ,MAAM,CAAC,CAAC,CAAC,CAACvE,IAAI;MAExC2E,MAAI,CAACI,YAAY,EAAE;MAEnBxC,OAAO,CAACS,OAAO,EAAE;IAAC;EAEpB;EAEA;;;;;;;;;;;;;EAgBA+B,YAAYA;IAEV;IACA,IAAI,CAACjI,aAAa,CAACkI,cAAc,CAAC,IAAI,CAAC7F,aAAa,CAAC,CAAC8D,IAAI,CAAEgC,WAAW,IAAI;MAEzE,IAAI,CAACnI,aAAa,CAACiI,YAAY,CAAC,IAAI,CAAC5F,aAAa,EAAE8F,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAChC,IAAI,CAC3ErF,MAAM,IAAG;QACP,IAAI,CAACuB,aAAa,GAAGvB,MAAM;MAE7B,CAAC,CACF;IAEH,CAAC,CAAC;EACJ;;;;;;;;;;;;;;;;;;;;;;;AAtfWvB,kBAAkB,eAL9BvB,SAAS,CAAC;EACToK,QAAQ,EAAE,qBAAqB;EAC/BC,8BAA0C;;CAE3C,CAAC,GACW9I,kBAAkB;SAAlBA,kBAAkB","names":["Component","ModalController","NavParams","Platform","LoadingController","PublicationsService","Publication","Image","PhotoService","ToastService","UntypedFormControl","UntypedFormGroup","Validators","formatDate","ThemeService","Camera","CameraResultType","CameraSource","Filesystem","Directory","NgxImageCompressService","HttpErrorHandle","IMAGE_DIR","NewPublicationPage","constructor","modalController","photoService","navParams","publications","toastService","platform","loadingCtrl","imageCompress","httpErrorHandle","Date","toISOString","slice","getTime","blob","Promise","resolve","reject","reader","FileReader","onerror","onload","result","readAsDataURL","catch","error","console","publicationType","get","folderId","publicationTitle","convertBlobToBase64Worker","Worker","URL","import","meta","url","ngOnInit","setTitle","mkdir","path","directory","Data","recursive","takePicture","capturedImage","getPhoto","quality","resultType","Uri","source","response","fetch","webPath","_this","postMessage","onmessage","oEvent","data","imageSize","image","canvas","document","createElement","ctx","getContext","width","height","drawImage","body","appendChild","laodPicture","Photos","_this2","runValidation","validateFrom","injectValidation","Form","Subject","pub","Title","required","Message","maxLength","save","_this3","invalid","publication","DateIndex","DocumentId","ProcessId","DatePublication","OriginalFileName","capturedImageTitle","FileBase64","FileExtension","loader","loading","UpdatePublication","toPromise","httpsSucessMessagge","close","httpStatusHandle","remove","date","CreatePublication","dismiss","then","showLoader","clear","selectImage","allowEditing","_this4","saveImage","photo","base64Data","_this5","readAsBase64","fileName","savedFile","writeFile","loadFileData","_this6","is","file","readFile","convertBlobToBase64","loadFiles","_this7","images","create","message","present","_this8","filePath","push","name","compressFile","getOrientation","orientation","selector","template"],"sourceRoot":"","sources":["C:\\Users\\eudes.inacio\\GabineteDigital\\gabinete-digital-fo\\src\\app\\pages\\publications\\new-publication\\new-publication.page.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\r\nimport { ModalController, NavParams, Platform, LoadingController } from '@ionic/angular';\r\n\r\n/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */\r\nimport { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';\r\nimport { PublicationsService } from 'src/app/services/publications.service';\r\nimport { Publication } from 'src/app/models/publication';\r\nimport { Image } from 'src/app/models/image';\r\nimport { PhotoService } from 'src/app/services/photo.service';\r\n//Capacitor\r\n\r\nimport { ToastService } from 'src/app/services/toast.service';\r\nimport { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';\r\nimport { ThemePalette } from '@angular/material/core';\r\nimport { formatDate } from 'src/plugin/momentG.js'\r\nimport { ThemeService } from 'src/app/services/theme.service';\r\nimport { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';\r\n\r\nimport { Filesystem, Directory } from '@capacitor/filesystem';\r\nimport { NgxImageCompressService } from \"ngx-image-compress\";\r\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\r\n\r\nconst IMAGE_DIR = 'stored-images';\r\n\r\ninterface LocalFile {\r\n name: string;\r\n path: string;\r\n data: string;\r\n}\r\n@Component({\r\n selector: 'app-new-publication',\r\n templateUrl: './new-publication.page.html',\r\n styleUrls: ['./new-publication.page.scss'],\r\n})\r\nexport class NewPublicationPage implements OnInit {\r\n images: LocalFile[] = [];\r\n\r\n // date picker\r\n public date: any;\r\n public disabled = false;\r\n public showSpinners = true;\r\n public showSeconds = false;\r\n public touchUi = false;\r\n public enableMeridian = false;\r\n public minDate = new Date().toISOString().slice(0, 10)\r\n public endMinDate = new Date(new Date().getTime() + 15 * 60000);\r\n public stepHour = 1;\r\n public stepMinute = 15;\r\n public stepSecond = 5;\r\n public color: ThemePalette = 'primary';\r\n\r\n Form: UntypedFormGroup;\r\n validateFrom = false\r\n\r\n showLoader: boolean;\r\n publication: Publication;\r\n pub: Publication = new Publication();\r\n folderId: string;\r\n image: Image = new Image();\r\n\r\n publicationType: string;\r\n publicationTitle: string;\r\n imgUrl: any;\r\n\r\n Defaultimage: any = '';\r\n\r\n photo: SafeResourceUrl;\r\n\r\n guestPicture: any;\r\n\r\n capturedImage: any = '';\r\n capturedImageTitle: any;\r\n public photos: any[] = [];\r\n\r\n imgResultBeforeCompress: string;\r\n imgResultAfterCompress: string;\r\n convertBlobToBase64Worker;\r\n\r\n constructor(\r\n private modalController: ModalController,\r\n public photoService: PhotoService,\r\n private navParams: NavParams,\r\n private publications: PublicationsService,\r\n private toastService: ToastService,\r\n public ThemeService: ThemeService,\r\n private platform: Platform,\r\n private loadingCtrl: LoadingController,\r\n public imageCompress: NgxImageCompressService,\r\n private httpErrorHandle: HttpErrorHandle\r\n ) {\r\n\r\n this.publicationType = this.navParams.get('publicationType');\r\n this.folderId = this.navParams.get('folderId');\r\n this.publicationTitle = 'Nova Publicação';\r\n\r\n\r\n this.convertBlobToBase64Worker = new Worker(new URL('./convertBlobToBase64.worker.js', import.meta.url));\r\n\r\n }\r\n\r\n ngOnInit() {\r\n this.setTitle();\r\n Filesystem.mkdir({\r\n path: IMAGE_DIR,\r\n directory: Directory.Data,\r\n recursive: true\r\n });\r\n\r\n // this.takePicture();\r\n }\r\n\r\n async takePicture() {\r\n\r\n const capturedImage = await Camera.getPhoto({\r\n quality: 50,\r\n // allowEditing: true,\r\n resultType: CameraResultType.Uri,\r\n source: CameraSource.Camera\r\n });\r\n\r\n const response = await fetch(capturedImage.webPath!);\r\n const blob = await response.blob();\r\n\r\n this.convertBlobToBase64Worker.postMessage(blob);\r\n this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {\r\n this.capturedImage = oEvent.data\r\n\r\n }\r\n }\r\n\r\n imageSize(image) {\r\n var canvas = document.createElement('canvas');\r\n var ctx = canvas.getContext('2d');\r\n canvas.width = 100\r\n canvas.height = 34\r\n ctx.drawImage(image, 0, 0);\r\n document.body.appendChild(canvas);\r\n }\r\n\r\n convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {\r\n const reader = new FileReader;\r\n reader.onerror = reject;\r\n reader.onload = () => {\r\n resolve(reader.result);\r\n };\r\n reader.readAsDataURL(blob);\r\n }).catch ((error) => {\r\n console.error(error);\r\n });\r\n\r\n\r\n /* async laodPicture() {\r\n const capturedImage = await Camera.getPhoto({\r\n resultType: CameraResultType.Uri,\r\n source: CameraSource.Photos,\r\n quality: 90,\r\n width: 1080,\r\n height: 720,\r\n });\r\n\r\n const response = await fetch(capturedImage.webPath!);\r\n const blob = await response.blob();\r\n\r\n this.photos.unshift({\r\n filepath: \"soon...\",\r\n webviewPath: capturedImage.webPath\r\n });\r\n\r\n this.capturedImage = await this.convertBlobToBase64(blob);\r\n this.capturedImageTitle = new Date().getTime() + '.jpeg';\r\n } */\r\n\r\n async laodPicture() {\r\n \r\n const capturedImage = await Camera.getPhoto({\r\n quality: 90,\r\n // allowEditing: true,\r\n resultType: CameraResultType.Uri,\r\n source: CameraSource.Photos\r\n });\r\n\r\n const response = await fetch(capturedImage.webPath!);\r\n const blob = await response.blob();\r\n\r\n this.convertBlobToBase64Worker.postMessage(blob);\r\n this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {\r\n this.capturedImage = oEvent.data\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n\r\n runValidation() {\r\n this.validateFrom = true\r\n }\r\n\r\n injectValidation() {\r\n\r\n this.Form = new UntypedFormGroup({\r\n Subject: new UntypedFormControl(this.pub.Title, [\r\n Validators.required,\r\n // Validators.minLength(4)\r\n ]),\r\n capturedImage: new UntypedFormControl(this.capturedImage, [\r\n\r\n ]),\r\n Message: new UntypedFormControl(this.pub.Message, [\r\n Validators.required,\r\n Validators.maxLength(1000)\r\n\r\n ])\r\n })\r\n }\r\n\r\n async save() {\r\n\r\n this.injectValidation()\r\n this.runValidation()\r\n\r\n if (this.Form.invalid) return false\r\n\r\n\r\n\r\n if (this.publicationType == '3') {\r\n\r\n if (this.capturedImage != '') {\r\n this.publication = {\r\n DateIndex: this.publication.DateIndex,\r\n DocumentId: this.publication.DocumentId,\r\n ProcessId: this.publication.ProcessId,\r\n Title: this.pub.Title,\r\n Message: this.pub.Message,\r\n DatePublication: this.publication.DatePublication,\r\n OriginalFileName: this.capturedImageTitle,\r\n FileBase64: this.capturedImage,\r\n FileExtension: 'jpeg',\r\n }\r\n\r\n const loader = this.toastService.loading()\r\n\r\n try {\r\n\r\n await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()\r\n this.httpErrorHandle.httpsSucessMessagge('Publicação Editada')\r\n\r\n this.close();\r\n } catch (error) {\r\n this.httpErrorHandle.httpStatusHandle(error)\r\n } finally {\r\n loader.remove()\r\n }\r\n\r\n }\r\n else if (!this.publication.OriginalFileName) {\r\n\r\n this.publication = {\r\n DateIndex: this.publication.DateIndex,\r\n DocumentId: this.publication.DocumentId,\r\n ProcessId: this.publication.ProcessId,\r\n Title: this.pub.Title,\r\n Message: this.pub.Message,\r\n DatePublication: this.publication.DatePublication,\r\n // OriginalFileName: this.publication.OriginalFileName,\r\n // FileBase64: this.publication.FileBase64,\r\n // FileExtension: 'jpeg',\r\n }\r\n\r\n const loader = this.toastService.loading()\r\n\r\n try {\r\n await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()\r\n this.httpErrorHandle.httpsSucessMessagge('Criar publicação')\r\n\r\n this.close();\r\n } catch (error) {\r\n this.httpErrorHandle.httpStatusHandle(error)\r\n } finally {\r\n loader.remove()\r\n }\r\n\r\n } else {\r\n this.publication = {\r\n DateIndex: this.publication.DateIndex,\r\n DocumentId: this.publication.DocumentId,\r\n ProcessId: this.publication.ProcessId,\r\n Title: this.pub.Title,\r\n Message: this.pub.Message,\r\n DatePublication: this.publication.DatePublication,\r\n OriginalFileName: this.capturedImageTitle,\r\n FileBase64: this.capturedImage,\r\n FileExtension: 'jpeg',\r\n }\r\n\r\n \r\n \r\n const loader = this.toastService.loading()\r\n\r\n try {\r\n await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()\r\n this.httpErrorHandle.httpsSucessMessagge('Publicação Editada')\r\n\r\n this.close();\r\n } catch (error) {\r\n this.httpErrorHandle.httpStatusHandle(error)\r\n } finally {\r\n loader.remove()\r\n }\r\n\r\n }\r\n }\r\n else {\r\n\r\n const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')\r\n \r\n \r\n\r\n\r\n this.publication = {\r\n DateIndex: date,\r\n DocumentId: null,\r\n ProcessId: this.folderId,\r\n Title: this.pub.Title,\r\n Message: this.pub.Message,\r\n DatePublication: date,\r\n OriginalFileName: this.capturedImageTitle,\r\n FileBase64: this.capturedImage,\r\n FileExtension: 'jpeg',\r\n }\r\n\r\n const loader = this.toastService.loading()\r\n\r\n try {\r\n \r\n await this.publications.CreatePublication(this.folderId, this.publication).toPromise();\r\n this.close();\r\n this.httpErrorHandle.httpsSucessMessagge('Criar publicação')\r\n\r\n\r\n this.close();\r\n } catch (error) {\r\n this.httpErrorHandle.httpStatusHandle(error)\r\n } finally {\r\n loader.remove()\r\n }\r\n\r\n }\r\n }\r\n\r\n\r\n close() {\r\n this.modalController.dismiss().then(() => {\r\n this.showLoader = true;\r\n });\r\n }\r\n\r\n clear() {\r\n this.capturedImage = '';\r\n }\r\n\r\n setTitle() {\r\n if (this.publicationType == '1') {\r\n this.publicationTitle = 'Nova Publicação Rápida';\r\n }\r\n else if (this.publicationType == '2') {\r\n this.publicationTitle = 'Nova Publicação';\r\n }\r\n else if (this.publicationType == '3') {\r\n this.publicationTitle = 'Editar Publicação';\r\n this.pub = this.navParams.get('publication');\r\n\r\n \r\n }\r\n }\r\n\r\n /* async openGallery() {\r\n const modal = await this.modalController.create({\r\n component: GalleryPage,\r\n componentProps:{\r\n },\r\n cssClass: 'new-publication',\r\n backdropDismiss: false\r\n });\r\n await modal.present();\r\n modal.onDidDismiss();\r\n } */\r\n\r\n /* async takePicture(){\r\n const image = await Plugins.Camera.getPhoto({\r\n quality: 100,\r\n allowEditing: false,\r\n resultType: CameraResultType.DataUrl,\r\n source: CameraSource.Camera\r\n });\r\n \r\n\r\n this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));\r\n } */\r\n\r\n async selectImage() {\r\n const image = await Camera.getPhoto({\r\n quality: 90,\r\n allowEditing: false,\r\n resultType: CameraResultType.Uri,\r\n source: CameraSource.Camera // Camera, Photos or Prompt!\r\n });\r\n if (image) {\r\n this.saveImage(image)\r\n }\r\n }\r\n\r\n\r\n\r\n // Create a new file from a capture image\r\n async saveImage(photo: Photo) {\r\n const base64Data = await this.readAsBase64(photo);\r\n\r\n const fileName = new Date().getTime() + '.jpeg';\r\n const savedFile = await Filesystem.writeFile({\r\n path: `${IMAGE_DIR}/${fileName}`,\r\n data: base64Data,\r\n directory: Directory.Data\r\n });\r\n\r\n //this.loadFiles(fileName);\r\n this.loadFileData(fileName);\r\n }\r\n\r\n private async readAsBase64(photo: Photo) {\r\n if (this.platform.is('hybrid')) {\r\n const file = await Filesystem.readFile({\r\n path: photo.path\r\n });\r\n\r\n return file.data;\r\n }\r\n else {\r\n // Fetch the photo, read as a blob, then convert to base64 format\r\n const response = await fetch(photo.webPath);\r\n const blob = await response.blob();\r\n\r\n return await this.convertBlobToBase64(blob) as string;\r\n }\r\n }\r\n\r\n async loadFiles(fileName) {\r\n this.images = [];\r\n\r\n const loading = await this.loadingCtrl.create({\r\n message: 'Loading data...',\r\n });\r\n await loading.present();\r\n\r\n /* Filesystem.readdir({\r\n path: `${IMAGE_DIR}/${fileName}`,\r\n directory: Directory.Data,\r\n }).then(result => {\r\n \r\n let lastphoto = result.files[result.files.length - 1]\r\n this.loadFileData(lastphoto);\r\n },\r\n async (err) => {\r\n \r\n // Folder does not yet exists!\r\n await Filesystem.mkdir({\r\n path: IMAGE_DIR,\r\n directory: Directory.Data,\r\n recursive: true\r\n });\r\n }\r\n ).then(_ => {\r\n loading.dismiss();\r\n }); */\r\n }\r\n\r\n async loadFileData(fileName: string) {\r\n \r\n\r\n const loading = await this.loadingCtrl.create({\r\n message: 'Loading data...',\r\n });\r\n await loading.present();\r\n\r\n const filePath = `${IMAGE_DIR}/${fileName}`;\r\n\r\n const readFile = await Filesystem.readFile({\r\n path: filePath,\r\n directory: Directory.Data,\r\n });\r\n\r\n this.images.push({\r\n name: fileName,\r\n path: filePath,\r\n data: `data:image/jpeg;base64,${readFile.data}`,\r\n });\r\n\r\n \r\n\r\n this.capturedImage = this.images[0].data\r\n\r\n this.compressFile();\r\n\r\n loading.dismiss();\r\n\r\n }\r\n\r\n /* compressImage() {\r\n let image = this.capturedImage;\r\n this.imageCompress.compressFile(image, orientation, 50, 50,).then(() => {\r\n\r\n this.imgResultBeforeCompress = image;\r\n \r\n\r\n this.imageCompress.compressFile(image, orientation, 50, 50).then(\r\n result => {\r\n this.imgResultAfterCompress = result;\r\n \r\n }\r\n );\r\n })\r\n } */\r\n\r\n compressFile() {\r\n\r\n //this.imgResultBeforeCompress = image;s\r\n this.imageCompress.getOrientation(this.capturedImage).then((orientation) => {\r\n \r\n this.imageCompress.compressFile(this.capturedImage, orientation, 90, 90).then(\r\n result => {\r\n this.capturedImage = result;\r\n \r\n }\r\n );\r\n\r\n });\r\n }\r\n\r\n\r\n\r\n}\r\n"]},"metadata":{},"sourceType":"module"}