diff --git a/package.json b/package.json index fb200c89b..713d488b3 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@capacitor/push-notifications": "^5.1.0", "@capacitor/share": "^4.1.0", "@capacitor/storage": "^1.2.5", - "@capawesome/capacitor-file-picker": "^5.1.1", + "@capawesome/capacitor-file-picker": "^5.3.0", "@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/fontawesome-free": "^5.15.3", "@fortawesome/fontawesome-svg-core": "^1.2.35", diff --git a/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts b/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts index 8132d5590..0064d51aa 100644 --- a/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts +++ b/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts @@ -479,6 +479,8 @@ export class DiplomaAssinarPage implements OnInit { try { const resd = await this.processes.GetDraftByID(strg).toPromise(); + console.log('DRAFT FFF',resd) + let object = { "ApplicationId": "", "Assunto": resd.data.description, diff --git a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts index b4e127dbf..549dcf098 100644 --- a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts +++ b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts @@ -537,6 +537,7 @@ export class DiplomaPage implements OnInit { console.log('List of ids', strg) const resd = await this.processes.GetDraftByID(strg).toPromise() + console.log('DRAFT FFF',resd) let object = { "ApplicationId": "", "Assunto": resd.data.description, diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index 7ea1fe1d3..4fa09463c 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -195,7 +195,8 @@ export class NewPublicationPage implements OnInit { this.photoOrVideo = false; let fileObject = { FileBase64: this.removeTextBeforeSlash(picture, ','), - FileExtension: capturedImage.format + FileExtension: capturedImage.format, + OriginalFileName: 'image' } this.seletedContent.push(fileObject) @@ -253,7 +254,7 @@ export class NewPublicationPage implements OnInit { let fileObject = { FileBase64: content.data, FileExtension: 'mp4', - OriginalFileName: 'record' + OriginalFileName: 'video' } this.seletedContent.push(fileObject) }) @@ -293,7 +294,8 @@ export class NewPublicationPage implements OnInit { this.filecontent = true; let fileObject = { FileBase64: content.data, - FileExtension: this.removeTextBeforeSlash(element.mimeType, '/') + FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'), + OriginalFileName: 'video' } this.seletedContent.push(fileObject) }) @@ -485,7 +487,7 @@ export class NewPublicationPage implements OnInit { Title: this.pub.Title, Message: this.pub.Message, DatePublication: date, - OriginalFileName: this.capturedImageTitle, + OriginalFileName: this.capturedImageTitle || 'foto', Files: this.seletedContent, /* FileExtension: 'jpeg', */ } @@ -513,6 +515,7 @@ export class NewPublicationPage implements OnInit { this.close(); this.httpErrorHandle.httpsSucessMessagge('Criar publicação') window["sharedContent"] = null; + window["endSharedContent"] = null; this.close(); } catch (error) { diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 019edb3b9..5ffd706d5 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -81,7 +81,7 @@ export class PublicationsPage implements OnInit { ) { this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; - + this.intent = window["sharedContent"] } diff --git a/src/app/services/publications.service.ts b/src/app/services/publications.service.ts index 143defd21..674409284 100644 --- a/src/app/services/publications.service.ts +++ b/src/app/services/publications.service.ts @@ -218,6 +218,8 @@ GetIdsPublicationNext(id:any){ //my last tries CreatePublication(folderId:any,body:any){ + + console.log('body publi', body) const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/v2/posts'; let params = new HttpParams(); @@ -226,6 +228,17 @@ GetIdsPublicationNext(id:any){ headers: this.headers, /* params: params */ }; + +/* this.http.post(`${geturl}`, body, options).subscribe( + (resposta) => { + console.log('Resposta da solicitação POST:', resposta); + }, + (erro) => { + console.error('Erro na solicitação POST:', erro); + }); + */ + + return this.http.post(`${geturl}`, body, options) } diff --git a/src/app/shared/publication/new-publication/new-publication.page.html b/src/app/shared/publication/new-publication/new-publication.page.html index c82a02b8e..c44017053 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.html +++ b/src/app/shared/publication/new-publication/new-publication.page.html @@ -70,11 +70,16 @@ > --> - + + @@ -102,7 +107,7 @@ -
+
Video
-
+ +
+ +
+ + +
+
+ Galeria +
+
+
+ +
diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index c89b2f9f6..06eacfc04 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -19,6 +19,7 @@ import { CMAPIService } from "src/app/shared/repository/CMAPI/cmapi.service"; import { CaptureError, CaptureImageOptions, MediaCapture, MediaFile } from '@awesome-cordova-plugins/media-capture/ngx'; import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem'; import { Platform } from '@ionic/angular'; +import { Capacitor } from '@capacitor/core'; enum ActionType { newRapid = "1", @@ -184,7 +185,8 @@ export class NewPublicationPage implements OnInit { this.photoOrVideo = false; let fileObject = { FileBase64: picture, - FileExtension: this.removeTextBeforeSlash('jpeg', '/') + FileExtension: this.removeTextBeforeSlash('jpeg', '/'), + OriginalFileName: 'imagem' } const FileExtension = this.removeTextBeforeSlash('jpeg', '/') @@ -228,7 +230,8 @@ export class NewPublicationPage implements OnInit { ).then((picture) => { let fileObject = { FileBase64: picture, - FileExtension: this.removeTextBeforeSlash('jpeg', '/') + FileExtension: this.removeTextBeforeSlash('jpeg', '/'), + OriginalFileName: 'image' } const FileExtension = this.removeTextBeforeSlash('jpeg', '/') @@ -260,9 +263,22 @@ export class NewPublicationPage implements OnInit { result.files.forEach(async blobFile => { console.log(blobFile) if (this.checkFileType.checkFileType(blobFile.mimeType) == 'image' || this.checkFileType.checkFileType(blobFile.mimeType) == 'video') { - console.log() + /* console.log('converte new way',this.getBase64(blobFile)) */ + + /* const blob = await fetch( + Capacitor.convertFileSrc(blobFile.path) + ).then(r => r.blob()); */ + + /* console.log(await blob.arrayBuffer()); + + + + console.log("base64 :data:video/mp4;base64,",this.arrayBufferToBase64(await blob.arrayBuffer())) */ + this.convertBlobToBase64(blobFile.blob).then((value) => { + console.log(value) + this.filesSizeSum = this.filesSizeSum + blobFile.size if (this.fileSizeToMB(this.filesSizeSum) <= 20) { @@ -290,6 +306,8 @@ export class NewPublicationPage implements OnInit { this.httpErroHandle.validationMessagge('filessize'); } + }).catch((erro) => { + console.log(erro) }) } else { this.httpErroHandle.validationMessagge('filetype'); @@ -297,6 +315,9 @@ export class NewPublicationPage implements OnInit { }); + + + /* this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String; this.capturedImageTitle = 'foto'; @@ -320,6 +341,49 @@ export class NewPublicationPage implements OnInit { }; + async loadVideoTablet() { + + const result = await FilePicker.pickMedia + ({ + multiple: true, + }); + console.log(result.files) + result.files.forEach(element => { + + this.filesSizeSum = this.filesSizeSum + element.size + if (this.fileSizeToMB(this.filesSizeSum) <= 20) { + if (this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') { + let resultUrl = decodeURIComponent(element.path); + try { + Filesystem.readFile({ path: resultUrl }) + + .then(async (content) => { + console.log(result) + console.log(content) + this.filecontent = true; + let fileObject = new PublicationAttachmentEntity ({ + base64: content.data, + extension: this.removeTextBeforeSlash(element.mimeType, '/'), + OriginalFileName: 'video', + FileType: this.checkFileType.checkFileType( this.removeTextBeforeSlash(element.mimeType, '/')) + }) + this.seletedContent.push(fileObject) + }) + .catch((err) => console.error(err)); + } catch (error) { + console.log('upload video error: ', error) + } + + } + } else { + if (this.seletedContent.length === 0) + this.filesSizeSum = 0 + + this.httpErrorHandle.validationMessagge('filessize') + } + }); + }; + runValidation() { this.validateFrom = true @@ -551,9 +615,18 @@ export class NewPublicationPage implements OnInit { resolve(reader.result) } reader.readAsDataURL(blob) - }) + },) } + getBase64(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); + } + removeTextBeforeSlash(inputString, mark) { if (inputString.includes(mark)) { const parts = inputString.split(mark); @@ -957,6 +1030,11 @@ export class NewPublicationPage implements OnInit { if (!this.platform.is('desktop')) return true; } + + checkDesktop() { + if (this.platform.is('desktop')) + return true; + } } // class UploadFileUseCase {