mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add new endpoint to save and get draft
This commit is contained in:
@@ -10,6 +10,7 @@ import { EventListOutputDTO } from '../dto/eventListDTOOutput';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { IGetDraftListByProcessIdOutput, IGetDraftListByProcessIdSchema } from '../../domain/usecase/getDraft-list-by-process-id.service';
|
||||
import { IDraftSaveByIdInput } from '../../domain/usecase/draft-save-by-id-use-case.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -135,4 +136,8 @@ export class AgendaDataService {
|
||||
async getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
|
||||
return await this.httpService.get<IGetDraftListByProcessIdOutput>(`${this.baseUrl}/Contents/FolderId/${input.processId}`);
|
||||
}
|
||||
|
||||
async draftSaveById(input: IDraftSaveByIdInput) {
|
||||
return await this.httpService.put<IGetDraftListByProcessIdOutput>(`${this.baseUrl}/Contents/${input.id}`, input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { GetDraftListByProcessIdService, IGetDraftListByProcessIdSchema } from './usecase/getDraft-list-by-process-id.service';
|
||||
import { DraftSaveByIdInputSchema, DraftSaveByIdUseCaseService, IDraftSaveByIdInput } from './usecase/draft-save-by-id-use-case.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -7,10 +8,15 @@ import { GetDraftListByProcessIdService, IGetDraftListByProcessIdSchema } from '
|
||||
export class AgendaService {
|
||||
|
||||
constructor(
|
||||
private getDraftListByProcessIdService: GetDraftListByProcessIdService
|
||||
private getDraftListByProcessIdService: GetDraftListByProcessIdService,
|
||||
private DraftSaveByIdUseCaseService: DraftSaveByIdUseCaseService
|
||||
) { }
|
||||
|
||||
getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
|
||||
return this.getDraftListByProcessIdService.execute(input)
|
||||
}
|
||||
|
||||
draftSaveById(input: IDraftSaveByIdInput) {
|
||||
return this.DraftSaveByIdUseCaseService.execute(input)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from '../../data/data-source/agenda-data.service';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DraftSaveByIdInputSchema = z.object({
|
||||
description: z.string(),
|
||||
status: z.boolean(),
|
||||
content: z.string(),
|
||||
path: z.string(),
|
||||
ownerId: z.number(),
|
||||
id: z.number()
|
||||
})
|
||||
|
||||
export type IDraftSaveByIdInput= z.infer< typeof DraftSaveByIdInputSchema>
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DraftSaveByIdUseCaseService {
|
||||
|
||||
constructor(
|
||||
private agendaDataService: AgendaDataService
|
||||
) { }
|
||||
|
||||
async execute(input: IDraftSaveByIdInput) {
|
||||
return await this.agendaDataService.draftSaveById(input)
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export class DespachoPage implements OnInit {
|
||||
// this.updateProcessOnDB(res);
|
||||
this.fulltask = res;
|
||||
|
||||
this.getDocumentPdf(this.fulltask.Documents)
|
||||
this.getDocumentPdf({FolderID: res.workflowInstanceDataFields.FolderID})
|
||||
|
||||
console.log('All', this.mergedArray)
|
||||
|
||||
@@ -200,53 +200,59 @@ export class DespachoPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// getDocumentPdf({FolderID}) {
|
||||
// this.agendaService.getDraftListByProcessId({
|
||||
// processId: FolderID
|
||||
// }).then(( draftList => {
|
||||
getDocumentPdf({FolderID}) {
|
||||
this.agendaService.getDraftListByProcessId({
|
||||
processId: FolderID
|
||||
}).then(( draftList => {
|
||||
|
||||
// if(draftList.isOk()) {
|
||||
// const docObject = draftList.value.data.map((e) => ({
|
||||
// "ApplicationId": "",
|
||||
// "Assunto": e.description,
|
||||
// "DocDate": e.createdAt,
|
||||
// "DocId": "",
|
||||
// "DocNumber": "element.DocNumber",
|
||||
// "FolderId": e.folderId,
|
||||
// "Sender": "uuid",
|
||||
// "SourceDocId": "element.SourceDocId",
|
||||
// "content": "",
|
||||
// "path": "",
|
||||
// "ownerId": "",
|
||||
// "status": "",
|
||||
// }))
|
||||
if(draftList.isOk()) {
|
||||
const docObject = draftList.value.data.map((e) => ({
|
||||
"id": e.id,
|
||||
"ownerId": e.ownerId,
|
||||
"path": e.path,
|
||||
"description":e.description,
|
||||
"ApplicationId": "",
|
||||
"Assunto": e.description,
|
||||
"DocDate": e.createdAt,
|
||||
"DocId": "",
|
||||
"DocNumber": "element.DocNumber",
|
||||
"FolderId": e.folderId,
|
||||
"content": e.content,
|
||||
"Sender": "uuid",
|
||||
"SourceDocId": "element.SourceDocId",
|
||||
"status": e.status,
|
||||
}))
|
||||
|
||||
// this.mergedArray.push(docObject);
|
||||
// }
|
||||
// }));
|
||||
// }
|
||||
for(const file of docObject) {
|
||||
this.mergedArray.push(file);
|
||||
}
|
||||
|
||||
getDocumentPdf(Documents: any) {
|
||||
|
||||
Documents.forEach(element => {
|
||||
let docObject = {
|
||||
"ApplicationId": element.ApplicationId,
|
||||
"Assunto": element.Assunto,
|
||||
"DocDate": element.DocDate,
|
||||
"DocId": element.DocId,
|
||||
"DocNumber": element.DocNumber,
|
||||
"FolderId": element.FolderId,
|
||||
"Sender": element.Sender,
|
||||
"SourceDocId": element.SourceDocId,
|
||||
"content": "",
|
||||
"path": "",
|
||||
"ownerId": "",
|
||||
"status": "",
|
||||
}
|
||||
this.mergedArray.push(docObject);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// getDocumentPdf(Documents: any) {
|
||||
|
||||
// Documents.forEach(element => {
|
||||
// let docObject = {
|
||||
// "ApplicationId": element.ApplicationId,
|
||||
// "Assunto": element.Assunto,
|
||||
// "DocDate": element.DocDate,
|
||||
// "DocId": element.DocId,
|
||||
// "DocNumber": element.DocNumber,
|
||||
// "FolderId": element.FolderId,
|
||||
// "Sender": element.Sender,
|
||||
// "SourceDocId": element.SourceDocId,
|
||||
// "content": "",
|
||||
// "path": "",
|
||||
// "ownerId": "",
|
||||
// "status": "",
|
||||
// }
|
||||
// this.mergedArray.push(docObject);
|
||||
// });
|
||||
// }
|
||||
|
||||
@XTracerAsync({name:'task/getDraft', bugPrint: true})
|
||||
getDraft(split_stringDraft: string[], tracing?: TracingType) {
|
||||
split_stringDraft.forEach(element => {
|
||||
|
||||
@@ -11,8 +11,9 @@ export const ViewerAttachmentParams = z.object({
|
||||
SourceDocId: z.string(),
|
||||
content: z.string().nonempty(),
|
||||
path: z.string().nonempty(),
|
||||
ownerId: z.string().nonempty(),
|
||||
ownerId: z.number(),
|
||||
status: z.string().nonempty(),
|
||||
id: z.number().optional()
|
||||
})
|
||||
|
||||
export type ViewerAttachment = z.infer<typeof ViewerAttachmentParams>;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div>
|
||||
<div class="subject add-ellipsis">{{ attachment.Assunto || "Sem assunto" }}</div>
|
||||
<div class="user" >
|
||||
{{ attachment.Sender }}
|
||||
{{ attachment?.Sender }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -65,10 +65,10 @@
|
||||
</div>
|
||||
|
||||
<div class="flex-1" [ngClass]="{'container-img': loading}">
|
||||
<div [ngClass]="{'d-none': draft}" #iframeContainer class="height-100 flex-1 " [ngClass]="{'container-img': loading}" ></div>
|
||||
<div [ngClass]="{'d-none': draft, 'container-img': loading}" #iframeContainer class="height-100 flex-1 " ></div>
|
||||
|
||||
<editor
|
||||
*ngIf="taskViewerAttachment[selectedIndex].content"
|
||||
*ngIf="draft"
|
||||
class="container-img height-100 flex-1"
|
||||
apiKey="wr5dk69kive0qr9ig6y5spqvlj3a0tsiwnzdsexnz241k69p"
|
||||
[(ngModel)]="taskViewerAttachment[selectedIndex].content"
|
||||
|
||||
@@ -73,3 +73,7 @@ iframe {
|
||||
background-position-x: center;
|
||||
background-position-y: center;
|
||||
}
|
||||
|
||||
.d-none {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { from, Subject } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { Result } from 'neverthrow';
|
||||
|
||||
import { AgendaService } from 'src/app/module/agenda/domain/agenda.service'
|
||||
@Component({
|
||||
selector: 'app-viewer-attachment',
|
||||
templateUrl: './viewer-attachment.page.html',
|
||||
@@ -40,6 +40,7 @@ export class ViewerAttachmentPage implements OnInit {
|
||||
private erroHandler: HttpErrorHandle,
|
||||
public p: PermissionService,
|
||||
private processService: ProcessesService,
|
||||
private AgendaService: AgendaService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
@@ -169,27 +170,28 @@ export class ViewerAttachmentPage implements OnInit {
|
||||
// do other stuff...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
saveDraft(selectedIndex) {
|
||||
async saveDraft(selectedIndex) {
|
||||
// Lógica que deseja executar em intervalos regulares
|
||||
console.log('Intervalo de 3 segundos...');
|
||||
|
||||
const document = this.taskViewerAttachment[selectedIndex]
|
||||
let objectDraft = {
|
||||
|
||||
const saveResult = await this.AgendaService.draftSaveById({
|
||||
"status": false,
|
||||
"description": document.Assunto,
|
||||
"content": document.content,
|
||||
"path": document.path,
|
||||
"ownerId": document.ownerId
|
||||
}
|
||||
this.processService.SaveDraftByID(document.DocId, objectDraft).subscribe((res) => {
|
||||
console.log('Saved tinymce')
|
||||
|
||||
}, (error) => {
|
||||
this.erroHandler.httpStatusHandle(error)
|
||||
"ownerId": document.ownerId,
|
||||
"id": document.id
|
||||
})
|
||||
if(saveResult.isOk()) {
|
||||
console.log('Saved tinymce')
|
||||
} else {
|
||||
if(saveResult.error.status) {
|
||||
this.erroHandler.httpStatusHandle(saveResult.error)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
onEditorContentChange() {
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
<div class="flex-1 overflow-hidden">
|
||||
<p class="attach-title-item overflow-hidden">{{ Document.Assunto || "Sem assunto" }} <span class="document-type" *ngIf="Document.content">Rascunho</span></p>
|
||||
<p class="overflow-hidden"><span class="span-left">{{ Document.Sender}}</span><span class="span-right">{{ Document.DocDate | date: 'dd-MM-yyyy HH:mm' }}</span></p>
|
||||
<p class="overflow-hidden"><span class="span-left">{{ Document?.Sender}}</span><span class="span-right">{{ Document.DocDate | date: 'dd-MM-yyyy HH:mm' }}</span></p>
|
||||
</div>
|
||||
|
||||
<!-- <div class="d-flex justify-center align-center font-25" (click)="clickDocumentUPdateIndex(Document.DocId, Document, Document.content);"> -->
|
||||
|
||||
Reference in New Issue
Block a user