This commit is contained in:
Peter Maquiran
2023-09-22 15:27:43 +01:00
9 changed files with 250 additions and 153 deletions
+85 -95
View File
@@ -12,6 +12,7 @@ import { ThemeService } from 'src/app/services/theme.service'
import { environment } from 'src/environments/environment';
import { ProcessesService } from 'src/app/services/processes.service';
import { EventsService } from 'src/app/services/events.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Component({
selector: 'app-profile',
@@ -21,7 +22,6 @@ import { EventsService } from 'src/app/services/events.service';
export class ProfilePage implements OnInit {
userLoginPreference = ''
notificationdata: any[] = [];
DataArray: Array<Object> = [];
service: "agenda";
@@ -56,6 +56,7 @@ export class ProfilePage implements OnInit {
private processesService: ProcessesService,
private eventsService: EventsService,
private storageService: StorageService,
public NotificationHolderService: NotificationHolderService
) {
@@ -84,10 +85,8 @@ export class ProfilePage implements OnInit {
ngOnInit() {
this.getNotificationData();
this.getProfilpicture();
// this.getNotificationData();
this.getProfilpicture();
}
@@ -109,87 +108,87 @@ export class ProfilePage implements OnInit {
asyncNotification() { }
async getNotificationData() {
// async getNotificationData() {
//const keyExist = await this.storageservice.keyExist("Notifications")
// //const keyExist = await this.storageservice.keyExist("Notifications")
//if(keyExist) {
await this.storageservice.get("Notifications").then((value) => {
// //if(keyExist) {
// await this.storageservice.get("Notifications").then((value) => {
console.log('Getnotifications 111', value)
// console.log('Getnotifications 111', value)
this.DataArray = []
value.forEach((element, i) => {
console.log('Getnotifications', element, i)
let notificationObject;
if (element.notification) {
// this.DataArray = []
// value.forEach((element, i) => {
// console.log('Getnotifications', element, i)
// let notificationObject;
// if (element.notification) {
notificationObject = {
index: i,
title: element.notification.title,
Service: element.data.Service,
Object: element.data.Object,
IdObject: element.data.IdObject,
FolderId: element.data.FolderId,
body: element.notification.body,
dateInit: this.getFormatedTime(element.data.dateInit),
dateEnd: this.getFormatedTime(element.data.dateEnd),
Location: element.data.Location,
TypeAgenda: element.data.TypeAgenda,
Role: element.data.Role,
Status: element.data.Status,
read: false,
}
// notificationObject = {
// index: i,
// title: element.notification.title,
// Service: element.data.Service,
// Object: element.data.Object,
// IdObject: element.data.IdObject,
// FolderId: element.data.FolderId,
// body: element.notification.body,
// dateInit: this.getFormatedTime(element.data.dateInit),
// dateEnd: this.getFormatedTime(element.data.dateEnd),
// Location: element.data.Location,
// TypeAgenda: element.data.TypeAgenda,
// Role: element.data.Role,
// Status: element.data.Status,
// read: false,
// }
} else if (element.data) {
notificationObject = {
index: i,
title: element.title,
Service: element.data.Service,
Object: element.data.Object,
IdObject: element.data.IdObject,
FolderId: element.data.FolderId,
body: element.body,
dateInit: this.getFormatedTime(element.data.dateInit),
dateEnd: this.getFormatedTime(element.data.dateEnd),
Location: element.data.Location,
TypeAgenda: element.data.TypeAgenda,
Role: element.data.Role,
Status: element.data.Status,
read: false,
}
// } else if (element.data) {
// notificationObject = {
// index: i,
// title: element.title,
// Service: element.data.Service,
// Object: element.data.Object,
// IdObject: element.data.IdObject,
// FolderId: element.data.FolderId,
// body: element.body,
// dateInit: this.getFormatedTime(element.data.dateInit),
// dateEnd: this.getFormatedTime(element.data.dateEnd),
// Location: element.data.Location,
// TypeAgenda: element.data.TypeAgenda,
// Role: element.data.Role,
// Status: element.data.Status,
// read: false,
// }
} else {
{
notificationObject = {
FolderId: element.FolderId,
IdObject: element.IdObject,
Location: element.Location,
Object: element.Object,
Role: element.Role,
Service: element.Service,
Status: element.Status,
TypeAgenda: element.TypeAgenda,
body: element.body,
dateEnd: element.dateEnd,
dateInit: element.dateInit,
index: element.index,
title: element.title,
read: false,
}
}
}
// } else {
// {
// notificationObject = {
// FolderId: element.FolderId,
// IdObject: element.IdObject,
// Location: element.Location,
// Object: element.Object,
// Role: element.Role,
// Service: element.Service,
// Status: element.Status,
// TypeAgenda: element.TypeAgenda,
// body: element.body,
// dateEnd: element.dateEnd,
// dateInit: element.dateInit,
// index: element.index,
// title: element.title,
// read: false,
// }
// }
// }
this.DataArray.push(notificationObject)
});
this.notificationdata = this.DataArray.reverse();
}).catch((error) => {
console.error('storage getnotification: ', error)
})
// }
// this.DataArray.push(notificationObject)
// });
// this.notificationdata = this.DataArray.reverse();
// }).catch((error) => {
// console.error('storage getnotification: ', error)
// })
// // }
}
// }
getFormatedTime(dateString) {
@@ -215,7 +214,7 @@ export class ProfilePage implements OnInit {
this.isloading = false
}, (error) => {
this.notificationdata[i].read = true;
this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false
})
}
@@ -230,7 +229,7 @@ export class ProfilePage implements OnInit {
}, (error) => {
console.log('evento não existe')
this.notificationdata[i].read = true;
this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false
})
@@ -274,7 +273,7 @@ export class ProfilePage implements OnInit {
this.isloading = false
}, (error) => {
this.notificationdata[i].read = true;
this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false
})
@@ -290,8 +289,12 @@ export class ProfilePage implements OnInit {
}
} else if (Service === "chat") {
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
this.zone.run(() => this.router.navigate(['/home/chat']));
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
this.deleteNotification(index);
}
@@ -359,21 +362,8 @@ export class ProfilePage implements OnInit {
}
deleteNotification(index) {
this.notificationdata = this.notificationdata.filter(item => item.index != index);
this.storageservice.store("Notifications", this.notificationdata).then((store) => {
this.storageservice.get("Notifications").then((value) => {
this.eventTriger.publishSomeData({
notification: "deleted"
})
}).catch((error) => {
console.error('storage delete notification: ', error)
})
});
const notificationdata = this.NotificationHolderService.notificationList.find(item => item.index == index);
this.NotificationHolderService.removeNotification(notificationdata)
}
logout() {
@@ -452,7 +442,7 @@ export class ProfilePage implements OnInit {
keppNotification(index) {
this.notificationdata[index].read = false;
this.NotificationHolderService.notificationList[index].read = false;
}
doNotKeppNotification(index) {