mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
remove unsude code
This commit is contained in:
@@ -47,12 +47,12 @@ export class EventsService {
|
||||
|
||||
calendarNames = {}
|
||||
|
||||
calendarNamesAry = []
|
||||
calendarNamesAryNoPr = []
|
||||
calendarNamesAryNoPrNMD = []
|
||||
calendarNamesAryOnlyMD = []
|
||||
calendarNamesAryReverse = []
|
||||
calendarNamesAryPR = []
|
||||
// calendarNamesAry = []
|
||||
// calendarNamesAryNoPr = []
|
||||
// calendarNamesAryNoPrNMD = []
|
||||
// calendarNamesAryOnlyMD = []
|
||||
// calendarNamesAryReverse = []
|
||||
// calendarNamesAryPR = []
|
||||
|
||||
calendarNamesType = {}
|
||||
calendarRole = []
|
||||
@@ -91,309 +91,8 @@ export class EventsService {
|
||||
}
|
||||
|
||||
async setHeader () {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
this.headers = new HttpHeaders();;
|
||||
this.headersMdOficial = new HttpHeaders();;
|
||||
this.headersMdPessoal = new HttpHeaders();;
|
||||
|
||||
this.headersPrOficial = new HttpHeaders();;
|
||||
this.headersPrPessoal = new HttpHeaders();;
|
||||
|
||||
this.headersSharedOficial = new HttpHeaders();;
|
||||
this.headersSharedPessoal = new HttpHeaders();;
|
||||
|
||||
|
||||
this.headerOwnOficial= new HttpHeaders();;
|
||||
this.headerOwnPessoal= new HttpHeaders();;
|
||||
|
||||
this.headerSharedOficial= new HttpHeaders();;
|
||||
this.headerSharedPessoal= new HttpHeaders();;
|
||||
|
||||
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
|
||||
this.usersCalendarIds = [];
|
||||
this.calendarNames = {}
|
||||
this.calendarRole = []
|
||||
this.calendrFullName = [];
|
||||
this.calendarIds = []
|
||||
|
||||
this.calendarNamesAry = []
|
||||
this.calendarNamesType = {}
|
||||
this.calendarNamesAryNoPr = []
|
||||
this.calendarNamesAryPR = []
|
||||
|
||||
|
||||
this.calendarNamesAryNoPrNMD = []
|
||||
this.calendarNamesAryOnlyMD = []
|
||||
|
||||
this.hasSharedCalendar = false
|
||||
this.hasSharedOficial = false
|
||||
this.hasSharedPessoal = false
|
||||
|
||||
this.hasOwnCalendar = false
|
||||
this.hasOwnOficial = false
|
||||
this.hasOwnPessoal = false
|
||||
this.HasMdGPR = false
|
||||
|
||||
|
||||
if (SessionStore.user) {
|
||||
if (SessionStore.user.Profile == 'MDGPR') {
|
||||
|
||||
if(SessionStore?.user?.OwnerCalendars) {
|
||||
for (let calendar of SessionStore?.user?.OwnerCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
|
||||
if (calendar.CalendarName == 'Oficial') {
|
||||
|
||||
this.hasOwnOficial = true
|
||||
|
||||
|
||||
this.headersMdOficial = this.headersMdOficial.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
}
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
|
||||
this.hasOwnPessoal = true
|
||||
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(SessionStore?.user?.SharedCalendars) {
|
||||
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
|
||||
if (sharedCalendar.CalendarName == 'Oficial') {
|
||||
|
||||
this.hasSharedOficial = true
|
||||
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
}
|
||||
else if (sharedCalendar.CalendarName == 'Pessoal') {
|
||||
|
||||
this.hasSharedPessoal = true
|
||||
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (SessionStore.user.Profile == 'PR') {
|
||||
|
||||
for (let calendar of SessionStore?.user?.OwnerCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
if (calendar.CalendarName == 'Oficial') {
|
||||
|
||||
this.hasOwnOficial = true
|
||||
|
||||
this.headersPrOficial = this.headersPrOficial.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
}
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
|
||||
this.hasOwnPessoal = true
|
||||
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (let calendar of SessionStore?.user?.OwnerCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
if(!this.usersCalendarIds.includes(calendar.OwnerUserId)) {
|
||||
this.usersCalendarIds.push(calendar.OwnerUserId)
|
||||
}
|
||||
|
||||
if(!this.calendarIds.includes(calendar.CalendarId)) {
|
||||
this.calendarIds.push(calendar.CalendarId)
|
||||
}
|
||||
|
||||
this.hasOwnCalendar = true
|
||||
|
||||
if (calendar.CalendarName == 'Oficial') {
|
||||
|
||||
this.hasOwnOficial = true
|
||||
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarId', calendar.CalendarId);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
this.headerOwnOficial = this.headerOwnOficial.set('CalendarName', calendar.CalendarName);
|
||||
}
|
||||
else if (calendar.CalendarName == 'Pessoal') {
|
||||
|
||||
this.hasOwnPessoal = true
|
||||
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarId', calendar.CalendarId);
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
|
||||
this.headerOwnPessoal = this.headerOwnPessoal.set('CalendarName', calendar.CalendarName);
|
||||
}
|
||||
}
|
||||
|
||||
for (let sharedCalendar of SessionStore?.user?.SharedCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
|
||||
if(!this.usersCalendarIds.includes(sharedCalendar.OwnerUserId)) {
|
||||
this.usersCalendarIds.push(sharedCalendar.OwnerUserId)
|
||||
}
|
||||
|
||||
if(!this.calendarIds.includes(sharedCalendar.CalendarId)) {
|
||||
this.calendarIds.push(sharedCalendar.CalendarId)
|
||||
}
|
||||
|
||||
this.hasSharedCalendar = true
|
||||
|
||||
if (sharedCalendar.CalendarName == 'Oficial') {
|
||||
this.hasSharedOficial = true
|
||||
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('Authorization','Bearer ' + SessionStore.user.Authorization);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
this.headerSharedOficial = this.headerSharedOficial.set('CalendarName', sharedCalendar.CalendarName);
|
||||
}
|
||||
else if (sharedCalendar.CalendarName == 'Pessoal') {
|
||||
|
||||
this.hasSharedPessoal = true
|
||||
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('Authorization','Bearer ' + SessionStore.user.Authorization);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
|
||||
this.headerSharedPessoal = this.headerSharedPessoal.set('CalendarName', sharedCalendar.CalendarName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let OwnerCalendar of SessionStore?.user?.OwnerCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
|
||||
this.calendarNames[OwnerCalendar.CalendarId] = 'Meu calendario'
|
||||
|
||||
if(!this.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.calendarNamesAry.push('Meu calendario')
|
||||
this.calendarNamesAryNoPr.push('Meu calendario')
|
||||
this.calendarNamesType['Meu calendario'] = {}
|
||||
}
|
||||
|
||||
this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName] = true
|
||||
this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName+'Id'] = OwnerCalendar.OwnerUserId || SessionStore.user.UserId
|
||||
this.calendarNamesType['Meu calendario']['RoleId'] = OwnerCalendar.CalendarRoleId
|
||||
this.calendarNamesType['Meu calendario']['OwnerId'] = OwnerCalendar.OwnerUserId || SessionStore.user.UserId
|
||||
this.calendarNamesType['Meu calendario']['FullName'] = SessionStore.user.FullName
|
||||
}
|
||||
for (let sharedCalendar of SessionStore?.user?.SharedCalendars) {
|
||||
this.hasAnyCalendar = true
|
||||
if(sharedCalendar?.OwnerUserId) {
|
||||
const e = await this.GetCalendarName(sharedCalendar.OwnerUserId).toPromise()
|
||||
|
||||
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') {
|
||||
this.calendarNamesAryPR.push(objectShared)
|
||||
} else {
|
||||
this.calendarNamesAryNoPr.push(objectShared)
|
||||
}
|
||||
|
||||
this.calendarNamesType[e.FullName] = {}
|
||||
}
|
||||
|
||||
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName] = true
|
||||
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName+'Id'] = sharedCalendar.OwnerUserId
|
||||
this.calendarNamesType[e.FullName]['RoleId'] = sharedCalendar.CalendarRoleId
|
||||
this.calendarNamesType[e.FullName]['OwnerId'] = sharedCalendar.OwnerUserId
|
||||
this.calendarNamesType[e.FullName]['Shared'] = sharedCalendar.OwnerUserId
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.calendarNamesAryNoPrNMD = this.calendarNamesAryNoPr.filter((e)=> {
|
||||
return e.Role != 'Ministro e Director do Gabinete do PR' && e.Role != 'Presidente da República'
|
||||
})
|
||||
|
||||
this.calendarNamesAryOnlyMD = this.calendarNamesAryNoPr.filter((e)=> {
|
||||
return e.Role == 'Ministro e Director do Gabinete do PR'
|
||||
})
|
||||
|
||||
|
||||
this.HasMdGPR = this.calendarNamesAryNoPr.find( (e)=> {
|
||||
if(e.Role == 'Ministro e Director do Gabinete do PR') {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
|
||||
if(SessionStore.user?.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) {
|
||||
this.hasAnyCalendar = false
|
||||
} else {
|
||||
this.hasAnyCalendar = true
|
||||
}
|
||||
|
||||
|
||||
this.calendarNamesAryReverse = this.calendarNamesAry.reverse();
|
||||
|
||||
this.onCalendarFinishLoad.executor();
|
||||
|
||||
(() => {
|
||||
const keys = {}
|
||||
|
||||
for (let e of SessionStore.user?.OwnerCalendars) {
|
||||
if(!keys[e.CalendarId]) {
|
||||
keys[e.CalendarId] = e.CalendarId
|
||||
} else {
|
||||
throw(`Calendar ${e.CalendarId} is repeated for user `+ SessionStore.user.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
for (let e of SessionStore.user.SharedCalendars) {
|
||||
if(!keys[e.CalendarId]) {
|
||||
keys[e.CalendarId] = e.CalendarId
|
||||
} else {
|
||||
throw(`Calendar ${e.CalendarId} is repeated for user `+ SessionStore.user.FullName);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.onLoadCalendars.forEach(e=> e());
|
||||
this.loadCalendars = true
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user