remove calendar id

This commit is contained in:
Peter Maquiran
2024-06-07 10:26:26 +01:00
parent 07c0223ed2
commit 59d0881669
15 changed files with 274 additions and 246 deletions
+16 -18
View File
@@ -54,28 +54,28 @@
margin-right: 10px;"
class="select-calendar">
{{ selectedUserCalendar }}
<!-- Debug line to print data -->
<mat-form-field class="select-calendar" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="reloadCalendar()" *ngIf="calendarData?.length">
<mat-form-field class="select-calendar" appearance="none" color="ion-color-secondary" placeholder="Selecione agenda" *ngIf="calendarData?.length && showCalendarField">
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="reloadCalendar()" >
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
<div *ngIf="environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES"> PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD"> MDGPR </div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.roleId != RoleIdService.PRES && calendars.roleId != RoleIdService.MD && calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda
</div>
<div *ngIf="environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES"> PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD"> MDGPR </div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.roleId != RoleIdService.PRES && calendars.roleId != RoleIdService.MD && calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda
</div>
</div>
<div *ngIf="!environment.presidential">
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.PRES"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.MD"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId">Minha agenda</div>
</div>
<div *ngIf="!environment.presidential">
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.PRES"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId == RoleIdService.MD"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars.wxUserId != SessionStore.user.UserId && calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId">Minha agenda</div>
</div>
</mat-option>
@@ -224,8 +224,6 @@
<div class="ss-timeline timeline-mobile flex-grow-1 pr-10 text-black height-100 width-100 overflow-y-auto" >
{{ TimelineMDList | json }}
<div *ngFor="let year of TimelineMDList " >
<!-- {{year.yearInfo.yearName}} -->
<div *ngFor="let month of year.months " class="header-day" >
+68 -66
View File
@@ -178,6 +178,8 @@ export class AgendaPage implements OnInit {
sharedCalendar: Observable<TableSharedCalendar[]>
showCalendarField = false
constructor(
@Inject(LOCALE_ID) private locale: string,
private modalCtrl: ModalController,
@@ -193,7 +195,15 @@ export class AgendaPage implements OnInit {
public AgendaDataRepositoryService: AgendaDataRepositoryService,
) {
this.AgendaDataRepositoryService.getSharedCalendar()
this.AgendaDataRepositoryService.getSharedCalendar().then(async ()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = await this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.reloadCalendar()
this.tigerUpdate()
})
// Define the role priorities
const rolePriorities: { [key: number]: number } = {
@@ -268,17 +278,6 @@ export class AgendaPage implements OnInit {
}
this.weekToShow()
this.eventService.registerOnLoadCalendars(async ()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = await this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.reloadCalendar()
this.tigerUpdate()
})
}
tigerUpdate() {
@@ -380,6 +379,7 @@ export class AgendaPage implements OnInit {
async setCalendarByDefault(force) {
if (!this.selectedUserCalendar || force) {
const data = await this.AgendaDataRepositoryService.geCalendars()
const prObject = data.find(e => e?.roleId == 100000014)
@@ -389,6 +389,8 @@ export class AgendaPage implements OnInit {
} else {
this.selectedUserCalendar = SessionStore.user.UserId
}
this.showCalendarField = true
}
}
@@ -630,7 +632,6 @@ export class AgendaPage implements OnInit {
this.array = [];
this.rangeStartDate = startTime
this.rangeEndDate = endTime
this.showLoader = true;
this.loadRangeEventRun(startTime, endTime)
}
@@ -662,18 +663,9 @@ export class AgendaPage implements OnInit {
this.rangeStartDate = startTime
this.rangeEndDate = endTime
this.showLoader = true;
const selectedCalendarIds = await this.getSelectedAgendaCalendars()
console.log({selectedCalendarIds})
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
console.log('listToPresent', this.listToPresent)
// this.calendar.currentDate.setDate(1);
this.updateEventListBox()
try {
@@ -681,59 +673,62 @@ export class AgendaPage implements OnInit {
this.myCal.loadEvents();
} catch (error) {}
let load = 0;
for (const selectedCalendar of selectedCalendarIds) {
const response = await this.AgendaDataRepositoryService.EventList({
userId: selectedCalendar.wxUserId,
calendarOwnerName: selectedCalendar.wxFullName,
endDate: endTime.toISOString(),
startDate: startTime.toISOString()
})
if(selectedCalendar.wxUserId) {
this.showLoader = true;
if(response.isOk()) {
let label;
const response = await this.AgendaDataRepositoryService.EventList({
userId: selectedCalendar.wxUserId,
calendarOwnerName: selectedCalendar.wxFullName,
endDate: endTime.toISOString(),
startDate: startTime.toISOString()
})
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (selectedCalendar.wxUserId == SessionStore.user.UserId as any) {
label = 'md'
if(response.isOk()) {
let label;
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (selectedCalendar.wxUserId == SessionStore.user.UserId as any) {
label = 'md'
} else {
label = "pr"
}
this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.wxUserId as any)
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.wxUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load ==(selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
} else {
label = "pr"
load++
if (load == (selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
}
this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.wxUserId as any)
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.wxUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load ==(selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
} else {
load++
if (load == (selectedCalendarIds).length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
alert('sekip '+ JSON.stringify(selectedCalendar))
console.log('not user', JSON.stringify(selectedCalendar))
}
}
}
@@ -758,7 +753,14 @@ export class AgendaPage implements OnInit {
const data = await this.AgendaDataRepositoryService.geCalendars()
return [data.find(e => e?.wxUserId == this.selectedUserCalendar)]
const array = []
const selected = data.find( e => e.wxUserId == this.selectedUserCalendar)
if(selected) {
array.push(selected)
}
return array
}
}
@@ -56,35 +56,18 @@
</mat-form-field>
</div>
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)" *ngIf="SessionStore.user.RoleID !== 100000014 && (sharedCalendar | async) as calendarData">
<!-- <ion-segment-button value="MDGPR">
Minha agenda
</ion-segment-button> -->
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryPR; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
<div *ngIf="calendars == 'Meu calendario'">
<!-- <span *ngIf="SessionStore.user.Profile == 'PR' ">PR</span>
<span *ngIf="SessionStore.user.Profile == 'MDGPR' ">MDGPR</span>
<span *ngIf="SessionStore.user.Profile != 'MDGPR' && SessionStore.user.Profile != 'PR' ">Minha agenda</span> -->
<ion-segment-button *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}" >
<div *ngIf="calendars.roleId == RoleIdService.PRES">AGENDA DO PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">AGENDA DO MDGPR</div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName"> Agenda do {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda
</div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
</ion-segment-button>
<ion-segment-button [class.d-none]="!eventService.HasMdGPR" *ngFor="let calendars of eventService.calendarNamesAryOnlyMD; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
</ion-segment-button>
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryNoPrNMD; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
</ion-segment-button>
</ion-segment>
@@ -15,7 +15,10 @@ import { EventsService } from 'src/app/services/events.service';
import { SessionStore } from 'src/app/store/session.service';
import { environment } from 'src/environments/environment';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { RoleIdService } from 'src/app/services/role-id.service'
@Component({
selector: 'app-event-list',
templateUrl: './event-list.page.html',
@@ -49,6 +52,8 @@ export class EventListPage implements OnInit {
}
SessionStore = SessionStore;
sharedCalendar: Observable<TableSharedCalendar[]>
selectedUserCalendar:any;
constructor(
private processes: ProcessesService,
@@ -60,7 +65,8 @@ export class EventListPage implements OnInit {
private RouteService: RouteService,
public eventService: EventsService,
public TaskService: TaskService,
public AgendaDataRepositoryService: AgendaDataRepositoryService
public AgendaDataRepositoryService: AgendaDataRepositoryService,
public RoleIdService: RoleIdService,
) { }
ngOnInit() {
@@ -127,8 +133,40 @@ export class EventListPage implements OnInit {
}
};
// Define the role priorities
const rolePriorities: { [key: number]: number } = {
100000014: 1, // Presidente da República
100000011: 2, // Vice Presidente (example role ID)
// Add other roles with their priorities here
};
this.sharedCalendar = this.AgendaDataRepositoryService.getShareCalendarItemsLive().pipe(
map(data => data.sort((a, b) => {
console.log('Raw data:', data); // Debug line
const priorityA = rolePriorities[a.roleId] || Infinity;
const priorityB = rolePriorities[b.roleId] || Infinity;
return priorityA - priorityB;
}))
)
this.eventService.onCalendarFinishLoad.subscribe(async() => {
this.setCalendarByDefault()
})
}
async setCalendarByDefault() {
const data = await this.AgendaDataRepositoryService.geCalendars()
const prObject = data.find(e => e?.roleId == 100000014)
if(prObject) {
this.selectedUserCalendar = prObject.wxUserId
} else {
this.selectedUserCalendar = SessionStore.user.UserId
}
}
ngOnDestroy() {
this.listSubscription.delete()
+7 -2
View File
@@ -23,6 +23,8 @@ import { CPSession } from 'src/app/store/documentManagement';
import { StorageService } from 'src/app/services/storage.service';
import { DeviceService } from 'src/app/services/device.service'
import { Cy } from 'cypress/enum'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
@@ -62,7 +64,8 @@ export class LoginPage implements OnInit {
private storage: Storage,
private storageService: StorageService,
private NotificationHolderService: NotificationHolderService,
private DeviceService: DeviceService
private DeviceService: DeviceService,
public AgendaDataRepositoryService: AgendaDataRepositoryService,
) { }
ngOnInit() { }
@@ -137,7 +140,9 @@ export class LoginPage implements OnInit {
loader.remove()
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
@@ -147,7 +152,7 @@ export class LoginPage implements OnInit {
if (attempt.ChatData) {
try {
await this.AgendaDataRepositoryService.getSharedCalendar()
await MessageModel.deleteAll();
await DeleteMessageModel.deleteAll();
this.ChatSystemService.clearChat();