mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
149 lines
5.4 KiB
TypeScript
149 lines
5.4 KiB
TypeScript
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
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 { 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';
|
|
import { EventListOutputDTO } from './model/eventListDTOOutput';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
|
|
export class AgendaDataService {
|
|
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
|
|
|
|
constructor(
|
|
private http: HttpClient,
|
|
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 });
|
|
}
|
|
|
|
viewDocument(userId: number, docId: number, applicationId: number): Observable<any> {
|
|
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 });
|
|
}
|
|
|
|
// Events Endpoints
|
|
createEvent(eventData: EventInputDTO) {
|
|
return this.http.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)
|
|
|
|
if(userId == null || userId == undefined) {
|
|
throw('userId '+ userId)
|
|
}
|
|
|
|
|
|
if(status != null || status != undefined) {
|
|
params = params.set('status', status);
|
|
}
|
|
|
|
if (startDate !== null && startDate !== undefined) {
|
|
params = params.set('startDate', startDate);
|
|
}
|
|
|
|
if (endDate !== null && endDate !== undefined) {
|
|
params = params.set('endDate', endDate);
|
|
}
|
|
|
|
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
|
|
}
|
|
|
|
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}`);
|
|
}
|
|
|
|
updateEvent(id: string, eventData: any): Observable<any> {
|
|
return this.http.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
|
|
}
|
|
|
|
approveEvent(id: string): Observable<any> {
|
|
return this.http.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 });
|
|
}
|
|
|
|
updateEventStatus(id: string, statusData: any): Observable<any> {
|
|
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
|
|
}
|
|
|
|
addEventAttendee(id: string, attendeeData: any): Observable<any> {
|
|
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attendee`, attendeeData);
|
|
}
|
|
|
|
|
|
removeEventAttendee(id: string, attendeeData: AttendeesRemoveInputDTO): Observable<any> {
|
|
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attendee`, { body: attendeeData });
|
|
}
|
|
|
|
addEventAttachment(id: string, attachmentData: any): Observable<any> {
|
|
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attachment`, attachmentData);
|
|
}
|
|
|
|
removeEventAttachment(id: string, attachmentData: any): Observable<any> {
|
|
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()
|
|
.set('userId', userId)
|
|
.set('Value', value)
|
|
.set('PageNumber', PageNumber)
|
|
.set('PageSize', PageSize);
|
|
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments${aplicationId}`, {params});
|
|
}
|
|
|
|
|
|
// @APIReturn(SharedCalendarListOutputDTOSchema, 'Users/${SessionStore.user.UserId}/ShareCalendar')
|
|
async getSharedCalendar() {
|
|
return await this.httpService.get<SharedCalendarListOutputDTO>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/ShareCalendar`);
|
|
}
|
|
}
|