mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix publication load and expediente
This commit is contained in:
@@ -94,6 +94,10 @@ export class ExpedienteDetailPage implements OnInit {
|
|||||||
this.caller = params["params"].caller;
|
this.caller = params["params"].caller;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window['attachments-expediente-update'] = () => {
|
||||||
|
this.LoadTaskDetail(this.serialNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { v4 as uuidv4 } from 'uuid'
|
|||||||
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
||||||
import { CMAPIService } from '../shared/repository/CMAPI/cmapi.service';
|
import { CMAPIService } from '../shared/repository/CMAPI/cmapi.service';
|
||||||
import { HubConnectionBuilder } from '@microsoft/signalr';
|
import { HubConnectionBuilder } from '@microsoft/signalr';
|
||||||
import { ok, err, Result } from 'neverthrow';
|
import { ok, err as Err, Result } from 'neverthrow';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -148,13 +148,21 @@ class ReconnectingWebSocketSignalR {
|
|||||||
|
|
||||||
commit(path): Promise<Result<true, false>> {
|
commit(path): Promise<Result<true, false>> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
console.log('this.connection.invoke', this.connection)
|
||||||
this.connection.invoke("CommitUpload", path).then((e) => {
|
this.connection.invoke("CommitUpload", path).then((e) => {
|
||||||
console.log("commit message", e)
|
console.log("commit message", e)
|
||||||
resolve(ok(true))
|
resolve(ok(true))
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
resolve(err(false))
|
console.error('upload catch commit error')
|
||||||
|
resolve(Err(false))
|
||||||
console.error(err.toString())
|
console.error(err.toString())
|
||||||
});
|
});
|
||||||
|
} catch(error) {
|
||||||
|
resolve(Err(false))
|
||||||
|
console.error('upload commit error')
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,42 +398,42 @@ export class ObjectMergeNotification{
|
|||||||
watchCount = 0
|
watchCount = 0
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// this.socket.onDisconnectCallback(()=> {
|
this.socket.onDisconnectCallback(()=> {
|
||||||
// console.log("run watch")
|
console.log("run watch")
|
||||||
// this.runWatch = true
|
this.runWatch = true
|
||||||
// this.watch()
|
this.watch()
|
||||||
// })
|
})
|
||||||
|
|
||||||
// this.socket.onConnectCallback(()=> {
|
this.socket.onConnectCallback(()=> {
|
||||||
|
|
||||||
// console.log("open trigger")
|
console.log("open trigger")
|
||||||
// this.runWatch = false
|
this.runWatch = false
|
||||||
// })
|
})
|
||||||
|
|
||||||
// this.socket.subscribe((data: socketResponse) => {
|
this.socket.subscribe((data: socketResponse) => {
|
||||||
// if(data.IsCompleted == true) {
|
if(data.IsCompleted == true) {
|
||||||
// console.log("==================!!!====================")
|
console.log("==================!!!====================")
|
||||||
// try {
|
try {
|
||||||
// this.callbacks[data.Guid](data)
|
this.callbacks[data.Guid](data)
|
||||||
// delete this.callbacks[data.Guid]
|
delete this.callbacks[data.Guid]
|
||||||
// } catch (error) {}
|
} catch (error) {}
|
||||||
// } else {
|
} else {
|
||||||
// console.log("else", data)
|
console.log("else", data)
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
|
|
||||||
// this.socket.connect();
|
// this.socket.connect();
|
||||||
// this.watch()
|
// this.watch()
|
||||||
}
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
this.socket.connect();
|
// this.socket.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.socket.disconnect();
|
// this.socket.disconnect();
|
||||||
this.watchCount = 0;
|
// this.watchCount = 0;
|
||||||
this.runWatch = false
|
// this.runWatch = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async watch() {
|
async watch() {
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ export class OptsExpedientePage implements OnInit {
|
|||||||
const loader = this.toastService.loading()
|
const loader = this.toastService.loading()
|
||||||
|
|
||||||
this.attachmentsService.AddAttachment(body).subscribe((res)=> {
|
this.attachmentsService.AddAttachment(body).subscribe((res)=> {
|
||||||
|
window['attachments-expediente-update']();
|
||||||
this.toastService._successMessage()
|
this.toastService._successMessage()
|
||||||
this.popoverController.dismiss()
|
this.popoverController.dismiss()
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
|
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="attach-document cursor-pointer">
|
<div class="attach-document cursor-pointer">
|
||||||
<ion-label>Galeria</ion-label>
|
<ion-label>Galeria 2</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
|
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="attach-document cursor-pointer">
|
<div class="attach-document cursor-pointer">
|
||||||
<ion-label>Galeria</ion-label>
|
<ion-label>Galeria 1</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
const upload = await this.publicationFormMV.uploadVideosFiles()
|
const upload = await this.publicationFormMV.uploadVideosFiles()
|
||||||
|
|
||||||
if(upload) {
|
if(upload) {
|
||||||
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity)=> {
|
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity) => {
|
||||||
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
||||||
e.OriginalFileName = e?.chucksManager?.path?.replace(".mp4", "") || e.OriginalFileName
|
e.OriginalFileName = e?.chucksManager?.path?.replace(".mp4", "") || e.OriginalFileName
|
||||||
e.FileExtension = "mp4"
|
e.FileExtension = "mp4"
|
||||||
@@ -406,14 +406,17 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
const upload = await this.publicationFormMV.uploadVideosFiles()
|
const upload = await this.publicationFormMV.uploadVideosFiles()
|
||||||
|
|
||||||
|
console.log({upload})
|
||||||
|
|
||||||
if(upload) {
|
if(upload) {
|
||||||
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity) => {
|
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity) => {
|
||||||
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
||||||
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
||||||
e.FileExtension = "mp4"
|
e.FileExtension = "mp4"
|
||||||
|
e.Base64 = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.FileType == 'video' ) {
|
if(e.FileType == 'video' && !e.toUpload) {
|
||||||
e.Base64 = e.url
|
e.Base64 = e.url
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,6 +457,9 @@ export class NewPublicationPage implements OnInit {
|
|||||||
loader.remove()
|
loader.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.toastService._badRequest("Tive um erro ao enviar o ficheiro")
|
||||||
|
loader.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -240,13 +240,25 @@ export class PublicationFormMV {
|
|||||||
return this.form.Files.filter( x => x.FileType == 'video')
|
return this.form.Files.filter( x => x.FileType == 'video')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async commit(PublicationAttachmentEntity: PublicationAttachmentEntity) {
|
||||||
|
PublicationAttachmentEntity.chucksManager.doneChunkUpload()
|
||||||
|
const mergeRequest = await this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path)
|
||||||
|
|
||||||
|
if(mergeRequest.isOk()) {
|
||||||
|
PublicationAttachmentEntity.chucksManager.contentSetReady()
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private upload(PublicationAttachmentEntity: PublicationAttachmentEntity) {
|
private upload(PublicationAttachmentEntity: PublicationAttachmentEntity) {
|
||||||
|
|
||||||
return new Promise(async (resolve, reject)=> {
|
return new Promise(async (resolve, reject)=> {
|
||||||
|
|
||||||
if(!PublicationAttachmentEntity.hasChunkManger) {
|
if(!PublicationAttachmentEntity.hasChunkManger) {
|
||||||
const fileBlob = PublicationAttachmentEntity.blobFile;
|
const fileBlob = PublicationAttachmentEntity.blobFile;
|
||||||
const fileChunks = new Chunks({chunkSize: 400 })
|
const fileChunks = new Chunks({chunkSize: 50 })
|
||||||
fileChunks.setFile(fileBlob)
|
fileChunks.setFile(fileBlob)
|
||||||
|
|
||||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||||
@@ -276,20 +288,16 @@ export class PublicationFormMV {
|
|||||||
resolve(false)
|
resolve(false)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
PublicationAttachmentEntity.chucksManager.doneChunkUpload()
|
return await resolve(this.commit(PublicationAttachmentEntity))
|
||||||
const mergeRequest = await this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path)
|
|
||||||
|
|
||||||
if(mergeRequest.isOk()) {
|
|
||||||
PublicationAttachmentEntity.chucksManager.contentSetReady()
|
|
||||||
resolve(true)
|
|
||||||
} else {
|
|
||||||
resolve(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if ( PublicationAttachmentEntity.chucksManager.contentReady == false) {
|
||||||
|
|
||||||
|
return await resolve(this.commit(PublicationAttachmentEntity))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('already uploading')
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -413,6 +421,7 @@ export class ChucksManager {
|
|||||||
contentReady = false
|
contentReady = false
|
||||||
manualRetry = false
|
manualRetry = false
|
||||||
isUploading = false
|
isUploading = false
|
||||||
|
needToCommit = true
|
||||||
subscribeToUseCaseResponse: Function[] = []
|
subscribeToUseCaseResponse: Function[] = []
|
||||||
|
|
||||||
getUploadPercentage() {
|
getUploadPercentage() {
|
||||||
@@ -531,6 +540,10 @@ export class ChucksManager {
|
|||||||
this.onSetLastChunk.forEach(callback => callback());
|
this.onSetLastChunk.forEach(callback => callback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doneCommit() {
|
||||||
|
this.needToCommit = false
|
||||||
|
}
|
||||||
|
|
||||||
contentSetReady() {
|
contentSetReady() {
|
||||||
this.merging = false
|
this.merging = false
|
||||||
this.contentReady = true
|
this.contentReady = true
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
|
|
||||||
this.stopVideo();
|
this.stopVideo();
|
||||||
|
|
||||||
|
setTimeout(()=> {
|
||||||
|
this.doRefresh({})
|
||||||
|
}, 1500)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1916,6 +1916,7 @@
|
|||||||
PDFViewerApplication.open(new Uint8Array(xhr.response));
|
PDFViewerApplication.open(new Uint8Array(xhr.response));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log({file})
|
||||||
xhr.open('GET', file);
|
xhr.open('GET', file);
|
||||||
xhr.responseType = 'arraybuffer';
|
xhr.responseType = 'arraybuffer';
|
||||||
xhr.send();
|
xhr.send();
|
||||||
@@ -1923,7 +1924,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
PDFViewerApplication.open(file);
|
console.log({file})
|
||||||
|
PDFViewerApplication.open(new URLSearchParams(window.location.search).get('file'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -4245,7 +4247,7 @@
|
|||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
},
|
},
|
||||||
defaultUrl: {
|
defaultUrl: {
|
||||||
value: 'compressed.tracemonkey-pldi-09.pdf',
|
value: new URLSearchParams(window.location.search).get('file'),
|
||||||
kind: OptionKind.VIEWER
|
kind: OptionKind.VIEWER
|
||||||
},
|
},
|
||||||
defaultZoomValue: {
|
defaultZoomValue: {
|
||||||
|
|||||||
Reference in New Issue
Block a user