This commit is contained in:
Peter Maquiran
2023-09-22 15:27:43 +01:00
9 changed files with 250 additions and 153 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
<ion-tab-button *ngIf="p.userPermission([permissionList.Chat.access])" tab="chat" [class.active]="ActiveTabService.pages.chat"> <ion-tab-button *ngIf="p.userPermission([permissionList.Chat.access])" tab="chat" [class.active]="ActiveTabService.pages.chat">
<ion-icon *ngIf="!ActiveTabService.pages.chat" class="nav-icon font-30-em" src="assets/images/icons-nav-chat-inactive.svg"></ion-icon> <ion-icon *ngIf="!ActiveTabService.pages.chat" class="nav-icon font-30-em" src="assets/images/icons-nav-chat-inactive.svg"></ion-icon>
<ion-icon *ngIf="ActiveTabService.pages.chat" class="nav-icon font-30-em" src="assets/images/nav-hover/icons-nav-chat-active.svg"></ion-icon> <ion-icon *ngIf="ActiveTabService.pages.chat" class="nav-icon font-30-em" src="assets/images/nav-hover/icons-nav-chat-active.svg"></ion-icon>
<ion-label class="font-12-em">Chat ...</ion-label> <ion-label class="font-12-em">Chat</ion-label>
</ion-tab-button> </ion-tab-button>
</ion-tab-bar> </ion-tab-bar>
+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">
+85 -95
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,10 +85,8 @@ export class ProfilePage implements OnInit {
ngOnInit() { ngOnInit() {
this.getNotificationData(); // this.getNotificationData();
this.getProfilpicture();
this.getProfilpicture();
} }
@@ -109,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) { // } else if (element.data) {
notificationObject = { // notificationObject = {
index: i, // index: i,
title: element.title, // title: element.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.body, // body: element.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 { // } else {
{ // {
notificationObject = { // notificationObject = {
FolderId: element.FolderId, // FolderId: element.FolderId,
IdObject: element.IdObject, // IdObject: element.IdObject,
Location: element.Location, // Location: element.Location,
Object: element.Object, // Object: element.Object,
Role: element.Role, // Role: element.Role,
Service: element.Service, // Service: element.Service,
Status: element.Status, // Status: element.Status,
TypeAgenda: element.TypeAgenda, // TypeAgenda: element.TypeAgenda,
body: element.body, // body: element.body,
dateEnd: element.dateEnd, // dateEnd: element.dateEnd,
dateInit: element.dateInit, // dateInit: element.dateInit,
index: element.index, // index: element.index,
title: element.title, // title: element.title,
read: false, // read: false,
} // }
} // }
} // }
this.DataArray.push(notificationObject) // this.DataArray.push(notificationObject)
}); // });
this.notificationdata = this.DataArray.reverse(); // this.notificationdata = this.DataArray.reverse();
}).catch((error) => { // }).catch((error) => {
console.error('storage getnotification: ', error) // console.error('storage getnotification: ', error)
}) // })
// } // // }
} // }
getFormatedTime(dateString) { getFormatedTime(dateString) {
@@ -215,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
}) })
} }
@@ -230,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
}) })
@@ -274,7 +273,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
}) })
@@ -290,8 +289,12 @@ export class ProfilePage implements OnInit {
} }
} else if (Service === "chat") { } else if (Service === "chat") {
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } }; let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
this.zone.run(() => this.router.navigate(['/home/chat']));
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras)); this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
this.deleteNotification(index); this.deleteNotification(index);
} }
@@ -359,21 +362,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() {
@@ -452,7 +442,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) {
+9 -38
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,
@@ -44,7 +48,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) {
} }
@@ -179,45 +184,11 @@ 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)
if(this.platform.is('mobile')) {
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('Notification Result',result);
this.storageService.store("Notifications", result).then(() => {
this.eventtrigger.publishSomeData({
notification: "recive"
})
})
} else { this.NotificationHolderService.addNotification(notification)
this.storageService.store("Notifications", store).then(() => {
this.eventtrigger.publishSomeData({
notification: "recive"
})
})
}
}).catch((error) => {
if (!error) {
this.storageService.store("Notifications", [notification])
}
})
} }
onReciveBackground() { onReciveBackground() {
+5 -5
View File
@@ -42,7 +42,7 @@
<div title="Perfil" class="div-profile cursor-pointer viewport-font-size " (click)="openProfile()"> <div title="Perfil" class="div-profile cursor-pointer viewport-font-size " (click)="openProfile()">
<!-- <div *ngIf="this.notificationLength > 0" class="icon-badge">{{notificationLength}}</div> --> <!-- <div *ngIf="this.NotificationHolderService.notificationList.length > 0" class="icon-badge">{{NotificationHolderService.notificationList.length}}</div> -->
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="icon font-45-em" src='assets/images/theme/doneIt/icons-profile.svg'></ion-icon> <!-- <ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="icon font-45-em" src='assets/images/theme/doneIt/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon font-45-em" src='assets/images/icons-profile.svg'></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon font-45-em" src='assets/images/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> --> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> -->
@@ -68,8 +68,8 @@
<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>
</div> </div>
@@ -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>
+3 -1
View File
@@ -15,6 +15,7 @@ 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 { AttachmentsService } from 'src/app/services/attachments.service'; import { AttachmentsService } from 'src/app/services/attachments.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
@Component({ @Component({
selector: 'app-header', selector: 'app-header',
@@ -57,7 +58,8 @@ export class HeaderPage implements OnInit {
private cdRef: ChangeDetectorRef, private cdRef: ChangeDetectorRef,
private storageService: StorageService, private storageService: StorageService,
private zone: NgZone, private zone: NgZone,
private attachmentService: AttachmentsService private attachmentService: AttachmentsService,
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()
}
}
+11 -11
View File
File diff suppressed because one or more lines are too long