2020-08-18 23:32:12 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
|
|
import { Event } from '../models/event.model';
|
|
|
|
|
import axios from 'axios'
|
2020-08-19 14:21:42 +01:00
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { Observable } from 'rxjs';
|
2020-08-18 23:32:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class EventsService {
|
|
|
|
|
/* Set events */
|
|
|
|
|
private events: Event[] = [
|
|
|
|
|
{
|
|
|
|
|
EventId: '1',
|
|
|
|
|
Subject: 'Reunião do Conselho de Ministros',
|
|
|
|
|
Body: null,
|
|
|
|
|
Location: 'Luanda, Palácio presidencial',
|
|
|
|
|
CalendarId: '',
|
2020-08-19 14:21:42 +01:00
|
|
|
CalendarName: 'pessoal',
|
2020-08-18 23:32:12 +01:00
|
|
|
StartDate: '10:30',
|
|
|
|
|
EndDate: '11:00',
|
|
|
|
|
EventType: '',
|
|
|
|
|
RequiredAttendees: null,
|
|
|
|
|
OptionalAttendees: null,
|
|
|
|
|
HasAttachments: false,
|
|
|
|
|
IsMeeting: false,
|
|
|
|
|
IsRecurring: false,
|
|
|
|
|
AppointmentState: 0,
|
|
|
|
|
TimeZone: '',
|
|
|
|
|
Organizer: '',
|
|
|
|
|
Categories: null,
|
|
|
|
|
Attachments: null,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
EventId: '2',
|
|
|
|
|
Subject: 'Conference call Particular',
|
|
|
|
|
Body: null,
|
|
|
|
|
Location: 'Luanda, Palácio presidencial',
|
|
|
|
|
CalendarId: '',
|
2020-08-19 14:21:42 +01:00
|
|
|
CalendarName: 'pessoal',
|
2020-08-18 23:32:12 +01:00
|
|
|
StartDate: '10:30',
|
|
|
|
|
EndDate: '11:00',
|
|
|
|
|
EventType: '',
|
|
|
|
|
RequiredAttendees: null,
|
|
|
|
|
OptionalAttendees: null,
|
|
|
|
|
HasAttachments: false,
|
|
|
|
|
IsMeeting: false,
|
|
|
|
|
IsRecurring: false,
|
|
|
|
|
AppointmentState: 0,
|
|
|
|
|
TimeZone: '',
|
|
|
|
|
Organizer: '',
|
|
|
|
|
Categories: null,
|
|
|
|
|
Attachments: null,
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2020-08-19 14:21:42 +01:00
|
|
|
url = 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/api/calendar/GetEvents?StartDate=2020-08-14 00:00:00&EndDate=2020-08-19 23:59:00&CalendarName=Pessoal';
|
|
|
|
|
options = { headers: {'Authorization': 'Basic cGF1bG8ucGludG86dGFidGVzdGVAMDA2'}};
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-19 14:21:42 +01:00
|
|
|
constructor(private http: HttpClient) { }
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-19 14:21:42 +01:00
|
|
|
allEvents(): Observable<Event[]>{
|
|
|
|
|
return this.http.get<Event[]>(`${this.url}`, this.options)
|
|
|
|
|
}
|
|
|
|
|
getEvent(ev: string): Observable<Event>{
|
|
|
|
|
const url = 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/api/calendar/GetEvent?EventId=';
|
|
|
|
|
return this.http.get<Event>(`${url + ev}`, this.options)
|
|
|
|
|
}
|
2020-08-18 23:32:12 +01:00
|
|
|
|
2020-08-19 14:21:42 +01:00
|
|
|
getStaticEvent(eventId: string){
|
2020-08-18 23:32:12 +01:00
|
|
|
return {
|
2020-08-19 14:21:42 +01:00
|
|
|
// The find() function looks for an event in a array and return true if found
|
2020-08-18 23:32:12 +01:00
|
|
|
...this.events.find(event => {
|
2020-08-19 14:21:42 +01:00
|
|
|
//Compare if the event found is the same as the event passed in as parameter
|
2020-08-18 23:32:12 +01:00
|
|
|
return event.EventId === eventId;
|
2020-08-19 14:21:42 +01:00
|
|
|
})
|
|
|
|
|
};
|
2020-08-18 23:32:12 +01:00
|
|
|
}
|
|
|
|
|
}
|