mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -182,9 +182,9 @@ export class HomePage implements OnInit {
|
||||
|
||||
synchro.registerCallback('Notification', (DataArray)=> {
|
||||
|
||||
this.webNotificationPopupService.sendNotification(DataArray.Object)
|
||||
this.webNotificationPopupService.sendNotification(DataArray)
|
||||
|
||||
this.storageService.get('Notifications').then((data)=>{
|
||||
this.storageService.get('Notifications').then((data:any)=>{
|
||||
data.push(DataArray)
|
||||
this.storageService.store("Notifications", data)
|
||||
}).catch(()=>{
|
||||
|
||||
@@ -464,7 +464,7 @@ export class AgendaPage implements OnInit {
|
||||
// loop
|
||||
this.calendarService.pushEvent(response, 'md');
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -485,7 +485,7 @@ export class AgendaPage implements OnInit {
|
||||
// calendar
|
||||
this.calendarService.pushEvent(response, 'pr');
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -511,7 +511,7 @@ export class AgendaPage implements OnInit {
|
||||
this.calendarService.pushEvent(response, 'pr');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
|
||||
this.myCal.update();
|
||||
@@ -539,7 +539,7 @@ export class AgendaPage implements OnInit {
|
||||
this.calendarService.pushEvent(eventsList, 'md');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -553,17 +553,13 @@ export class AgendaPage implements OnInit {
|
||||
}
|
||||
else{
|
||||
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) => {
|
||||
//this.eventSource=[];
|
||||
|
||||
// clear the current month only
|
||||
this.calendarService.removeRange(startTime, endTime, 'pr')
|
||||
|
||||
const eventsList = response.filter(data => data.CalendarName == "Pessoal");
|
||||
this.calendarService.pushEvent(eventsList, 'pr');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -592,7 +588,7 @@ export class AgendaPage implements OnInit {
|
||||
this.calendarService.pushEvent(eventsList, 'md');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -614,7 +610,7 @@ export class AgendaPage implements OnInit {
|
||||
this.calendarService.pushEvent(eventsList, 'pr');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -645,7 +641,7 @@ export class AgendaPage implements OnInit {
|
||||
// loop
|
||||
this.calendarService.pushEvent(eventsList, 'md');
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -674,7 +670,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
this.calendarService.pushEvent(eventsList, 'pr');
|
||||
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
@@ -712,7 +708,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
this.calendarService.pushEvent(eventsList, 'pr');
|
||||
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
|
||||
this.myCal.update();
|
||||
@@ -739,8 +735,8 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
updateEventListBox() {
|
||||
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelinePRList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
}
|
||||
|
||||
@@ -939,13 +935,13 @@ export class AgendaPage implements OnInit {
|
||||
if(this.profile == "mdgpr") {
|
||||
this.profile ="pr";
|
||||
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, {})
|
||||
|
||||
}
|
||||
else {
|
||||
this.profile ="mdgpr";
|
||||
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, 'date')
|
||||
this.TimelineMDList = this.listBoxService.list(this.calendarService.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, {})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ export class ListBoxService {
|
||||
|
||||
daysBetween(){ }
|
||||
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
|
||||
|
||||
console.log('eventSource: EventListStore[]',eventSource)
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'todo'}) {
|
||||
|
||||
if(profile != 'all') {
|
||||
eventSource = this.filterProfile(eventSource, profile)
|
||||
@@ -71,8 +69,7 @@ export class ListBoxService {
|
||||
days[day] = []
|
||||
}
|
||||
|
||||
if (new Date(startDate).toLocaleDateString() != new Date(endDate).toLocaleDateString()) {
|
||||
|
||||
if (this.dateService.notSameDate(startDate, endDate)) {
|
||||
|
||||
const diffDays = this.dateService.deferenceBetweenDays(endDate, startDate)
|
||||
|
||||
@@ -80,27 +77,8 @@ export class ListBoxService {
|
||||
|
||||
if (diffDays >= 1) {
|
||||
|
||||
const StartEvent = Object.assign({}, {
|
||||
title: event.event.Subject,
|
||||
start: event.start,
|
||||
end: event.end,
|
||||
color: event.color,
|
||||
id: event.id,
|
||||
index: event.index,
|
||||
CalendarName: event.CalendarName,
|
||||
event: {
|
||||
Subject: event.event.Subject,
|
||||
StartDate: event.event.StartDate,
|
||||
EndDate: event.event.EndDate,
|
||||
Location: event.event.Location,
|
||||
EventId: event.event.EventId,
|
||||
CalendarName: event.event.CalendarName
|
||||
},
|
||||
startMany: true,
|
||||
endMany: false,
|
||||
middle: false
|
||||
})
|
||||
|
||||
const StartEvent = this.transForm(event, {startMany: true,endMany: false, middle: false})
|
||||
|
||||
days[day].push(StartEvent)
|
||||
|
||||
let i = 1;
|
||||
@@ -126,53 +104,12 @@ export class ListBoxService {
|
||||
startDate.getDate() != endDate.getDate())) {
|
||||
// last push
|
||||
|
||||
const EndEvent = Object.assign({}, {
|
||||
title: event.event.Subject,
|
||||
start: event.start,
|
||||
end: event.end,
|
||||
color: event.color,
|
||||
id: event.id,
|
||||
index: event.index,
|
||||
CalendarName: event.CalendarName,
|
||||
event: {
|
||||
Subject: event.event.Subject,
|
||||
StartDate: event.event.StartDate,
|
||||
EndDate: event.event.EndDate,
|
||||
Location: event.event.Location,
|
||||
EventId: event.event.EventId,
|
||||
CalendarName: event.event.CalendarName
|
||||
},
|
||||
Subject: event.event.Subject,
|
||||
startMany: false,
|
||||
endMany: true,
|
||||
middle: false
|
||||
})
|
||||
|
||||
const EndEvent = this.transForm(event, {startMany: false,endMany: true, middle: false})
|
||||
days[otherDays].push(EndEvent)
|
||||
|
||||
} else {
|
||||
const EndEvent = Object.assign({}, {
|
||||
title: event.event.Subject,
|
||||
start: event.start,
|
||||
end: event.end,
|
||||
color: event.color,
|
||||
id: event.id,
|
||||
index: event.index,
|
||||
profile: event,
|
||||
CalendarName: event.CalendarName,
|
||||
event: {
|
||||
Subject: event.event.Subject,
|
||||
StartDate: event.event.StartDate,
|
||||
EndDate: event.event.EndDate,
|
||||
Location: event.event.Location,
|
||||
EventId: event.event.EventId,
|
||||
CalendarName: event.event.CalendarName
|
||||
},
|
||||
Subject: event.event.Subject,
|
||||
startMany: false,
|
||||
endMany: true,
|
||||
middle: true
|
||||
})
|
||||
|
||||
const EndEvent = this.transForm(event, {startMany: false,endMany: true, middle: true})
|
||||
days[otherDays].push(EndEvent)
|
||||
}
|
||||
|
||||
@@ -180,13 +117,10 @@ export class ListBoxService {
|
||||
|
||||
} else {
|
||||
days[day].push(event)
|
||||
|
||||
}
|
||||
} else {
|
||||
days[day].push(event)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
days[day].push(event)
|
||||
@@ -231,4 +165,32 @@ export class ListBoxService {
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
|
||||
transForm(event: CustomCalendarEvent, {startMany, endMany, middle}) {
|
||||
return Object.assign({}, {
|
||||
title: event.event.Subject,
|
||||
start: event.start,
|
||||
end: event.end,
|
||||
color: event.color,
|
||||
id: event.id,
|
||||
index: event.index,
|
||||
profile: event,
|
||||
CalendarName: event.CalendarName,
|
||||
event: {
|
||||
Subject: event.event.Subject,
|
||||
StartDate: event.event.StartDate,
|
||||
EndDate: event.event.EndDate,
|
||||
Location: event.event.Location,
|
||||
EventId: event.event.EventId,
|
||||
CalendarName: event.event.CalendarName
|
||||
},
|
||||
Subject: event.event.Subject,
|
||||
startMany: false,
|
||||
endMany: true,
|
||||
middle: true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
self.addEventListener('install', function() {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', function(event) {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', function(event) {
|
||||
// Close the notification when it is clicked
|
||||
event.notification.close();
|
||||
console.log(event)
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class WebNotificationPopupService {
|
||||
|
||||
constructor( private platform: Platform) { }
|
||||
constructor( private platform: Platform) {
|
||||
|
||||
navigator.serviceWorker.register(new URL('./sw.js', import.meta.url));
|
||||
|
||||
}
|
||||
|
||||
|
||||
askNotificationPermission() {
|
||||
@@ -44,7 +49,35 @@ export class WebNotificationPopupService {
|
||||
return true;
|
||||
}
|
||||
|
||||
sendNotification(message) {
|
||||
var n = new Notification(message);
|
||||
sendNotification(e) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
||||
else {return false}
|
||||
|
||||
Notification.requestPermission((result) => {
|
||||
if (result === 'granted') {
|
||||
navigator.serviceWorker.ready.then((registration)=> {
|
||||
|
||||
registration.showNotification(e.Object, {
|
||||
body: e.Service,
|
||||
icon: 'assets/icon/favicon.png',
|
||||
requireInteraction: true,
|
||||
tag: 'require-interaction'+uuidv4(),
|
||||
// actions: [
|
||||
// {action: 'like', title: 'Like', icon: 'https://example/like.png'},
|
||||
// {action: 'reply', title: 'Reply', icon: 'https://example/reply.png'}
|
||||
// ]
|
||||
}).then(e =>{
|
||||
console.log(e)
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ const { Storage } = Plugins; */
|
||||
export class StorageService {
|
||||
private keyName: string;
|
||||
|
||||
|
||||
constructor(private storage:Storage,
|
||||
private platform: Platform
|
||||
) {}
|
||||
@@ -22,50 +21,27 @@ const { Storage } = Plugins; */
|
||||
|
||||
// Store the value
|
||||
async store(key: string, value: any) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await localstoreService.set(this.key(key), value)
|
||||
} else {
|
||||
const encryptedValue = btoa(escape(JSON.stringify(value)));
|
||||
await this.storage.set(key, encryptedValue);
|
||||
}
|
||||
|
||||
await localstoreService.set(this.key(key), value)
|
||||
|
||||
}
|
||||
// Get the value
|
||||
async get(key: string) {
|
||||
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
const data = localstoreService.get(this.key(key), false)
|
||||
if(data) resolve(data)
|
||||
else reject(data)
|
||||
})
|
||||
} else {
|
||||
const ret = await this.storage.get(key).then((val) => { return val; });
|
||||
try {
|
||||
return JSON.parse(unescape(atob(ret)));
|
||||
} catch (error) {
|
||||
if(ret == 'ée') {
|
||||
throw(key+' not found')
|
||||
}
|
||||
return unescape(atob(ret))
|
||||
}
|
||||
}
|
||||
async get(key: string): Promise<any> {
|
||||
|
||||
return new Promise((resolve, reject)=>{
|
||||
const data = localstoreService.get(this.key(key), false)
|
||||
if(data) resolve(data)
|
||||
else reject(data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async remove(key: string){
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await localstoreService.delete(this.key(key))
|
||||
} else {
|
||||
await this.storage.remove(key);
|
||||
}
|
||||
await localstoreService.delete(this.key(key))
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Get the value
|
||||
async get(storageKey: string) {
|
||||
|
||||
Reference in New Issue
Block a user