header change

This commit is contained in:
Peter Maquiran
2023-08-31 16:37:11 +01:00
parent 680f57313f
commit c877fe002b
8 changed files with 259 additions and 126 deletions
+2 -2
View File
@@ -84,7 +84,7 @@
</div> </div>
<div class="line"></div> <div class="line"></div>
<ion-progress-bar type="indeterminate" *ngIf="isloading"></ion-progress-bar> <ion-progress-bar type="indeterminate" *ngIf="isloading"></ion-progress-bar>
<ion-label (click)="asyncNotification()" *ngIf="notificationdata">{{notificationStatus}}</ion-label> <!-- <ion-label (click)="asyncNotification()" *ngIf="NotificationHolderService.notificationList">{{notificationStatus}}</ion-label> -->
</div> </div>
</ion-header> </ion-header>
@@ -95,7 +95,7 @@
<ion-list> <ion-list>
<div class="item cursor-pointer ion-no-padding ion-no-margin" lines="none" <div class="item cursor-pointer ion-no-padding ion-no-margin" lines="none"
*ngFor="let item of notificationdata; let i = index"> *ngFor="let item of NotificationHolderService.notificationList; let i = index">
<div *ngIf="item.read == false" class="item-conten-{{item.Service}}-{{item.TypeAgenda}}-{{item.Role}}" (click)="notificatinsRoutes(item.index,item.Service,item.Object,item.IdObject,item.FolderId,i)"> <div *ngIf="item.read == false" class="item-conten-{{item.Service}}-{{item.TypeAgenda}}-{{item.Role}}" (click)="notificatinsRoutes(item.index,item.Service,item.Object,item.IdObject,item.FolderId,i)">
<div class="notification-item"> <div class="notification-item">
+82 -94
View File
@@ -12,6 +12,7 @@ import { ThemeService } from 'src/app/services/theme.service'
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { EventsService } from 'src/app/services/events.service'; import { EventsService } from 'src/app/services/events.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Component({ @Component({
selector: 'app-profile', selector: 'app-profile',
@@ -21,7 +22,6 @@ import { EventsService } from 'src/app/services/events.service';
export class ProfilePage implements OnInit { export class ProfilePage implements OnInit {
userLoginPreference = '' userLoginPreference = ''
notificationdata: any[] = [];
DataArray: Array<Object> = []; DataArray: Array<Object> = [];
service: "agenda"; service: "agenda";
@@ -56,6 +56,7 @@ export class ProfilePage implements OnInit {
private processesService: ProcessesService, private processesService: ProcessesService,
private eventsService: EventsService, private eventsService: EventsService,
private storageService: StorageService, private storageService: StorageService,
public NotificationHolderService: NotificationHolderService
) { ) {
@@ -84,7 +85,7 @@ export class ProfilePage implements OnInit {
ngOnInit() { ngOnInit() {
this.getNotificationData(); // this.getNotificationData();
this.getProfilpicture(); this.getProfilpicture();
} }
@@ -107,87 +108,87 @@ export class ProfilePage implements OnInit {
asyncNotification() { } asyncNotification() { }
async getNotificationData() { // async getNotificationData() {
//const keyExist = await this.storageservice.keyExist("Notifications") // //const keyExist = await this.storageservice.keyExist("Notifications")
//if(keyExist) { // //if(keyExist) {
await this.storageservice.get("Notifications").then((value) => { // await this.storageservice.get("Notifications").then((value) => {
console.log('Getnotifications 111', value) // console.log('Getnotifications 111', value)
this.DataArray = [] // this.DataArray = []
value.forEach((element, i) => { // value.forEach((element, i) => {
console.log('Getnotifications', element, i) // console.log('Getnotifications', element, i)
let notificationObject; // let notificationObject;
if (element.notification) { // if (element.notification) {
notificationObject = { // notificationObject = {
index: i, // index: i,
title: element.notification.title, // title: element.notification.title,
Service: element.data.Service, // Service: element.data.Service,
Object: element.data.Object, // Object: element.data.Object,
IdObject: element.data.IdObject, // IdObject: element.data.IdObject,
FolderId: element.data.FolderId, // FolderId: element.data.FolderId,
body: element.notification.body, // body: element.notification.body,
dateInit: this.getFormatedTime(element.data.dateInit), // dateInit: this.getFormatedTime(element.data.dateInit),
dateEnd: this.getFormatedTime(element.data.dateEnd), // dateEnd: this.getFormatedTime(element.data.dateEnd),
Location: element.data.Location, // Location: element.data.Location,
TypeAgenda: element.data.TypeAgenda, // TypeAgenda: element.data.TypeAgenda,
Role: element.data.Role, // Role: element.data.Role,
Status: element.data.Status, // Status: element.data.Status,
read: false, // 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,
}
}
}
this.DataArray.push(notificationObject)
});
this.notificationdata = this.DataArray.reverse();
}).catch((error) => {
console.error('storage getnotification: ', error)
})
// } // }
// } 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,
// }
// }
// }
// this.DataArray.push(notificationObject)
// });
// this.notificationdata = this.DataArray.reverse();
// }).catch((error) => {
// console.error('storage getnotification: ', error)
// })
// // }
// }
getFormatedTime(dateString) { getFormatedTime(dateString) {
@@ -213,7 +214,7 @@ export class ProfilePage implements OnInit {
this.isloading = false this.isloading = false
}, (error) => { }, (error) => {
this.notificationdata[i].read = true; this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false this.isloading = false
}) })
} }
@@ -228,7 +229,7 @@ export class ProfilePage implements OnInit {
}, (error) => { }, (error) => {
console.log('evento não existe') console.log('evento não existe')
this.notificationdata[i].read = true; this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false this.isloading = false
}) })
@@ -259,7 +260,7 @@ export class ProfilePage implements OnInit {
this.isloading = false this.isloading = false
}, (error) => { }, (error) => {
this.notificationdata[i].read = true; this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false this.isloading = false
}) })
@@ -344,21 +345,8 @@ export class ProfilePage implements OnInit {
} }
deleteNotification(index) { deleteNotification(index) {
this.notificationdata = this.notificationdata.filter(item => item.index != index); const notificationdata = this.NotificationHolderService.notificationList.find(item => item.index == index);
this.NotificationHolderService.removeNotification(notificationdata)
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)
})
});
} }
logout() { logout() {
@@ -434,7 +422,7 @@ export class ProfilePage implements OnInit {
keppNotification(index) { keppNotification(index) {
this.notificationdata[index].read = false; this.NotificationHolderService.notificationList[index].read = false;
} }
doNotKeppNotification(index) { doNotKeppNotification(index) {
+30 -21
View File
@@ -13,6 +13,9 @@ import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } fr
import { notificationObject } from '../models/notifications'; import { notificationObject } from '../models/notifications';
import { Capacitor } from '@capacitor/core'; import { Capacitor } from '@capacitor/core';
import { AngularFireMessaging } from '@angular/fire/messaging'; import { AngularFireMessaging } from '@angular/fire/messaging';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@@ -23,6 +26,7 @@ export class NotificationsService {
DataArray = new Array(); DataArray = new Array();
callbacks: { callbacks: {
[key: string]: { [key: string]: {
type: notificationObject, type: notificationObject,
@@ -43,7 +47,8 @@ export class NotificationsService {
private router: Router, private router: Router,
private zone: NgZone, private zone: NgZone,
private eventtrigger: EventTrigger, private eventtrigger: EventTrigger,
private afMessaging: AngularFireMessaging,) { private afMessaging: AngularFireMessaging,
public NotificationHolderService: NotificationHolderService) {
} }
@@ -157,33 +162,37 @@ export class NotificationsService {
} }
storenotification(notification) { storenotification(notification) {
console.log('Store Notification ',notification)
this.storageService.get("Notifications").then((store) => {
store.push(notification)
console.log('Store Notification ',store)
const result = store.reduce((accumulator, current) => { this.NotificationHolderService.addNotification(notification)
let exists = accumulator.find(item => {
return item.id === current.id;
});
if(!exists) {
accumulator = accumulator.concat(current);
}
return accumulator;
}, []);
console.log(result); // console.log('Store Notification ',notification)
// this.storageService.get("Notifications").then((store) => {
// store.push(notification)
// console.log('Store Notification ',store)
// const result = store.reduce((accumulator, current) => {
// let exists = accumulator.find(item => {
// return item.id === current.id;
// });
// if(!exists) {
// accumulator = accumulator.concat(current);
// }
// return accumulator;
// }, []);
// console.log(result);
this.storageService.store("Notifications", result) // this.storageService.store("Notifications", result)
}).catch((error) => { // }).catch((error) => {
if (!error) { // if (!error) {
this.storageService.store("Notifications", [notification]) // this.storageService.store("Notifications", [notification])
} // }
}) // })
} }
onReciveBackground() { onReciveBackground() {
+2 -2
View File
@@ -230,8 +230,8 @@
</div> </div>
<div class="profile-text"> <div class="profile-text">
<div *ngIf="notificationLength > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;"> <div *ngIf="NotificationHolderService.notificationList.length > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
{{notificationLength}} </div> {{NotificationHolderService.notificationList.length}} </div>
</div> </div>
</div> </div>
+2
View File
@@ -14,6 +14,7 @@ import { PermissionService } from 'src/app/services/permission.service';
import { EventTrigger } from 'src/app/services/eventTrigger.service' import { EventTrigger } from 'src/app/services/eventTrigger.service'
import { ActiveTabService } from 'src/app/services/active-tab.service'; import { ActiveTabService } from 'src/app/services/active-tab.service';
import { NotificationsService } from 'src/app/services/notifications.service'; import { NotificationsService } from 'src/app/services/notifications.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Component({ @Component({
selector: 'app-header', selector: 'app-header',
@@ -55,6 +56,7 @@ export class HeaderPage implements OnInit {
private notificationService: NotificationsService, private notificationService: NotificationsService,
private cdRef: ChangeDetectorRef, private cdRef: ChangeDetectorRef,
private storageService: StorageService, private storageService: StorageService,
public NotificationHolderService: NotificationHolderService
) { ) {
this.loggeduser = SessionStore.user; this.loggeduser = SessionStore.user;
router.events.subscribe((val) => { router.events.subscribe((val) => {
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NotificationHolderService } from './notification-holder.service';
describe('NotificationHolderService', () => {
let service: NotificationHolderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NotificationHolderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,118 @@
import { Injectable } from '@angular/core';
import { StorageService } from '../services/storage.service';
@Injectable({
providedIn: 'root'
})
export class NotificationHolderService {
notificationList = []
constructor(
private storageService: StorageService,
) {
try {
this.restore()
} catch(error) {}
}
restore() {
this.storageService.get("Notifications").then((store) => {
if(Array.isArray(store)) {
this.notificationList = store
}
}).catch((error) => {})
}
save() {
this.storageService.store("Notifications", this.notificationList)
}
addNotification(notification) {
const element = notification
const i = this.notificationList.length + 1
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,
}
} 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,
}
}
}
this.notificationList.push(notificationObject)
this.save()
}
getFormatedTime(dateString) {
var date = new Date(dateString);
var hours = date.getHours() /* > 12 ? date.getHours() - 12 : date.getHours() */;
var am_pm = date.getHours() >= 12 ? "pm" : "am";
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let time = hours + ":" + minutes /* + " " + am_pm */;
return time;
}
removeNotification(notification) {
this.notificationList = this.notificationList.filter( (e) => {
return e.index != notification.index
})
this.save()
}
}
File diff suppressed because one or more lines are too long