This commit is contained in:
Peter Maquiran
2022-04-02 09:40:09 +01:00
parent 53c59e7a43
commit e69392ce58
19 changed files with 786 additions and 213 deletions
+4 -14
View File
@@ -93,14 +93,6 @@
</div>
<!-- <div class="drop-down">
<ion-icon slot="icon-only" class="arrow-down" src="assets/images/icons-arrow-arrow-down.svg"></ion-icon>
<div class="drop-down-container">
<ul>
<li *ngFor="let month of monthList" (click)="dropDownChangeDate(month.id)" >{{ month.name }}</li>
</ul>
</div>
</div> -->
<!-- Move forward one screen of the slides -->
<div (click)="next()" class="arrow cursor-pointer resize">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="icon-only" src="assets/images/icons-calendar-arrow-right.svg"></ion-icon>
@@ -111,11 +103,11 @@
</ion-row>
<ion-row class="ion-align-items-center">
<button *ngIf="profile == 'mdgpr' && loggeduser.Profile =='MDGPR' " (click)="changeProfile()" class="d-md-none btn-no-color resize">
<button *ngIf="profile == 'mdgpr' && eventService.calendarOwnerIds.length >= 2 " (click)="changeProfile()" class="d-md-none btn-no-color resize">
<ion-icon class="right-icons" src="assets/images/icons-profile-calendar-md.svg"></ion-icon>
</button>
<button title="Mudar de Agenda" *ngIf="profile == 'pr' && loggeduser.Profile =='MDGPR' " (click)="changeProfile()" class="btn-no-color resize">
<button title="Mudar de Agenda" *ngIf="profile == 'pr'&& eventService.calendarOwnerIds.length >= 2 " (click)="changeProfile()" class="btn-no-color resize">
<ion-icon class="right-icons d-md-none" src="assets/images/icons-profile-calendar-pr.svg"></ion-icon>
</button>
@@ -184,9 +176,7 @@
</div>
<div class="calendar-border">
</div>
<div class="calendar-border"></div>
<!-- Calendar currente date -->
<ion-row class="timeline-header pb-0 ion-justify-content-between ion-align-items-center currente-date-timelien">
@@ -290,7 +280,7 @@
</div>
</div>
<div class="fs-timeline flex-grow-1 d-none d-md-block d-md-block text-black pr-20 width-100 height-100 overflow-y-auto" *ngIf="loggeduser.Profile == 'MDGPR'">
<div class="fs-timeline flex-grow-1 d-none d-md-block d-md-block text-black pr-20 width-100 height-100 overflow-y-auto" *ngIf="eventService.calendarOwnerIds.length >= 2">
<div *ngFor="let events of TimelineMDList | keyvalue;" >
<div class="EventListBox-container" >
+210 -39
View File
@@ -167,7 +167,7 @@ export class AgendaPage implements OnInit {
private alertCtrl: AlertController,
@Inject(LOCALE_ID) private locale: string,
private modalCtrl: ModalController,
private eventService: EventsService,
public eventService: EventsService,
private router: Router,
private sanitizer: DomSanitizer,
authService: AuthService,
@@ -192,16 +192,27 @@ export class AgendaPage implements OnInit {
if (this.loggeduser.Profile == 'MDGPR') {
this.mobileComponent.showEventList = true;
this.profile = "mdgpr";
} else {
} else if (this.loggeduser.Profile == 'PR') {
this.profile = "pr";
} else {
this.profile = "mdgpr";
}
})
if (this.loggeduser.Profile == 'MDGPR') {
this.mobileComponent.showEventList = true;
this.profile = "mdgpr";
} else {
} else if (this.loggeduser.Profile == 'PR') {
this.profile = "pr";
} else {
if(this.eventService.calendarOwnerIds.length >= 2) {
this.profile = "mdgpr";
} else if (this.eventService.hasOwnCalendar) {
this.profile = "mdgpr";
} else if (this.eventService.hasSharedCalendar) {
this.profile = "pr";
}
}
this.calendarHeight = "356px";
@@ -529,8 +540,7 @@ export class AgendaPage implements OnInit {
}).catch((error) => {
this.getFromDB();
})
.finally(() => {
}).finally(() => {
this.showLoader = false;
})
@@ -560,9 +570,9 @@ export class AgendaPage implements OnInit {
}).catch((error) => {
this.getFromDB()
})
.finally(() => {
this.showLoader = false;
})
.finally(() => {
this.showLoader = false;
})
}
else if (this.loggeduser.Profile == 'PR') {
@@ -597,6 +607,70 @@ export class AgendaPage implements OnInit {
.finally(() => {
this.showLoader = false;
})
} else if (this.loggeduser.Profile != 'PR' && this.loggeduser.Profile != 'MDGPR'){
if(this.profile == "mdgpr") {
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) => {
console.log('ALL MD EVENTS', response);
this.addEventToDB(response, "md");
// calendar
this.CalendarStore.removeRange(startTime, endTime, 'md')
// loop
this.CalendarStore.pushEvent(response, 'md');
console.log('CALENDAR STORE', this.CalendarStore.eventSource)
this.listToPresent = this.CalendarStore.eventSource
this.trasnformData(response, 'md');
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log('check list to present data', this.listToPresent);
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
}).catch((error) => {
this.getFromDB();
}).finally(() => {
this.showLoader = false;
})
} else if (this.profile == "pr" ) {
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.addEventToDB(response, "pr");
this.CalendarStore.removeRange(startTime, endTime, 'pr')
// calendar
this.CalendarStore.pushEvent(response, 'pr');
this.listToPresent = this.CalendarStore.eventSource
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log('check list to present data', this.listToPresent);
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
}).catch((error) => {
this.getFromDB()
}).finally(() => {
this.showLoader = false;
})
}
}
} else {
@@ -604,9 +678,11 @@ export class AgendaPage implements OnInit {
let counter = 0;
// view MDGPR calendar with MDGPR profile
if (this.loggeduser.Profile == 'MDGPR') {
alert('MDGPR')
this.eventService.getAllMdEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
this.addEventToDB(response, "md");
@@ -635,13 +711,12 @@ export class AgendaPage implements OnInit {
}).catch((error) => {
this.getFromDB()
}).finally(() => {
counter++;
if (counter == 2) {
this.showLoader = false;
}
})
.finally(() => {
counter++;
if (counter == 2) {
this.showLoader = false;
}
})
this.eventService.getAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
@@ -673,15 +748,14 @@ export class AgendaPage implements OnInit {
}).catch((error) => {
this.getFromDB()
})
.finally(() => {
}).finally(() => {
counter++;
if (counter == 2) {
this.showLoader = false;
}
})
if (counter == 2) {
this.showLoader = false;
}
})
} else {
} else if(this.loggeduser.Profile == 'PR') {
// view PR calendar with PR profile
this.eventService.getAllPrEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
@@ -719,12 +793,105 @@ export class AgendaPage implements OnInit {
}).catch((error) => {
this.getFromDB()
}).finally(() => {
if (counter == 1 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
})
.finally(() => {
if (counter == 1 || this.loggeduser.Profile == 'PR') {
} else {
if(this.loggeduser.OwnerCalendars.length != 0) {
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) => {
this.addEventToDB(response, "md");
let eventsList = response;
this.CalendarStore.removeRange(startTime, endTime, 'md')
// loop
this.CalendarStore.pushEvent(eventsList, 'md');
this.listToPresent = this.CalendarStore.eventSource
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log('check list to present data', this.listToPresent);
this.myCal.update();
this.myCal.loadEvents();
this.showTimelineMD = true;
counter++;
if (counter == 2) {
this.showLoader = false;
}
}).catch((error) => {
this.getFromDB()
}).finally(() => {
counter++;
if (counter == 2) {
this.showLoader = false;
}
})
} else {
counter++;
if (counter == 2) {
this.showLoader = false;
}
}
console.log(this.loggeduser.SharedCalendars)
if(this.loggeduser.SharedCalendars.length != 0) {
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.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.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log('check list to present data', this.listToPresent);
this.myCal.update();
this.myCal.loadEvents();
this.showTimelinePR = true;
counter++;
if (counter == 2 || this.loggeduser.Profile == 'PR') {
this.showLoader = false;
}
}).catch((error) => {
this.getFromDB()
})
.finally(() => {
counter++;
if (counter == 2) {
this.showLoader = false;
}
})
} else {
counter++;
if (counter == 2) {
this.showLoader = false;
}
}
}
@@ -751,21 +918,25 @@ export class AgendaPage implements OnInit {
//Deve ser removido para ficar só um method transform
trasnformDataDB(response) {
console.log('Transform ', response)
response.forEach(element => {
let event = {
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: element.Profile,
id: element.EventId,
}
this.array.push(event)
});
this.listToPresent = this.array;
console.log('LIST TO PRESET', this.listToPresent)
if(response) {
console.log('Transform ', response)
response.forEach(element => {
let event = {
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: element.Profile,
id: element.EventId,
}
this.array.push(event)
});
this.listToPresent = this.array;
console.log('LIST TO PRESET', this.listToPresent)
}
}
addEventToDB(response, profile) {
@@ -14,7 +14,6 @@ import { AttendeesPageModal } from '../../events/attendees/attendees.page';
import { SearchPage } from '../../search/search.page';
import { ThemePalette } from '@angular/material/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { EventRecurrence } from 'src/app/models/agenda/eventrecurrence.model';
import { ThemeService } from 'src/app/services/theme.service';
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
@@ -315,6 +314,8 @@ export class NewEventPage implements OnInit {
console.log(this.loggeduser.Profile);
eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise();
} else {
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).toPromise();
}
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -36,6 +36,7 @@ import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, Cur
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { DomSanitizer } from '@angular/platform-browser';
import { MessageService } from 'src/app/services/chat/message.service';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-group-messages',
@@ -85,6 +86,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
durationDisplay = '';
duration = 0;
showAvatar = true;
audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
constructor(
private menu: MenuController,
@@ -111,6 +113,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
private processesService: ProcessesService,
private CameraService: CameraService,
private sanitiser: DomSanitizer,
private alertController: AlertController
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
@@ -296,15 +299,49 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
startRecording() {
console.log('Recording');
async checkAudioPermission() {
const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any)
console.log('permission', permissionStatus.state); // granted, denied, prompt
if (this.recording) {
return;
this.audioPermissionStatus = permissionStatus.state
permissionStatus.onchange = (data : any) => {
// console.log("Permission changed to " + data.state);
// console.log('permission', permissionStatus.state); // granted, denied, prompt
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
}
async startRecording() {
await this.checkAudioPermission();
if(this.audioPermissionStatus == 'granted') {
if (this.recording) {
return;
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
} else {
const alertPopup = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Necessita de permissão para gravar áudio',
buttons: [{
text: 'Ok',
handler: () => {
}
}]
});
await alertPopup.present();
}
}
+80 -37
View File
@@ -1,6 +1,6 @@
import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'
import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular';
import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform, AlertController } from '@ionic/angular';
import { map } from 'rxjs/operators';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { EventPerson } from 'src/app/models/eventperson.model';
@@ -97,6 +97,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
downloadFile: any;
downloadProgess: number;
audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
constructor(
public popoverController: PopoverController,
private modalController: ModalController,
@@ -122,6 +124,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private storage: Storage,
private fileToBase64Service: FileToBase64Service,
private sanitiser: DomSanitizer,
private alertController: AlertController
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.roomId = this.navParams.get('roomId');
@@ -143,6 +146,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.scrollToBottomClicked()
}, 150)
}
ngOnInit() {
@@ -220,17 +224,49 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
startRecording() {
console.log('Recording');
if (this.recording) {
return;
async checkAudioPermission() {
const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any)
console.log('permission', permissionStatus.state); // granted, denied, prompt
this.audioPermissionStatus = permissionStatus.state
permissionStatus.onchange = (data : any) => {
// console.log("Permission changed to " + data.state);
// console.log('permission', permissionStatus.state); // granted, denied, prompt
}
}
async startRecording() {
await this.checkAudioPermission();
if(this.audioPermissionStatus == 'granted') {
if (this.recording) {
return;
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
} else {
const alertPopup = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Necessita de permissão para gravar áudio',
buttons: [{
text: 'Ok',
handler: () => {
}
}]
});
await alertPopup.present();
}
this.recording = true;
VoiceRecorder.startRecording()
.then((result: GenericResponse) => console.log(result.value))
.catch(error => console.log(error));
this.calculateDuration();
}
stopRecording() {
@@ -397,35 +433,42 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.storage.get('recordData').then((recordData) => {
audioFile = recordData;
if(recordData?.value?.recordDataBase64.includes('data:audio')){
this.audioRecorded = recordData?.value?.recordDataBase64;
}
else{
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
if(recordData?.value?.recordDataBase64) {
if(recordData.value.recordDataBase64.includes('data:audio')){
this.audioRecorded = recordData.value.recordDataBase64;
}
else{
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
}
console.log(this.audioRecorded);
//Converting base64 to blob
const encodedData = btoa(this.audioRecorded);
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
console.log(blob)
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/audio",
"msDuration":audioFile.value.msDuration,
"mimeType":audioFile.value.mimeType,
},
attachments: [{
"title": fileName ,
"title_link_download": true,
"type": "audio"
}],
temporaryData: formData
})
} else {
alert('no audio')
}
console.log(this.audioRecorded);
//Converting base64 to blob
const encodedData = btoa(this.audioRecorded);
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
console.log(blob)
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/audio",
"msDuration":audioFile.value.msDuration,
"mimeType":audioFile.value.mimeType,
},
attachments: [{
"title": fileName ,
"title_link_download": true,
"type": "audio"
}],
temporaryData: formData
})
});
this.deleteRecording();
+11 -5
View File
@@ -178,7 +178,7 @@ export class InactivityPage implements OnInit {
SessionStore.setInativity(true)
this.goback()
setTimeout(()=>{
setTimeout(() => {
this.clearCode()
}, 1000)
@@ -194,16 +194,22 @@ export class InactivityPage implements OnInit {
if(pathName) {
this.router.navigate([pathName],{replaceUrl: true});
} else {
this.router.navigate(['/home/events'], {replaceUrl: true});
setTimeout(()=>{
this.router.navigate(['/home/events'], {replaceUrl: true});
}, 5000)
}
}
storePin() {
const code = this.code.join('');
SessionStore.setPin(code);
this.router.navigate(['/home/events']);
setTimeout(()=>{
const code = this.code.join('');
SessionStore.setPin(code);
this.router.navigate(['/home/events']);
}, 5000)
}
+2 -2
View File
@@ -123,11 +123,12 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run();
await this.authService.loginChat();
await this.authService.loginToChatWs();
this.getToken();
this.router.navigateByUrl('/pin', { replaceUrl: true });
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
}
else{
@@ -155,7 +156,6 @@ export class LoginPage implements OnInit {
this.router.navigate(['/home/chat']);
}
else if(this.permissionService.userPermission(this.permissionList.Actions.access)){
alert('here')
this.router.navigate(['/home/publications']);
}
}