add either pattern

This commit is contained in:
Peter Maquiran
2024-07-09 12:36:46 +01:00
parent 06417ead0f
commit a26fbbddba
45 changed files with 985 additions and 701 deletions
+4
View File
@@ -313,6 +313,10 @@ const routes = [
{
path: 'event-recurrence',
loadChildren: () => import('./modals/event-recurrence/event-recurrence.module').then( m => m.EventRecurrencePageModule)
},
{
path: 'delete-event-recurrence',
loadChildren: () => import('./modals/delete-event-recurrence/delete-event-recurrence.module').then( m => m.DeleteEventRecurrencePageModule)
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DeleteEventRecurrencePage } from './delete-event-recurrence.page';
const routes: Routes = [
{
path: '',
component: DeleteEventRecurrencePage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class DeleteEventRecurrencePageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { DeleteEventRecurrencePageRoutingModule } from './delete-event-recurrence-routing.module';
import { DeleteEventRecurrencePage } from './delete-event-recurrence.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
DeleteEventRecurrencePageRoutingModule
],
declarations: [DeleteEventRecurrencePage]
})
export class DeleteEventRecurrencePageModule {}
@@ -0,0 +1,22 @@
<ion-content>
<div class="pb-30 text-center pt-25">Este é um evento recorrente</div>
<div>
<ion-buttons slot="start" class="pb-15">
<button class="btn-ok" style="width: 240px !important" fill="clear" color="#fff" (click)="close('DeleteAll')" >
<ion-label>Eliminar todos eventos da serie</ion-label>
</button>
</ion-buttons>
<ion-buttons slot="end" class="pb-15">
<button class="btn-cancel" fill="clear" color="#061b52" style="width: 240px !important" (click)="close('DeleteOne')">
<ion-label>Eliminar apenas este evento</ion-label>
</button>
</ion-buttons>
<ion-buttons slot="end">
<button class="btn-cancel" fill="clear" color="#061b52" style="width: 240px !important" (click)="close('Cancel')">
<ion-label>Cancelar</ion-label>
</button>
</ion-buttons>
</div>
</ion-content>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { DeleteEventRecurrencePage } from './delete-event-recurrence.page';
describe('DeleteEventRecurrencePage', () => {
let component: DeleteEventRecurrencePage;
let fixture: ComponentFixture<DeleteEventRecurrencePage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ DeleteEventRecurrencePage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(DeleteEventRecurrencePage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
export type EventDeleteRecurrenceComponentReturn = 'DeleteAll' | 'DeleteOne' | 'Cancel'
@Component({
selector: 'app-delete-event-recurrence',
templateUrl: './delete-event-recurrence.page.html',
styleUrls: ['./delete-event-recurrence.page.scss'],
})
export class DeleteEventRecurrencePage implements OnInit {
constructor(
private modalController: ModalController
) { }
ngOnInit() {
}
close(data: EventDeleteRecurrenceComponentReturn) {
this.modalController.dismiss(data)
}
}
+19
View File
@@ -0,0 +1,19 @@
import { z } from "zod";
const userSchema = z.object({
Id: z.number(),
EmailAddress: z.string().optional(),
Name: z.string(),
IsRequired: z.boolean(),
UserType: z.string(),
IsPR: z.boolean(),
Entity: z.string(),
Acknowledgment: z.boolean(),
RoleDescription: z.string().nullable(),
RoleId: z.number(),
});
const usersSchema = z.array(userSchema);
export type UserListItem = z.infer<typeof userSchema>
export type UserList = z.infer<typeof usersSchema>
@@ -0,0 +1,17 @@
export interface NotificationLive {
id: string;
title: string;
Service: string;
Object: string;
IdObject: string;
FolderId: string;
body: string;
dateInit: string; // Assuming dateInit and dateEnd are strings representing formatted dates
dateEnd: string;
Location: string;
TypeAgenda: string;
Role: string;
Status: string;
read: boolean;
}
@@ -6,12 +6,18 @@ import { LocalNotificationService } from './datasource/local-notification.servic
import { SessionStore } from 'src/app/store/session.service';
import { NotificationListMapper } from '../domain/mapper/notificationListMapper';
import { NotificationTable } from './infra/db/notification.db';
import { Observable, Subject } from 'rxjs';
import { filter } from 'rxjs/operators';
import { NotificationMapper } from '../domain/mapper/notificationMapper';
import { NotificationLive } from './dto/NotificationLiveOutputDTO';
@Injectable({
providedIn: 'root'
})
export class NotificationRepositoryService {
private notificationSubject: Subject<NotificationLive> = new Subject<NotificationLive>();
constructor(
private RemoteNotificationService: RemoteNotificationService,
private FirebasePushNotificationService: FirebasePushNotificationService,
@@ -19,10 +25,9 @@ export class NotificationRepositoryService {
) {
this.FirebasePushNotificationService.onReceiveForeground(async (data)=> {
this.notificationSubject.next(NotificationMapper(data));
console.log('FirebasePushNotificationService', data)
this.init()
})
@@ -32,6 +37,12 @@ export class NotificationRepositoryService {
}
listenToEventNotification(): Observable<any> {
return this.notificationSubject.pipe(
filter(notification => notification.Service == 'agenda' )
)
}
async init() {
const result = await this.getNotification({
PageNumber: "1",
@@ -0,0 +1,80 @@
import { v4 as uuidv4 } from 'uuid'
import { NotificationLive } from '../../data/dto/NotificationLiveOutputDTO';
function getFormatedTime(dateString) {
var date = new Date(dateString);
var hours = date.getHours() /* > 12 ? date.getHours() - 12 : date.getHours() */;
var am_pm = date.getHours() >= 12 ? "pm" : "am";
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let time = hours + ":" + minutes /* + " " + am_pm */;
return time;
}
export function NotificationMapper(notification: any): NotificationLive {
let notificationObject;
if (notification.notification) {
notificationObject = {
id: notification?.id || uuidv4(),
title: notification.notification.title,
Service: notification.data.Service || notification.data.service,
Object: notification.data.Object || notification.data.object,
IdObject: notification.data.IdObject || notification.data.idObject,
FolderId: notification.data.FolderId || notification.data.folderId,
body: notification.notification.body,
dateInit: getFormatedTime(notification.data.dateInit),
dateEnd: getFormatedTime(notification.data.dateEnd),
Location: notification.data.Location,
TypeAgenda: notification.data.TypeAgenda,
Role: notification.data.Role,
Status: notification.data.Status,
read: false,
}
} else if (notification.data) {
notificationObject = {
id: notification?.id || uuidv4(),
title: notification.title,
Service: notification.data.Service || notification.data.service,
Object: notification.data.Object || notification.data.object,
IdObject: notification.data.IdObject || notification.data.idObject,
FolderId: notification.data.FolderId || notification.data.folderId,
body: notification.body,
dateInit: getFormatedTime(notification.data.dateInit),
dateEnd: getFormatedTime(notification.data.dateEnd),
Location: notification.data.Location,
TypeAgenda: notification.data.TypeAgenda,
Role: notification.data.Role,
Status: notification.data.Status,
read: false,
}
} else {
{
notificationObject = {
id: notification?.id || uuidv4(),
FolderId: notification.FolderId || notification.data.folderId,
IdObject: notification.IdObject || notification.data.idObject,
Location: notification.Location,
Object: notification.Object || notification.data.object,
Role: notification.Role,
Service: notification.Service || notification.data.service,
Status: notification.Status,
TypeAgenda: notification.TypeAgenda,
body: notification.body,
dateEnd: notification.dateEnd,
dateInit: notification.dateInit,
index: notification.index,
title: notification.title,
read: false,
}
}
}
return notificationObject
}
+23 -4
View File
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, Inject, LOCALE_ID } from '@angular/core';
import { Component, OnInit, ViewChild, Inject, LOCALE_ID, OnDestroy } from '@angular/core';
import { CalendarComponent } from 'ionic2-calendar';
import { ModalController } from '@ionic/angular';
import { EventsService } from 'src/app/services/events.service';
@@ -35,15 +35,17 @@ import { environment } from 'src/environments/environment';
import { RoleIdService } from 'src/app/services/role-id.service'
import { EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { Cy } from 'cypress/enum'
import { Observable } from 'rxjs';
import { Observable, Subject, Subscription } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { map } from 'rxjs/operators';
import { map, throttleTime } from 'rxjs/operators';
import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
import { ToastService } from 'src/app/services/toast.service';
import { CalendarState, selectEventSource } from 'src/app/services/Repositorys/Agenda/agenda-memory-source.service';
import { Store } from '@ngrx/store';
import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service';
import { Unsubscribable } from '../../../../android/app/build/intermediates/assets/debug/public/assets/dexie/dist/dexie';
@Component({
selector: 'app-agenda',
templateUrl: './agenda.page.html',
@@ -188,6 +190,9 @@ export class AgendaPage implements OnInit {
hasChangeCalendar = false
eventSource$ = this.store.select(selectEventSource);
private NotificationUpdate = new Subject<void>();
listenToEventNotificationSubscription!: Subscription;
constructor(
@Inject(LOCALE_ID) private locale: string,
@@ -203,9 +208,20 @@ export class AgendaPage implements OnInit {
public RoleIdService: RoleIdService,
public AgendaDataRepositoryService: AgendaDataRepositoryService,
private toastService: ToastService,
private store: Store<CalendarState>
private store: Store<CalendarState>,
private notificationRepository: NotificationRepositoryService
) {
this.NotificationUpdate.pipe(
throttleTime(1000) // Prevents the function from being called more than once per second
).subscribe(() => {
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
});
this.listenToEventNotificationSubscription = this.notificationRepository.listenToEventNotification().subscribe(() => {
this.NotificationUpdate.next()
})
this.selectedUserCalendar = SessionStore.user.UserId
this.AgendaDataRepositoryService.getSharedCalendar().then(async ()=> {
this.setCalendarByDefault(true)
@@ -291,6 +307,9 @@ export class AgendaPage implements OnInit {
this.weekToShow()
}
OnDestroy() {
this.listenToEventNotificationSubscription?.unsubscribe()
}
hasPrCalendar(data: TableSharedCalendar[]) {
for(const e of data) {
@@ -456,15 +456,18 @@ export class EditEventPage implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, this.editAllEvent, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.close();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
tracing.setAttribute('outcome', 'success')
}, ((error) => {
tracing.setAttribute('outcome', 'failed')
console.log('edit event error: ', error)
}));
const value = await this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, this.editAllEvent, calendar.value, tracing)//.subscribe((value) => {
if(value.isOk()) {
console.log(value.value)
this.close();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
tracing.setAttribute('outcome', 'success')
} else {
tracing.setAttribute('outcome', 'failed')
console.log('edit event error: ', value.error)
}
console.log({serverCurrentList: this.serverCurrentList, Attendees: this.postEvent.Attendees})
@@ -472,7 +475,7 @@ export class EditEventPage implements OnInit {
console.log({insert, remove })
if(insert.length >= 1) {
this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, insert).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, insert, tracing).subscribe((value) => {
console.log(value)
}, ((error) => {
tracing.setAttribute('failed.attendees', 'true')
@@ -62,24 +62,19 @@ export class EventActionsPopoverPage implements OnInit {
const loader = this.toastService.loading()
try {
/* await this.processes.PostTaskAction(body).toPromise() */
this.agendaDataRepository.approveEvent(this.serialNumber).subscribe((value) => {
console.log(value)
const value = await this.agendaDataRepository.approveEvent(this.serialNumber)// .subscribe((value) => {
if(value.isOk()) {
console.log(value.value)
this.TaskService.loadEventosParaAprovacao()
this.httpErrorHandle.httpsSucessMessagge('Evento aprovação')
this.goBack();
}, ((error) => {
console.log('aprove event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} else {
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
console.log('aprove event error: ', value.error)
this.httpErrorHandle.httpStatusHandle(value.error)
}
loader.remove()
}
}
@@ -130,22 +125,17 @@ export class EventActionsPopoverPage implements OnInit {
const loader = this.toastService.loading()
try {
/* await this.processes.PostTaskAction(body).toPromise(); */
this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Revision', res.data.note).subscribe((value) => {
this.httpErrorHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao()
this.goBack();
}, ((error) => {
console.log('send event to revision error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}));
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
const result = await this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Revision', res.data.note)// .subscribe((value) => {
if(result.isOk()) {
this.httpErrorHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao()
this.goBack();
} else {
console.log('send event to revision error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove()
} else {
}
@@ -160,22 +150,16 @@ export class EventActionsPopoverPage implements OnInit {
let body = { "serialNumber": this.serialNumber, "action": "Descartar" }
const loader = this.toastService.loading();
try {
/* await this.processes.PostTaskAction(body).toPromise(); */
this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Declined', '').subscribe((value) => {
this.TaskService.loadEventosParaAprovacao()
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.goBack();
}, ((error) => {
console.log('reject event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove();
const result = await this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Declined', '')//.subscribe((value) => {
if(result.isOk()) {
this.TaskService.loadEventosParaAprovacao()
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.goBack();
} else {
console.log('reject event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove();
}
@@ -498,20 +498,21 @@ export class NewEventPage implements OnInit {
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.IsAllDayEvent = this.allDayCheck;
try {
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing).toPromise()
console.log(value)
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing)
if(value.isOk()) {
console.log(value.value)
loader.remove()
this.hhtpErrorHandle.httpsSucessMessagge('new event')
let data = Object.assign(this.postEvent)
this.modalController.dismiss(data);
tracing.setAttribute('outcome', 'success');
} catch(error) {
} else {
tracing.setAttribute('outcome', 'failed');
console.log('create event error: ', error)
console.log('create event error: ', value.error)
loader.remove()
}
} else {
}
@@ -519,22 +520,6 @@ export class NewEventPage implements OnInit {
}
//This method return calendar id
selectedCalendarId() {
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.postEvent.CalendarName == 'Oficial') {
return this.eventService.calendarNamesType[this.CalendarName]['OficialId']
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal'] && this.postEvent.CalendarName == 'Pessoal') {
return this.eventService.calendarNamesType[this.CalendarName]['PessoalId']
} else {
return '11:11'
}
}
//This method return calendar onwner user id
selectedCalendarUserId() {
@@ -19,6 +19,7 @@ import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
import { PermissionService } from 'src/app/services/permission.service';
import { DeleteEventRecurrencePage, EventDeleteRecurrenceComponentReturn } from 'src/app/modals/delete-event-recurrence/delete-event-recurrence.page';
@Component({
selector: 'app-view-event',
@@ -186,42 +187,33 @@ export class ViewEventPage implements OnInit {
}
deleteYesOrNo() {
async deleteYesOrNo() {
if (this.loadedEvent.IsRecurring) {
this.alertController.create({
header: 'Eliminar evento?',
message: 'Este evento tem recorrência, deseja eliminar a Sequência de eventos?',
inputs: [
{
name: 'confirm',
type: 'checkbox',
label: '',
value: 'confirm',
checked: false,
}
],
buttons: [
{
text: 'Sim',
handler: (data) => {
if (data.includes('confirm')) {
this.deleteEvent(true);
} else {
this.deleteEvent(false);
}
}
},
{
text: 'Não',
handler: () => {
// sconsole.log('Let me think');
}
}
]
}).then(res => {
res.present();
const modal = await this.modalController.create({
component: DeleteEventRecurrencePage,
componentProps: {},
cssClass: 'event-recurrence-modal',
});
modal.onDidDismiss().then((res) => {
const data: EventDeleteRecurrenceComponentReturn = res.data
if(data =='DeleteAll') {
this.deleteEvent(true);
} else if (data == 'DeleteOne') {
this.deleteEvent(false);
} else if(data == 'Cancel') {
this.close()
} else {
this.close()
}
});
await modal.present();
} else {
this.alertController.create({
header: 'Eliminar evento?',
@@ -247,13 +239,14 @@ export class ViewEventPage implements OnInit {
}
deleteEvent(deleteAll) {
async deleteEvent(deleteAll) {
const loader = this.toastService.loading()
console.log(this.loadedEvent.EventId)
this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll).subscribe(async () => {
const result = await this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll)//.subscribe(async () => {
if(result.isOk()) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento removido',
@@ -265,14 +258,14 @@ export class ViewEventPage implements OnInit {
}, 1500);
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('delete event')
}, (error) => {
console.log('delete event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}, () => {
loader.remove();
});
} else {
console.log('delete event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove();
}
@@ -143,27 +143,22 @@ export class ApproveEventPage implements OnInit {
const loader = this.toastService.loading()
try {
const result = await this.AgendaDataRepositoryService.approveEvent(serialNumber)//.subscribe(async (value) => {
this.AgendaDataRepositoryService.approveEvent(serialNumber).subscribe(async (value) => {
if(result.isOk()) {
await this.processes.PostTaskAction(body).toPromise()
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Evento aprovação')
this.TaskService.loadEventosParaAprovacao();
await this.processes.PostTaskAction(body).toPromise()
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Evento aprovação')
this.TaskService.loadEventosParaAprovacao();
} else {
}, ((error) => {
console.log('aprove event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
console.log('aprove event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove()
}
async emendTask(serialNumber: string) {
@@ -193,28 +188,25 @@ export class ApproveEventPage implements OnInit {
}
const loader = this.toastService.loading()
const loader = this.toastService.loading()
try {
this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Revision', res.data.note).subscribe((value) => {
const result = await this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Revision', res.data.note)//.subscribe((value) => {
if(result.isOk()) {
this.httpErrorHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
}, ((error) => {
console.log('send event to revision error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
this.offlineManager.storeRequestData('event-listRever', body);
}));
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
} finally {
} else {
console.log('send event to revision error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
this.offlineManager.storeRequestData('event-listRever', body);
}
loader.remove()
}
}
}, (error) => {
console.log(error)
});
@@ -227,22 +219,19 @@ export class ApproveEventPage implements OnInit {
let body = { "serialNumber": serialNumber, "action": "Descartar" }
const loader = this.toastService.loading()
try {
/* await this.processes.PostTaskAction(body).toPromise(); */
this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Declined', '').subscribe((value) => {
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
}, ((error) => {
console.log('reject event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
/* await this.processes.PostTaskAction(body).toPromise(); */
const result = await this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Declined', '')//.subscribe((value) => {
if(result.isOk()) {
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
} else {
console.log('reject event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove()
}
async viewDocument(DocId: string, Document) {
@@ -369,27 +369,29 @@ export class BookMeetingModalPage implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
try {
const value = await this.agendaDataRepository.createEvent(postData, this.documents, calendar.value, tracing).toPromise()
console.log(value)
const value = await this.agendaDataRepository.createEvent(postData, this.documents, calendar.value, tracing)
if(value.isOk()) {
console.log(value.value)
this.httpErroHandle.httpsSucessMessagge('new event')
loader.remove();
tracing.setAttribute('outcome', 'success')
this.close();
} catch (error) {
} else {
if(!isHttpError(error)) {
if(!isHttpError(value.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #1')
console.log(error)
console.log(value.error)
tracing.bugFlag()
} else {
this.httpErroHandle.httpStatusHandle(error.status)
this.httpErroHandle.httpStatusHandle(value.error.status)
}
console.log('create event error: ', error)
console.log('create event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
}
} else {
@@ -19,7 +19,6 @@ import { EventToApproveDataOutputDTOSchema } from './model/eventToApproveListOut
import { EventOutputDTOSchema } from './model/eventDTOOutput';
import { SharedCalendarListDetectChanges } from './async/change/shareCalendarChangeDetector';
import { SharedCalendarListItemOutputDTO } from './model/sharedCalendarOutputDTO';
import { EventInputDTOSchema } from './agendaDataModels';
import { EventUpdateInputDTOSchema } from './model/eventUpdateInputDtO';
import { AttachInputDTOSchema } from './model/addAttachmentDTOInput';
import { EventListDataOutputDTOSchema } from './model/eventListDTOOutput';
@@ -29,6 +28,8 @@ import { CalendarState, pushEvent, removeRangeForCalendar, selectEventsInRange }
import { NativeNotificationService } from 'src/app/services/native-notification.service';
import { ListBoxService } from 'src/app/services/agenda/list-box.service';
import { EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { AttendeeInputDTOSchema } from './model/attendeeInputDTO';
import { EventInputDTOSchema } from './model/eventInputDTO';
@Injectable({
providedIn: 'root'
})
@@ -59,61 +60,31 @@ export class AgendaDataRepositoryService {
}
async getEventById(id: string, tracing?: TracingType) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
APINODReturn(EventOutputDTOSchema, response, `get/Events/${id}`, tracing)
return EventMapper.toDomain(response)
})
).toPromise()
return ok(result)
} catch (e) {
tracing.setAttribute('eventId', id)
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
if (e.status == 400) {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
}
} else {
tracing?.bugFlag()
tracing.setAttribute('outcome', 'failed')
tracing?.setAttribute('map.error', 'true')
tracing?.setAttribute('map.error.context', JSON.stringify(e))
}
return err(e as HttpErrorResponse)
const result = await this.agendaDataService.getEvent(id, tracing)
if(result.isOk()) {
APINODReturn(EventOutputDTOSchema, result.value, `get/Events/${id}`, tracing)
return result.map(e => EventMapper.toDomain(e))
}
return result
}
async getEventToApproveById(id: string, tracing?: TracingType) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
APINODReturn(EventOutputDTOSchema, response, `get/Events/${id}`, tracing)
console.log('response',response)
console.log('ToDomain',EventToApproveDetailsMapper.toDomain(response))
return EventToApproveDetailsMapper.toDomain(response)
})
).toPromise()
return ok(result)
} catch (e) {
tracing.setAttribute('eventId', id)
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
if (e.status == 400) {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
}
} else {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
tracing?.setAttribute('map.error', 'true')
tracing?.setAttribute('map.error.context', JSON.stringify(e))
}
return err(e as HttpErrorResponse)
const result = await this.agendaDataService.getEvent(id)
if(result.isOk()) {
APINODReturn(EventOutputDTOSchema, result.value, `get/Events/${id}`, tracing)
return result.map(e => EventToApproveDetailsMapper.toDomain(e))
}
return result
}
async searchEvent(queryParameters: {value, status}, tracing?: TracingType) {
@@ -126,94 +97,69 @@ export class AgendaDataRepositoryService {
async EventList({ userId, startDate, endDate, status = EEventFilterStatus.Approved, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
const result = await this.agendaDataService.getEvents({userId, startDate, endDate, status, category, type})
if(result.isOk()) {
return result.map(response => {
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
let profile;
let profile;
if (SessionStore.user.Profile == 'PR') {
profile = "pr"
} else if (userId == SessionStore.user.UserId as any) {
profile = 'md'
} else {
profile = "pr"
if (SessionStore.user.Profile == 'PR') {
profile = "pr"
} else if (userId == SessionStore.user.UserId as any) {
profile = 'md'
} else {
profile = "pr"
}
const listToPresent = ListEventMapper.toDomain(response, calendarOwnerName, userId)
const map : EventListStore[] = listToPresent.map( element => {
return {
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: userId
}
const listToPresent = ListEventMapper.toDomain(response, calendarOwnerName, userId)
const map : EventListStore[] = listToPresent.map( element => {
return {
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: userId
}
}) as any
}) as any
const year = this.listBoxService.list(map, 'md', startDate, endDate, { selectedDate: new Date() })
const events = this.utils.getAllEvents(year)
this.NativeNotificationService.scheduleNotifications(events)
const year = this.listBoxService.list(map, 'md', startDate, endDate, { selectedDate: new Date() })
const events = this.utils.getAllEvents(year)
this.NativeNotificationService.scheduleNotifications(events)
this.memoryStore.pipe(
select(selectEventsInRange(startDate, endDate, userId))
).subscribe((localList)=> {
// console.log({localList})
});
this.memoryStore.pipe(
select(selectEventsInRange(startDate, endDate, userId))
).subscribe((localList)=> {
// console.log({localList})
});
// this.memoryStore.dispatch(removeRangeForCalendar({ startDate, endDate, userId }));
// this.memoryStore.dispatch(pushEvent({ eventsList:eventsList as any, userId, profile }));
this.memoryStore.dispatch(removeRangeForCalendar({ startDate, endDate, userId }));
this.memoryStore.dispatch(pushEvent({ eventsList:listToPresent as any, userId, profile }));
return listToPresent
}
)).toPromise()
return ok(result)
} catch (e) {
if(isHttpError(e)) {
console.log(e.status)
tracing?.setAttribute('status.code', e.status.toString())
if (e.status == 400) {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
}
} else {
tracing?.setAttribute('map.error', 'true')
tracing?.setAttribute('map.error.context', JSON.stringify(e))
}
return err(e as HttpErrorResponse)
return listToPresent
})
}
return result
}
async eventToApproveList({ userId, startDate = null, endDate = null, status = EEventFilterStatus.Pending, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null, tracing).pipe(
map((response) => {
APINODReturn(EventToApproveDataOutputDTOSchema, response, 'get/ApproveList', tracing)
return EventListToApproveMapper.toDomain(response, calendarOwnerName, userId)
}
)).toPromise()
const result = await this.agendaDataService.getEvents({userId, startDate : null, endDate: null, status, category: null, type: null}, tracing)
return result.map(response => {
APINODReturn(EventToApproveDataOutputDTOSchema, response, 'get/ApproveList', tracing)
return EventListToApproveMapper.toDomain(response, calendarOwnerName, userId)
})
return ok(result)
} catch (e) {
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
if (e.status == 400) {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
}
} else {
tracing?.setAttribute('map.error', 'true')
tracing?.setAttribute('map.error.context', JSON.stringify(e))
}
return err(e as HttpErrorResponse)
}
}
createEvent(eventData: Event, documents, calendar: TableSharedCalendar, tracing: TracingType) {
@@ -278,14 +224,17 @@ export class AgendaDataRepositoryService {
return this.agendaDataService.updateEvent(eventId, eventInput)
}
addEventAttendee(id, attendeeData) {
addEventAttendee(id, attendeeData, tracing?: TracingType) {
console.log(attendeeData)
console.log(this.utils.attendeesEdit(attendeeData))
const data = { attendees: this.utils.attendeesAdded(attendeeData) }
APINODReturn(AttendeeInputDTOSchema, data, `PUT/Events/${id}/Attendee`, tracing)
return this.agendaDataService.addEventAttendee(id, { attendees: this.utils.attendeesAdded(attendeeData) });
}
removeEventAttendee(id, attendeeData: {Id : string}[]) {
return this.agendaDataService.removeEventAttendee(id, { attendees: attendeeData.map(e => e.Id || e['id']) } );
@@ -309,12 +258,7 @@ export class AgendaDataRepositoryService {
async deleteEvent1(eventId) {
try {
const result = await this.agendaDataService.deleteEvent(eventId, false).toPromise()
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
return await this.agendaDataService.deleteEvent(eventId, false)
}
@@ -3,9 +3,8 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { EventInputDTO } from './model/eventInputDTO';
import { SessionStore } from 'src/app/store/session.service';
import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from './model/sharedCalendarOutputDTO';
import { SharedCalendarListOutputDTO } from './model/sharedCalendarOutputDTO';
import { HttpService } from '../../http.service';
import { APIReturn } from '../../decorator/api-validate-schema.decorator';
import { TracingType } from '../../monitoring/opentelemetry/tracer';
import { EventOutputDTO } from './model/eventDTOOutput';
import { AttendeesRemoveInputDTO } from './model/attendeeRemoveInputDTO';
@@ -23,36 +22,34 @@ export class AgendaDataService {
private httpService: HttpService
) { }
getContacts(value: string): Observable<any> {
const params = new HttpParams().set('value', value);
return this.http.get<any>(`${this.baseUrl}/Contacts`, { params });
}
// Documents Endpoints
getAttachments(subject: string, applicationType: number): Observable<any> {
const params = new HttpParams()
.set('Subject', subject)
.set('ApplicationType', applicationType.toString());
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
getAttachments(subject: string, applicationType: number) {
const params = {
Subject: subject,
ApplicationType: applicationType.toString()
}
return this.httpService.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
}
viewDocument(userId: number, docId: number, applicationId: number): Observable<any> {
viewDocument(userId: number, docId: number, applicationId: number) {
const params = new HttpParams()
.set('userId', userId.toString())
.set('docId', docId.toString())
.set('applicationId', applicationId.toString());
return this.http.get<any>(`${this.baseUrl}/Documents/view`, { params });
return this.httpService.get<any>(`${this.baseUrl}/Documents/view`, params);
}
// Events Endpoints
createEvent(eventData: EventInputDTO) {
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
return this.httpService.post<any>(`${this.baseUrl}/Events`, eventData);
}
// @APIReturn(EventListOutputDTOSchema, 'get/Events')
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string, tracing?: TracingType): Observable<EventListOutputDTO> {
let params = new HttpParams()
.set('UserId', userId)
getEvents({userId, startDate, endDate, status, category, type }, tracing?: TracingType) {
let params: any = {
UserId: userId
}
if(userId == null || userId == undefined) {
throw('userId '+ userId)
@@ -60,43 +57,45 @@ export class AgendaDataService {
if(status != null || status != undefined) {
params = params.set('status', status);
params.status = status;
}
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
params.startDate = startDate;
}
if (endDate !== null && endDate !== undefined) {
params = params.set('endDate', endDate);
params.endDate = endDate;
}
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
return this.httpService.get<EventListOutputDTO>(`${this.baseUrl}/Events`, params, tracing);
}
searchEvent(queryParameter: {value, status}) {
return this.httpService.get<EventListOutputDTO>(`${this.baseUrl}/Events`, queryParameter);
}
getEvent(id: string): Observable<EventOutputDTO> {
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
getEvent(id: string, tracing?: TracingType) {
return this.httpService.get<EventOutputDTO>(`${this.baseUrl}/Events/${id}`, {}, tracing);
}
updateEvent(id: string, eventData: any): Observable<any> {
return this.http.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
updateEvent(id: string, eventData: any) {
return this.httpService.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
}
approveEvent(id: string): Observable<any> {
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
approveEvent(id: string) {
return this.httpService.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
}
deleteEvent(id: string, deleteAllEvents: boolean): Observable<any> {
const params = new HttpParams().set('DeleteAllEvents', deleteAllEvents.toString());
return this.http.delete<any>(`${this.baseUrl}/Events/${id}`, { params });
async deleteEvent(id: string, deleteAllEvents: boolean) {
const params = {
'DeleteAllEvents': deleteAllEvents.toString()
};
return this.httpService.delete<any>(`${this.baseUrl}/Events/${id}`, params);
}
updateEventStatus(id: string, statusData: any): Observable<any> {
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
updateEventStatus(id: string, statusData: Object) {
return this.httpService.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
}
addEventAttendee(id: string, attendeeData: any): Observable<any> {
@@ -116,20 +115,6 @@ export class AgendaDataService {
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attachment`, { body: attachmentData });
}
communicateEvent(id: string, communicationData: any): Observable<any> {
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Communicate`, communicationData);
}
// Users Endpoints
getUsers(value: string): Observable<any> {
const params = new HttpParams().set('value', value);
return this.http.get<any>(`${this.baseUrl}/Users`, { params });
}
getToken(): Observable<any> {
return this.http.get<any>(`${this.baseUrl}/Users/token`);
}
getDocumentAttachment(aplicationId,userId,value,PageNumber,PageSize): Observable<any> {
const params = new HttpParams()
@@ -1,151 +1,151 @@
import { z } from 'zod';
// import { z } from 'zod';
export const AttachCommunicationInputDTOSchema = z.object({
attachmentId: z.string().uuid(),
description: z.string().nullable().optional(),
typeSharing: z.number().int(),
dateViewExpire: z.string().datetime().nullable().optional(),
}).strict();
// export const AttachCommunicationInputDTOSchema = z.object({
// attachmentId: z.string().uuid(),
// description: z.string().nullable().optional(),
// typeSharing: z.number().int(),
// dateViewExpire: z.string().datetime().nullable().optional(),
// }).strict();
export const AttachmentInputDTOSchema = z.object({
sourceId: z.string().nullable().optional(),
sourceName: z.string().nullable().optional(),
description: z.string().nullable().optional(),
applicationId: z.number().int(),
}).strict();
// export const AttachmentInputDTOSchema = z.object({
// sourceId: z.string().nullable().optional(),
// sourceName: z.string().nullable().optional(),
// description: z.string().nullable().optional(),
// applicationId: z.number().int(),
// }).strict();
export const AttendeeCommunicationInputDTOSchema = z.object({
attendeeId: z.string().uuid(),
message: z.string().nullable().optional(),
}).strict();
// export const AttendeeCommunicationInputDTOSchema = z.object({
// attendeeId: z.string().uuid(),
// message: z.string().nullable().optional(),
// }).strict();
export const AttendeeExternalInputDTOSchema = z.object({
name: z.string().min(1),
emailAddress: z.string().email().nullable().optional(),
message: z.string().nullable().optional(),
}).strict();
// export const AttendeeExternalInputDTOSchema = z.object({
// name: z.string().min(1),
// emailAddress: z.string().email().nullable().optional(),
// message: z.string().nullable().optional(),
// }).strict();
export const AttendeeInputDTOSchema = z.object({
name: z.string().min(1),
emailAddress: z.string().nullable().optional(),
attendeeType: z.number(),
wxUserId: z.number().int(),
}).strict();
// export const AttendeeInputDTOSchema = z.object({
// name: z.string().min(1),
// emailAddress: z.string().nullable().optional(),
// attendeeType: z.number(),
// wxUserId: z.number().int(),
// }).strict();
const EAttendeeTypeDTO = z.number();
// const EAttendeeTypeDTO = z.number();
const EEventCategoryDTO = z.number();
// const EEventCategoryDTO = z.number();
const EEventFilterCategoryDTO = z.number();
// const EEventFilterCategoryDTO = z.number();
const EEventFilterStatusDTO = z.number();
// const EEventFilterStatusDTO = z.number();
const EEventFilterTypeDTO = z.number();
// const EEventFilterTypeDTO = z.number();
const EEventOwnerTypeDTO = z.number();
// const EEventOwnerTypeDTO = z.number();
const EEventStatusDTO = z.number();
// const EEventStatusDTO = z.number();
const EEventTypeDTO = z.number();
// const EEventTypeDTO = z.number();
const ERecurringTypeDTO = z.number();
// const ERecurringTypeDTO = z.number();
const EventAddAttachmentDTOSchema = z.object({
attachments: z.array(AttachmentInputDTOSchema),
}).strict();
// const EventAddAttachmentDTOSchema = z.object({
// attachments: z.array(AttachmentInputDTOSchema),
// }).strict();
const EventAddAttendeeDTOSchema = z.object({
attendees: z.array(AttendeeInputDTOSchema),
}).strict();
// const EventAddAttendeeDTOSchema = z.object({
// attendees: z.array(AttendeeInputDTOSchema),
// }).strict();
export const EventCommunicationInputDTOSchema = z.object({
attachs: z.array(AttachCommunicationInputDTOSchema).nullable().optional(),
attendees: z.array(AttendeeCommunicationInputDTOSchema).nullable().optional(),
externalAttendees: z.array(AttendeeExternalInputDTOSchema).nullable().optional(),
}).strict();
// export const EventCommunicationInputDTOSchema = z.object({
// attachs: z.array(AttachCommunicationInputDTOSchema).nullable().optional(),
// attendees: z.array(AttendeeCommunicationInputDTOSchema).nullable().optional(),
// externalAttendees: z.array(AttendeeExternalInputDTOSchema).nullable().optional(),
// }).strict();
export const EventInputDTOSchema = z.object({
userId: z.number().int(),
ownerType: EEventOwnerTypeDTO,
subject: z.string().min(1),
body: z.string().min(1),
location: z.string().nullable().optional(),
startDate: z.string(),
endDate: z.string(),
type: EEventTypeDTO,
category: EEventCategoryDTO,
attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
recurrence: z.object({
frequency: z.number().int(),
until: z.string(),
}),
organizerId: z.number().int(),
isAllDayEvent: z.boolean(),
}).strict();
// // export const EventInputDTOSchema = z.object({
// // userId: z.number().int(),
// // ownerType: EEventOwnerTypeDTO,
// // subject: z.string().min(1),
// // body: z.string().min(1),
// // location: z.string().nullable().optional(),
// // startDate: z.string(),
// // endDate: z.string(),
// // type: EEventTypeDTO,
// // category: EEventCategoryDTO,
// // attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
// // attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
// // recurrence: z.object({
// // frequency: z.number().int(),
// // until: z.string(),
// // }),
// // organizerId: z.number().int(),
// // isAllDayEvent: z.boolean(),
// // }).strict();
export const EventRecurrenceInputDTOSchema = z.object({
frequency: z.number().int(),
occurrences: z.number().int(),
}).strict();
// export const EventRecurrenceInputDTOSchema = z.object({
// frequency: z.number().int(),
// occurrences: z.number().int(),
// }).strict();
export const EventRemoveAttachmentDTOSchema = z.object({
attachments: z.array(z.string().uuid()),
}).strict();
// export const EventRemoveAttachmentDTOSchema = z.object({
// attachments: z.array(z.string().uuid()),
// }).strict();
export const EventRemoveAttendeeDTOSchema = z.object({
attendees: z.array(z.string().uuid()),
}).strict();
// export const EventRemoveAttendeeDTOSchema = z.object({
// attendees: z.array(z.string().uuid()),
// }).strict();
export const EventUpdateDTOSchema = z.object({
subject: z.string().min(1),
body: z.string().min(1),
location: z.string().min(1),
startDate: z.string().datetime(),
endDate: z.string().datetime(),
isAllDayEvent: z.boolean(),
updateAllEvents: z.boolean(),
recurrence: z.object({
frequency: z.number().int(),
occurrences: z.number().int(),
}),
}).strict();
// export const EventUpdateDTOSchema = z.object({
// subject: z.string().min(1),
// body: z.string().min(1),
// location: z.string().min(1),
// startDate: z.string().datetime(),
// endDate: z.string().datetime(),
// isAllDayEvent: z.boolean(),
// updateAllEvents: z.boolean(),
// recurrence: z.object({
// frequency: z.number().int(),
// occurrences: z.number().int(),
// }),
// }).strict();
export const EventUpdateStatusDTOSchema = z.object({
status: EEventStatusDTO,
comment: z.string().nullable().optional(),
}).strict();
// export const EventUpdateStatusDTOSchema = z.object({
// status: EEventStatusDTO,
// comment: z.string().nullable().optional(),
// }).strict();
export const ProblemDetailsDTOSchema = z.object({
type: z.string().nullable().optional(),
title: z.string().nullable().optional(),
status: z.number().int().nullable().optional(),
detail: z.string().nullable().optional(),
instance: z.string().nullable().optional(),
}).strict();
// export const ProblemDetailsDTOSchema = z.object({
// type: z.string().nullable().optional(),
// title: z.string().nullable().optional(),
// status: z.number().int().nullable().optional(),
// detail: z.string().nullable().optional(),
// instance: z.string().nullable().optional(),
// }).strict();
export const ResponseSimpleDTOSchema = z.object({
success: z.boolean(),
message: z.string().nullable().optional(),
data: z.any().nullable().optional(),
})
// export const ResponseSimpleDTOSchema = z.object({
// success: z.boolean(),
// message: z.string().nullable().optional(),
// data: z.any().nullable().optional(),
// })
export type AttachCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type AttachmentInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type AttendeeCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type AttendeeExternalInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type AttendeeInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventAddAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventAddAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventInputDTO = z.infer<typeof EventInputDTOSchema>;
export type EventRecurrenceInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventRemoveAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventRemoveAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventUpdateDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type EventUpdateStatusDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type ProblemDetailsDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
export type ResponseSimpleDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type AttachCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type AttachmentInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type AttendeeCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type AttendeeExternalInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type AttendeeInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventAddAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventAddAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// // export type EventInputDTO = z.infer<typeof EventInputDTOSchema>;
// export type EventRecurrenceInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventRemoveAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventRemoveAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventUpdateDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type EventUpdateStatusDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type ProblemDetailsDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
// export type ResponseSimpleDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
@@ -0,0 +1,14 @@
import { z } from 'zod';
export const AttendeeInputDTOSchema = z.array(z.object({
name: z.string(),
emailAddress: z.string(),
attendeeType: z.number(),
wxUserId: z.number(),
userType: z.enum(['GD','External', 'Internal']),
entity: z.string()
}))
export type AttendeeInputDTO = z.infer<typeof AttendeeInputDTOSchema>
@@ -5,7 +5,9 @@ const attendeeSchema = z.object({
name: z.string(),
emailAddress: z.string(),
attendeeType: z.number(),
wxUserId: z.number()
wxUserId: z.number(),
userType: z.enum(['GD','External', 'Internal']),
entity: z.string()
});
const attachmentSchema = z.object({
@@ -1,19 +1,6 @@
import { z } from 'zod';
import { EEventCategory, EEventOwnerType, EEventType } from './enums';
const attendeeSchema = z.object({
name: z.string(),
emailAddress: z.string(),
attendeeType: z.number(),
wxUserId: z.number()
});
const attachmentSchema = z.object({
docId: z.number(),
sourceName: z.string(),
description: z.string(),
applicationId: z.number()
});
const recurrenceSchema = z.object({
frequency: z.number(),
+7 -1
View File
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { AgendaDataService } from './agenda-data.service';
import { EventsService } from '../../events.service';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TableSharedCalendar } from './agenda-local-data-source.service';
@@ -131,12 +130,17 @@ export class Utils {
attendeesAdded(taskParticipants: any[]) {
console.log({taskParticipants});
return taskParticipants.map((e) => {
return {
name: e.Name,
emailAddress: e.EmailAddress,
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
wxUserId: e.Id,
userType: e.UserType,
entity: e.Entity,
}
});
}
@@ -159,6 +163,8 @@ export class Utils {
emailAddress: e.EmailAddress,
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
wxUserId: e.wxUserId || e.Id,
userType: e.UserType,
entity: e.Entity,
}
});
}
@@ -0,0 +1,19 @@
import { z } from 'zod';
export const EventListOutputDTOSchema = z.object({
wxUserId: z.number(),
fullName: z.string(),
email: z.string(),
role: z.any(),
roleId: z.number(),
entity: z.string(),
userType: z.string(),
})
export const EventListDataOutputDTOSchema = z.object({
success: z.boolean(),
message: z.string(),
data: z.array(EventListOutputDTOSchema),
}).nullable();
export type ContactCombinedOutputDTO = z.infer<typeof EventListDataOutputDTOSchema>;
@@ -0,0 +1,18 @@
export interface UserContacts {
wxUserId: number;
wxFullName: string;
wxeMail: string | null;
userPhoto: string | null;
}
export interface UserListResult {
total: number,
result: UserContacts[]
}
export interface UserListOutOutDTO {
success: boolean;
message: string;
data: UserListResult;
}
@@ -0,0 +1,26 @@
import { Injectable } from '@angular/core';
import { HttpService } from 'src/app/services/http.service';
import { UserListOutOutDTO } from '../DTO/userListOutput';
import { ContactCombinedOutputDTO, EventListDataOutputDTOSchema } from '../DTO/contactsCombined';
import { APIReturn } from 'src/app/services/decorator/api-validate-schema.decorator';
@Injectable({
providedIn: 'root'
})
export class ContactsDataSourceService {
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
constructor(private httpService: HttpService) {}
@APIReturn(EventListDataOutputDTOSchema, '/Contacts/Combined')
async getCombinedList() {
return await this.httpService.get<ContactCombinedOutputDTO>(`${this.baseUrl}/Contacts/Combined`);
}
async getUsers() {
return await this.httpService.get<UserListOutOutDTO>(`${this.baseUrl}/Users`);
}
}
@@ -0,0 +1,28 @@
import { RoleIdService } from "src/app/services/role-id.service";
import { ContactCombinedOutputDTO } from "../DTO/contactsCombined";
import { UserList } from "src/app/models/entiry/agenda/contact";
const roles = new RoleIdService()
export class ListEventMapper {
// @XTracer({name:'ListEventMapper/toDomain', log: false, bugPrint: false})
static toDomain(dto: ContactCombinedOutputDTO): UserList {
return dto.data.map((e) => {
return {
Id: e.wxUserId,
EmailAddress: e.email,
Name: e.fullName,
UserType: e.userType,
Entity: e.entity,
IsPR: e.roleId == roles.PRES,
RoleId: e.roleId,
IsRequired: false
}
})
}
static toDTO() {}
}
@@ -0,0 +1,26 @@
import { Injectable } from '@angular/core';
import { ContactsDataSourceService } from '../data-source/contacts-data-source.service';
import { ListEventMapper } from '../mapper/contactCombinedMapper';
@Injectable({
providedIn: 'root'
})
export class ContactRepositoryService {
constructor(
private constactsDataSourceService: ContactsDataSourceService,
) {}
async getUsersMap() {
const result = await this.constactsDataSourceService.getCombinedList();
return result.map((result) => {
return ListEventMapper.toDomain(result).filter(e => e.EmailAddress != null)
});
}
async getUsers() {
const result = await this.constactsDataSourceService.getUsers();
return result;
}
}
@@ -13,7 +13,6 @@ import { NativeNotificationService } from 'src/app/services/native-notification.
import { SortService } from '../functions/sort.service';
import { chatUser } from 'src/app/models/chatMethod';
import { NfService } from 'src/app/services/chat/nf.service'
import { ChangeProfileService } from '../change-profile.service';
import { ChatMethodsService } from './chat-methods.service';
import { AESEncrypt } from '../aesencrypt.service'
import { AttachmentsService } from 'src/app/services/attachments.service';
@@ -11,6 +11,8 @@ export function APIReturn(schema: z.ZodTypeAny, path: string) {
descriptor.value = async function (...args: any[]) {
const result: Result<any, HttpErrorResponse> = await originalMethod.apply(this, args);
const tracing: TracingType = args[args.length - 1];
if(result.isOk()) {
try {
// Validate the result using the provided schema
@@ -23,6 +25,14 @@ export function APIReturn(schema: z.ZodTypeAny, path: string) {
// Capture the Zod validation error with additional context
console.error('Validation failed:', error.errors);
console.log(result.value)
tracing?.setAttribute?.('APIReturn.error', 'true')
let i = 0;
for(const schema of error.errors) {
tracing?.setAttribute?.('map.error.schema-'+i, JSON.stringify(schema))
}
} else {
// Throw any other unexpected errors
// throw error;
@@ -57,6 +67,7 @@ export function APINODReturn(schema: z.ZodTypeAny, data , path: string, tracing?
console.log(data)
tracing?.setAttribute('APIReturn.error', 'true')
tracing?.setAttribute('path', path)
let i = 0;
for(const schema of error.errors) {
+30 -4
View File
@@ -2,6 +2,7 @@ import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/htt
import { Injectable } from '@angular/core';
import { ok, err, Result } from 'neverthrow';
import { HttpParams } from '@angular/common/http';
import { TracingType } from './monitoring/opentelemetry/tracer';
@Injectable({
providedIn: 'root'
})
@@ -9,7 +10,7 @@ export class HttpService {
constructor(private http:HttpClient) { }
async post<T>(url: string, body: any): Promise<Result<T, HttpErrorResponse>> {
async post<T>(url: string, body: any, tracing?: TracingType): Promise<Result<T, HttpErrorResponse>> {
try {
const result = await this.http.post(url, body).toPromise()
@@ -19,7 +20,7 @@ export class HttpService {
}
}
async get<T>(url: string, httpParamsObj = {} ): Promise<Result<T, HttpErrorResponse>> {
async get<T>(url: string, httpParamsObj = {}, tracing?: TracingType): Promise<Result<T, HttpErrorResponse>> {
try {
let httpParams = new HttpParams();
@@ -38,6 +39,18 @@ export class HttpService {
return ok (result as T)
} catch (e) {
if(isHttpError(e)) {
tracing?.setAttribute('status.code', e.status.toString())
if (e.status == 400) {
tracing?.bugFlag()
tracing?.setAttribute('outcome', 'failed')
}
} else {
tracing?.bugFlag()
tracing.setAttribute('outcome', 'failed')
tracing?.setAttribute('map.error', 'true')
tracing?.setAttribute('map.error.context', JSON.stringify(e))
}
return err(e as HttpErrorResponse)
}
}
@@ -53,10 +66,23 @@ export class HttpService {
}
async delete<T>(url: string): Promise<Result<T, HttpErrorResponse>> {
async delete<T>(url: string, httpParamsObj = {}): Promise<Result<T, HttpErrorResponse>> {
let httpParams = new HttpParams();
// Convert params object to HttpParams
if (httpParamsObj) {
Object.keys(httpParamsObj).forEach(key => {
httpParams = httpParams.set(key, httpParamsObj[key]);
})
}
let opts = {
params : httpParams
}
try {
const result = await this.http.delete<T>(url).toPromise()
const result = await this.http.delete<T>(url, opts).toPromise()
return ok (result as T)
} catch (e) {
return err(e as HttpErrorResponse)
+1 -3
View File
@@ -60,15 +60,13 @@ export class NotificationsService {
constructor(
private http: HttpClient,
private storageService: StorageService,
public modalCtrl: AlertController,
private platform: Platform,
private router: Router,
private zone: NgZone,
private eventtrigger: EventTrigger,
private afMessaging: AngularFireMessaging,
public NotificationHolderService: NotificationHolderService,
private NotificationRepositoryService: NotificationRepositoryService) {
public NotificationHolderService: NotificationHolderService) {
// this.onReciveForeground();
this.onReciveBackground();
@@ -118,25 +118,23 @@ export class ApproveEventPage implements OnInit {
const loader = this.toastService.loading()
try {
this.agendaDataRepository.approveEvent(serialNumber).subscribe((value) => {
console.log(value)
this.modalController.dismiss(serialNumber);
this.httpErroHandle.httpsSucessMessagge('Aprovar')
this.TaskService.loadEventosParaAprovacao();
}, ((error) => {
console.log('aprove event error: ', error)
this.httpErroHandle.httpStatusHandle(error)
}))
/* await this.processes.PostTaskAction(body).toPromise() */
const result = await this.agendaDataRepository.approveEvent(serialNumber)// .subscribe((value) => {
if(result.isOk()) {
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
} finally {
this.close()
loader.remove()
console.log(result.value)
this.modalController.dismiss(serialNumber);
this.httpErroHandle.httpsSucessMessagge('Aprovar')
this.TaskService.loadEventosParaAprovacao();
} else {
console.log('aprove event error: ', result.error)
this.httpErroHandle.httpStatusHandle(result.error)
}
this.close()
loader.remove()
}
async rejectTask(serialNumber: string) {
@@ -145,24 +143,20 @@ export class ApproveEventPage implements OnInit {
const loader = this.toastService.loading()
const result = await this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Declined', "")//.subscribe((value) => {
try {
/* await this.processes.PostTaskAction(body).toPromise() */
this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Declined', "").subscribe((value) => {
if(result.isOk()) {
this.httpErroHandle.httpsSucessMessagge('Rejeitar');
this.TaskService.loadEventosParaAprovacao();
}, ((error) => {
console.log('reject event error: ', error)
this.httpErroHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
} finally {
loader.remove()
this.close()
} else {
console.log('reject event error: ', result.error)
this.httpErroHandle.httpStatusHandle(result.error)
}
loader.remove()
}
@@ -235,23 +229,20 @@ export class ApproveEventPage implements OnInit {
}
const loader = this.toastService.loading();
try {
/* await this.processes.PostTaskAction(body).toPromise(); */
this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Revision', res.data.note).subscribe((value) => {
/* await this.processes.PostTaskAction(body).toPromise(); */
const result = await this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Revision', res.data.note)// .subscribe((value) => {
if(result.isOk()) {
this.httpErroHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao();
this.close();
},((error) => {
console.log('send event to revision error: ', error)
this.httpErroHandle.httpStatusHandle(error)
}));
} else {
console.log('send event to revision error: ', result.error)
this.httpErroHandle.httpStatusHandle(result.error)
}
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
} finally {
loader.remove()
}
} else {
@@ -400,19 +400,20 @@ export class EditEventToApprovePage implements OnInit {
}
try {
/* await this.eventsService.postEventToApproveEdit(event).toPromise() */
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, true, calendar.value, tracing).subscribe((value) => {
const value = await this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, true, calendar.value, tracing)
if(value.isOk()) {
console.log(value)
this.close()
tracing.setAttribute('outcome', 'success')
}, ((error) => {
console.log('edit event error: ', error)
} else {
console.log('edit event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
}));
}
console.log({serverCurrentList, list: this.eventProcess.workflowInstanceDataFields.ParticipantsList, e: this.eventProcess})
@@ -421,7 +422,7 @@ export class EditEventToApprovePage implements OnInit {
console.log({insert, remove})
if(insert.length >= 1) {
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, insert).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, insert, tracing).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
@@ -416,34 +416,33 @@ export class EditEventPage implements OnInit {
try {
console.log('this.selectedUserCalendar', this.selectedUserCalendar)
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.showLoader = true;
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, this.editAllEvent, calendar.value, tracing).subscribe((value) => {
console.log(value)
const value = await this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, this.editAllEvent, calendar.value, tracing)
if(value.isOk()) {
console.log(value.value)
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
this.clearPostEvent.emit();
this.deleteTemporaryData();
this.showLoader = false;
this.close();
tracing.setAttribute('outcome', 'success')
}, ((error) => {
console.log('edit event error: ', error)
tracing
} else {
console.log('edit event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
}));
}
console.log({serverCurrentList, Attendees: this._postEvent.Attendees})
const { insert, remove } = AttendeesLIstChangeDetector(serverCurrentList as any, this._postEvent.Attendees as any)
console.log({ insert, remove });
if(insert.length >= 1) {
this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, insert).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, insert, tracing).subscribe((value) => {
console.log(value)
}, ((error) => {
tracing.setAttribute('failed.attendees', 'true')
@@ -33,6 +33,8 @@ import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda
import { RoleIdService } from 'src/app/services/role-id.service'
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
import { UserList } from 'src/app/models/entiry/agenda/contact';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
@@ -85,7 +87,7 @@ export class NewEventPage implements OnInit {
@Input() selectedSegment: string;
@Input() selectedDate: Date;
@Input() CalendarDate: Date;
@Input() taskParticipants: EventPerson[] = [];
@Input() taskParticipants: UserList = [];
@Input() taskParticipantsCc: any = [];
@Output() setIntervenient = new EventEmitter<any>();
@@ -131,8 +133,8 @@ export class NewEventPage implements OnInit {
CalendarNamesOptions = ['Oficial', 'Pessoal']
environment = environment
eventPersons: EventPerson[];
contacts: EventPerson[] = [];
eventPersons: UserList;
contacts: UserList = [];
allDayCheck: boolean = false;
@@ -153,6 +155,7 @@ export class NewEventPage implements OnInit {
private changeProfileService: ChangeProfileService,
private agendaDataRepository: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
private ContactRepositoryService: ContactRepositoryService
) {
this.dateAdapter.setLocale('pt');
this.loggeduser = SessionStore.user;
@@ -208,7 +211,7 @@ export class NewEventPage implements OnInit {
if (this.postEvent.Attendees != null) {
this.postEvent.Attendees.forEach(e => {
if (e.IsRequired) {
this.taskParticipants.push(e);
this.taskParticipants.push(e as any);
} else {
this.taskParticipantsCc.push(e);
}
@@ -553,29 +556,30 @@ export class NewEventPage implements OnInit {
}
let loader = this.toastService.loading();
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc) as any
this.postEvent.IsAllDayEvent = this.allDayCheck;
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
try {
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing).toPromise()
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing)
if(value.isOk()) {
console.log(value)
this.afterSave();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
loader.remove();
tracing.setAttribute('outcome', 'success')
} catch (error) {
console.log('create event error: ', error)
} else {
console.log('create event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
loader.remove();
this.hhtpErrorHandle.httpStatusHandle(error.status)
this.hhtpErrorHandle.httpStatusHandle(value.error.status)
}
} else {
}
} else {}
}
@@ -672,7 +676,11 @@ export class NewEventPage implements OnInit {
async fetchContacts(filter: string) {
console.log(this.loggeduser.Profile)
if (this.loggeduser.Profile == 'PR') {
this.contactsService.getContacts(filter).subscribe(result => {
const RequestResult = await this.ContactRepositoryService.getUsersMap();
if(RequestResult.isOk()) {
const result = RequestResult.value
if (this.eventPersons != null) {
this.eventPersons.forEach(attendee => {
const index: number = result.findIndex((cont) => {
@@ -685,7 +693,7 @@ export class NewEventPage implements OnInit {
}
this.contacts = result;
console.log('Attendes Email', this.loggeduser.Email)
let filterLoggedUserEmail = this.contacts.filter(item => item.RoleDescription == "Ministro e Director do Gabinete do PR")
let filterLoggedUserEmail = this.contacts.filter(item => item.RoleId == this.RoleIdService.MD)
console.log('Attendes Email', filterLoggedUserEmail)
this.contacts = filterLoggedUserEmail;
@@ -693,8 +701,11 @@ export class NewEventPage implements OnInit {
this.taskParticipants.push(this.contacts[0]);
this.setIntervenient.emit(this.taskParticipants);
console.log('Attendes Email', this.taskParticipants)
} else {
}
);
}
}
@@ -23,6 +23,7 @@ import { SearchList_v2 } from 'src/app/models/search-document';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
import { PermissionService } from 'src/app/services/permission.service';
import { DeleteEventRecurrencePage, EventDeleteRecurrenceComponentReturn } from 'src/app/modals/delete-event-recurrence/delete-event-recurrence.page';
@Component({
selector: 'app-view-event',
templateUrl: './view-event.page.html',
@@ -209,29 +210,41 @@ export class ViewEventPage implements OnInit {
}
deleteYesOrNo() {
async deleteYesOrNo() {
if (this.loadedEvent.IsRecurring) {
const modal = await this.modalController.create({
component: DeleteEventRecurrencePage,
componentProps: {},
cssClass: 'event-recurrence-modal',
});
modal.onDidDismiss().then((res) => {
const data: EventDeleteRecurrenceComponentReturn = res.data
if(data =='DeleteAll') {
this.deleteEvent_v2(true);
} else if (data == 'DeleteOne') {
this.deleteEvent_v2(false);
} else if(data == 'Cancel') {
this.close()
} else {
this.close()
}
});
await modal.present();
} else {
this.alertController.create({
header: 'Eliminar evento?',
message: 'Este evento tem recorrência, deseja eliminar a Sequência de eventos?',
inputs: [
{
name: 'confirm',
type: 'checkbox',
label: '',
value: 'confirm',
checked: false,
}
],
message: '',
buttons: [
{
text: 'Sim',
handler: (data) => {
if (data.includes('confirm')) {
this.deleteEvent_v2(true);
} else {
this.deleteEvent_v2(false);
}
handler: () => {
this.deleteEvent_v2(false);
}
},
{
@@ -242,44 +255,29 @@ export class ViewEventPage implements OnInit {
]
}).then(res => {
res.present();
});
} else {
this.alertController.create({
header: 'Eliminar evento?',
message: '',
buttons: [
{
text: 'Sim',
handler: () => {
this.deleteEvent_v2(false);
}
},
{
text: 'Não',
handler: () => {
}
}
]
}).then(res => {
res.present();
});
})
}
}
deleteEvent_v2(deleteAll) {
async deleteEvent_v2(deleteAll) {
console.log(this.loadedEvent.EventId)
const loader = this.toastService.loading()
this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll).subscribe(() => {
console.log()
const value = await this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll)//.subscribe(() => {
if(value.isOk()) {
console.log(value.value)
this.httpErrorHandle.httpsSucessMessagge('delete event')
this.close();
},(error) => {
console.log('delete event error: ',error)
this.httpErrorHandle.httpStatusHandle(error)
},()=>{
loader.remove();
});
} else {
console.log('delete event error: ', value.error)
this.httpErrorHandle.httpStatusHandle(value.error)
}
loader.remove();
}
// async deleteEvent() {
@@ -1,6 +1,4 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ContactsService } from 'src/app/services/contacts.service';
import { EventPerson } from 'src/app/models/eventperson.model';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { ThemeService } from 'src/app/services/theme.service'
@@ -9,6 +7,7 @@ import { Searchbar } from 'ionic-angular';
import { LoginUserRespose } from 'src/app/models/user.model';
import { SessionStore } from 'src/app/store/session.service';
import { Router } from '@angular/router';
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
@Component({
selector: 'app-attendee-modal',
@@ -52,10 +51,9 @@ export class AttendeePage implements OnInit {
listOfNotAllowdRoute = ['/home/gabinete-digital/despachos/', ]
constructor(
private modalCtrl: ModalController,
private contactsService: ContactsService,
public ThemeService: ThemeService,
private router: Router,) {
private router: Router,
private ContactRepositoryService: ContactRepositoryService) {
@@ -234,7 +232,13 @@ export class AttendeePage implements OnInit {
async fetchContacts(filter: string) {
this.showLoader = true;
this.contactsService.getContacts(filter).subscribe(_result => {
const RequestResult = await this.ContactRepositoryService.getUsersMap();
if(RequestResult.isOk()) {
const _result = RequestResult.value
console.log({_result})
let result
if(this.hideExternalDomain) {
@@ -270,8 +274,10 @@ export class AttendeePage implements OnInit {
this.showLoader = false;
}
} else {
}
);
}
checkStringNull(value: string) {
@@ -327,17 +327,19 @@ export class EditEventToApproveComponent implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, true, calendar.value, tracing).subscribe((value) => {
const value = await this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, true, calendar.value, tracing)//.subscribe((value) => {
if(value.isOk()) {
console.log(value)
this.httpErroHalde.httpsSucessMessagge('Editar evento')
window['approve-event-getTask']()
this.close();
tracing.setAttribute('outcome', 'success')
}, ((error) => {
this.httpErroHalde.httpStatusHandle(error)
console.log('edit event error: ', error)
} else {
this.httpErroHalde.httpStatusHandle(value.error)
console.log('edit event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
}));
}
console.log({serverCurrentList, ParticipantsList:this.eventProcess.workflowInstanceDataFields.ParticipantsList})
const { insert, remove } = AttendeesLIstChangeDetector(serverCurrentList as any, this.eventProcess.workflowInstanceDataFields.ParticipantsList as any)
@@ -346,7 +348,7 @@ export class EditEventToApproveComponent implements OnInit {
if(insert.length >= 1) {
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, insert).subscribe((value) => {
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, insert, tracing).subscribe((value) => {
}, ((error) => {
console.log('add Attendee error: ', error)
+2 -49
View File
@@ -11,9 +11,7 @@ import { ThemeService } from '../../services/theme.service';
import { RouteService } from 'src/app/services/route.service';
import { PermissionList } from 'src/app/models/permission/permissionList';
import { PermissionService } from 'src/app/services/permission.service';
import { EventTrigger } from 'src/app/services/eventTrigger.service'
import { ActiveTabService } from 'src/app/services/active-tab.service';
import { NotificationsService } from 'src/app/services/notifications.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
import { HeaderSettingsService } from "src/app/services/header-settings.service"
@@ -64,15 +62,11 @@ export class HeaderPage implements OnInit {
private router: Router,
private modalController: ModalController,
private animationController: AnimationController,
private storageservice: StorageService,
public platform: Platform,
public ThemeService: ThemeService,
public RouteService: RouteService,
public p: PermissionService,
private eventTriger: EventTrigger,
public ActiveTabService: ActiveTabService,
private notificationService: NotificationsService,
private cdRef: ChangeDetectorRef,
private storageService: StorageService,
private zone: NgZone,
private attachmentService: AttachmentsService,
@@ -84,10 +78,6 @@ export class HeaderPage implements OnInit {
this.notificationCount$ = this.notificationRepositoryService.getNotificationLiveCount()
this.notificationCount$.subscribe(count => {
console.log('Notification Count:', count);
});
this.loggeduser = SessionStore.user;
router.events.subscribe((val) => {
this.hideSearch();
@@ -162,50 +152,15 @@ export class HeaderPage implements OnInit {
}
updateReciveNotification() {
this.eventTriger.getObservable().subscribe((event) => {
if (event.notification == "recive") {
console.log('header', event.notification)
this.notificationLengthData()
}
});
}
updateDeleteNotification() {
this.eventTriger.getObservable().subscribe((event) => {
if (event.notification == "deleted") {
console.log('header', event.notification)
this.notificationLengthData()
}
});
}
async notificationLengthData() {
console.log('Call notification data')
await this.storageservice.get("Notifications").then((value) => {
console.log('Get notification data',)
this.zone.run(() => {
this.notificationLength = value.length;
console.log('Call notification data', this.notificationLength)
});
}).catch((error) => {
if (!error) {
this.zone.run(() => {
console.error('header storage get notification', error)
this.notificationLength = 0;
});
} else {
console.error('header storage get notification', error)
}
})
}
hideSearch() {
if (this.router.url.startsWith('/home/events') || this.router.url.startsWith('/home/chat')) {
this.hideSearchBtn = true;
@@ -301,8 +256,6 @@ export class HeaderPage implements OnInit {
modal.onDidDismiss().then(() => {
this.notificationLengthData()
this.getProfilePictureSorage()
this.showProfileModal = false
})
+9 -9
View File
@@ -4,14 +4,14 @@ importScripts('./assets/dexie/dist/dexie.js');
// Initialize the Firebase app in the service worker by passing the generated config
var firebaseConfig = {
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
authDomain: "gabinete-digital-2020.firebaseapp.com",
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
projectId: "gabinete-digital-2020",
storageBucket: "gabinete-digital-2020.appspot.com",
messagingSenderId: "800733765231",
appId: "1:800733765231:web:28e7792ab150006513779a",
measurementId: "G-8QN4BLZ8XK"
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
authDomain: "gabinete-digital-2020.firebaseapp.com",
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
projectId: "gabinete-digital-2020",
storageBucket: "gabinete-digital-2020.appspot.com",
messagingSenderId: "800733765231",
appId: "1:800733765231:web:28e7792ab150006513779a",
measurementId: "G-8QN4BLZ8XK"
};
firebase.initializeApp(firebaseConfig);
@@ -20,7 +20,7 @@ firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();
messaging.onBackgroundMessage(function(payload) {
// console.log('Received background message 22 ', payload);
console.log('Received background message 22 bbb ', payload);
const notificationTitle = payload.notification.title;
const notificationOptions = {
+31 -12
View File
@@ -7,6 +7,10 @@
font-family: arial;
}
body {
margin: 0px;
}
.body {
background-color: #f5f7fb;
padding: 35px;
@@ -94,40 +98,45 @@
<img class="pa-15 m-auto d-flex" src="https://gwjkdh.stripocdn.email/content/guids/videoImgGuid/images/governo_de_angola_horizontal_logo_MH1.png" style="display:block; border:0; text-decoration:none;" alt="Logo" title="Logo" width="160" height="136">
<p class="f-22 ma-15 text-center"><b>República De Angola</b></p>
<p class="f-22 ma-15 text-center"><b>Gabinete do Presidente da República</b></p>
<p class="f-22 ma-15 text-center"><b>Convite para reunião</b></p>
<p class="f-22 ma-15 text-center"><b>Agenda do dia</b></p>
</div>
<hr/>
<div class="pa-40">
<p class="f-weight-600 text-center" >Agenda da semana</p>
<table class="width-100">
<thead>
<tr>
<th>
Localiizas&ccedil;&atilde;o
</th>
<th>
Data
</th>
<th>
Assunto
</th>
<th>
Inicio
</th>
<th>
Fim
</th>
<th>
Localização
</th>
</tr>
</thead>
<tbody>
<tr>
<td >Palácio Presidencial de</td>
<td >15 de Julho de 2024 19:00</td>
<td >08:24</td>
<td >09:24</td>
<td >Luanda</td>
</tr>
<tr>
<td >Palácio Presidencial de</td>
<td >15 de Julho de 2024 19:00</td>
<td >08:24</td>
<td >09:24</td>
<td >Luanda</td>
</tr>
<tr>
<td >Palácio Presidencial de</td>
<td >15 de Julho de 2024 19:00</td>
<td >07:23</td>
<td >08:23</td>
<td >Luanda</td>
</tr>
</tbody>
@@ -135,6 +144,16 @@
</div>
<hr/>
<div class="px-40">
<div>
<p class="text-gray f-13 d-block ">Mensagem</p>
<span class="d-block ">Cordial saudações prezado(a),<br>
Eis a vossa agenda do dia.</span>
</div>
</div>
<hr/>
<div class="px-40 pb-40">
<div>
@@ -147,7 +166,7 @@
</div>
<div class="footer">
<p>&nbsp;&nbsp;&nbsp;<b>Gabinete Digital - Uma iniciativa do Presidente da República</b></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Gabinete Digital - Uma iniciativa do Presidente da República</b></p>
</div>
</div>
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "0e12b5de5",
"SHA": "0e12b5de5e32ff09a2fa53b7f69a9bff30e20d57",
"shortSHA": "06417ead0",
"SHA": "06417ead0fcc05d1d7f1fada6465ece88558be6d",
"branch": "feature/agenda-api-peter",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Wed Jul 3 10:15:53 2024 +0100'",
"lastCommitMessage": "add margin",
"lastCommitNumber": "5858",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 5 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/app.module.ts\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/models/entiry/agenda/eventList.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.html\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tnew file: src/app/services/Repositorys/Agenda/agenda-memory-source.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/utils.ts\n\tmodified: src/app/services/agenda/list-box.service.ts\n\tmodified: src/app/services/chat/chat-system.service.ts\n\tmodified: src/app/services/events.service.ts\n\tmodified: src/app/services/native-notification.service.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.html\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: version/event-da-semana.html\n\tmodified: version/evento-revisao.html\n\tmodified: version/git-version.ts",
"lastCommitTime": "'Thu Jul 4 16:33:45 2024 +0100'",
"lastCommitMessage": "create event from gabinete",
"lastCommitNumber": "5859",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 6 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/app-routing.module.ts\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence-routing.module.ts\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence.module.ts\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence.page.html\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence.page.scss\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence.page.spec.ts\n\tnew file: src/app/modals/delete-event-recurrence/delete-event-recurrence.page.ts\n\tnew file: src/app/models/entiry/agenda/contact.ts\n\tnew file: src/app/module/notification/data/dto/NotificationLiveOutputDTO.ts\n\tmodified: src/app/module/notification/data/notification-repository.service.ts\n\tnew file: src/app/module/notification/domain/mapper/notificationMapper.ts\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/pages/agenda/event-actions-popover/event-actions-popover.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/agenda/view-event/view-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/agendaDataModels.ts\n\tnew file: src/app/services/Repositorys/Agenda/model/attendeeInputDTO.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventInputDTO.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventUpdateInputDtO.ts\n\tmodified: src/app/services/Repositorys/Agenda/utils.ts\n\tnew file: src/app/services/Repositorys/contacts/DTO/contactsCombined.ts\n\tnew file: src/app/services/Repositorys/contacts/DTO/userListOutput.ts\n\tnew file: src/app/services/Repositorys/contacts/data-source/contacts-data-source.service.ts\n\tnew file: src/app/services/Repositorys/contacts/mapper/contactCombinedMapper.ts\n\tnew file: src/app/services/Repositorys/contacts/repository/contacts-repository.service.ts\n\tmodified: src/app/services/chat/chat-system.service.ts\n\tmodified: src/app/services/decorator/api-validate-schema.decorator.ts\n\tmodified: src/app/services/http.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/agenda/approve-event/approve-event.page.ts\n\tmodified: src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/agenda/view-event/view-event.page.ts\n\tmodified: src/app/shared/event/attendee-modal/attendee-modal.page.ts\n\tmodified: src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts\n\tmodified: src/app/shared/header/header.page.ts\n\tmodified: src/firebase-messaging-sw.js\n\tmodified: version/event-da-semana.html",
"changeAuthor": "peter.maquiran"
}