-
{{ environment.agendaPR}}
-
{{ environment.agendaVP}}
-
Agenda do {{calendars.wxFullName}}
-
Minha agenda
-
+
{{ environment.agendaPR}}
+
{{ environment.agendaVP}}
+
Agenda do {{calendars.wxFullName}}
+
Minha agenda
+
- {{ TimelineMDList | json }}
-
-
+
-
-
-
+
+ AGENDA DO PR
+ AGENDA DO MDGPR
+ Agenda do {{calendars.wxFullName}}
+
Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
-
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
-
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.ts b/src/app/pages/gabinete-digital/event-list/event-list.page.ts
index 12191b829..5e0c70336 100644
--- a/src/app/pages/gabinete-digital/event-list/event-list.page.ts
+++ b/src/app/pages/gabinete-digital/event-list/event-list.page.ts
@@ -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
+ 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()
diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts
index 6890a104a..bb341577e 100644
--- a/src/app/pages/login/login.page.ts
+++ b/src/app/pages/login/login.page.ts
@@ -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();
diff --git a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts
index ff23afd6d..1a4078af3 100644
--- a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts
+++ b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts
@@ -53,7 +53,8 @@ export class AgendaDataRepositoryService {
}
- async EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
+ async EventList({userId, startDate , endDate , status= 2, category= null, type= null, calendarOwnerName = ''}) {
+
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
@@ -177,6 +178,19 @@ export class AgendaDataRepositoryService {
if(result.isOk()) {
await this.agendaLocalDataSourceService.clearSharedCalendar()
if(result.value?.data) {
+
+ const currentUserCalendar = {
+ wxUserId: SessionStore.user.UserId,
+ wxFullName: SessionStore.user.FullName,
+ wxeMail: SessionStore.user.Email,
+ role: SessionStore.user.RoleDescription,
+ roleId: SessionStore.user.RoleID,
+ shareType: 0,
+ date: '',
+ }
+
+ result.value.data.push(currentUserCalendar)
+
return await this.agendaLocalDataSourceService.bulkCreate(result.value.data)
} else {
return result
diff --git a/src/app/services/Repositorys/Agenda/agenda-data.service.ts b/src/app/services/Repositorys/Agenda/agenda-data.service.ts
index 0f63f907e..8c98533fc 100644
--- a/src/app/services/Repositorys/Agenda/agenda-data.service.ts
+++ b/src/app/services/Repositorys/Agenda/agenda-data.service.ts
@@ -41,7 +41,7 @@ export class AgendaDataService {
}
// Events Endpoints
- createEvent(eventData: EventInputDTO): Observable {
+ createEvent(eventData: EventInputDTO) {
return this.http.post(`${this.baseUrl}/Events`, eventData);
}
@@ -50,6 +50,10 @@ export class AgendaDataService {
.set('UserId', userId)
.set('Status', status)
+ if(userId == null || userId == undefined) {
+ throw('userId '+ userId)
+ }
+
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
}
diff --git a/src/app/services/decorator/api-validate-schema.decorator.ts b/src/app/services/decorator/api-validate-schema.decorator.ts
index a9c9f5536..ecc1f468e 100644
--- a/src/app/services/decorator/api-validate-schema.decorator.ts
+++ b/src/app/services/decorator/api-validate-schema.decorator.ts
@@ -27,7 +27,6 @@ export function APIReturn(schema: z.ZodTypeAny) {
Sentry.captureException(error);
});
console.error('Validation failed:', error.errors);
-
} else {
console.log('failed to setup the connection successful')
// Throw any other unexpected errors
diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts
index fc261c5a0..ec24414d6 100644
--- a/src/app/services/events.service.ts
+++ b/src/app/services/events.service.ts
@@ -11,6 +11,7 @@ import { catchError } from "rxjs/operators";
import { SessionStore } from '../store/session.service';
import { calendarInterface } from '../models/user.model';
import { Subscribe } from './subcribe';
+import { EventOutputDTO } from './Repositorys/Agenda/model/eventDTOOutput';
@Injectable({
@@ -418,19 +419,8 @@ export class EventsService {
isMyEvent(event: any) {
- for (let calendar of SessionStore.user.OwnerCalendars) {
- if(event.CalendarId == calendar.CalendarId) {
- return true
- }
- }
-
- for (let sharedCalendar of SessionStore.user.SharedCalendars) {
- if(event.CalendarId == sharedCalendar.CalendarId) {
- return false
- }
- }
-
- return false
+ const data: any = event
+ return data.Organizer.Id == SessionStore.user.UserId
}
diff --git a/src/app/shared/agenda/approve-event/approve-event.page.html b/src/app/shared/agenda/approve-event/approve-event.page.html
index 345bc6d08..f9f560d32 100644
--- a/src/app/shared/agenda/approve-event/approve-event.page.html
+++ b/src/app/shared/agenda/approve-event/approve-event.page.html
@@ -46,7 +46,6 @@
{{loadedEvent.workflowInstanceDataFields.Location}}
- {{ loadedEvent.workflowDisplayName }}
{{loadedEvent.workflowInstanceDataFields.Agenda}}
diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts
index 73d185134..cb3282a1d 100644
--- a/src/app/shared/agenda/approve-event/approve-event.page.ts
+++ b/src/app/shared/agenda/approve-event/approve-event.page.ts
@@ -69,7 +69,6 @@ export class ApproveEventPage implements OnInit {
ngOnInit() {
this.getTask();
- this.getAttachments();
}
@@ -147,15 +146,6 @@ export class ApproveEventPage implements OnInit {
}
- async getAttachments() {
- try {
- this.loadedAttachments = await this.attachmentsService.getAttachmentsById(this.InstanceId).toPromise();
- } catch (error) {
- console.error('getAttchaments', error)
- }
-
-
- }
async viewDocument(DocId: string, Document) {
diff --git a/src/app/shared/agenda/event-list/event-list.page.html b/src/app/shared/agenda/event-list/event-list.page.html
index 04ada75ef..81a55f438 100644
--- a/src/app/shared/agenda/event-list/event-list.page.html
+++ b/src/app/shared/agenda/event-list/event-list.page.html
@@ -9,33 +9,16 @@
-
-
-
-
-
+
+
+ AGENDA DO PR
+ AGENDA DO MDGPR
+ Agenda do {{calendars.wxFullName}}
+
Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
-
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
@@ -54,7 +37,7 @@
diff --git a/src/app/shared/agenda/event-list/event-list.page.ts b/src/app/shared/agenda/event-list/event-list.page.ts
index e9a72c7cc..4a350c6f9 100644
--- a/src/app/shared/agenda/event-list/event-list.page.ts
+++ b/src/app/shared/agenda/event-list/event-list.page.ts
@@ -11,6 +11,11 @@ import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.servic
import { environment } from 'src/environments/environment';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { EventToApproveList } from 'src/app/models/entiry/agenda/eventToApproveList';
+import { RoleIdService } from 'src/app/services/role-id.service'
+import { map } from 'rxjs/operators';
+import { Observable } from 'rxjs';
+import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
+
@Component({
selector: 'app-event-list',
templateUrl: './event-list.page.html',
@@ -37,36 +42,55 @@ export class EventListPage implements OnInit {
@Input() showComponent:string;
@Output() cloneAllmobileComponent = new EventEmitter
();
@Output() approveEventDismiss = new EventEmitter();
-
+ sharedCalendar: Observable
+ selectedUserCalendar:any;
constructor(
private processes:ProcessesService,
private router: Router,
private sortService: SortService,
public eventService: EventsService,
- public AgendaDataRepositoryService: AgendaDataRepositoryService
+ public AgendaDataRepositoryService: AgendaDataRepositoryService,
+ public RoleIdService: RoleIdService,
) {
this.loggeduser = SessionStore.user;
+
+ // 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()
+ })
+
}
- ngAfterViewInit(): void {
- this.eventService.onCalendarFinishLoad.subscribe(() => {
- if(!this.segment) {
- if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
- this.segment = 'Meu calendario';
- } else {
- this.segment = this.eventService.calendarNamesAry[0].OwnerUserId
- }
+ async setCalendarByDefault() {
+ const data = await this.AgendaDataRepositoryService.geCalendars()
- // select pr by default
- const pr = this.eventService.calendarNamesAry.find( e => e.Role == 'Presidente da República')
- if(pr) {
- this.segment = pr.OwnerUserId
- }
- }
- })
+ const prObject = data.find(e => e?.roleId == 100000014)
+
+ if(prObject) {
+ this.selectedUserCalendar = prObject.wxUserId
+ } else {
+ this.selectedUserCalendar = SessionStore.user.UserId
+ }
}
+ ngAfterViewInit(): void {}
+
ngOnInit() {
const pathname = window.location.pathname
@@ -96,11 +120,13 @@ export class EventListPage implements OnInit {
async LoadToApproveEvents() {
this.showLoader = true;
+ const segment = this.selectedUserCalendar
+
- const segment: any = this.segment
let userId;
- if(this.segment == 'Meu calendario') {
+ if(this.selectedUserCalendar == SessionStore.user.UserId) {
+ // color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
} else {
@@ -110,7 +136,7 @@ export class EventListPage implements OnInit {
} else if(segment) {
this.color = 'pr'
- userId = segment
+ userId = this.selectedUserCalendar
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
@@ -118,13 +144,12 @@ export class EventListPage implements OnInit {
if(allEvents.value.length >= 1) {
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
- this.eventoaprovacaostore.save(segment, this.eventsList)
+ this.eventoaprovacaostore.save(this.selectedUserCalendar, this.eventsList)
} else {
- this.eventoaprovacaostore.save(segment, [])
+ this.eventoaprovacaostore.save(this.selectedUserCalendar, [])
}
} else {
this.eventsList = [];
- // this.showLoader = false;
}
this.showLoader = false;
diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html
index 6eaa521f1..be5eee7ef 100644
--- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html
+++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html
@@ -9,42 +9,42 @@
-
+
-
+
-
+
Para hoje
-
+
Novas
-
+
Lidas
-
+
Não lidas
-
-
+
+
Em atraso
-
+
Todas
-
-
+
+
@@ -53,35 +53,17 @@
-
-
-
-
-
+
+
+
+ AGENDA DO PR
+ AGENDA DO MDGPR
+ Agenda do {{calendars.wxFullName}}
+
Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
-
-
- Minha agenda
- {{ environment.agendaPR}}
- {{ environment.agendaVP}}
- Agenda do {{calendars.Fullname}}
-
diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
index 4c3e17829..c3b17c78d 100644
--- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
+++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts
@@ -13,6 +13,10 @@ import { environment } from 'src/environments/environment';
import { TaskService } from 'src/app/services/task.service'
import { ThemeService } from 'src/app/services/theme.service'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
+import { map } from 'rxjs/operators';
+import { RoleIdService } from 'src/app/services/role-id.service'
+import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
+import { Observable } from 'rxjs';
@Component({
selector: 'app-events-to-approve',
@@ -26,7 +30,7 @@ export class EventsToApprovePage implements OnInit {
eventBody: EventBody;
categories: string[];
serialnumber:string;
- segment:any;
+ selectedUserCalendar:any;
eventaprovacaostore = EventoAprovacaoStore;
eventsList: any = []
@@ -47,7 +51,7 @@ export class EventsToApprovePage implements OnInit {
}
routerSubscription;
SessionStore = SessionStore;
-
+ sharedCalendar: Observable
constructor(
private processes:ProcessesService,
@@ -58,31 +62,31 @@ export class EventsToApprovePage implements OnInit {
public eventService: EventsService,
public TaskService: TaskService,
public ThemeService: ThemeService,
- public AgendaDataRepositoryService: AgendaDataRepositoryService
+ public AgendaDataRepositoryService: AgendaDataRepositoryService,
+ public RoleIdService: RoleIdService,
)
{}
ngOnInit() {
- this.eventService.onCalendarFinishLoad.subscribe(() => {
- if(!this.segment) {
- if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
- this.segment = 'Meu calendario';
- } else {
- this.segment = this.eventService.calendarNamesAry[0].OwnerUserId
- }
+ // 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
+ };
- // select pr by default
- const pr = this.eventService.calendarNamesAry.find( e => e.Role == 'Presidente da República')
- if(pr) {
- this.segment = pr.OwnerUserId
- }
-
- this.dynamicSearch();
- } else {
- this.dynamicSearch();
- }
+ 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()
})
this.LoadToApproveEvents()
@@ -116,6 +120,18 @@ export class EventsToApprovePage implements OnInit {
this.dynamicSearch();
}
+ 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()
@@ -135,7 +151,7 @@ export class EventsToApprovePage implements OnInit {
if(this.showSearch && this.searchSubject) {
- const list = this.eventoaprovacaostore.get(this.segment).filter((task) => {
+ const list = this.eventoaprovacaostore.get(this.selectedUserCalendar).filter((task) => {
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
subject = subject.toLowerCase();
return subject.includes(this.searchSubject.toLowerCase())
@@ -143,7 +159,7 @@ export class EventsToApprovePage implements OnInit {
this.list = this.TaskService.reorderList(this.ordinance, list)
} else {
- const list = this.eventoaprovacaostore.get(this.segment)
+ const list = this.eventoaprovacaostore.get(this.selectedUserCalendar)
this.list = this.TaskService.reorderList(this.ordinance, list)
}
@@ -176,11 +192,11 @@ export class EventsToApprovePage implements OnInit {
async LoadToApproveEvents() {
this.showLoader = true;
- const segment = this.segment
+ const segment = this.selectedUserCalendar
let userId;
- if(this.segment == 'Meu calendario') {
+ if(this.selectedUserCalendar == SessionStore.user.UserId) {
// color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
@@ -191,7 +207,7 @@ export class EventsToApprovePage implements OnInit {
} else {
this.color = 'pr'
- userId = segment
+ userId = this.selectedUserCalendar
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})