mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix commit to hub
This commit is contained in:
@@ -238,6 +238,42 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
async onFileSelect(event: any) {
|
||||
|
||||
const file:File = event.target.files[0];
|
||||
|
||||
|
||||
const chunkSize = 1024 * 1024; // Adjust the chunk size as needed
|
||||
const chunks = [];
|
||||
let offset = 0;
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
function count () {
|
||||
j++
|
||||
return j
|
||||
}
|
||||
|
||||
while (offset < file.size) {
|
||||
const chunk = file.slice(offset, offset + chunkSize);
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = async () => {
|
||||
|
||||
const headers = new HttpHeaders()
|
||||
.append('X-File-Name', "fileName")
|
||||
.append('X-File-Extension', "mp4")
|
||||
.append('X-File-Content-Length', i.toString())
|
||||
.append('X-File-Index', count().toString());
|
||||
|
||||
const a = new Uint8Array(reader.result as ArrayBuffer)
|
||||
await this.http.post('http://localhost:3001/upload', a.buffer, { headers, responseType: 'blob' }).toPromise();
|
||||
|
||||
|
||||
};
|
||||
reader.readAsArrayBuffer(chunk);
|
||||
offset += chunkSize;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -265,9 +301,6 @@ export class PublicationsPage implements OnInit {
|
||||
const loader = this.toastService.loading();
|
||||
try {
|
||||
await this.publications.DeletePresidentialAction(id).toPromise();
|
||||
if(window["refreshPublication"]) {
|
||||
window["refreshPublication"]();
|
||||
}
|
||||
this.toastService._successMessage()
|
||||
} catch (error) {
|
||||
if(error.status == 0) {
|
||||
@@ -316,7 +349,7 @@ export class PublicationsPage implements OnInit {
|
||||
componentProps: {
|
||||
publicationType: publicationType,
|
||||
folderId: folderId,
|
||||
intent: intent
|
||||
intent: window["sharedContent"]
|
||||
},
|
||||
cssClass: 'new-publication modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
@@ -329,8 +362,8 @@ export class PublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
goToPublicationsList(folderId: string) {
|
||||
if(this.intent){
|
||||
this.AddPublication('2',folderId,this.intent)
|
||||
if(window["sharedContent"]){
|
||||
this.AddPublication('2',folderId,window["sharedContent"])
|
||||
return
|
||||
}
|
||||
if (window.innerWidth < 701) {
|
||||
|
||||
@@ -53,6 +53,16 @@
|
||||
X
|
||||
</div>
|
||||
|
||||
<div *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && seleted.chucksManager">
|
||||
|
||||
<mat-progress-bar
|
||||
|
||||
mode="determinate"
|
||||
[style.width]="seleted.chucksManager.uploadPercentage"
|
||||
></mat-progress-bar>
|
||||
|
||||
</div>
|
||||
|
||||
<ion-img *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'image'"
|
||||
name="image" ngDefaultControl [src]="seleted.url" style="height: 69px;"></ion-img>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { PublicationAttachmentEntity, PublicationFormMV } from '../upload/upload-streaming.service';
|
||||
|
||||
import { PublicationFormMVService } from "src/app/shared/publication/upload/publication-form-mv.service"
|
||||
|
||||
enum ActionType {
|
||||
newRapid = "1",
|
||||
@@ -75,6 +75,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
constructor(
|
||||
PublicationFormMVService: PublicationFormMVService,
|
||||
public photoService: PhotoService,
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
@@ -452,8 +453,6 @@ export class NewPublicationPage implements OnInit {
|
||||
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
||||
e.FileExtension = "mp4"
|
||||
}
|
||||
this.publicationFormMV.ObjectMergeNotification.socket.commit(e.chucksManager.path)
|
||||
|
||||
return e
|
||||
})
|
||||
|
||||
@@ -515,7 +514,6 @@ export class NewPublicationPage implements OnInit {
|
||||
e.Base64 = ""
|
||||
}
|
||||
|
||||
this.publicationFormMV.ObjectMergeNotification.socket.commit(e.chucksManager.path)
|
||||
|
||||
return e
|
||||
})
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PublicationFormMVService } from './publication-form-mv.service';
|
||||
|
||||
describe('PublicationFormMVService', () => {
|
||||
let service: PublicationFormMVService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(PublicationFormMVService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PublicationFormMVService {
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { ObjectMergeNotification } from 'src/app/services/socket-connection-mcr.
|
||||
import { CMAPIService } from "src/app/shared/repository/CMAPI/cmapi.service"
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
const objectMergeNotification = new ObjectMergeNotification()
|
||||
|
||||
|
||||
export enum UploadError {
|
||||
noConnection = 'noConnection',
|
||||
@@ -192,10 +192,10 @@ export class PublicationFormMV {
|
||||
|
||||
private UploadFileUseCase = new UploadFileUseCase()
|
||||
private form = new PublicationFormModel()
|
||||
ObjectMergeNotification = objectMergeNotification
|
||||
ObjectMergeNotification = new ObjectMergeNotification()
|
||||
|
||||
constructor() {
|
||||
this.ObjectMergeNotification.connect();
|
||||
// this.ObjectMergeNotification.connect();
|
||||
}
|
||||
|
||||
setDataToFrom(data: IPublicationFormModelEntity) {
|
||||
@@ -218,11 +218,11 @@ export class PublicationFormMV {
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.registerOnLastChunk(() => {
|
||||
this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path)
|
||||
|
||||
const guid = PublicationAttachmentEntity.chucksManager.path
|
||||
|
||||
this.ObjectMergeNotification.subscribe(guid, (data) => {
|
||||
// console.log("data", data)
|
||||
PublicationAttachmentEntity
|
||||
resolve(true)
|
||||
})
|
||||
@@ -437,7 +437,7 @@ export class ChucksManager {
|
||||
}
|
||||
|
||||
registerOnLastChunk(a: Function) {
|
||||
this.onSetPath.push(a)
|
||||
this.onSetLastChunk.push(a)
|
||||
}
|
||||
|
||||
registerToUseCaseResponse(a: Function) {
|
||||
|
||||
Reference in New Issue
Block a user