fix agenda

This commit is contained in:
Peter Maquiran
2023-03-28 13:59:37 +01:00
parent 6f99c792dc
commit 8deed4cf94
5 changed files with 152 additions and 101 deletions
+29
View File
@@ -28,6 +28,23 @@ import { EventListPageModule } from 'src/app/shared/agenda/event-list/event-list
import { EditEventPageModule } from 'src/app/shared/agenda/edit-event/edit-event.module';
import { EditEventToApprovePageModule } from 'src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.module';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatInputModule } from '@angular/material/input';
import { MatNativeDateModule } from '@angular/material/core';
import {
NgxMatDatetimePickerModule,
NgxMatNativeDateModule,
NgxMatTimepickerModule
} from '@angular-material-components/datetime-picker';
import { ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatSelectModule } from '@angular/material/select';
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
@NgModule({
imports: [
CommonModule,
@@ -50,6 +67,18 @@ import { EditEventToApprovePageModule } from 'src/app/shared/agenda/edit-event-t
EventListPageModule,
EditEventPageModule,
EditEventToApprovePageModule,
//
MatDatepickerModule,
MatInputModule,
MatNativeDateModule,
NgxMatDatetimePickerModule,
NgxMatTimepickerModule,
NgxMatNativeDateModule,
NgxMatMomentModule,
MatSelectModule,
MatButtonModule,
ReactiveFormsModule
],
declarations: [
AgendaPage
+21 -3
View File
@@ -97,8 +97,26 @@
</ion-row>
<ion-row class="ion-align-items-center">
<div class="calendar-letters cal-reverse" *ngIf="SessionStore.user.Profile != 'PR' && SessionStore.user.Profile != 'MDGPR' && eventService.hasSharedCalendar && eventService.hasOwnCalendar" class="calendar-letters" [class.cal-reverse]="profile == 'mdgpr' " (click)="changeProfile()">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="CalendarName">
<!-- <mat-option *ngFor="let calendars of _eventService.calendarNamesAry; let i = index" value="{{calendars}}">
<div *ngIf="calendars != 'Meu calendario' && calendars == 'Presidente da República'"> {{ environment.agendaPR}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
<div *ngIf="calendars != 'Meu calendario' && calendars != 'Ministro e Director do Gabinete do PR' && calendars != 'Presidente da República'"> Agenda do {{calendars}} </div>
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div> -->
<mat-option *ngFor="let calendars of eventService.calendarNamesAry" value="{{calendars.Fullname || calendars}}">
<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>
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
</mat-option>
</mat-select>
</mat-form-field>
<!-- <div class="calendar-letters cal-reverse" *ngIf="SessionStore.user.Profile != 'PR' && SessionStore.user.Profile != 'MDGPR' && eventService.hasSharedCalendar && eventService.hasOwnCalendar" class="calendar-letters" [class.cal-reverse]="profile == 'mdgpr' " (click)="changeProfile()">
<div class="text" *ngIf="profile == 'mdgpr'">
MC
</div>
@@ -129,7 +147,7 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && !mobileComponent.showAddNewEvent" class="right-icons" src="assets/images/theme/gov/icons-add.svg" ></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && mobileComponent.showAddNewEvent" class="right-icons" src="assets/images/theme/gov/icons-add-selected.svg" ></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="right-icons" slot="icon-only" src="assets/images/theme/{{ThemeService.currentTheme}}/icons-add.svg"></ion-icon>
</button>
</button> -->
</ion-row>
</ion-row>
+56 -86
View File
@@ -166,6 +166,7 @@ export class AgendaPage implements OnInit {
SessionStore = SessionStore;
environment = environment
CalendarName = ''
constructor(
@Inject(LOCALE_ID) private locale: string,
@@ -254,6 +255,8 @@ export class AgendaPage implements OnInit {
ngOnInit() {
this.setCalendarByDefault()
setTimeout(() => {
const pathname = window.location.pathname
let realoadCounter = 0
@@ -283,6 +286,17 @@ export class AgendaPage implements OnInit {
}, 1000)
}
setCalendarByDefault() {
if(!this.CalendarName) {
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
next() {
this.myCal.slideNext();
@@ -821,105 +835,61 @@ export class AgendaPage implements OnInit {
} else {
if(this.loggeduser.OwnerCalendars.length != 0 ) {
const selectedCalendarUserId = this.selectedCalendarUserId();
this.eventService.getEventsByRoleId(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59'), selectedCalendarUserId).then((response: any) => {
this.eventService.getAllOwnEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
let label;
this.addEventToDB(response, "md");
let eventsList = response;
this.CalendarStore.removeRange(startTime, endTime, 'md')
// loop
this.CalendarStore.pushEvent(eventsList, 'md');
this.TimelineMDList = this.listBoxService.list(this.CalendarStore.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
this.myCal.update();
this.myCal.loadEvents();
this.showTimelineMD = true;
counter++;
if (counter == 2) {
this.showLoader = false;
}
}).catch((error) => {
console.error(error)
this.getFromDB()
}).finally(() => {
this.deleteLoadRangeEvent(startTime, endTime)
counter++;
if (counter == 2) {
this.showLoader = false;
}
this.updateEventListBox()
})
} else {
counter++;
if (counter == 2) {
this.showLoader = false;
if(selectedCalendarUserId == SessionStore.user.UserId) {
label = 'md'
} else {
label = "pr"
}
}
this.addEventToDB(response, label);
let eventsList = response;
this.CalendarStore.removeRange(startTime, endTime, label)
this.CalendarStore.pushEvent(eventsList, label);
this.listToPresent = this.CalendarStore.eventSource
if(this.loggeduser.SharedCalendars.length != 0 ) {
this.TimelinePRList = this.listBoxService.list(this.CalendarStore.eventSource, label, this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
this.eventService.genericGetAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
this.myCal.update();
this.myCal.loadEvents();
this.addEventToDB(response, "pr");
let eventsList = response;
// clear the current month only
this.CalendarStore.removeRange(startTime, endTime, 'pr')
this.CalendarStore.pushEvent(eventsList, 'pr');
this.listToPresent = this.CalendarStore.eventSource
this.TimelinePRList = this.listBoxService.list(this.CalendarStore.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
// console.log('this.TimelinePRList', this.TimelinePRList)
//
this.myCal.update();
this.myCal.loadEvents();
this.showTimelinePR = true;
counter++;
if (counter == 2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
}).catch((error) => {
console.error(error)
this.getFromDB()
})
.finally(() => {
this.deleteLoadRangeEvent(startTime, endTime)
counter++;
if (counter == 2) {
this.showLoader = false;
}
this.updateEventListBox()
})
} else {
counter++;
if (counter == 2) {
this.showLoader = false;
}
}
this.showTimelinePR = true;
this.showLoader = false;
}).finally(() => {
this.deleteLoadRangeEvent(startTime, endTime)
this.showLoader = false;
this.updateEventListBox()
})
}
}
}
getSelectedAgendaCalendars () {
let Oficial = this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']
let Pessoal = this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']
if(Oficial && Pessoal) {
return [Oficial, Pessoal]
} else if (Oficial) {
return [Oficial]
} else if (Pessoal) {
return [Pessoal]
} else {
return [Oficial, Pessoal]
}
}
trasnformData(response, profile) {
response.forEach(element => {
+39 -5
View File
@@ -282,19 +282,19 @@ export class EventsService {
}
for (let sharedCalendar of SessionStore.user.OwnerCalendars) {
for (let OwnerCalendar of SessionStore.user.OwnerCalendars) {
this.hasAnyCalendar = true
this.calendarNames[sharedCalendar.CalendarId] = 'Meu calendario'
this.calendarNames[OwnerCalendar.CalendarId] = 'Meu calendario'
if(!this.calendarNamesAry.includes('Meu calendario')) {
this.calendarNamesAry.push('Meu calendario')
this.calendarNamesType['Meu calendario'] = {}
}
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName] = true
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
this.calendarNamesType['Meu calendario']['RoleId'] = sharedCalendar.CalendarRoleId
this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName] = true
this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName+'Id'] = OwnerCalendar.CalendarId
this.calendarNamesType['Meu calendario']['RoleId'] = OwnerCalendar.CalendarRoleId
}
@@ -525,6 +525,40 @@ export class EventsService {
return this.http.get<any>(`${geturl}`, options)
}
async getEventsByCalendarId( startdate: string, enddate: string, calendarIds: any[]) {
const calendars = SessionStore.user.OwnerCalendars.concat(SessionStore.user.SharedCalendars)
const agendasCalendars = calendars.filter( e => calendarIds.includes(e.CalendarId))
let result = []
for(let agendasCalendar of agendasCalendars) {
var header = new HttpHeaders();
header = header.set('Authorization', SessionStore.user.BasicAuthKey);
header = header.set('CalendarId', agendasCalendar.CalendarId);
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
};
const calendar = await this.http.get<Event[]>(`${geturl}`, options).toPromise()
result = result.concat(calendar)
}
return result
}
async genericGetAllSharedEvents(startdate: string, enddate: string) {
let result = []
+7 -7
View File
@@ -1,12 +1,12 @@
export let versionData = {
"shortSHA": "7c03c3f82",
"SHA": "7c03c3f822d7af32096a855cd83877bf61532e65",
"branch": "no_bug_movemente",
"shortSHA": "6f99c792d",
"SHA": "6f99c792dcb13965ba29278b58b374766f4fa8a4",
"branch": "feature/agenda-layout",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Mon Mar 20 16:10:11 2023 +0100'",
"lastCommitMessage": "fix",
"lastCommitNumber": "4883",
"lastCommitTime": "'Wed Mar 22 15:31:01 2023 +0100'",
"lastCommitMessage": "fix sayings",
"lastCommitNumber": "4884",
"change": "",
"changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: dockerfile\n\tmodified: src/app/modals/document-set-up-meeting/document-set-up-meeting.page.html\n\tmodified: src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n\tmodified: src/app/modals/view-event/view-event.page.ts\n\tmodified: src/app/models/envarioment.ts\n\tmodified: src/app/models/user.model.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.html\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.html\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/services/events.service.ts\n\tmodified: src/app/shared/agenda/event-list/event-list.page.html\n\tmodified: src/app/shared/agenda/event-list/event-list.page.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.html\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/shared/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/app/shared/popover/despachos-options/despachos-options.page.html\n\tmodified: src/app/shared/popover/despachos-options/despachos-options.page.ts\n\tmodified: src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html\n\tmodified: src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts\n\tmodified: src/app/shared/popover/opts-expediente/opts-expediente.page.html\n\tmodified: src/app/shared/popover/opts-expediente/opts-expediente.page.ts\n\tmodified: src/environments/suport/doneIt.ts\n\tmodified: src/environments/suport/oapr.ts\n\tmodified: version/git-version.ts",
"changeStatus": "On branch feature/agenda-layout\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/pages/agenda/agenda.module.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/services/events.service.ts",
"changeAuthor": "peter.maquiran"
}