mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
merge
This commit is contained in:
@@ -71,11 +71,6 @@
|
||||
<source type="video/mp4" [src]="seleted.url">
|
||||
</video>
|
||||
|
||||
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkTableDivice() == true" width="70" height="70"
|
||||
preload="metadata" webkit-playsinline="webkit-playsinline">
|
||||
<source type="video/mp4" [src]="'data:video/mp4;base64,' +seleted.Base64">
|
||||
</video>
|
||||
|
||||
<ion-icon *ngIf="seleted?.chucksManager?.manualRetry" src="assets/images/retry-svgrepo-com.svg" class="icon-download font-12"> </ion-icon>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -253,26 +253,26 @@ export class NewPublicationPage implements OnInit {
|
||||
multiple: true,
|
||||
});
|
||||
|
||||
console.log(result)
|
||||
console.log(result)
|
||||
|
||||
result.files.forEach(async blobFile => {
|
||||
console.log(blobFile)
|
||||
if (this.checkFileType.checkFileType(blobFile.mimeType) == 'image' || this.checkFileType.checkFileType(blobFile.mimeType) == 'video') {
|
||||
/* console.log('converte new way',this.getBase64(blobFile)) */
|
||||
/* console.log('converte new way',this.getBase64(blobFile)) */
|
||||
|
||||
/* const blob = await fetch(
|
||||
Capacitor.convertFileSrc(blobFile.path)
|
||||
).then(r => r.blob()); */
|
||||
/* 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())) */
|
||||
/* console.log(await blob.arrayBuffer());
|
||||
|
||||
|
||||
|
||||
console.log("base64 :data:video/mp4;base64,",this.arrayBufferToBase64(await blob.arrayBuffer())) */
|
||||
|
||||
this.convertBlobToBase64(blobFile.blob).then((value: string) => {
|
||||
|
||||
console.log(value)
|
||||
console.log(this.removeTextBeforeSlash(value, ','))
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + blobFile.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
@@ -283,7 +283,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
const newAttachment = new PublicationAttachmentEntity(
|
||||
{
|
||||
base64: value,
|
||||
base64: this.removeTextBeforeSlash(value, ','),
|
||||
extension: FileExtension,
|
||||
blobFile: file,
|
||||
FileType: this.checkFileType.checkFileType(FileExtension) as any,
|
||||
@@ -343,7 +343,7 @@ export class NewPublicationPage implements OnInit {
|
||||
({
|
||||
multiple: true,
|
||||
});
|
||||
console.log(result.files)
|
||||
console.log(result.files)
|
||||
result.files.forEach(element => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
@@ -355,15 +355,16 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(result)
|
||||
console.log('load video tablet base64',content)
|
||||
console.log('load video tablet base64', content)
|
||||
this.filecontent = true;
|
||||
let fileObject = new PublicationAttachmentEntity ({
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'video',
|
||||
FileType: this.checkFileType.checkFileType( this.removeTextBeforeSlash(element.mimeType, '/')) as any
|
||||
})
|
||||
this.seletedContent.push(fileObject)
|
||||
console.log('Files array',this.seletedContent)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
@@ -638,17 +639,59 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
convertBlobToBase64(blob: Blob) {
|
||||
console.log('Convert blob ',blob)
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader;
|
||||
reader.onerror = reject;
|
||||
reader.onload = () => {
|
||||
resolve(reader.result)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
},)
|
||||
try {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunkSize = 5000000; // 5 MB
|
||||
const fileSize = blob.size;
|
||||
const chunks = Math.ceil(fileSize / chunkSize);
|
||||
let currentChunk = 0;
|
||||
const base64Chunks = [];
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function () {
|
||||
base64Chunks.push(reader.result);
|
||||
currentChunk++;
|
||||
|
||||
if (currentChunk < chunks) {
|
||||
loadNextChunk();
|
||||
} else {
|
||||
const base64Data = base64Chunks.join("");
|
||||
resolve(base64Data);
|
||||
}
|
||||
};
|
||||
|
||||
reader.onerror = function (error) {
|
||||
reject(error);
|
||||
};
|
||||
|
||||
function loadNextChunk() {
|
||||
const start = currentChunk * chunkSize;
|
||||
const end = Math.min(start + chunkSize, fileSize);
|
||||
const chunk = blob.slice(start, end);
|
||||
reader.readAsDataURL(chunk);
|
||||
}
|
||||
|
||||
loadNextChunk();
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* convertBlobToBase64(blob: Blob) {
|
||||
console.log('Convert blob ',blob)
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader;
|
||||
reader.onerror = reject;
|
||||
reader.onload = () => {
|
||||
resolve(reader.result)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
},)
|
||||
} */
|
||||
|
||||
getBase64(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
@@ -656,7 +699,7 @@ export class NewPublicationPage implements OnInit {
|
||||
reader.onload = () => resolve(reader.result);
|
||||
reader.onerror = error => reject(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
removeTextBeforeSlash(inputString, mark) {
|
||||
if (inputString.includes(mark)) {
|
||||
@@ -1031,7 +1074,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('',content)
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
@@ -1057,7 +1100,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
checkTableDivice() {
|
||||
if (!this.platform.is('desktop'))
|
||||
if (this.platform.is('tablet'))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,10 @@ class UploadFileUseCase {
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.setPath(path)
|
||||
PublicationAttachmentEntity.chucksManager.setResponse(initIndex, uploadRequest)
|
||||
alert("passs")
|
||||
} else {
|
||||
alert("erro dfsdfsdfsdr")
|
||||
PublicationAttachmentEntity.chucksManager.clearUploading()
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
return reject(err(PublicationAttachmentEntity))
|
||||
}
|
||||
@@ -60,7 +63,6 @@ class UploadFileUseCase {
|
||||
const pingRequest = await this.CMAPIService.ping()
|
||||
if( pingRequest.isErr()) {
|
||||
connection = false
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
return reject(err(PublicationAttachmentEntity))
|
||||
}
|
||||
} else {
|
||||
@@ -85,24 +87,31 @@ class UploadFileUseCase {
|
||||
}
|
||||
|
||||
if(!connection) {
|
||||
PublicationAttachmentEntity.chucksManager.clearUploading()
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
return reject(err(PublicationAttachmentEntity))
|
||||
} else {
|
||||
} else if (PublicationAttachmentEntity.chucksManager.chunks.totalChunks != 1) {
|
||||
await Promise.all(allRequest)
|
||||
|
||||
const uploadRequest = await readAndUploadChunk(PublicationAttachmentEntity.chucksManager.chunks.totalChunks)
|
||||
if(uploadRequest.isErr()) {
|
||||
const pingRequest = await this.CMAPIService.ping()
|
||||
if( pingRequest.isErr()) {
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
return reject(err(PublicationAttachmentEntity))
|
||||
}
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.clearUploading()
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
return reject(err(PublicationAttachmentEntity))
|
||||
} else {
|
||||
PublicationAttachmentEntity.chucksManager.setResponse(PublicationAttachmentEntity.chucksManager.chunks.totalChunks, uploadRequest)
|
||||
PublicationAttachmentEntity.chucksManager.doneChunkUpload()
|
||||
return resolve(ok(PublicationAttachmentEntity))
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.doneChunkUpload()
|
||||
resolve(ok(PublicationAttachmentEntity))
|
||||
return resolve(ok(PublicationAttachmentEntity))
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +231,7 @@ export class PublicationFormMV {
|
||||
|
||||
if(!PublicationAttachmentEntity.hasChunkManger) {
|
||||
const fileBlob = PublicationAttachmentEntity.blobFile;
|
||||
const fileChunks = new Chunks({chunkSize: 500 })
|
||||
const fileChunks = new Chunks({chunkSize: 2000 })
|
||||
fileChunks.setFile(fileBlob)
|
||||
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
@@ -239,6 +248,7 @@ export class PublicationFormMV {
|
||||
|
||||
} else {
|
||||
if(PublicationAttachmentEntity.chucksManager.doneUpload) {
|
||||
alert("done")
|
||||
return resolve(true)
|
||||
}
|
||||
}
|
||||
@@ -247,10 +257,18 @@ export class PublicationFormMV {
|
||||
PublicationAttachmentEntity.chucksManager.setUploading()
|
||||
const result = await this.UploadFileUseCase.execute(PublicationAttachmentEntity)
|
||||
PublicationAttachmentEntity.chucksManager.clearUploading()
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
|
||||
|
||||
if(result.isErr()) {
|
||||
alert("error")
|
||||
|
||||
reject(false)
|
||||
} else {
|
||||
alert("passs")
|
||||
}
|
||||
} else {
|
||||
alert("not")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -225,6 +225,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
if (!found) {
|
||||
this.publicationFolderService.publicationList[folderId].push(publicationDetails)
|
||||
this.publicationFolderService.revertPublicationOrder(folderId)
|
||||
} else {
|
||||
|
||||
let a: any = Object.assign({},this.publicationFolderService.publicationList[folderId][findIndex])
|
||||
|
||||
Reference in New Issue
Block a user