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:
Generated
+11
@@ -124,6 +124,7 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"duration": "^0.2.2",
|
||||
"faker": "^5.5.3",
|
||||
"fifo-process-queue": "^1.2.0",
|
||||
"firebase": "^9.8.4",
|
||||
"g": "^2.0.1",
|
||||
"global": "^4.4.0",
|
||||
@@ -13335,6 +13336,11 @@
|
||||
"version": "0.3.11",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fifo-process-queue": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fifo-process-queue/-/fifo-process-queue-1.2.0.tgz",
|
||||
"integrity": "sha512-BKVkBX9OfEsNcIeJabA7UWpHOlaE/spFbXEVDXdVv6cBlLqzOjrYfIgF4DUfFtwmOnMc+C3ktfZItJxmwzE9hw=="
|
||||
},
|
||||
"node_modules/figures": {
|
||||
"version": "2.0.0",
|
||||
"license": "MIT",
|
||||
@@ -47217,6 +47223,11 @@
|
||||
"fflate": {
|
||||
"version": "0.3.11"
|
||||
},
|
||||
"fifo-process-queue": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fifo-process-queue/-/fifo-process-queue-1.2.0.tgz",
|
||||
"integrity": "sha512-BKVkBX9OfEsNcIeJabA7UWpHOlaE/spFbXEVDXdVv6cBlLqzOjrYfIgF4DUfFtwmOnMc+C3ktfZItJxmwzE9hw=="
|
||||
},
|
||||
"figures": {
|
||||
"version": "2.0.0",
|
||||
"requires": {
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"duration": "^0.2.2",
|
||||
"faker": "^5.5.3",
|
||||
"fifo-process-queue": "^1.2.0",
|
||||
"firebase": "^9.8.4",
|
||||
"g": "^2.0.1",
|
||||
"global": "^4.4.0",
|
||||
|
||||
@@ -18,6 +18,11 @@ const routes: Routes = [
|
||||
loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule),
|
||||
canActivate: [LoginGuard]
|
||||
},
|
||||
{
|
||||
path: 'auth',
|
||||
loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule),
|
||||
canActivate: [LoginGuard]
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -76,53 +76,60 @@ export class ProfilePage implements OnInit {
|
||||
asyncNotification() { }
|
||||
|
||||
async getNotificationData() {
|
||||
this.storageservice.get("Notifications").then((value) => {
|
||||
|
||||
console.log('profile',this.storageservice.key("Notifications"))
|
||||
|
||||
const keyExist = await this.storageservice.keyExist("Notifications")
|
||||
|
||||
if(keyExist) {
|
||||
this.storageservice.get("Notifications").then((value) => {
|
||||
|
||||
this.DataArray = []
|
||||
value.forEach((element, i) => {
|
||||
let notificationObject;
|
||||
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
|
||||
}
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
||||
this.DataArray.push(notificationObject)
|
||||
});
|
||||
this.notificationdata = this.DataArray
|
||||
}).catch((error) => {
|
||||
console.error('storage getnotification: ',error)
|
||||
})
|
||||
}
|
||||
|
||||
this.DataArray = []
|
||||
value.forEach((element, i) => {
|
||||
let notificationObject;
|
||||
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
|
||||
}
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
||||
this.DataArray.push(notificationObject)
|
||||
});
|
||||
this.notificationdata = this.DataArray
|
||||
}).catch((error) => {
|
||||
console.error('storage getnotification: ',error)
|
||||
})
|
||||
/* await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.getNotificationData(); */
|
||||
}
|
||||
|
||||
|
||||
@@ -216,12 +223,12 @@ export class ProfilePage implements OnInit {
|
||||
|
||||
setTimeout(() => {
|
||||
// alert('logout')
|
||||
this.router.navigateByUrl('/', { replaceUrl: true });
|
||||
this.router.navigate(['/']);
|
||||
this.router.navigateByUrl('/auth', { replaceUrl: true });
|
||||
this.router.navigate(['/auth']);
|
||||
|
||||
setTimeout(() =>{
|
||||
if(this.logoutOut == false) {
|
||||
window.location.pathname = '/'
|
||||
window.location.pathname = '/auth'
|
||||
}
|
||||
}, 500)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { AESEncrypt } from '../aesencrypt.service'
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { NetworkServiceService} from 'src/app/services/network-service.service';
|
||||
import { JsonStore } from '../jsonStore.service';
|
||||
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -57,6 +57,7 @@ export class ChatSystemService {
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService:AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ViewedMessageService: ViewedMessageService
|
||||
) {
|
||||
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
@@ -408,7 +409,7 @@ export class ChatSystemService {
|
||||
if (setData.name != 'Rocket Cat') {
|
||||
// create room
|
||||
if(!this.roomExist(roomId)) {
|
||||
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this)
|
||||
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService)
|
||||
room.setData(setData)
|
||||
room.receiveMessage()
|
||||
room.getAllUsers = this.getUsers
|
||||
|
||||
@@ -22,6 +22,7 @@ import { IncomingChatMessage, ChatMessageInterface, falseTypingMethod } from 'sr
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { ConnectionStatus, NetworkServiceService} from 'src/app/services/network-service.service';
|
||||
import { ChatSystemService } from './chat-system.service';
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -94,7 +95,8 @@ export class RoomService {
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ChatSystemService: ChatSystemService
|
||||
private ChatSystemService: ChatSystemService,
|
||||
private ViewedMessageService: ViewedMessageService
|
||||
) {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
|
||||
@@ -104,37 +106,8 @@ export class RoomService {
|
||||
const statusNum = d.fields.args[0][2]
|
||||
const statusText = this.statusNumberToText(statusNum)
|
||||
|
||||
if(this.membersExcludeMe?.map) {
|
||||
const membersIds = this.membersExcludeMe.map((user)=> user._id)
|
||||
this.ViewedMessageService.request(this, userId, statusNum, statusText)
|
||||
|
||||
if(membersIds.includes(userId)) {
|
||||
|
||||
if(statusText != 'offline') {
|
||||
this.deleteMessageToReceive(userId)
|
||||
}
|
||||
|
||||
this.messages.forEach((message, index) => {
|
||||
if(!message.messageOwnerById(userId)) {
|
||||
|
||||
if(!this.messages[index]?.received?.includes(userId)) {
|
||||
|
||||
|
||||
if(this.messages[index]._id) {
|
||||
try {
|
||||
if(!this.messages[index].received.includes(userId)) {
|
||||
this.messages[index].received.push(userId)
|
||||
}
|
||||
} catch(e) {
|
||||
this.messages[index].received = [userId]
|
||||
}
|
||||
this.messages[index].save()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ViewedMessageService } from './viewed-message.service';
|
||||
|
||||
describe('ViewedMessageService', () => {
|
||||
let service: ViewedMessageService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ViewedMessageService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as FIFOProcessQueue from 'fifo-process-queue';
|
||||
import { RoomService } from './room.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ViewedMessageService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
viewQueue = FIFOProcessQueue(async ({room, userId, statusNum, statusText}, callback) => {
|
||||
|
||||
if(room.membersExcludeMe?.map) {
|
||||
const membersIds = room.membersExcludeMe.map((user)=> user._id)
|
||||
|
||||
if(membersIds.includes(userId)) {
|
||||
|
||||
if(statusText != 'offline') {
|
||||
room.deleteMessageToReceive(userId)
|
||||
}
|
||||
|
||||
await room.messages.forEach(async (message, index) => {
|
||||
if(!message.messageOwnerById(userId)) {
|
||||
|
||||
if(!room.messages[index]?.received?.includes(userId)) {
|
||||
|
||||
if(room.messages[index]._id) {
|
||||
try {
|
||||
if(!room.messages[index].received.includes(userId)) {
|
||||
room.messages[index].received.push(userId)
|
||||
}
|
||||
} catch(e) {
|
||||
room.messages[index].received = [userId]
|
||||
}
|
||||
room.messages[index].save()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(function () {
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
request(room:RoomService, userId, statusNum, statusText) {
|
||||
this.viewQueue.push({room, userId, statusNum, statusText})
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,10 @@ const { Storage } = Plugins; */
|
||||
return (SHA1('service'+this.constructor.name+key)).toString()
|
||||
}
|
||||
|
||||
async keyExist(key:string) {
|
||||
return await localstoreService.keyExist(this.key(key))
|
||||
}
|
||||
|
||||
// Store the value
|
||||
async store(key: string, value: any) {
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ export class LocalstoreService {
|
||||
getKey(keyName:string) {
|
||||
return this.prefix + keyName
|
||||
}
|
||||
|
||||
keyExist(keyName) {
|
||||
keyName = this.getKey(keyName)
|
||||
return !localStorage.getItem(keyName) === null
|
||||
}
|
||||
|
||||
get( keyName:string, safe) {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const environment = {
|
||||
production: true,
|
||||
domain: 'paulo.pinto@gabinetedigital.local',
|
||||
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto@gabinetedigital.local
|
||||
defaultuserpwd: 'tabteste@006', //tabteste@006,
|
||||
defaultuserpwd: 'M@p2022', //tabteste@006,
|
||||
chatOffline: true,
|
||||
presidencia: false,
|
||||
version: versionData,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "2f13e82c9",
|
||||
"SHA": "2f13e82c96626aa0088dc2c9afeb0fcc491aa6d6",
|
||||
"shortSHA": "0d485672d",
|
||||
"SHA": "0d485672d85fe521eb51dcdeec7f77e70579246b",
|
||||
"branch": "develop_bitOut-fix",
|
||||
"lastCommitAuthor": "'Peter Maquiran'",
|
||||
"lastCommitTime": "'Wed Jan 4 12:16:44 2023 +0100'",
|
||||
"lastCommitMessage": "chat loader",
|
||||
"lastCommitNumber": "4611",
|
||||
"lastCommitTime": "'Wed Jan 4 14:45:17 2023 +0100'",
|
||||
"lastCommitMessage": "save",
|
||||
"lastCommitNumber": "4612",
|
||||
"change": "",
|
||||
"changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/services/inativity.service.ts",
|
||||
"changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/index/index-routing.module.ts\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/services/chat/chat-system.service.ts\n\tmodified: src/app/services/chat/room.service.ts\n\tnew file: src/app/services/chat/viewed-message.service.spec.ts\n\tnew file: src/app/services/chat/viewed-message.service.ts\n\tmodified: src/app/services/storage.service.ts\n\tmodified: src/app/store/localstore.service.ts\n\tmodified: src/environments/environment.ts\n\tmodified: version/git-version.ts",
|
||||
"changeAuthor": "peter.maquiran"
|
||||
}
|
||||
Reference in New Issue
Block a user