diff --git a/src/app/services/socket-connection-mcr.service.ts b/src/app/services/socket-connection-mcr.service.ts index d885b7895..79487258a 100644 --- a/src/app/services/socket-connection-mcr.service.ts +++ b/src/app/services/socket-connection-mcr.service.ts @@ -75,7 +75,7 @@ class ReconnectingWebSocketSignalR { private onDisconnect: Function[] = [] private onConnect: Function[] = [] private whenConnected: Function[] = [] - private stop = true + stop = true constructor() {} diff --git a/src/app/shared/API/middleware/middleware-service.service.ts b/src/app/shared/API/middleware/middleware-service.service.ts index a82bd7cf6..afa8c69e2 100644 --- a/src/app/shared/API/middleware/middleware-service.service.ts +++ b/src/app/shared/API/middleware/middleware-service.service.ts @@ -182,28 +182,19 @@ export class MiddlewareServiceService { - CMAPIFileContent({length, path, index, blobFile}) { - const headers = new HttpHeaders(); - headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization); + CMAPIFileContent({length, path, index, base64}) { // const geturl = 'http://localhost:3001/FileHub'; const geturl = environment.apiPCURL + 'FileContent/UploadFile'; - let options = { - headers: headers - }; - - const formData = new FormData(); - - formData.append("blobFile", blobFile); - formData.append("length", length); - formData.append("index", index.toString()); - - if(path) { - formData.append("path", path); + const data = { + index, + length, + base64, + path, } - return this.http.post(`${geturl}`, formData, options) + return this.http.post(`${geturl}`, data) } CMAPIRequestUpload() { 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 bb6c32fd5..bd1ee85d7 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -430,8 +430,6 @@ export class NewPublicationPage implements OnInit { if (this.publicationType == ActionType.edit) { - - if (this.seletedContent.length >= 1) { const loader = this.toastService.loading() @@ -459,8 +457,6 @@ export class NewPublicationPage implements OnInit { return e }) - - console.log("this.publication.Files", this.publication.Files) } this.publication.Files = this.publication.Files.map( (e: PublicationAttachmentEntity) => ({ @@ -481,7 +477,7 @@ export class NewPublicationPage implements OnInit { this.httpErroHandle.httpStatusHandle(error) if (error.status == 404) { this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) - //this.goBack(); + this.goBack(); } } finally { loader.remove() @@ -512,14 +508,13 @@ export class NewPublicationPage implements OnInit { const upload = await this.publicationFormMV.uploadVideosFiles() if(upload) { - this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> { + this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity) => { if(e.FileType == 'video') { e.OriginalFileName = e.chucksManager.path.replace(".mp4", "") e.FileExtension = "mp4" e.Base64 = "" } - alert("commit") this.publicationFormMV.ObjectMergeNotification.socket.commit(e.chucksManager.path) return e @@ -550,7 +545,7 @@ export class NewPublicationPage implements OnInit { this.httpErroHandle.httpsSucessMessagge('Editar publicação') } - //this.goBackToViewPublications.emit(); + this.goBackToViewPublications.emit(); } catch (error) { this.httpErroHandle.httpStatusHandle(error) } finally { @@ -568,11 +563,11 @@ export class NewPublicationPage implements OnInit { } - // this.publicationFormMV.ObjectMergeNotification.close() + this.publicationFormMV.ObjectMergeNotification.close() } ngOnDestroy() { - // this.publicationFormMV.ObjectMergeNotification.close() + this.publicationFormMV.ObjectMergeNotification.close() } close() { diff --git a/src/app/shared/publication/upload/upload-streaming.service.ts b/src/app/shared/publication/upload/upload-streaming.service.ts index 211df04c9..1696a803b 100644 --- a/src/app/shared/publication/upload/upload-streaming.service.ts +++ b/src/app/shared/publication/upload/upload-streaming.service.ts @@ -12,7 +12,6 @@ export enum UploadError { export type IOUploadError = "noConnection" | "slow" - @Injectable({ providedIn: 'root' }) @@ -34,21 +33,7 @@ class UploadFileUseCase { const base64 = await PublicationAttachmentEntity.chucksManager.chunks.getChunks(index) - if(index == 2) { - const base1 = await PublicationAttachmentEntity.chucksManager.chunks.getChunks(2) - - // Get the video element from the DOM - const videoElement: any = document.getElementById("yourVideoElementId"); - - // Set the src attribute of the video element to the blob URL - videoElement.src = "data:video/mp4;base64,"+ base1 + base64 ; - - // Optionally, you can also set other attributes or play the video - videoElement.controls = true; // Add controls for play, pause, etc. - videoElement.play(); // Auto-play the vid - } - - const uploadRequest = this.CMAPIService.FileContent({length, path: PublicationAttachmentEntity.chucksManager.path, index, blobFile: base64}) + const uploadRequest = this.CMAPIService.FileContent({length, path: PublicationAttachmentEntity.chucksManager.path, index, base64}) uploadRequest.then((uploadRequest) => { if(uploadRequest.isOk()) { @@ -59,21 +44,21 @@ class UploadFileUseCase { return uploadRequest; } - // if(!PublicationAttachmentEntity.chucksManager.hasPath()) { - // const guidRequest = await this.CMAPIService.RequestUpload() + if(!PublicationAttachmentEntity.chucksManager.hasPath()) { + const guidRequest = await this.CMAPIService.RequestUpload() - // if(guidRequest.isOk()) { - // path = guidRequest.value+".mp4" - // PublicationAttachmentEntity.chucksManager.setPath(path) - // } else { - // const pingRequest = await this.CMAPIService.ping() - // if( pingRequest.isErr()) { - // return resolve(err(UploadError.noConnection)) - // } else { - // return resolve(err(UploadError.slow)) - // } - // } - // } + if(guidRequest.isOk()) { + path = guidRequest.value+".mp4" + PublicationAttachmentEntity.chucksManager.setPath(path) + } else { + const pingRequest = await this.CMAPIService.ping() + if( pingRequest.isErr()) { + return resolve(err(UploadError.noConnection)) + } else { + return resolve(err(UploadError.slow)) + } + } + } const allRequest: Promise[] = [] let connection = true @@ -219,14 +204,13 @@ export class PublicationFormMV { if(!PublicationAttachmentEntity.hasChunkManger) { const fileBlob = PublicationAttachmentEntity.blobFile; - const fileChunks = new Chunks({chunkSize: 70 }) + const fileChunks = new Chunks({chunkSize: 1024 }) fileChunks.setFile(fileBlob) PublicationAttachmentEntity.setChunkManger(fileChunks) PublicationAttachmentEntity.chucksManager.registerOnLastChunk(() => { - console.log("last chunk ===============================================") const guid = PublicationAttachmentEntity.chucksManager.path this.ObjectMergeNotification.subscribe(guid, (data) => { diff --git a/src/app/shared/repository/CMAPI/cmapi.service.ts b/src/app/shared/repository/CMAPI/cmapi.service.ts index dc8cda20a..12e3d7715 100644 --- a/src/app/shared/repository/CMAPI/cmapi.service.ts +++ b/src/app/shared/repository/CMAPI/cmapi.service.ts @@ -17,9 +17,9 @@ export class CMAPIService { window["CMAPIAPIRepository"] = this } - async FileContent({length, path, index, blobFile}): Promise> { + async FileContent({length, path, index, base64}): Promise> { try { - const result = await this.MiddlewareServiceService.CMAPIFileContent({length, path, index, blobFile}).toPromise(); + const result = await this.MiddlewareServiceService.CMAPIFileContent({length, path, index, base64}).toPromise(); return ok(result) } catch (error) { if(error.status >= 400 && error.status >= 499) {