mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add defualt calendar
This commit is contained in:
@@ -140,7 +140,7 @@
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div class="calendar-conteiner-height overflow-hidden" [style.height]="listBoxService.height">
|
||||
<div class="calendar-conteiner-height overflow-hidden" [style.height]="listBoxService.height">
|
||||
<calendar
|
||||
class="calendar-component"
|
||||
[eventSource]="listToPresent"
|
||||
|
||||
@@ -239,6 +239,14 @@ export class AgendaPage implements OnInit {
|
||||
}
|
||||
|
||||
this.weekToShow()
|
||||
|
||||
this.eventService.registerOnLoadCalendars(()=> {
|
||||
this.setCalendarByDefault(true)
|
||||
const selectedCalendarIds = this.getSelectedAgendaCalendars();
|
||||
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
|
||||
|
||||
this.tigerUpdate()
|
||||
})
|
||||
}
|
||||
|
||||
tigerUpdate() {
|
||||
@@ -257,7 +265,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.setCalendarByDefault()
|
||||
this.setCalendarByDefault(false)
|
||||
const selectedCalendarIds = this.getSelectedAgendaCalendars();
|
||||
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
|
||||
|
||||
@@ -338,14 +346,20 @@ export class AgendaPage implements OnInit {
|
||||
}, 250)
|
||||
}
|
||||
|
||||
setCalendarByDefault() {
|
||||
if (!this.CalendarName) {
|
||||
if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
setCalendarByDefault(force) {
|
||||
if (!this.CalendarName || force) {
|
||||
const prObject = this.eventService.calendarNamesAry.find(e => e?.RoleId == 100000014)
|
||||
|
||||
if(prObject) {
|
||||
console.log({prObject})
|
||||
this.CalendarName = prObject.Fullname
|
||||
} else if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.CalendarName = 'Meu calendario';
|
||||
} else {
|
||||
this.CalendarName = this.eventService.calendarNamesAry[0]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Go to the next view of the calendar month/week/day
|
||||
|
||||
@@ -35,10 +35,10 @@ export class EventsService {
|
||||
|
||||
headersSharedOficial: HttpHeaders;
|
||||
headersSharedPessoal: HttpHeaders;
|
||||
|
||||
|
||||
calendarIds = []
|
||||
usersCalendarIds = []
|
||||
|
||||
|
||||
hasSharedCalendar = false;
|
||||
hasSharedOficial: boolean = false;
|
||||
hasSharedPessoal: boolean = false;
|
||||
@@ -48,7 +48,7 @@ export class EventsService {
|
||||
hasOwnCalendar = false
|
||||
|
||||
calendarNames = {}
|
||||
|
||||
|
||||
calendarNamesAry = []
|
||||
calendarNamesAryNoPr = []
|
||||
calendarNamesAryNoPrNMD = []
|
||||
@@ -62,9 +62,13 @@ export class EventsService {
|
||||
|
||||
myCalendarNames = {}
|
||||
hasAnyCalendar = false
|
||||
|
||||
|
||||
HasMdGPR = false
|
||||
|
||||
onLoadCalendars: Function[] =[]
|
||||
loadCalendars = false
|
||||
|
||||
|
||||
onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true})
|
||||
|
||||
constructor(
|
||||
@@ -81,7 +85,7 @@ export class EventsService {
|
||||
}
|
||||
|
||||
async setHeader () {
|
||||
|
||||
|
||||
this.headers = new HttpHeaders();;
|
||||
this.headersMdOficial = new HttpHeaders();;
|
||||
this.headersMdPessoal = new HttpHeaders();;
|
||||
@@ -95,7 +99,7 @@ export class EventsService {
|
||||
|
||||
this.headerOwnOficial= new HttpHeaders();;
|
||||
this.headerOwnPessoal= new HttpHeaders();;
|
||||
|
||||
|
||||
this.headerSharedOficial= new HttpHeaders();;
|
||||
this.headerSharedPessoal= new HttpHeaders();;
|
||||
|
||||
@@ -106,7 +110,7 @@ export class EventsService {
|
||||
this.calendarRole = []
|
||||
this.calendrFullName = [];
|
||||
this.calendarIds = []
|
||||
|
||||
|
||||
this.calendarNamesAry = []
|
||||
this.calendarNamesType = {}
|
||||
this.calendarNamesAryNoPr = []
|
||||
@@ -151,10 +155,10 @@ export class EventsService {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
|
||||
|
||||
if (sharedCalendar.CalendarName == 'Oficial') {
|
||||
|
||||
this.hasSharedOficial = true
|
||||
@@ -288,17 +292,17 @@ export class EventsService {
|
||||
|
||||
this.calendarNames[sharedCalendar.CalendarId] = e.FullName
|
||||
this.myCalendarNames[sharedCalendar.CalendarId] = e.FullName
|
||||
|
||||
|
||||
if(!this.calendarNamesAry.find(x => x.Role == e.Role)) {
|
||||
|
||||
|
||||
|
||||
|
||||
let objectShared = {
|
||||
"Fullname": e.FullName,
|
||||
"Role": e.Role,
|
||||
"OwnerUserId": sharedCalendar.OwnerUserId,
|
||||
"RoleId": sharedCalendar.CalendarRoleId
|
||||
}
|
||||
|
||||
|
||||
this.calendarNamesAry.push(objectShared)
|
||||
|
||||
if(e.Role == 'Presidente da República') {
|
||||
@@ -306,7 +310,7 @@ export class EventsService {
|
||||
} else {
|
||||
this.calendarNamesAryNoPr.push(objectShared)
|
||||
}
|
||||
|
||||
|
||||
this.calendarNamesType[e.FullName] = {}
|
||||
}
|
||||
|
||||
@@ -315,7 +319,7 @@ export class EventsService {
|
||||
this.calendarNamesType[e.FullName]['RoleId'] = sharedCalendar.CalendarRoleId
|
||||
this.calendarNamesType[e.FullName]['OwnerId'] = sharedCalendar.OwnerUserId
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.calendarNamesAryNoPrNMD = this.calendarNamesAryNoPr.filter((e)=> {
|
||||
@@ -329,7 +333,7 @@ export class EventsService {
|
||||
|
||||
this.HasMdGPR = this.calendarNamesAryNoPr.find( (e)=> {
|
||||
if(e.Role == 'Ministro e Director do Gabinete do PR') {
|
||||
return true
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
@@ -341,7 +345,7 @@ export class EventsService {
|
||||
this.hasAnyCalendar = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.calendarNamesAryReverse = this.calendarNamesAry.reverse();
|
||||
|
||||
this.onCalendarFinishLoad.executor();
|
||||
@@ -366,8 +370,22 @@ export class EventsService {
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.onLoadCalendars.forEach(e=> e());
|
||||
this.loadCalendars = true
|
||||
}
|
||||
|
||||
|
||||
registerOnLoadCalendars(e: Function) {
|
||||
if( this.loadCalendars) {
|
||||
e()
|
||||
} else {
|
||||
this.onLoadCalendars.push(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +415,7 @@ export class EventsService {
|
||||
|
||||
|
||||
isMyEvent(event: any) {
|
||||
|
||||
|
||||
for (let calendar of SessionStore.user.OwnerCalendars) {
|
||||
if(event.CalendarId == calendar.CalendarId) {
|
||||
return true
|
||||
@@ -409,14 +427,14 @@ export class EventsService {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
detectCalendarNameByCalendarId(calendarId) {
|
||||
|
||||
|
||||
for ( const property in this.calendarNamesType) {
|
||||
if(this.calendarNamesType[property]?.['Oficial']) {
|
||||
if(this.calendarNamesType[property]['OficialId'] == calendarId) {
|
||||
@@ -429,7 +447,7 @@ export class EventsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +560,7 @@ export class EventsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const resFinal = prO.concat(prP);
|
||||
return new Promise(resolve => {
|
||||
return resolve(resFinal)
|
||||
@@ -621,14 +639,14 @@ export class EventsService {
|
||||
header = header.set('CalendarRoleId', agendasCalendar.CalendarRoleId);
|
||||
header = header.set('CalendarName', agendasCalendar.CalendarName);
|
||||
|
||||
|
||||
|
||||
let geturl = environment.apiURL + 'calendar/GetEvents';
|
||||
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
|
||||
params = params.set("StartDate", startdate);
|
||||
params = params.set("EndDate", enddate);
|
||||
|
||||
|
||||
let options = {
|
||||
headers: header,
|
||||
params: params
|
||||
@@ -655,12 +673,12 @@ export class EventsService {
|
||||
header = header.set('CalendarName', sharedCalendar.CalendarName);
|
||||
|
||||
let geturl = environment.apiURL + 'calendar/GetEvents';
|
||||
|
||||
|
||||
let params = new HttpParams();
|
||||
|
||||
|
||||
params = params.set("StartDate", startdate);
|
||||
params = params.set("EndDate", enddate);
|
||||
|
||||
|
||||
let options = {
|
||||
headers: header,
|
||||
params: params
|
||||
@@ -686,7 +704,7 @@ export class EventsService {
|
||||
params = params.set("StartDate", startdate);
|
||||
params = params.set("EndDate", enddate);
|
||||
|
||||
|
||||
|
||||
|
||||
let options = {
|
||||
headers: this.headerSharedOficial,
|
||||
@@ -725,7 +743,7 @@ export class EventsService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const resFinal = prO.concat(prP);
|
||||
|
||||
return new Promise(resolve => {
|
||||
@@ -746,7 +764,7 @@ export class EventsService {
|
||||
headers: this.headersSharedOficial,
|
||||
params: params
|
||||
};
|
||||
|
||||
|
||||
|
||||
return this.http.get<Event[]>(`${geturl}`, options);
|
||||
}
|
||||
@@ -814,13 +832,13 @@ export class EventsService {
|
||||
|
||||
const calendar = this.DetectCalendars(calendarId)
|
||||
const header = this.makeHeader(calendar)
|
||||
|
||||
|
||||
if(header) {
|
||||
let options = {
|
||||
headers: header,
|
||||
params: params
|
||||
}
|
||||
|
||||
|
||||
return this.http.get<Event>(`${geturl}`, options);
|
||||
} else {
|
||||
|
||||
@@ -875,18 +893,18 @@ export class EventsService {
|
||||
else if (SessionStore.user.Profile == 'PR') {
|
||||
this.headers = this.headersPrOficial;
|
||||
} else {
|
||||
|
||||
|
||||
const headers = [
|
||||
this.headerSharedOficial,
|
||||
this.headerSharedPessoal,
|
||||
this.headerOwnPessoal,
|
||||
this.headerOwnOficial
|
||||
]
|
||||
|
||||
]
|
||||
|
||||
const header = headers.find((header)=> {
|
||||
return header?.get('CalendarId')?.includes(CalendarId)
|
||||
})
|
||||
|
||||
|
||||
this.headers = header
|
||||
}
|
||||
}
|
||||
@@ -903,12 +921,12 @@ export class EventsService {
|
||||
this.headerSharedPessoal,
|
||||
this.headerOwnPessoal,
|
||||
this.headerOwnOficial
|
||||
]
|
||||
|
||||
]
|
||||
|
||||
const header = headers.find((header)=> {
|
||||
return header?.get('CalendarId')?.includes(CalendarId)
|
||||
})
|
||||
|
||||
|
||||
this.headers = header
|
||||
}
|
||||
}
|
||||
@@ -920,13 +938,13 @@ export class EventsService {
|
||||
|
||||
return this.http.put<Event>(`${puturl}`, event, options).pipe(
|
||||
catchError(err => {
|
||||
|
||||
|
||||
this.offlinemanager.storeRequestData('eventEdit', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
changeAgenda(body: any) {
|
||||
const puturl = environment.apiURL + 'Calendar/MoveEvent';
|
||||
@@ -948,7 +966,7 @@ export class EventsService {
|
||||
let options: any;
|
||||
switch (calendarName) {
|
||||
case 'Oficial':
|
||||
|
||||
|
||||
options = {
|
||||
headers: this.headersMdOficial,
|
||||
params: params
|
||||
@@ -956,14 +974,14 @@ export class EventsService {
|
||||
break;
|
||||
|
||||
case 'Pessoal':
|
||||
|
||||
|
||||
options = {
|
||||
headers: this.headersMdPessoal,
|
||||
params: params
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return this.http.post<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
@@ -980,7 +998,7 @@ export class EventsService {
|
||||
let options: any;
|
||||
switch (calendarName) {
|
||||
case 'Oficial':
|
||||
|
||||
|
||||
options = {
|
||||
headers: this.headersPrOficial,
|
||||
params: params
|
||||
@@ -988,7 +1006,7 @@ export class EventsService {
|
||||
break;
|
||||
|
||||
case 'Pessoal':
|
||||
|
||||
|
||||
options = {
|
||||
headers: this.headersPrPessoal,
|
||||
params: params
|
||||
@@ -1006,7 +1024,7 @@ export class EventsService {
|
||||
let params = new HttpParams();
|
||||
|
||||
const now = new Date();
|
||||
|
||||
|
||||
event.TimeZone = now.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1];
|
||||
event.Organizer = {
|
||||
"Id": SessionStore.user.UserId,
|
||||
@@ -1028,11 +1046,11 @@ export class EventsService {
|
||||
headers: header,
|
||||
params: params
|
||||
};
|
||||
|
||||
|
||||
return this.http.post<string>(`${puturl}`, event, options)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
|
||||
let arrayReq = [];
|
||||
@@ -1084,7 +1102,7 @@ export class EventsService {
|
||||
|
||||
return this.http.delete(`${puturl}`, options).pipe(
|
||||
catchError(err => {
|
||||
|
||||
|
||||
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
@@ -1143,8 +1161,8 @@ export class EventsService {
|
||||
this.headerSharedPessoal,
|
||||
this.headerOwnPessoal,
|
||||
this.headerOwnOficial
|
||||
]
|
||||
|
||||
]
|
||||
|
||||
const header = headers.find((header)=> {
|
||||
return header?.get('CalendarId')?.includes(calendarId)
|
||||
})
|
||||
@@ -1159,20 +1177,20 @@ export class EventsService {
|
||||
|
||||
return this.http.delete(`${puturl}`, options).pipe(
|
||||
catchError(err => {
|
||||
|
||||
|
||||
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
|
||||
throw('header not found')
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1230,7 +1248,7 @@ export class EventsService {
|
||||
|
||||
const calendar = this.DetectCalendars(CalendarId)
|
||||
const header = this.makeHeader(calendar)
|
||||
|
||||
|
||||
options = {
|
||||
headers: header,
|
||||
params: params
|
||||
@@ -1277,7 +1295,7 @@ export class EventsService {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return this.http.post<any>(`${geturl}`, body, options)
|
||||
}
|
||||
|
||||
@@ -1326,4 +1344,4 @@ const token = {
|
||||
}
|
||||
|
||||
|
||||
// decryptept token 873845982739845723987459823ouhfouidskfdjasklhdjfkusdhfliasdhfkljashdfkjhaskfhaskjdhfkasjdfhkjasdf
|
||||
// decryptept token 873845982739845723987459823ouhfouidskfdjasklhdjfkusdhfliasdhfkljashdfkjhaskfhaskjdhfkasjdfhkjasdf
|
||||
|
||||
Reference in New Issue
Block a user