diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts
index 5e10e9e55..b17be7331 100644
--- a/src/app/pages/events/events.page.ts
+++ b/src/app/pages/events/events.page.ts
@@ -4,6 +4,7 @@ import { Event } from '../../models/event.model';
import { EventsService } from 'src/app/services/events.service';
import { Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
+import { Observable } from 'rxjs';
@Component({
@@ -28,6 +29,7 @@ timeDate = this.today.getHours() + ":" + this.today.getMinutes();
segment:string;
events: Event[];
+ eventsList: Observable;
constructor(private eventService: EventsService, private router: Router, public activatedRoute: ActivatedRoute) { }
@@ -37,6 +39,7 @@ timeDate = this.today.getHours() + ":" + this.today.getMinutes();
this.showGreeting();
/* Call Get events method */
this.events = this.eventService.getAllEvents();
+ this.eventsList = this.eventService.allEvents();/* .subscribe(prods=>console.log(prods)); */
}
showGreeting(){
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index e4ede12bd..8e41344eb 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -54,6 +54,7 @@ export class AuthService {
return false;
}
}
+
/* logout(){
this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts
index 9b99330a0..0dfaa0fcf 100644
--- a/src/app/services/events.service.ts
+++ b/src/app/services/events.service.ts
@@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
import { Event } from '../models/event.model';
import axios from 'axios'
+import { HttpClient } from '@angular/common/http';
+import { Observable } from 'rxjs';
@Injectable({
@@ -9,27 +11,8 @@ import axios from 'axios'
})
export class EventsService {
/* Set events */
- private eventos: Event = {
- EventId: '1',
- Subject: 'Reunião do Conselho de Ministros',
- Body: null,
- Location: 'Luanda, Palácio presidencial',
- CalendarId: '',
- CalendarName: 'poo',
- 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,
-};
+ private eventos: Event[];
+
private events: Event[] = [
{
EventId: '1',
@@ -37,7 +20,7 @@ export class EventsService {
Body: null,
Location: 'Luanda, Palácio presidencial',
CalendarId: '',
- CalendarName: 'poo',
+ CalendarName: 'pessoal',
StartDate: '10:30',
EndDate: '11:00',
EventType: '',
@@ -58,7 +41,7 @@ export class EventsService {
Body: null,
Location: 'Luanda, Palácio presidencial',
CalendarId: '',
- CalendarName: 'poo',
+ CalendarName: 'pessoal',
StartDate: '10:30',
EndDate: '11:00',
EventType: '',
@@ -75,54 +58,41 @@ export class EventsService {
}
];
- constructor() { }
+ 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'}};
- getAllEvents(){
- /* Return a copy of the events in my array */
- console.log("All eventes loaded");
+ constructor(private http: HttpClient) { }
- const options = {
- headers: {'Authorization': 'Basic cGF1bG8ucGludG86dGFidGVzdGVAMDA2'}
- };
- const 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';
-
-
- axios.get(url, options)
- .then((response) => {
- console.log(response.data[0].EventId);
- /* console.log(response.data[0].Subject);
- console.log(response.status);
- console.log(response.statusText);
- console.log(response.headers); */
- console.log(response.data[0]);
- console.log(this.eventos);
- this.eventos = response.data[0];
- console.log(this.events[0].CalendarName);
- console.log(this.events[0].CalendarName);
- console.log("THEN");
-
- console.log([this.eventos.CalendarName])
- /* return [this.events[0]]; */
- console.log(response.data);
- console.log(this.eventos);
- console.log(this.events[0].CalendarName);
-
- this.events = response.data;
-
- /* return [...this.events]; */
- });
-
- return [...this.events];
- /* return [...this.events]; */
+ allEvents(): Observable{
+ return this.http.get(`${this.url}`, this.options)
+ }
+ getEvent(ev: string): Observable{
+ const url = 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/api/calendar/GetEvent?EventId=';
+ return this.http.get(`${url + ev}`, this.options)
}
- getEvent(eventId: string){
+ getAllEvents(){
+ //Return a copy of the events in my array
+ console.log("All eventes loaded");
+ const options = { headers: {'Authorization': 'Basic cGF1bG8ucGludG86dGFidGVzdGVAMDA2'}};
+ axios.get(this.url, options)
+ .then((response) => {
+ console.log(this.eventos);
+ this.eventos = response.data;
+ console.log(this.eventos);
+ return this.events;
+ });
+ return this.eventos;
+ //return [...this.events];
+ }
+
+ getStaticEvent(eventId: string){
return {
- /* The find() function looks for an event in a array and return true if found */
+ // The find() function looks for an event in a array and return true if found
...this.events.find(event => {
- /* Compare if the event found is the same as the event passed in as parameter */
+ //Compare if the event found is the same as the event passed in as parameter
return event.EventId === eventId;
- })
- };
+ })
+ };
}
}