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 class="line"></div>
<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>
</ion-header>
@@ -95,7 +95,7 @@
<ion-list>
<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 class="notification-item">
+80 -92
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,7 +85,7 @@ export class ProfilePage implements OnInit {
ngOnInit() {
this.getNotificationData();
// this.getNotificationData();
this.getProfilpicture();
}
@@ -107,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) {
@@ -213,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
})
}
@@ -228,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
})
@@ -259,7 +260,7 @@ export class ProfilePage implements OnInit {
this.isloading = false
}, (error) => {
this.notificationdata[i].read = true;
this.NotificationHolderService.notificationList[i].read = true;
this.isloading = false
})
@@ -344,21 +345,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() {
@@ -434,7 +422,7 @@ export class ProfilePage implements OnInit {
keppNotification(index) {
this.notificationdata[index].read = false;
this.NotificationHolderService.notificationList[index].read = false;
}
doNotKeppNotification(index) {
+30 -21
View File
@@ -13,6 +13,9 @@ import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } fr
import { notificationObject } from '../models/notifications';
import { Capacitor } from '@capacitor/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Injectable({
providedIn: 'root'
})
@@ -23,6 +26,7 @@ export class NotificationsService {
DataArray = new Array();
callbacks: {
[key: string]: {
type: notificationObject,
@@ -43,7 +47,8 @@ export class NotificationsService {
private router: Router,
private zone: NgZone,
private eventtrigger: EventTrigger,
private afMessaging: AngularFireMessaging,) {
private afMessaging: AngularFireMessaging,
public NotificationHolderService: NotificationHolderService) {
}
@@ -157,33 +162,37 @@ export class NotificationsService {
}
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) => {
let exists = accumulator.find(item => {
return item.id === current.id;
});
if(!exists) {
accumulator = accumulator.concat(current);
}
return accumulator;
}, []);
this.NotificationHolderService.addNotification(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) => {
// let exists = accumulator.find(item => {
// return item.id === current.id;
// });
// if(!exists) {
// accumulator = accumulator.concat(current);
// }
// return accumulator;
// }, []);
console.log(result);
// console.log(result);
this.storageService.store("Notifications", result)
}).catch((error) => {
if (!error) {
this.storageService.store("Notifications", [notification])
}
})
// this.storageService.store("Notifications", result)
// }).catch((error) => {
// if (!error) {
// this.storageService.store("Notifications", [notification])
// }
// })
}
onReciveBackground() {
+2 -2
View File
@@ -230,8 +230,8 @@
</div>
<div class="profile-text">
<div *ngIf="notificationLength > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
{{notificationLength}} </div>
<div *ngIf="NotificationHolderService.notificationList.length > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
{{NotificationHolderService.notificationList.length}} </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 { ActiveTabService } from 'src/app/services/active-tab.service';
import { NotificationsService } from 'src/app/services/notifications.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Component({
selector: 'app-header',
@@ -55,6 +56,7 @@ export class HeaderPage implements OnInit {
private notificationService: NotificationsService,
private cdRef: ChangeDetectorRef,
private storageService: StorageService,
public NotificationHolderService: NotificationHolderService
) {
this.loggeduser = SessionStore.user;
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