diff --git a/config.xml b/config.xml
index 7b18d7926..97d2fb38d 100644
--- a/config.xml
+++ b/config.xml
@@ -3,7 +3,7 @@
gabinete digital
An awesome Ionic/Cordova app.
Ionic Framework Team
-
+
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts
index 912061afe..035f1debd 100644
--- a/src/app/home/home.page.ts
+++ b/src/app/home/home.page.ts
@@ -162,8 +162,19 @@ export class HomePage implements OnInit {
}
)
- synchro.registerCallback('Notification', (notification)=> {
- console.log('notification====== £=======£==========£======', notification)
+
+ synchro.registerCallback('Notification', (DataArray)=> {
+
+ this.storageService.get('Notifications').then((data)=>{
+ data.push(DataArray)
+ this.storageService.store("Notifications", data)
+ }).catch(()=>{
+
+ const a = []
+ a.push(DataArray)
+ this.storageService.store("Notifications",a)
+ })
+
}, 'any')
}
diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts
index aaf8562af..6f77c2f10 100644
--- a/src/app/modals/profile/profile.page.ts
+++ b/src/app/modals/profile/profile.page.ts
@@ -11,6 +11,7 @@ import { JsonStore } from '../../services/jsonStore.service';
import { StorageService } from '../../services/storage.service';
import { NotificationsService } from '../../services/notifications.service';
import { SessionStore } from 'src/app/store/session.service';
+import { synchro } from 'src/app/services/socket/synchro.service';
@Component({
selector: 'app-profile',
@@ -42,24 +43,35 @@ export class ProfilePage implements OnInit {
private zone: NgZone,
private notificationservice: NotificationsService,
private platform: Platform,
+ private notificationsService: NotificationsService,
) {
this.loggeduser = authService.ValidatedUser;
console.log(this.loggeduser.RoleDescription)
- this.checkState()
}
ngOnInit() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
+ this.getNotificationData();
} else {
- this.getNotificationData();
+ this.getNotificationData();
}
+ this.notificationsService.registerCallback(
+ 'any',
+ () => {
+ setTimeout(()=>{
+ this.getNotificationData();
+ }, 100)
+ }
+ )
+
}
+
close() {
this.modalController.dismiss();
}
@@ -68,7 +80,7 @@ export class ProfilePage implements OnInit {
asyncNotification(){}
- async getNotificationData(){
+ async getNotificationData() {
this.storageservice.get("Notifications").then((value) => {
console.log("Init get store", value)
@@ -78,6 +90,8 @@ export class ProfilePage implements OnInit {
value = JSON.parse(value)
console.log("CSDfdvdf",value)
}
+
+ this.DataArray = []
value.forEach((element,i) => {
console.log("ARaaAA", element)
let notificationObject;
@@ -213,18 +227,6 @@ export class ProfilePage implements OnInit {
}
- checkState() {
-
- let userData = this.localstoreService.get('UserData', {})
-
- if (userData.hasOwnProperty('loginPreference')) {
- this.userLoginPreference = userData.loginPreference
- } else {
- this.userLoginPreference = ''
- }
-
- }
-
async editProfile() {
const enterAnimation = (baseEl: any) => {
diff --git a/src/app/models/agenda/AgendaEventList.ts b/src/app/models/agenda/AgendaEventList.ts
new file mode 100644
index 000000000..63a798d4a
--- /dev/null
+++ b/src/app/models/agenda/AgendaEventList.ts
@@ -0,0 +1,37 @@
+export interface EventList {
+ HasAttachments: boolean;
+ IsAllDayEvent: boolean;
+ EventId: string;
+ Subject: string;
+ Location: string;
+ CalendarId: string;
+ CalendarName: string;
+ StartDate: string;
+ EndDate: string;
+ HumanDate: string;
+}
+
+export interface EventListStore {
+ title: string
+ startTime: Date
+ endTime: Date
+ allDay: boolean,
+ event: EventList,
+ calendarName: string
+ profile: "md" | "pr",
+ id: string
+}
+
+
+export interface CustomCalendarEvent {
+ start: Date
+ end: Date
+ color: {
+ primary: string,
+ secondary: string
+ },
+ id: string
+ index: number,
+ CalendarName: string
+ event: EventListStore
+}
\ No newline at end of file
diff --git a/src/app/pages/agenda/eventListBox.ts b/src/app/pages/agenda/eventListBox.ts
index 83a03759e..72f7b295b 100644
--- a/src/app/pages/agenda/eventListBox.ts
+++ b/src/app/pages/agenda/eventListBox.ts
@@ -1,5 +1,7 @@
import { eventSource } from 'src/app/models/agenda/eventSource';
import { setHours, setMinutes } from 'date-fns';
+import { CustomCalendarEvent, EventList, EventListStore } from 'src/app/models/agenda/AgendaEventList';
+import { CalendarEvent } from 'angular-calendar';
export class eventListBox {
@@ -24,11 +26,11 @@ export class eventListBox {
}
- filterProfile(eventSource: eventSource[], profile: 'md' | 'pr' | 'all') {
+ filterProfile(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all') {
return eventSource.filter((e) => e.profile == profile)
}
- getEventInsideRange(eventSource: eventSource[], rangeStartDate, randEndDate) {
+ getEventInsideRange(eventSource: EventListStore[], rangeStartDate, randEndDate) {
return eventSource.filter((e)=> {
if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() &&
new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) {
@@ -40,7 +42,7 @@ export class eventListBox {
daysBetween(){ }
- list(eventSource: eventSource[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
+ list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, calendarDate) {
if(profile != 'all') {
eventSource = this.filterProfile(eventSource, profile)
@@ -48,19 +50,21 @@ export class eventListBox {
eventSource = this.getEventInsideRange(eventSource, rangeStartDate, randEndDate)
+ let newStracture:CustomCalendarEvent[];
if(profile == 'md') {
- eventSource = this.encapsulation(eventSource, 'mdgpr');
+ newStracture = this.encapsulation(eventSource, 'mdgpr');
} else {
- eventSource = this.encapsulation(eventSource, 'pr');
+ newStracture = this.encapsulation(eventSource, 'pr');
}
- return this.display(eventSource)
+ return this.display(newStracture)
}
display(list) {
let days = {};
+ console.log(list)
- list.forEach( (event:any, index)=> {
+ list.forEach( (event, index)=> {
var startDate: any = new Date(event.start);
@@ -215,27 +219,28 @@ export class eventListBox {
return days
}
- encapsulation(eventsList, profile) {
+ encapsulation(eventsList, profile): CustomCalendarEvent[] {
// remove all event
- let events = [];
+ let events: CustomCalendarEvent[] = [];
eventsList.forEach((element, eventIndex) => {
events.push({
- start: new Date(element.StartDate || element.startTime),
- end: new Date(element.EndDate || element.endTime),
+ start: new Date(element.startTime),
+ end: new Date(element.endTime),
color: {
primary: '#0000',
secondary: '#0000'
},
- id: element.EventId || element.id,
+ id: element.id,
index: eventIndex,
- profile: profile,
CalendarName: element.calendarName,
event: element.event,
});
+ console.log('element.event', element.event)
+
});
return events;
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts
index c2643fe1c..a3a986157 100644
--- a/src/app/pages/events/events.page.ts
+++ b/src/app/pages/events/events.page.ts
@@ -53,7 +53,7 @@ export class EventsPage implements OnInit {
customText = false;
totalEvent=0;
- currentHoursMinutes: Date;
+ currentHoursMinutes: Date | string;
showLoader: boolean;
diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts
index 79769d4c7..a3a0d8983 100644
--- a/src/app/services/events.service.ts
+++ b/src/app/services/events.service.ts
@@ -5,6 +5,7 @@ import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
+import { EventList } from '../models/agenda/AgendaEventList';
@Injectable({
@@ -107,7 +108,7 @@ export class EventsService {
} */
- getAllPrOficialEvents(startdate:string, enddate:string): Observable{
+ getAllPrOficialEvents(startdate:string, enddate:string): Observable{
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
@@ -120,10 +121,10 @@ export class EventsService {
headers: this.headersPrOficial,
params: params
};
- return this.http.get(`${geturl}`, options);
+ return this.http.get(`${geturl}`, options);
}
- getAllPrPessoalEvents(startdate:string, enddate:string): Observable{
+ getAllPrPessoalEvents(startdate:string, enddate:string): Observable{
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
@@ -136,10 +137,10 @@ export class EventsService {
headers: this.headersPrPessoal,
params: params
};
- return this.http.get(`${geturl}`, options);
+ return this.http.get(`${geturl}`, options);
}
- async getAllPrEvents(startdate:string, enddate:string){
+ async getAllPrEvents(startdate:string, enddate:string): Promise{
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
@@ -148,7 +149,7 @@ export class EventsService {
})
}
- getAllMdOficialEvents(startdate:string, enddate:string): any{
+ getAllMdOficialEvents(startdate:string, enddate:string): Observable{
let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams();
@@ -160,7 +161,7 @@ export class EventsService {
headers: this.headersMdOficial,
params: params
};
- return this.http.get(`${geturl}`, options);
+ return this.http.get(`${geturl}`, options);
}
getAllMdPessoalEvents(startdate:string, enddate:string): any{
diff --git a/src/app/services/storage.service.ts b/src/app/services/storage.service.ts
index 884c6407c..4371edbda 100644
--- a/src/app/services/storage.service.ts
+++ b/src/app/services/storage.service.ts
@@ -1,30 +1,65 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
+import { AnimationController, ModalController,Platform } from '@ionic/angular';
+import { SHA1 } from 'crypto-js'
+import { localstoreService } from '../store/localstore.service';
/* import { Plugins } from '@capacitor/core';
const { Storage } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class StorageService {
- constructor(private storage:Storage,) {}
+ private keyName: string;
+
+
+ constructor(private storage:Storage,
+ private platform: Platform
+ ) {}
+
+ key(key) {
+ this.keyName = (SHA1('service'+this.constructor.name+'key')).toString()
+ }
// Store the value
- async store(key: string, value: any){
- const encryptedValue = btoa(escape(JSON.stringify(value)));
- await this.storage.set(key, encryptedValue);
+ 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);
+ }
+
}
// Get the value
async get(key: string) {
- const ret = await this.storage.get(key).then((val) => { return val; });
- try {
- return JSON.parse(unescape(atob(ret)));
- } catch (error) {
- return unescape(atob(ret))
+
+
+ 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) {
+ return unescape(atob(ret))
+ }
}
+
+
}
async remove(key: string){
- await this.storage.remove(key);
+
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+ await localstoreService.delete(this.key(key))
+ } else {
+ await this.storage.remove(key);
+ }
+
}
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts
index c7aad3f17..eb4212478 100644
--- a/src/app/shared/header/header.page.ts
+++ b/src/app/shared/header/header.page.ts
@@ -46,17 +46,20 @@ export class HeaderPage implements OnInit {
this.hideSearch();
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
+ this.UpdateNotificationCount();
} else {
this.UpdateNotificationCount();
}
}
-
+
UpdateNotificationCount() {
this.notificationsService.registerCallback(
'any',
() => {
- this.notificationLengthData();
+ setTimeout(()=>{
+ this.notificationLengthData();
+ }, 100)
}
)
}
@@ -146,7 +149,6 @@ export class HeaderPage implements OnInit {
return enterAnimation(baseEl).direction('reverse');
}
-
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
@@ -156,6 +158,10 @@ export class HeaderPage implements OnInit {
}
});
await modal.present();
+
+ modal.onDidDismiss().then(()=>{
+ this.notificationLengthData()
+ })
}
diff --git a/src/app/store/calendar.service.ts b/src/app/store/calendar.service.ts
index 9028b36bf..0559532e6 100644
--- a/src/app/store/calendar.service.ts
+++ b/src/app/store/calendar.service.ts
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { eventSource } from '../models/agenda/eventSource';
import { SHA1, SHA256, AES, enc } from 'crypto-js'
import { LocalstoreService } from './localstore.service'
+import { EventList, EventListStore } from '../models/agenda/AgendaEventList';
@Injectable({
providedIn: 'root'
@@ -9,7 +10,7 @@ import { LocalstoreService } from './localstore.service'
export class CalendarService {
- private _eventSource : eventSource[] = []
+ private _eventSource : EventListStore[] = []
private keyName: string;
constructor(private localstoreService: LocalstoreService) {
@@ -19,7 +20,7 @@ export class CalendarService {
let restore = localstoreService.get(this.keyName, [])
setTimeout(()=>{
- restore.forEach((element, eventIndex) => {
+ restore.forEach((element:EventListStore, eventIndex) => {
this._eventSource.push({
title: element.title,
startTime: new Date(element.startTime),
@@ -36,7 +37,7 @@ export class CalendarService {
}
- ResetList(eventSource: eventSource[]) {
+ ResetList(eventSource: EventListStore[]) {
this._eventSource = eventSource
setTimeout(() => {
@@ -61,7 +62,7 @@ export class CalendarService {
})
}
- pushEvent(eventsList, profile: 'pr' | 'md') {
+ pushEvent(eventsList: EventList[], profile: 'pr' | 'md') {
let news = []
eventsList.forEach((element, eventIndex) => {
diff --git a/src/app/store/to-day-event-storage.service.ts b/src/app/store/to-day-event-storage.service.ts
index 70f1fa2ad..0868c059d 100644
--- a/src/app/store/to-day-event-storage.service.ts
+++ b/src/app/store/to-day-event-storage.service.ts
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { Event } from '../models/event.model';
import { localstoreService } from './localstore.service'
import { AES, enc, SHA1 } from 'crypto-js'
+import { EventList } from '../models/agenda/AgendaEventList';
@Injectable({
providedIn: 'root'
@@ -10,7 +11,7 @@ import { AES, enc, SHA1 } from 'crypto-js'
export class ToDayEventStorageService {
// main data
- private _eventsList: Event[] = []
+ private _eventsList:EventList[] = []
// local storage keyName
private keyName: string;
private _count = 0
@@ -39,7 +40,7 @@ export class ToDayEventStorageService {
this.save()
}
- reset(eventsList: Event[]) {
+ reset(eventsList: EventList[]) {
this._eventsList = eventsList
this.count = this._eventsList.length