mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
changed xcalendario to agenda
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ActiveTabService } from './active-tab.service';
|
||||
|
||||
describe('ActiveTabService', () => {
|
||||
let service: ActiveTabService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ActiveTabService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ActiveTabService {
|
||||
|
||||
pages = {
|
||||
chat: false,
|
||||
agenda: false,
|
||||
publication: false,
|
||||
home: false,
|
||||
gabinete: false
|
||||
}
|
||||
|
||||
constructor(private router: Router) {
|
||||
|
||||
this.detectActiveTab()
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
this.detectActiveTab()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
detectActiveTab() {
|
||||
this.setFalseToAllPage();
|
||||
const pathName = window.location.pathname
|
||||
|
||||
if(pathName.startsWith('/home/agenda')) {
|
||||
this.pages.agenda = true
|
||||
} else if (pathName.startsWith('/home/events')) {
|
||||
this.pages.home = true
|
||||
} else if (pathName.startsWith('/home/gabinete-digital')) {
|
||||
this.pages.gabinete = true
|
||||
} else if (pathName.startsWith('/home/publications')) {
|
||||
this.pages.publication = true
|
||||
} else if (pathName.startsWith('/home/chat')) {
|
||||
this.pages.chat = true
|
||||
}
|
||||
}
|
||||
|
||||
setFalseToAllPage() {
|
||||
for( const page in this.pages) {
|
||||
this.pages[page] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,13 @@ export class ChatSystemService {
|
||||
this.loadChat();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('resume', function () {
|
||||
if(this._dm?.length == 0 && this._group?.length == 0) {
|
||||
this.getAllRooms();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
loadChat() {
|
||||
|
||||
@@ -480,7 +480,7 @@ export class MessageService {
|
||||
return SessionStore.user.ChatData.data.userId == this.u._id
|
||||
}
|
||||
|
||||
private getChatObj() {
|
||||
getChatObj() {
|
||||
return {
|
||||
channels: this.channels,
|
||||
mentions: this.mentions,
|
||||
|
||||
@@ -125,7 +125,7 @@ export class RoomService {
|
||||
this.hasLoadHistory = false
|
||||
this.subscribeAttempt = false
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -174,11 +174,7 @@ export class RoomService {
|
||||
|
||||
this.calDateDuration();
|
||||
|
||||
(async () => {
|
||||
await this.restoreMessageFromDB()
|
||||
await this.loadHistory({})
|
||||
})()
|
||||
|
||||
|
||||
if(this.customFields?.countDownDate) {
|
||||
this.countDownDate(this.customFields.countDownDate);
|
||||
}
|
||||
@@ -327,7 +323,7 @@ export class RoomService {
|
||||
if(!found) {
|
||||
|
||||
ChatMessage.origin = 'stream'
|
||||
const message = await this.prepareCreate({message: ChatMessage, save: true});
|
||||
const message = await this.prepareCreate({message: ChatMessage, save: false});
|
||||
this.registerSendMessage(message)
|
||||
|
||||
message.from = 'stream'
|
||||
@@ -348,7 +344,10 @@ export class RoomService {
|
||||
}
|
||||
|
||||
if(this.hasLoadHistory == true) {
|
||||
this.messages.push(message)
|
||||
await message.addMessageDB()
|
||||
} else {
|
||||
this.messagesBeforeOfflineAPI.push(message)
|
||||
}
|
||||
|
||||
if(this.chatOpen == false) {
|
||||
@@ -503,7 +502,6 @@ export class RoomService {
|
||||
|
||||
if(previousLastMessage) {
|
||||
this.lastMessage = previousLastMessage;
|
||||
// console.log("last message"+ previousLastMessage)
|
||||
this.calDateDuration(previousLastMessage._updatedAt)
|
||||
this.sortRoomList()
|
||||
}
|
||||
@@ -736,12 +734,11 @@ export class RoomService {
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// runs onces only
|
||||
|
||||
loadHistoryCount = 0
|
||||
async loadHistory({limit = 1000, forceUpdate = false }) {
|
||||
|
||||
if(forceUpdate == false) {
|
||||
@@ -752,33 +749,37 @@ export class RoomService {
|
||||
|
||||
this.hasLoadHistory = true
|
||||
|
||||
await this.restoreMessageFromDB()
|
||||
const chatHistory: chatHistory = await this.RochetChatConnectorService.loadHistory(this.id, limit)
|
||||
|
||||
if(chatHistory?.result?.messages) {
|
||||
const messagesId = this.messages.map((message)=> message._id)
|
||||
|
||||
const users = this.getUsersByStatus('online')
|
||||
|
||||
for(let message of chatHistory.result.messages.reverse()) {
|
||||
if (!messagesId.includes(message._id)) {
|
||||
message.origin = 'history'
|
||||
message.from = 'History'
|
||||
const messagesToSave = await this.prepareMessageCreateIfNotExist({message: message});
|
||||
if(messagesToSave != null) {
|
||||
|
||||
messagesToSave.received = users.map((user) => user._id)
|
||||
messagesToSave.addMessageDB()
|
||||
|
||||
// console.log('add history', message)
|
||||
} else {
|
||||
// console.log('exit')
|
||||
}
|
||||
} else {
|
||||
// console.log('exit')
|
||||
message.origin = 'history'
|
||||
message.from = 'History'
|
||||
const messagesToSave = await this.prepareMessageCreateIfNotExist({message: message});
|
||||
if(messagesToSave != null) {
|
||||
|
||||
messagesToSave.received = users.map((user) => user._id)
|
||||
messagesToSave.addMessageDB()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for( const message of this.messagesBeforeOfflineAPI) {
|
||||
const messagesToSave = await this.prepareMessageCreateIfNotExist({message: message});
|
||||
if(messagesToSave != null) {
|
||||
|
||||
messagesToSave.received = users.map((user) => user._id)
|
||||
messagesToSave.addMessageDB()
|
||||
}
|
||||
}
|
||||
this.messagesBeforeOfflineAPI = []
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
@@ -824,8 +825,10 @@ export class RoomService {
|
||||
wewMessage.setData(message)
|
||||
wewMessage.loadHistory = this.hasLoadHistory
|
||||
|
||||
this.messages.push(wewMessage)
|
||||
|
||||
if(save) {
|
||||
this.messages.push(wewMessage)
|
||||
}
|
||||
|
||||
return wewMessage
|
||||
}
|
||||
|
||||
@@ -842,17 +845,17 @@ export class RoomService {
|
||||
|
||||
private findMessageBy_id (id) {
|
||||
for( let m of this.messages) {
|
||||
if(m._id == id) {
|
||||
if(m?._id == id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private findMessageBy_localReference (localReference) {
|
||||
for( let m of this.messages) {
|
||||
if(m.localReference == localReference) {
|
||||
if(m?.localReference == localReference) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -893,7 +896,7 @@ export class RoomService {
|
||||
async prepareMessageCreateIfNotExist({message}) {
|
||||
message = this.fix_updatedAt(message)
|
||||
|
||||
let found = await this.findMessageBy_id(message._id) || this.findMessageBy_localReference(message.localReference)
|
||||
let found = await this.findMessageBy_id(message._id) || await this.findMessageBy_localReference(message.localReference)
|
||||
// || await this.findMessageInDBByData({_id:message._id, localReference:message.localReference })
|
||||
|
||||
if (!found) {
|
||||
|
||||
@@ -259,7 +259,7 @@ export class EventsService {
|
||||
|
||||
console.log('ROLE',e.Role, e.FullName)
|
||||
|
||||
if(!this.calendarNamesAry.includes(e.FullName)) {
|
||||
if(!this.calendarNamesAry.find(x => x.Role == e.Role)) {
|
||||
/* if(e.Role == "Presidente da República") {
|
||||
this.calendarNamesAry.push(e.Role)
|
||||
console.log('PR ROLE',this.calendarNamesAry)
|
||||
@@ -271,13 +271,21 @@ export class EventsService {
|
||||
console.log('NORMAL ROLE',this.calendarNamesAry)
|
||||
} */
|
||||
//this.calendarRole.push(e.Role)
|
||||
let objectShared = {
|
||||
"Fullname": e.FullName,
|
||||
"Role": e.Role
|
||||
}
|
||||
|
||||
this.calendarNamesAry.push(objectShared)
|
||||
|
||||
|
||||
console.log('objectShared',this.calendarNamesAry)
|
||||
this.calendarNamesType[e.FullName] = {}
|
||||
}
|
||||
|
||||
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName] = true
|
||||
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
|
||||
|
||||
this.calendarNamesType[e.FullName]['RoleId'] = sharedCalendar.CalendarRoleId
|
||||
})
|
||||
}
|
||||
|
||||
@@ -290,11 +298,13 @@ export class EventsService {
|
||||
|
||||
if(!this.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.calendarNamesAry.push('Meu calendario')
|
||||
console.log(this.calendarNamesAry)
|
||||
this.calendarNamesType['Meu calendario'] = {}
|
||||
}
|
||||
|
||||
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName] = true
|
||||
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
|
||||
this.calendarNamesType['Meu calendario']['RoleId'] = sharedCalendar.CalendarRoleId
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export class ProcessesService {
|
||||
return this.http.get<ExpedienteFullTask[]>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
GetTask(serialnumber:string): Observable<any>{
|
||||
GetTask(serialnumber:string): Observable<any> {
|
||||
const geturl = environment.apiURL + 'Tasks/FindTask';
|
||||
let params = new HttpParams();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user