New Services, New Login, Better things

This commit is contained in:
Paulo Pinto
2020-08-21 16:18:37 +01:00
parent 86b3c8f039
commit ffadf6601c
15 changed files with 177 additions and 238 deletions
+2 -2
View File
@@ -13,10 +13,10 @@
<ion-icon name="file-tray-stacked"></ion-icon>
<ion-label>Gabinete Digital</ion-label>
</ion-tab-button>
<ion-tab-button tab="search">
<!-- <ion-tab-button tab="search">
<ion-icon name="search"></ion-icon>
<ion-label>Pesquisa</ion-label>
</ion-tab-button>
</ion-tab-button> -->
</ion-tab-bar>
</ion-tabs>
+1 -2
View File
@@ -1,5 +1,4 @@
export interface DailyWorkTask{
export class DailyWorkTask{
SerialNumber: string;
Folio: string;
Senders: string;
+4 -6
View File
@@ -3,7 +3,7 @@ import { EventPerson } from './eventperson.model';
import { EventAttachment } from './eventattachment.model';
import { EventOrganizer } from './organizer.model';
export interface Event{
export class Event{
EventId: string;
Subject: string;
@@ -14,15 +14,13 @@ export interface Event{
StartDate: string;
EndDate: string;
EventType: string;
RequiredAttendees: EventPerson;
OptionalAttendees: EventPerson;
HasAttachments: boolean;
RequiredAttendees: EventPerson[];
OptionalAttendees: EventPerson[];
IsMeeting: boolean;
IsRecurring: boolean;
AppointmentState: number;
TimeZone: string;
Organizer: string;
Categories: string[];
Attachments: EventAttachment;
Attachments: EventAttachment[];
}
+15 -7
View File
@@ -1,8 +1,16 @@
export interface EventAttachment{
Name: string;
OwnerId: string;
Subject: string;
Location: string;
ExternalEntities: string;
CreatedIn: string;
export class EventAttachment{
Id: number;
ParentId: string;
Sources: Sources;
SourceId: string;
Data: any;
}
enum Sources
{
Unknow = 0,
webTRIX = 1,
K2 = 2,
Exchange = 3,
File = 4
}
+2 -2
View File
@@ -1,4 +1,4 @@
export interface EventBody{
bodyType: string;
export class EventBody{
BodyType: string;
Text: string;
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface EventPerson{
export class EventPerson{
EmailAddress: string;
Name: string;
}
+1 -1
View File
@@ -1,4 +1,4 @@
export interface EventOrganizer{
export class EventOrganizer{
EmailAddress: string;
Text: string;
}
+4 -4
View File
@@ -1,6 +1,6 @@
export interface User {
username: string,
password: string,
domainName: string,
export class User {
username: string;
password: string;
domainName: string;
BasicAuthKey: string
}
+1 -1
View File
@@ -210,7 +210,7 @@ export class AgendaPage implements OnInit {
console.log(test);
const defaultEndDate = new Date();
await this.eventService.allEvents().subscribe(
await this.eventService.getAllEvents("2020-01-01","2020-12-31").subscribe(
response => {
this.eventsList = response;
+17 -10
View File
@@ -13,21 +13,21 @@
<div class="div-ion-content">
<ion-item>
<ion-label position="stacked">Assunto</ion-label>
<ion-input tpye="text" [(ngModel)]="postEvent.Subject"></ion-input>
<ion-input type="text" [(ngModel)]="postEvent.Subject"></ion-input>
</ion-item>
<ion-item>
<ion-label position="stacked">Descrição</ion-label>
<ion-input tpye="text" [(ngModel)]="postEvent.Body.Text"></ion-input>
<ion-input type="text" [(ngModel)]="postEvent.Body.Text"></ion-input>
</ion-item>
<ion-item>
<ion-label position="stacked">Localização</ion-label>
<ion-input tpye="text" [(ngModel)]="postEvent.Location"></ion-input>
<ion-input type="text" [(ngModel)]="postEvent.Location"></ion-input>
</ion-item>
<ion-item>
<!-- <ion-item>
<ion-label position="stacked">Intervenientes</ion-label>
<ion-input tpye="text" [(ngModel)]="postEvent.RequiredAttendees.Name"></ion-input>
</ion-item>
<ion-list>
<ion-input type="text" [(ngModel)]="postEvent.RequiredAttendees.Name"></ion-input>
</ion-item> -->
<!-- <ion-list>
<ion-radio-group value="biff">
<ion-item class="radio-button" lines="none">
<ion-label>Oficial</ion-label>
@@ -39,7 +39,14 @@
<ion-radio [(ngModel)]="postEvent.CalendarName" slot="start" value="griff"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</ion-list> -->
<ion-item>
<ion-label>Selecione o calendário</ion-label>
<ion-select [(ngModel)]="postEvent.CalendarName" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option Pessoal="Reunião">Pessoal</ion-select-option>
<ion-select-option Oficial="Viagem">Oficial</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Selecione o tipo de evento</ion-label>
<ion-select [(ngModel)]="postEvent.EventType" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
@@ -61,7 +68,7 @@
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<div class="div-attach">
<!-- <div class="div-attach">
<ion-item>
<ion-icon name="add" slot="end"></ion-icon>
<ion-label class="attach-label">Anexos</ion-label>
@@ -74,7 +81,7 @@
<ion-icon name="trash" slot="end"></ion-icon>
</ion-item>
</ion-list>
</div>
</div>-->
</div>
</ion-content>
<ion-footer class="ion-no-border">
+8 -29
View File
@@ -3,6 +3,7 @@ import { ModalController } from '@ionic/angular';
import { Event } from '../../models/event.model';
import { EventsService } from 'src/app/services/events.service';
import { EventBody } from 'src/app/models/eventbody.model';
@Component({
selector: 'app-cal-modal',
@@ -17,32 +18,13 @@ export class CalModalPage implements AfterViewInit {
};
viewTitle: string;
public postEvent: Event = {
EventId: '',
Subject: '',
Body: null,
Location: '',
CalendarId: '',
CalendarName: '',
StartDate: '',
EndDate: '',
EventType: '',
RequiredAttendees: null,
OptionalAttendees: null,
HasAttachments: false,
IsMeeting: false,
IsRecurring: false,
AppointmentState: 0,
TimeZone: '',
Organizer: '',
Categories: null,
Attachments: null,
};
postEvent: Event;
modalReady = false;
constructor(private modalCtrl: ModalController, private eventService: EventsService) { }
constructor(private modalCtrl: ModalController, private eventService: EventsService) {
this.postEvent = new Event();
this.postEvent.Body = { BodyType : "1", Text : ""};
}
ngOnInit() {
}
@@ -54,11 +36,8 @@ export class CalModalPage implements AfterViewInit {
}
save(){
this.modalCtrl.dismiss({postEvent: this.eventService.AddEvent(this.postEvent)});
/* this.eventService.AddEvent(); */
console.log("created");
this.eventService.postEvent(this.postEvent, this.postEvent.CalendarName).subscribe();
this.modalCtrl.dismiss();
}
onViewTitleChanged(title){
@@ -15,7 +15,9 @@ export class EventDetailPage implements OnInit {
loadedEvent: Event;
eventItem: Observable<Event>;
constructor(private activatedRoute: ActivatedRoute, private eventsService: EventsService) { }
constructor(private activatedRoute: ActivatedRoute, private eventsService: EventsService) {
this.loadedEvent = new Event();
}
ngOnInit() {
/* Emit new data when something changes */
@@ -38,7 +40,7 @@ export class EventDetailPage implements OnInit {
Save()
{
this.eventsService.PutEvent(this.loadedEvent).subscribe(response =>
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(response =>
{
this.loadedEvent = response;
});
+9 -11
View File
@@ -13,7 +13,7 @@
<ion-item class="ion-text-right" lines="none">
<ion-label class="ion-text-wrap">
<h3 class="header-medium"> {{greetting}} Sua Excelência <br />
Minístro Director do Gabinete do<br />
Ministro Director do Gabinete do<br />
Presidente da República
</h3>
<p class="p-small">{{customDate}}</p>
@@ -41,11 +41,10 @@
<!-- List of Text Items -->
<div [ngSwitch]="segment">
<ion-list *ngSwitchCase="'combinada'" >
<ion-item-group *ngIf="eventsList | async as events">
<ion-item-group>
<ion-item-sliding>
<ion-item lines="none"
*ngFor="let event of events"
*ngFor="let event of eventsList"
[routerLink]="['/home/events', event.EventId]">
<div class="div-item">
<div class="div-up">
@@ -77,12 +76,12 @@
</ion-list>
<!-- OFICIAL -->
<ion-list *ngSwitchCase="'oficial'">
<ion-item-group>
<!-- <ion-item-group>
<ion-item-sliding>
<ion-item-divider>
<ion-label>8:00 am</ion-label>
</ion-item-divider>
<ion-item lines="none" *ngFor="let event of events">
<ion-item lines="none" *ngFor="let event of eventsList">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
@@ -107,13 +106,13 @@
</div>
</ion-item>
</ion-item-sliding>
</ion-item-group>
</ion-item-group> -->
</ion-list>
<ion-list *ngSwitchCase="'pessoal'">
<ion-item-group>
<!-- <ion-item-group>
<ion-item-sliding>
<ion-item lines="none" *ngFor="let event of events">
<ion-item lines="none" *ngFor="let event of eventsList">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
@@ -138,8 +137,7 @@
</div>
</ion-item>
</ion-item-sliding>
</ion-item-group>
</ion-item-group> -->
</ion-list>
</div>
</ion-content>
+42 -40
View File
@@ -1,10 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, LOCALE_ID } from '@angular/core';
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';
import { formatDate } from '@angular/common';
@Component({
@@ -13,52 +13,54 @@ import { Observable } from 'rxjs';
styleUrls: ['./events.page.scss'],
})
export class EventsPage implements OnInit {
/* Get current system date */
today = new Date();
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
/* Get current system date */
today = new Date();
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate = this.days[this.today.getDay()]+ ", "
+ this.today.getDate() +" de "
+ ( this.months[this.today.getMonth()]);
/* Setting appropriate greeting according to the time */
grettings = ["Bom dia", "Boa tarde", "Boa noite"];
greetting='';
timeDate = this.today.getHours() + ":" + this.today.getMinutes();
/* Set segment variable */
segment:string;
customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
events: Event[];
eventsList: Observable<Event[]>;
/* Setting appropriate greeting according to the time */
grettings = ["Bom dia", "Boa tarde", "Boa noite"];
greetting='';
constructor(private eventService: EventsService, private router: Router, public activatedRoute: ActivatedRoute) { }
timeDate = this.today.getHours() + ":" + this.today.getMinutes();
/* Set segment variable */
segment:string;
ngOnInit() {
//Inicializar segment
this.segment = "combinada";
this.showGreeting();
/* Call Get events method */
this.eventsList = this.eventService.allEvents();/* .subscribe(prods=>console.log(prods)); */
}
eventsList: Event[];
showGreeting(){
if(this.today.getHours() >= 6 && this.today.getHours() < 12){
console.log(this.grettings[0]+this.today.getHours());
this.greetting = this.grettings[0];
constructor(private eventService: EventsService, private router: Router, public activatedRoute: ActivatedRoute) { }
ngOnInit() {
//Inicializar segment
this.segment = "combinada";
this.showGreeting();
/* Call Get events method */
this.eventService.getAllEvents(formatDate(new Date(), 'yyyy-MM-dd', 'pt') + ' 00:00:00', formatDate(new Date(), 'yyyy-MM-dd', 'pt') + ' 23:59:59')
.subscribe(response => {
this.eventsList = response;
}
);
}
else if(this.today.getHours() >= 12 && this.today.getHours() < 18){
console.log(this.grettings[1]+this.today.getHours());
this.greetting = this.grettings[1];
}
else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */{
console.log(this.grettings[2]+this.today.getHours());
this.greetting = this.grettings[2];
showGreeting(){
if(this.today.getHours() >= 6 && this.today.getHours() < 12){
this.greetting = this.grettings[0];
}
else if(this.today.getHours() >= 12 && this.today.getHours() < 18){
this.greetting = this.grettings[1];
}
else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */{
this.greetting = this.grettings[2];
}
}
gotTo(){
this.router.navigate(['/home/events']);
}
}
gotTo(ev){
this.router.navigate(['/home/events']);
}
}
+66 -120
View File
@@ -2,141 +2,87 @@ import { Injectable } from '@angular/core';
import { Event } from '../models/event.model';
import axios from 'axios'
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { stringify } from 'querystring';
import { AuthService } from '../services/auth.service';
import { User } from '../models/user.model';
import { CalModalPageRoutingModule } from '../pages/cal-modal/cal-modal-routing.module';
@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: '',
CalendarName: 'pessoal',
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: '',
CalendarName: 'pessoal',
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,
}
];
options = {};
authheader = {};
loggeduser: User;
headers: HttpHeaders;
constructor(private http: HttpClient, private user: AuthService) {
constructor(private http: HttpClient, user: AuthService) {
this.loggeduser = user.ValidatedUser;
this.options = { headers: {'Authorization': this.loggeduser.BasicAuthKey}};
this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
allEvents(): Observable<Event[]>{
console.log(this.loggeduser);
const geturl = environment.apiURL + 'calendar/GetEvents?StartDate=2020-08-14 00:00:00&EndDate=2020-08-19 23:59:00&CalendarName=Pessoal';
getAllEvents(startdate:string, enddate:string): Observable<Event[]>{
const geturl = environment.apiURL + 'calendar/GetAllEvents';
let params = new HttpParams();
params = params.set("StartDate", startdate);
params = params.set("EndDate", enddate);
return this.http.get<Event[]>(`${geturl}`, this.options)
}
getEvent(ev: string): Observable<Event>{
const geturl = environment.apiURL + 'calendar/GetEvent?EventId=';
return this.http.get<Event>(`${geturl + ev}`, this.options)
}
PutEvent(event: Event): Observable<Event>
{
const puturl = environment.apiURL +'calendar/PutEvent?conflictResolutionMode=2&sendInvitationsOrCancellationsMode=3';
return this.http.put<Event>(`${puturl}`, event,this.options)
}
AddEvent(postEvent: any){
const url = 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/api/calendar/PostEvent';
const mydata = JSON.stringify({
"AppointmentState":1,
"Body":{"BodyType":1,"Text":"Noooooo"},
"CalendarId":"AAMkAGMwNTJiZDY2LTZjN2MtNDgzYS1hNzAzLTZhZWRhNTk3ZWNiMAAuAAAAAABgX8u97PeNQrYTHXctnZkcAQB4Hy3hTowgSI7Yp8YAVgKKAAACCd9zAAA=",
"EndDate":"8/16/2020 6:00:00 PM",
"EventType":"Single","HasAttachments":false,
"IsMeeting":true,"IsRecurring":false,
"Location":postEvent.Location,
"OptionalAttendees":null,
"Organizer":{"EmailAddress":"paulo.pinto@gabinetedigital.local","Name":"Paulo Pinto"},
"RequiredAttendees":[{"EmailAddress":"Administrator@gabinetedigital.local","Name":"Administrator"},{"EmailAddress":"tiago.kayaya@gabinetedigital.local","Name":"Tiago Kayaya"}],
"StartDate":"8/14/2020 5:30:00 PM",
"Subject":postEvent.Subject,
"TimeZone":"(UTC+01:00) Centro-Oeste da África"});
/* const options = {
method: 'post',
url: 'url',
headears: {
'Authorization': 'Basic Z2FiaW5ldGVkaWdpdGFsLmxvY2FsXHBhdWxvLnBpbnRvOnRhYnRlc3RlQDAwNg==',
'Content-Type': 'application/json'
},
data: data
} */
console.log(postEvent.Subject);
axios({
method: 'post',
url: url,
data: mydata,
headers: {'Authorization': 'Basic Z2FiaW5ldGVkaWdpdGFsLmxvY2FsXHBhdWxvLnBpbnRvOnRhYnRlc3RlQDAwNg==',
'Content-Type': 'application/json' }
})
.then(function (response) {
//handle success
console.log(response);
})
.catch(function (response) {
//handle error
console.log(response);
});
}
getStaticEvent(eventId: string){
return {
// 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
return event.EventId === eventId;
})
let options = {
headers: this.headers,
params: params
};
console.log(options);
return this.http.get<Event[]>(`${geturl}`, options);
}
getEvent(eventid: string): Observable<Event>{
const geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams();
params = params.set("EventId", eventid);
let options = {
headers: this.headers,
params: params
};
return this.http.get<Event>(`${geturl}`, options)
}
putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event>
{
const puturl = environment.apiURL + 'calendar/PutEvent';
let params: HttpParams;
params.append("conflictResolutionMode", conflictResolutionMode.toString());
params.append("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
let options = {
headers: this.headers,
params: params
};
return this.http.put<Event>(`${puturl}`, event, options)
}
postEvent(event:Event, calendarName:string)
{
const puturl = environment.apiURL + 'calendar/PostEvent';
let params = new HttpParams();
params = params.set("CalendarName", calendarName);
let options = {
headers: this.headers,
params: params
};
return this.http.post<Event>(`${puturl}`, event, options)
}
}