mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Removed synchro services
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Event, EventToApproveEdit } from '../models/event.model';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Observable, from} from 'rxjs';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { UserSession } from '../models/user.model';
|
||||
import { EventList } from '../models/agenda/AgendaEventList';
|
||||
import { ChangeProfileService } from './change-profile.service';
|
||||
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
|
||||
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||
import { catchError } from "rxjs/operators";
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -32,12 +32,12 @@ export class EventsService {
|
||||
headersSharedPessoal: HttpHeaders;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private http: HttpClient,
|
||||
public user: AuthService,
|
||||
private changeProfileService: ChangeProfileService,
|
||||
private offlinemanager: OfflineManagerService,
|
||||
private storage: Storage)
|
||||
{
|
||||
private storage: Storage,
|
||||
private backgroundservice: BackgroundService) {
|
||||
|
||||
this.loggeduser = this.user.ValidatedUser;
|
||||
|
||||
@@ -50,9 +50,9 @@ export class EventsService {
|
||||
this.headersSharedOficial = new HttpHeaders();
|
||||
this.headersSharedPessoal = new HttpHeaders();
|
||||
|
||||
|
||||
|
||||
this.setHeader()
|
||||
this.changeProfileService.registerCallback(()=>{
|
||||
this.changeProfileService.registerCallback(() => {
|
||||
this.loggeduser = this.user.ValidatedUser;
|
||||
this.setHeader()
|
||||
})
|
||||
@@ -61,16 +61,16 @@ export class EventsService {
|
||||
|
||||
setHeader() {
|
||||
|
||||
if(this.loggeduser){
|
||||
if(this.loggeduser.Profile == 'MDGPR') {
|
||||
if (this.loggeduser) {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
|
||||
this.loggeduser.OwnerCalendars.forEach(calendar => {
|
||||
if(calendar.CalendarName == 'Oficial') {
|
||||
if (calendar.CalendarName == 'Oficial') {
|
||||
this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
}
|
||||
else if(calendar.CalendarName == 'Pessoal') {
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
@@ -79,27 +79,27 @@ export class EventsService {
|
||||
});
|
||||
|
||||
this.loggeduser.SharedCalendars.forEach(sharedCalendar => {
|
||||
if(sharedCalendar.CalendarName == 'Oficial') {
|
||||
if (sharedCalendar.CalendarName == 'Oficial') {
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
}
|
||||
else if(sharedCalendar.CalendarName == 'Pessoal') {
|
||||
else if (sharedCalendar.CalendarName == 'Pessoal') {
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR') {
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
|
||||
this.loggeduser.OwnerCalendars.forEach(calendar =>{
|
||||
if(calendar.CalendarName == 'Oficial'){
|
||||
this.loggeduser.OwnerCalendars.forEach(calendar => {
|
||||
if (calendar.CalendarName == 'Oficial') {
|
||||
this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
}
|
||||
else if(calendar.CalendarName == 'Pessoal') {
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
@@ -128,9 +128,9 @@ export class EventsService {
|
||||
} */
|
||||
|
||||
|
||||
getAllPrOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
|
||||
getAllPrOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
|
||||
let geturl = environment.apiURL + 'calendar/pr';
|
||||
geturl = geturl.replace('/V4/','/V5/')
|
||||
geturl = geturl.replace('/V4/', '/V5/')
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -144,9 +144,9 @@ export class EventsService {
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<EventList[]>{
|
||||
getAllPrPessoalEvents(startdate: string, enddate: string): Observable<EventList[]> {
|
||||
let geturl = environment.apiURL + 'calendar/pr';
|
||||
geturl = geturl.replace('/V4/','/V5/')
|
||||
geturl = geturl.replace('/V4/', '/V5/')
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -160,17 +160,17 @@ export class EventsService {
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
async getAllPrEvents(startdate:string, enddate:string): Promise<EventList[]>{
|
||||
async getAllPrEvents(startdate: string, enddate: string): Promise<EventList[]> {
|
||||
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
|
||||
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
|
||||
const resFinal = prO.concat(prP);
|
||||
return new Promise(resolve =>{
|
||||
return new Promise(resolve => {
|
||||
return resolve(resFinal)
|
||||
})
|
||||
}
|
||||
|
||||
getAllMdOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
|
||||
let geturl = environment.apiURL + 'calendar/md';
|
||||
getAllMdOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
|
||||
let geturl = environment.apiURL + 'calendar/md';
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -184,7 +184,7 @@ export class EventsService {
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getAllMdPessoalEvents(startdate:string, enddate:string): any{
|
||||
getAllMdPessoalEvents(startdate: string, enddate: string): any {
|
||||
let geturl = environment.apiURL + 'calendar/md';
|
||||
|
||||
let params = new HttpParams();
|
||||
@@ -199,30 +199,30 @@ export class EventsService {
|
||||
return this.http.get<any>(`${geturl}`, options)
|
||||
}
|
||||
|
||||
async getAllMdEvents(startdate:string, enddate:string) {
|
||||
async getAllMdEvents(startdate: string, enddate: string) {
|
||||
let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
|
||||
let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
|
||||
const resFinal = prO.concat(prP);
|
||||
return new Promise(resolve =>{
|
||||
return new Promise(resolve => {
|
||||
return resolve(resFinal)
|
||||
});
|
||||
}
|
||||
|
||||
async getAllSharedEvents(startdate:string, enddate:string) {
|
||||
async getAllSharedEvents(startdate: string, enddate: string) {
|
||||
let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise();
|
||||
let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise();
|
||||
const resFinal = prO.concat(prP);
|
||||
|
||||
return new Promise(resolve =>{
|
||||
return new Promise(resolve => {
|
||||
return resolve(resFinal)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
getAllSharedOficialEvents(startdate:string, enddate:string): Observable<Event[]>{
|
||||
getAllSharedOficialEvents(startdate: string, enddate: string): Observable<Event[]> {
|
||||
let geturl = environment.apiURL + 'calendar/pr';
|
||||
geturl = geturl.replace('/V4/','/V5/')
|
||||
geturl = geturl.replace('/V4/', '/V5/')
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -238,9 +238,9 @@ export class EventsService {
|
||||
return this.http.get<Event[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getAllSharedPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{
|
||||
getAllSharedPessoalEvents(startdate: string, enddate: string): Observable<Event[]> {
|
||||
let geturl = environment.apiURL + 'calendar/pr';
|
||||
geturl = geturl.replace('/V4/','/V5/')
|
||||
geturl = geturl.replace('/V4/', '/V5/')
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -255,7 +255,7 @@ export class EventsService {
|
||||
}
|
||||
|
||||
|
||||
getRecurrenceTypes(): any{
|
||||
getRecurrenceTypes(): any {
|
||||
const geturl = environment.apiURL + 'Calendar/RecurrenceTypes';
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
@@ -264,7 +264,7 @@ export class EventsService {
|
||||
}
|
||||
|
||||
|
||||
getEvents(calendarname:string, startdate:string, enddate:string): Observable<Event[]>{
|
||||
getEvents(calendarname: string, startdate: string, enddate: string): Observable<Event[]> {
|
||||
const geturl = environment.apiURL + 'calendar/GetEvents';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -279,7 +279,7 @@ export class EventsService {
|
||||
return this.http.get<Event[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getEvent(eventid: string): Observable<Event>{
|
||||
getEvent(eventid: string): Observable<Event> {
|
||||
let geturl = environment.apiURL + 'calendar/GetEvent';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -293,8 +293,7 @@ export class EventsService {
|
||||
return this.http.get<Event>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number, sharedagenda:string): Observable<Event>
|
||||
{
|
||||
putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable<Event> {
|
||||
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent');
|
||||
|
||||
let params = new HttpParams();
|
||||
@@ -310,55 +309,50 @@ export class EventsService {
|
||||
return this.http.put<Event>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
editEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event>
|
||||
{
|
||||
editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number): Observable<Event> {
|
||||
let arrayReq = [];
|
||||
arrayReq.push(event);
|
||||
const puturl = environment.apiURL + 'calendar/PutEvent';
|
||||
if(synchro.connected === false) {
|
||||
arrayReq.push(event)
|
||||
return from(this.storage.set('storedreq', arrayReq))
|
||||
} else {
|
||||
let params = new HttpParams();
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
|
||||
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
|
||||
params.set('CalendarId', event.CalendarId)
|
||||
params.set('CalendarName', event.CalendarName)
|
||||
this.headers['CalendarId'] = event.CalendarId
|
||||
this.headers['CalendarName'] = event.CalendarName
|
||||
|
||||
if(event.CalendarName == 'Oficial'){
|
||||
if(this.loggeduser.Profile == 'MDGPR'){
|
||||
this.headers = this.headersMdOficial;
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR'){
|
||||
this.headers = this.headersPrOficial;
|
||||
}
|
||||
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
|
||||
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
|
||||
params.set('CalendarId', event.CalendarId)
|
||||
params.set('CalendarName', event.CalendarName)
|
||||
this.headers['CalendarId'] = event.CalendarId
|
||||
this.headers['CalendarName'] = event.CalendarName
|
||||
|
||||
if (event.CalendarName == 'Oficial') {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
this.headers = this.headersMdOficial;
|
||||
}
|
||||
else{
|
||||
if(this.loggeduser.Profile == 'MDGPR'){
|
||||
this.headers = this.headersMdPessoal;
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR'){
|
||||
this.headers = this.headersPrPessoal;
|
||||
}
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
this.headers = this.headersPrOficial;
|
||||
}
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
|
||||
return this.http.put<Event>(`${puturl}`, event, options).pipe(
|
||||
catchError(err => {
|
||||
this.offlinemanager.storeRequest(puturl, 'PUT', event);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
}
|
||||
else {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
this.headers = this.headersMdPessoal;
|
||||
}
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
this.headers = this.headersPrPessoal;
|
||||
}
|
||||
}
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
|
||||
return this.http.put<Event>(`${puturl}`, event, options).pipe(
|
||||
catchError(err => {
|
||||
this.offlinemanager.storeRequest(puturl, 'PUT', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
changeAgenda(body:any){
|
||||
changeAgenda(body: any) {
|
||||
const puturl = environment.apiURL + 'Calendar/MoveEvent';
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
@@ -381,14 +375,13 @@ export class EventsService {
|
||||
return this.http.post<Event>(`${puturl}`, event, options)
|
||||
} */
|
||||
|
||||
postEventMd(event:Event, calendarName:string)
|
||||
{
|
||||
postEventMd(event: Event, calendarName: string) {
|
||||
const puturl = environment.apiURL + 'calendar/md';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("CalendarName", calendarName);
|
||||
|
||||
let options:any;
|
||||
let options: any;
|
||||
switch (calendarName) {
|
||||
case 'Oficial':
|
||||
console.log(calendarName);
|
||||
@@ -410,14 +403,13 @@ export class EventsService {
|
||||
return this.http.post<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
postEventPr(event:Event, calendarName:string)
|
||||
{
|
||||
postEventPr(event: Event, calendarName: string) {
|
||||
const puturl = environment.apiURL + 'calendar/pr';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("CalendarName", calendarName);
|
||||
|
||||
let options:any;
|
||||
let options: any;
|
||||
switch (calendarName) {
|
||||
case 'Oficial':
|
||||
console.log(calendarName);
|
||||
@@ -439,8 +431,7 @@ export class EventsService {
|
||||
return this.http.post<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
deleteEvent(eventid:string, eventDeleteType:number, calendarName:string)
|
||||
{
|
||||
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
|
||||
const puturl = environment.apiURL + 'calendar/DeleteEvent';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -452,13 +443,13 @@ export class EventsService {
|
||||
|
||||
switch (this.loggeduser.Profile) {
|
||||
case 'MDGPR':
|
||||
if(calendarName == 'Pessoal'){
|
||||
if (calendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersMdPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(calendarName == 'Oficial'){
|
||||
else if (calendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersMdOficial,
|
||||
params: params
|
||||
@@ -466,13 +457,13 @@ export class EventsService {
|
||||
}
|
||||
break;
|
||||
case 'PR':
|
||||
if(calendarName == 'Pessoal'){
|
||||
if (calendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersPrPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(calendarName == 'Oficial'){
|
||||
else if (calendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersPrOficial,
|
||||
params: params
|
||||
@@ -483,8 +474,8 @@ export class EventsService {
|
||||
|
||||
return this.http.delete(`${puturl}`, options)
|
||||
}
|
||||
postExpedientEvent(docId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/event';
|
||||
postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
|
||||
let params = new HttpParams();
|
||||
let options;
|
||||
|
||||
@@ -494,13 +485,13 @@ export class EventsService {
|
||||
|
||||
switch (this.loggeduser.Profile) {
|
||||
case 'MDGPR':
|
||||
if(body.CalendarName == 'Pessoal'){
|
||||
if (body.CalendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersMdPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(body.CalendarName == 'Oficial'){
|
||||
else if (body.CalendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersMdOficial,
|
||||
params: params
|
||||
@@ -508,13 +499,13 @@ export class EventsService {
|
||||
}
|
||||
break;
|
||||
case 'PR':
|
||||
if(body.CalendarName == 'Pessoal'){
|
||||
if (body.CalendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersPrPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(body.CalendarName == 'Oficial'){
|
||||
else if (body.CalendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersPrOficial,
|
||||
params: params
|
||||
@@ -524,8 +515,8 @@ export class EventsService {
|
||||
}
|
||||
return this.http.post<any>(`${geturl}`, body, options)
|
||||
}
|
||||
createTaskEvent(folderId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/dispatch';
|
||||
createTaskEvent(folderId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/dispatch';
|
||||
let params = new HttpParams();
|
||||
let options;
|
||||
|
||||
@@ -535,13 +526,13 @@ export class EventsService {
|
||||
|
||||
switch (this.loggeduser.Profile) {
|
||||
case 'MDGPR':
|
||||
if(body.CalendarName == 'Pessoal'){
|
||||
if (body.CalendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersMdPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(body.CalendarName == 'Oficial'){
|
||||
else if (body.CalendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersMdOficial,
|
||||
params: params
|
||||
@@ -549,20 +540,20 @@ export class EventsService {
|
||||
}
|
||||
break;
|
||||
case 'PR':
|
||||
if(body.CalendarName == 'Pessoal'){
|
||||
if (body.CalendarName == 'Pessoal') {
|
||||
options = {
|
||||
headers: this.headersPrPessoal,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
else if(body.CalendarName == 'Oficial'){
|
||||
else if (body.CalendarName == 'Oficial') {
|
||||
options = {
|
||||
headers: this.headersPrOficial,
|
||||
params: params
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.http.post<any>(`${geturl}`, body, options)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user