add new endpoint to save and get draft

This commit is contained in:
Peter Maquiran
2024-09-12 18:57:45 +01:00
parent 38f51bd7e1
commit 82d6a15d5e
10 changed files with 118 additions and 66 deletions
@@ -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);"> -->
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "f3e09cadf",
"SHA": "f3e09cadf241a72b4a79dbe59ac500ff54e0cea4",
"shortSHA": "38f51bd7e",
"SHA": "38f51bd7e14fe61747947721d048e7674d55ff9d",
"branch": "feature/agenda-api-peter",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Wed Sep 11 16:04:43 2024 +0100'",
"lastCommitMessage": "add endpoint to get document drafts",
"lastCommitNumber": "5901",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 1 commit.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: version/git-version.ts",
"lastCommitTime": "'Wed Sep 11 16:06:47 2024 +0100'",
"lastCommitMessage": "fix images",
"lastCommitNumber": "5902",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 2 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tnew file: src/app/module/agenda/domain/usecase/draft-save-by-id-use-case.service.ts\n\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n\tmodified: src/app/module/agenda/data/data-source/agenda-data.service.ts\n\tmodified: src/app/module/agenda/domain/agenda.service.ts\n\tmodified: src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts\n\tmodified: src/app/pages/gabinete-digital/viewer-attachment/prop.ts\n\tmodified: src/app/pages/gabinete-digital/viewer-attachment/viewer-attachment.page.html\n\tmodified: src/app/pages/gabinete-digital/viewer-attachment/viewer-attachment.page.scss\n\tmodified: src/app/pages/gabinete-digital/viewer-attachment/viewer-attachment.page.ts\n\tmodified: src/app/shared/gabinete-digital/generic/task-details/task-details.page.html",
"changeAuthor": "peter.maquiran"
}