This commit is contained in:
Peter Maquiran
2024-02-28 09:04:11 +01:00
parent d851aff6ef
commit a5f458de2e
111 changed files with 7528 additions and 942 deletions
@@ -21,6 +21,7 @@ export class UploadStreamingService {
private CMAPIService: CMAPIService,
private sanitizer: DomSanitizer
) {
this.CMAPIService
window["sanitizer"] = this.sanitizer
}
}
@@ -75,35 +76,38 @@ class UploadFileUseCase {
if(needUpload) {
// upload every chunk at onces
const request = readAndUploadChunk(index).then(async(uploadRequest) => {
// // upload every chunk at onces
// const request = readAndUploadChunk(index).then(async(uploadRequest) => {
if(uploadRequest.isErr()) {
connection = false
const pingRequest = await this.CMAPIService.ping()
if( pingRequest.isErr()) {
errorMessage = UploadError.noConnection
} else {
errorMessage = UploadError.slow
}
}
// if(uploadRequest.isErr()) {
})
allRequest.push(request)
// if(connection) {
// connection = false
// const pingRequest = await this.CMAPIService.ping()
// if( pingRequest.isErr()) {
// errorMessage = UploadError.noConnection
// } else {
// errorMessage = UploadError.slow
// }
// }
// }
// })
// allRequest.push(request)
// one by one chunk upload
// const request = readAndUploadChunk(index)
// allRequest.push(request)
// const uploadRequest = await request
const request = readAndUploadChunk(index)
allRequest.push(request)
const uploadRequest = await request
// if(uploadRequest.isErr()) {
// const pingRequest = await this.CMAPIService.ping()
// if( pingRequest.isErr()) {
// return resolve(err(UploadError.noConnection))
// } else {
// return resolve(err(UploadError.slow))
// }
// }
if(uploadRequest.isErr()) {
const pingRequest = await this.CMAPIService.ping()
if( pingRequest.isErr()) {
return resolve(err(UploadError.noConnection))
} else {
return resolve(err(UploadError.slow))
}
}
}
}
@@ -183,7 +187,7 @@ interface IPublicationFormModelEntity {
Title: any
Message: any
DatePublication: any
Files: PublicationAttachmentEntity[]
Files?: PublicationAttachmentEntity[]
}
interface PublicationAttachmentEntityParams {
@@ -196,22 +200,24 @@ interface PublicationAttachmentEntityParams {
export class PublicationFormModel implements IPublicationFormModelEntity {
constructor() {}
DateIndex: any;
DocumentId: any;
ProcessId: any;
DateIndex: any = new Date()
DocumentId: any = null
ProcessId: any = null
Title: any;
Message: any;
DatePublication: any;
DatePublication = new Date()
OriginalFileName: string;
Files: PublicationAttachmentEntity[];
Files: PublicationAttachmentEntity[] = []
hasSet = false
setData(data: IPublicationFormModelEntity) {
if(data.Files) {
data.Files = []
}
if(!this.hasSet) {
Object.assign(this, data)
}
this.hasSet = true
}
}
@@ -219,7 +225,7 @@ export class PublicationFormModel implements IPublicationFormModelEntity {
export class PublicationFormMV {
private UploadFileUseCase = new UploadFileUseCase()
private form = new PublicationFormModel()
form = new PublicationFormModel()
ObjectMergeNotification = new ObjectMergeNotification()
constructor() {
@@ -329,6 +335,24 @@ export class PublicationFormMV {
})
}
get uploadPercentage() {
const videosFiles = this.getVideoFiles()
const percentageArray = videosFiles.map((e) => e.chucksManager.calculatePercentage())
// Check if the array is not empty
if (percentageArray.length === 0) {
return null;
}
let sum = percentageArray.reduce((acc, percentage) => acc + percentage, 0);
// Calculate the average percentage
let averagePercentage = sum / percentageArray.length;
return averagePercentage;
}
}