mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
save
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
<name>gabinete digital</name>
|
||||
<description>An awesome Ionic/Cordova app.</description>
|
||||
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
|
||||
<content original-src="index.html" src="http://localhost:8100" />
|
||||
<content src="index.html" />
|
||||
<access origin="*" />
|
||||
<allow-navigation href="http://*/*" />
|
||||
<allow-navigation href="https://*/*" />
|
||||
|
||||
@@ -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')
|
||||
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -53,7 +53,7 @@ export class EventsPage implements OnInit {
|
||||
|
||||
customText = false;
|
||||
totalEvent=0;
|
||||
currentHoursMinutes: Date;
|
||||
currentHoursMinutes: Date | string;
|
||||
|
||||
showLoader: boolean;
|
||||
|
||||
|
||||
@@ -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<Event[]>{
|
||||
getAllPrOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
|
||||
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<Event[]>(`${geturl}`, options);
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{
|
||||
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<EventList[]>{
|
||||
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<Event[]>(`${geturl}`, options);
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
async getAllPrEvents(startdate:string, enddate:string){
|
||||
async getAllPrEvents(startdate:string, enddate:string): Promise<EventList[]>{
|
||||
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<EventList[]>{
|
||||
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<any>(`${geturl}`, options);
|
||||
return this.http.get<EventList[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
getAllMdPessoalEvents(startdate:string, enddate:string): any{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user