mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
new api implementation
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from './agenda-data.service';
|
||||
import { Utils } from './utils';
|
||||
import { EventInputDTO } from './agendaDataModels';
|
||||
import { Event } from 'src/app/models/event.model';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -7,10 +11,75 @@ import { AgendaDataService } from './agenda-data.service';
|
||||
export class AgendaDataRepositoryService {
|
||||
|
||||
constructor(
|
||||
private agendaDataService: AgendaDataService
|
||||
private agendaDataService: AgendaDataService,
|
||||
private utils: Utils
|
||||
) { }
|
||||
|
||||
createEvent(eventData) {
|
||||
this.agendaDataService.createEvent(eventData);
|
||||
createEvent(eventData: Event,CalendarName,documents) {
|
||||
console.log(eventData)
|
||||
|
||||
let eventInput: EventInputDTO = {
|
||||
userId: this.utils.selectedCalendarUserId(CalendarName,eventData),
|
||||
ownerType: this.utils.selectedCalendarOwner(CalendarName),
|
||||
subject: eventData.Subject,
|
||||
body: eventData.Body.Text,
|
||||
location: eventData.Location,
|
||||
startDate: eventData.StartDate.toISOString(),
|
||||
endDate: eventData.EndDate.toISOString(),
|
||||
type: this.utils.calendarTypeSeleted(eventData.Category),
|
||||
category: this.utils.calendarCategorySeleted(eventData.CalendarName),
|
||||
attendees: this.utils.attendeesAdded(eventData.Attendees),
|
||||
attachments: this.utils.documentAdded(documents),
|
||||
recurrence: {
|
||||
frequency: 0,
|
||||
occurrences: 0,
|
||||
},
|
||||
organizerId: SessionStore.user.UserId,
|
||||
isAllDayEvent: eventData.IsAllDayEvent,
|
||||
}
|
||||
|
||||
this.agendaDataService.createEvent(eventInput).subscribe((value) => {
|
||||
console.log(value)
|
||||
},((error) => {
|
||||
console.log('create event',error)
|
||||
}));
|
||||
}
|
||||
|
||||
updateEvent(eventId,eventData: Event,CalendarName,documents) {
|
||||
console.log(this.utils.editeEventCalendarUserId(CalendarName,eventData));
|
||||
|
||||
let eventInput: EventInputDTO = {
|
||||
userId: this.utils.selectedCalendarUserId(CalendarName,eventData),
|
||||
ownerType: this.utils.selectedCalendarOwner(CalendarName),
|
||||
subject: eventData.Subject,
|
||||
body: eventData.Body.Text,
|
||||
location: eventData.Location,
|
||||
startDate: JSON.stringify(eventData.StartDate),
|
||||
endDate: JSON.stringify(eventData.EndDate),
|
||||
type: this.utils.calendarTypeSeleted(eventData.Category),
|
||||
category: this.utils.calendarCategorySeleted(eventData.CalendarName),
|
||||
attendees: this.utils.attendeesAdded(eventData.Attendees),
|
||||
attachments: this.utils.documentAdded(documents),
|
||||
recurrence: {
|
||||
frequency: 0,
|
||||
occurrences: 0,
|
||||
},
|
||||
organizerId: SessionStore.user.UserId,
|
||||
isAllDayEvent: eventData.IsAllDayEvent,
|
||||
}
|
||||
|
||||
this.agendaDataService.updateEvent(eventId,eventInput).subscribe((value) => {
|
||||
console.log(value)
|
||||
},((error) => {
|
||||
console.log(error)
|
||||
}));
|
||||
}
|
||||
|
||||
deleteEvent(eventId) {
|
||||
this.agendaDataService.deleteEvent(eventId,false).subscribe(() => {
|
||||
console.log()
|
||||
},((error) => {
|
||||
console.log(error)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Observable } from 'rxjs';
|
||||
})
|
||||
|
||||
export class AgendaDataService {
|
||||
private baseUrl = '/stage/api/v2'; // Your base URL
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
|
||||
@@ -30,27 +30,27 @@ export const AttendeeExternalInputDTOSchema = z.object({
|
||||
export const AttendeeInputDTOSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
emailAddress: z.string().nullable().optional(),
|
||||
attendeeType: z.enum(["0", "1", "2"]),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number().int(),
|
||||
}).strict();
|
||||
|
||||
const EAttendeeTypeDTO = z.enum(["0", "1", "2"]);
|
||||
const EAttendeeTypeDTO = z.number();
|
||||
|
||||
const EEventCategoryDTO = z.enum(["1", "2"]);
|
||||
const EEventCategoryDTO = z.number();
|
||||
|
||||
const EEventFilterCategoryDTO = z.enum(["1", "2", "3"]);
|
||||
const EEventFilterCategoryDTO = z.number();
|
||||
|
||||
const EEventFilterStatusDTO = z.enum(["0", "1", "2", "3", "4", "5"]);
|
||||
const EEventFilterStatusDTO = z.number();
|
||||
|
||||
const EEventFilterTypeDTO = z.enum(["1", "2", "3", "4"]);
|
||||
const EEventFilterTypeDTO = z.number();
|
||||
|
||||
const EEventOwnerTypeDTO = z.enum(["1", "2", "3"]);
|
||||
const EEventOwnerTypeDTO = z.number();
|
||||
|
||||
const EEventStatusDTO = z.enum(["0", "1", "2", "3", "4"]);
|
||||
const EEventStatusDTO = z.number();
|
||||
|
||||
const EEventTypeDTO = z.enum(["1", "2", "3"]);
|
||||
const EEventTypeDTO = z.number();
|
||||
|
||||
const ERecurringTypeDTO = z.enum(["0", "1", "2", "3", "4"]);
|
||||
const ERecurringTypeDTO = z.number();
|
||||
|
||||
const EventAddAttachmentDTOSchema = z.object({
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
@@ -79,7 +79,7 @@ export const EventInputDTOSchema = z.object({
|
||||
attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
|
||||
attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
|
||||
recurrence: z.object({
|
||||
frequency: ERecurringTypeDTO,
|
||||
frequency: z.number().int(),
|
||||
occurrences: z.number().int(),
|
||||
}),
|
||||
organizerId: z.number().int(),
|
||||
@@ -87,7 +87,7 @@ export const EventInputDTOSchema = z.object({
|
||||
}).strict();
|
||||
|
||||
export const EventRecurrenceInputDTOSchema = z.object({
|
||||
frequency: ERecurringTypeDTO,
|
||||
frequency: z.number().int(),
|
||||
occurrences: z.number().int(),
|
||||
}).strict();
|
||||
|
||||
@@ -108,7 +108,7 @@ export const EventUpdateDTOSchema = z.object({
|
||||
isAllDayEvent: z.boolean(),
|
||||
updateAllEvents: z.boolean(),
|
||||
recurrence: z.object({
|
||||
frequency: ERecurringTypeDTO,
|
||||
frequency: z.number().int(),
|
||||
occurrences: z.number().int(),
|
||||
}),
|
||||
}).strict();
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from './agenda-data.service';
|
||||
import { EventsService } from '../../events.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class Utils {
|
||||
constructor(
|
||||
private agendaDataService: AgendaDataService,
|
||||
public eventService: EventsService,
|
||||
) { }
|
||||
|
||||
|
||||
selectedCalendarUserId(CalendarName,postEvent) {
|
||||
|
||||
if (this.eventService.calendarNamesType[CalendarName]?.['Oficial'] && postEvent.CalendarName == 'Oficial') {
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
|
||||
} else if (this.eventService.calendarNamesType[CalendarName]?.['Pessoal'] && postEvent.CalendarName == 'Pessoal') {
|
||||
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
|
||||
} else {
|
||||
return '11:11'
|
||||
}
|
||||
}
|
||||
|
||||
editeEventCalendarUserId(CalendarName,postEvent) {
|
||||
|
||||
let CalendarNameOwnerName = this.eventService.detectCalendarNameByCalendarId(postEvent.CalendarId)
|
||||
if(this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial'] && this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) {
|
||||
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
|
||||
} else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial']) {
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
|
||||
} else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) {
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
|
||||
} else {
|
||||
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
|
||||
}
|
||||
}
|
||||
|
||||
selectedCalendarOwner(CalendarName) {
|
||||
let selectedCalendar = this.eventService.calendarNamesType[CalendarName]?.['RoleId'];
|
||||
|
||||
if (selectedCalendar) {
|
||||
if (selectedCalendar.Role == 100000014) {
|
||||
return 1;
|
||||
} else if (selectedCalendar.Role == 100000011) {
|
||||
return 2
|
||||
} else {
|
||||
return 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
calendarCategorySeleted(calendarName) {
|
||||
var selectedCalendar = {
|
||||
'Oficial': 1,
|
||||
'Pessoal': 2
|
||||
}
|
||||
return selectedCalendar[calendarName];
|
||||
}
|
||||
|
||||
calendarTypeSeleted(calendarName) {
|
||||
var selectedType = {
|
||||
'Reunião': 1,
|
||||
'Viagem': 2,
|
||||
'Conferência': 3,
|
||||
'Encontro': 1
|
||||
}
|
||||
return selectedType[calendarName];
|
||||
}
|
||||
|
||||
documentAdded(documents:any[]) {
|
||||
return documents.map((e) => {
|
||||
return {
|
||||
sourceId: e.Id,
|
||||
sourceName: e.Assunto,
|
||||
description: "",
|
||||
applicationId: parseInt(e.ApplicationType.toString())
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
atendeesSeletedType(type) {
|
||||
var selectedType = {
|
||||
'true': 1,
|
||||
'false':2,
|
||||
'other':3,
|
||||
}
|
||||
return selectedType[type];
|
||||
}
|
||||
|
||||
|
||||
attendeesAdded(taskParticipants: any[]) {
|
||||
return taskParticipants.map((e) => {
|
||||
return {
|
||||
name: e.Name,
|
||||
emailAddress: e.EmailAddress,
|
||||
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
|
||||
wxUserId: e.Id,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user