This commit is contained in:
Peter Maquiran
2024-07-19 17:50:25 +01:00
parent f80e49d533
commit ef7edb3978
12 changed files with 332 additions and 67 deletions
@@ -671,6 +671,7 @@ export class DespachoPrPage implements OnInit {
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
"draft": true
}
this.mergedArray.push(object)
console.log('List of draff', resd)
@@ -231,6 +231,7 @@ export class DespachoPage implements OnInit {
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
"draft": true
}
this.mergedArray.push(object)
// console.log('List of draff', resd)
@@ -504,6 +504,7 @@ export class DiplomaAssinarPage implements OnInit {
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
"draft": true
};
this.draftArray.push(object);
this.mergedArray.push(object);
@@ -562,6 +562,7 @@ export class DiplomaPage implements OnInit {
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
"draft": true
}
this.mergedArray.push(object)
this.DraftNames = this.DraftNames + resd.data.description+";"
@@ -251,6 +251,8 @@ export class ExpedienteDetailPage implements OnInit {
this.processes.GetTask(serial).subscribe(res => {
console.log('LoadTaskDetail')
this.TaskService.loadExpedientes();
console.log("res========", res)
@@ -372,6 +374,7 @@ export class ExpedienteDetailPage implements OnInit {
modal.onDidDismiss().then(async (res) => {
if (res) {
console.log('attachment to add ==', res)
const data = res.data;
this.documents.push(data.selected);
let body
@@ -395,7 +398,15 @@ export class ExpedienteDetailPage implements OnInit {
try {
loader.remove()
await this.attachmentsService.AddAttachment(body).toPromise()
this.LoadTaskDetail(this.serialNumber);
console.log('attachment post')
setTimeout(() => {
this.LoadTaskDetail(this.serialNumber);
}, 1000);
setTimeout(() => {
this.LoadTaskDetail(this.serialNumber);
}, 4000);
this.toastService._successMessage()
} catch (error) {
if (error.status == 0) {
@@ -594,9 +605,8 @@ export class ExpedienteDetailPage implements OnInit {
await modal.present();
}
// mobile
async openOptions(taskAction?: any) {
if (window.innerWidth > 500) {
this.showOptions = true
@@ -613,7 +623,16 @@ export class ExpedienteDetailPage implements OnInit {
});
return await popover.present().then(() => {
this.TaskService.loadExpedientes()
this.LoadTaskDetail(this.serialNumber);
setTimeout(()=> {
this.LoadTaskDetail(this.serialNumber);
}, 1000)
setTimeout(()=> {
this.LoadTaskDetail(this.serialNumber);
}, 4000)
}, (error) => {
console.log(error)
})
@@ -6,7 +6,9 @@ import { DeviceService } from "src/app/services/device.service"
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { PermissionService } from 'src/app/services/permission.service';
import { HeaderSettingsService } from "src/app/services/header-settings.service"
import { from, Subject } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { Result } from 'neverthrow';
@Component({
selector: 'app-viewer-attachment',
@@ -17,6 +19,9 @@ export class ViewerAttachmentPage implements OnInit {
@Input() showAttachmentList = true;
@Input() selectedIndex = 0;
currentIndex = null;
currentLickTime = new Date();
swiperModules = [IonicSlides];
@Input() taskViewerAttachment: ViewerAttachment[];
viewer: {[key: string]: HTMLDivElement} = {}
@@ -27,19 +32,30 @@ export class ViewerAttachmentPage implements OnInit {
draft = false
loading = false
private fetchDataSubject = new Subject<any>();
constructor(
public middlewareRepositoryService: MiddlewareRepositoryService,
public DeviceService: DeviceService,
private processes: ProcessesService,
private erroHandler: HttpErrorHandle,
public p: PermissionService,
private processService: ProcessesService,
private HeaderSettingsService: HeaderSettingsService
) { }
ngOnInit() {
this.validateParams()
const selectFirst = this.taskViewerAttachment[0]
this.fetchDataSubject.pipe(
switchMap((data: any) => from(this.middlewareRepositoryService.getViewerLink(data)))
).subscribe({
next: (linkRequest) => {
this.renderViewer(linkRequest)
console.log({linkRequest})
},
error: (error) => console.error(error)
});
}
@@ -56,7 +72,6 @@ export class ViewerAttachmentPage implements OnInit {
firstLoad = true
async clickDocument(viewerAttachment: ViewerAttachment, i) {
this.draft = false
let count = 0
@@ -68,55 +83,52 @@ export class ViewerAttachmentPage implements OnInit {
return
}
try {
try {
this.selectedIndex = i;
this.iframeContainer.nativeElement.style.display = 'none'
const requestI = this.selectedIndex
const linkRequest = await this.middlewareRepositoryService.getViewerLink({
this.fetchDataSubject.next({
ApplicationId: viewerAttachment.ApplicationId,
DocId: viewerAttachment.DocId
})
if(linkRequest.isOk() && requestI == this.selectedIndex) {
// Optionally, you can add new content or recreate the iframe
var newIframe = document.createElement('iframe');
if(linkRequest.value.includes("http")) {
newIframe.src = linkRequest.value;
newIframe.width = '100%'
newIframe.height = '100%'
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer.nativeElement.appendChild(newIframe)
} else {
this.iframeContainer.nativeElement.innerHTML = "Sem documento"
}
this.loading = false
this.iframeContainer.nativeElement.style.display = 'flex'
} else if (requestI != this.selectedIndex) {
} else {
this.loading = false
this.iframeContainer.nativeElement.style.display = 'none'
}
} catch (error) {
setTimeout(async ()=> {
this.currentIndex = i
} catch (err) {
setTimeout(()=> {
this.clickDocument(viewerAttachment, i);
}, 1000)
}
}
renderViewer(linkRequest: Result<string, any>) {
if(linkRequest.isOk()) {
// Optionally, you can add new content or recreate the iframe
var newIframe = document.createElement('iframe');
if(linkRequest.value.includes("http")) {
newIframe.src = linkRequest.value;
newIframe.width = '100%'
newIframe.height = '100%'
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer.nativeElement.appendChild(newIframe)
} else {
this.iframeContainer.nativeElement.innerHTML = "Sem documento"
}
this.loading = false
this.iframeContainer.nativeElement.style.display = 'flex'
} else {
this.loading = false
this.iframeContainer.nativeElement.style.display = 'none'
}
}
validateParams() {
@@ -138,7 +150,10 @@ export class ViewerAttachmentPage implements OnInit {
this.draft = this.isSelectedAttachmentIsDraft(this.taskViewerAttachment[this.selectedIndex])
if(!this.draft) {
this.clickDocument(task, this.selectedIndex)
if(this.selectedIndex != this.currentIndex) {
this.clickDocument(task, this.selectedIndex)
}
}
}