pull amde

This commit is contained in:
Equilibrium ITO
2024-03-11 11:24:01 +01:00
40 changed files with 449 additions and 324 deletions
+3 -2
View File
@@ -87,7 +87,7 @@ import { LoggingInterceptorService } from './services/logging-interceptor.servic
import { PopupQuestionPipe } from './modals/popup-question.pipe';
import '@teamhive/capacitor-video-recorder';
import { tokenInterceptor } from './interceptors/token.interceptors';
import { ChatTokenInterceptor } from './interceptors/chatToken.interceptor';
import { chatTokenInterceptor } from './interceptors/chatToken.interceptor';
import { InputFilterDirective } from './services/directives/input-filter.directive';
import { VisibilityDirective } from './services/directives/visibility.directive';
@@ -217,8 +217,9 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
DocumentViewer,
FFMpeg,
{ provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptorService, multi: true },
chatTokenInterceptor,
tokenInterceptor,
/* ChatTokenInterceptor */
],
bootstrap: [AppComponent],
+133 -113
View File
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import {
HttpInterceptor,
HttpRequest,
HttpHandler,
HttpEvent,
HttpErrorResponse,
HTTP_INTERCEPTORS,
HttpHeaders,
HttpInterceptor,
HttpRequest,
HttpHandler,
HttpEvent,
HttpErrorResponse,
HTTP_INTERCEPTORS,
HttpHeaders,
} from '@angular/common/http';
import { Observable, throwError, BehaviorSubject } from 'rxjs';
import { catchError, switchMap, filter, take } from 'rxjs/operators';
@@ -15,138 +15,158 @@ import { Router } from '@angular/router';
import { SessionStore } from '../store/session.service';
import { environment } from "src/environments/environment";
import { PermissionService } from '../services/permission.service';
import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
import { NetworkServiceService, ConnectionStatus } from 'src/app/services/network-service.service';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
@Injectable()
export class ChatTokenInterceptor implements HttpInterceptor {
private isRefreshing = false;
headers: HttpHeaders;
options: any;
private refreshTokenSubject: BehaviorSubject<any> = new BehaviorSubject<any>(
null
);
private excludedDomain = 'https://gdchat-dev.dyndns.info';// Add other domains as needed
constructor(private http: HttpClient, private router: Router,private p: PermissionService,private NetworkServiceService: NetworkServiceService,
private RochetChatConnectorService: RochetChatConnectorService) {}
intercept(
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (this.shouldExcludeDomain(request)) {
return next.handle(request);
}
return next.handle(request).pipe(
catchError((error) => {
if (error instanceof HttpErrorResponse && error.status === 401) {
return this.handle401Error(request, next);
} else {
return throwError(error);
}
})
private isRefreshing = false;
headers: HttpHeaders;
options: any;
private refreshChatTokenSubject: BehaviorSubject<any> = new BehaviorSubject<any>(
null
);
}
private shouldExcludeDomain(request: HttpRequest<any>): boolean {
const url = request.url.toLowerCase();
return !url.includes(this.excludedDomain.toLowerCase());
}
private excludedDomains = ['Login',environment.apiURL];// Add other domains as needed
private handle401Error(
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (!this.isRefreshing) {
this.isRefreshing = true;
this.refreshTokenSubject.next(null);
constructor(private http: HttpClient, private router: Router, private p: PermissionService, private NetworkServiceService: NetworkServiceService,
private RochetChatConnectorService: RochetChatConnectorService) { }
return this.refreshToken().pipe(
switchMap((token: any) => {
this.isRefreshing = false;
intercept(
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (this.shouldExcludeDomain(request)) {
return next.handle(request);
}
let data = {
status: token['status'],
data: {
userId: token['data'].userId,
authToken: token['data'].authToken
}
if (SessionStore.user.Authorization) {
request = this.addToken(request, SessionStore.user.Authorization);
}
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
this.refreshTokenSubject.next(token.Authorization);
return next.handle(this.addToken(request, token.Authorization));
})
);
} else {
return this.refreshTokenSubject.pipe(
filter((token) => token != null),
take(1),
switchMap((jwt) => {
return next.handle(this.addToken(request, jwt));
})
);
return next.handle(request).pipe(
catchError((error) => {
if (error instanceof HttpErrorResponse && error.status === 401) {
return this.handle401Error(request, next);
} else {
return throwError(error);
}
})
);
}
}
private addToken(request: HttpRequest<any>, token: string) {
return request.clone({
/* setHeaders: {
Authorization: `Bearer ${token}`,
}, */
});
}
private shouldExcludeDomain(request: HttpRequest<any>): boolean {
const url = request.url.toLowerCase();
return this.excludedDomains.some((domain) => url.includes(domain.toLowerCase()));
}
private refreshToken(): Observable<any> {
return this.http
.get<any>(environment.apiURL + 'UserAuthentication/RegenereChatToken', {
/* refreshToken: SessionStore.user.RefreshToken, */
})
.pipe(
catchError((error) => {
// Handle token refresh failure
console.log('ChatToken refresh failed:', error);
return throwError(error);
})
);
}
private handle401Error(
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (!this.isRefreshing) {
this.isRefreshing = true;
this.refreshChatTokenSubject.next(null);
return this.refreshToken().pipe(
switchMap((token: any) => {
this.isRefreshing = false;
let data = {
status: token['status'],
data: {
userId: token['data'].userId,
authToken: token['data'].authToken
}
}
SessionStore.user.ChatData = data
SessionStore.save()
/* this.setheader() */
setheader() {
try {
this.refreshChatTokenSubject.next(token.Authorization);
return next.handle(this.addToken(request, token.Authorization));
})
);
} else {
return this.refreshChatTokenSubject.pipe(
filter((token) => token != null),
take(1),
switchMap((jwt) => {
return next.handle(this.addToken(request, jwt));
})
);
}
}
if (this.p.userPermission(this.p.permissionList.Chat.access) && SessionStore.user.ChatData) {
this.headers = new HttpHeaders();;
private addToken(request: HttpRequest<any>, token: string) {
let headers = new HttpHeaders();
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
//
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
this.options = {
headers: this.headers,
};
console.log('X-User-Id', SessionStore.user.ChatData.data.userId)
console.log('X-Auth-Token', SessionStore.user.ChatData.data.authToken)
headers = headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
headers = headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
return request.clone({
setHeaders: {
Authorization: `Bearer ${token}`,
...headers.keys().reduce((acc, key) => ({ ...acc, [key]: headers.get(key) }), {}),
},
});
}
/* private addToken(request: HttpRequest<any>, token: string) {
return request.clone({
setHeaders: {
Authorization: `Bearer ${token}`,
},
});
} */
private refreshToken(): Observable<any> {
return this.http
.get<any>(environment.apiURL + 'UserAuthentication/RegenereChatToken', {
/* refreshToken: SessionStore.user.RefreshToken, */
})
.pipe(
catchError((error) => {
// Handle token refresh failure
console.log('ChatToken refresh failed:', error);
return throwError(error);
})
);
}
setheader() {
try {
if (this.p.userPermission(this.p.permissionList.Chat.access) && SessionStore.user.ChatData) {
this.headers = new HttpHeaders();;
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
//
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
this.options = {
headers: this.headers,
};
}
}
} catch (error) {
}
}
} catch (error) {
}
}
}
export const tokenInterceptor = {
export const chatTokenInterceptor = {
provide: HTTP_INTERCEPTORS,
useClass: ChatTokenInterceptor,
multi: true
};
};
+3 -2
View File
@@ -119,9 +119,10 @@ export class TokenInterceptor implements HttpInterceptor {
if (environment.production) {
window.location.pathname = '/auth'
} else {
/* const pathBeforeGoOut = window.location.pathname */
const pathBeforeGoOut = window.location.pathname
console.log('Before auth',window.location.pathname)
this.router.navigateByUrl('/auth', { replaceUrl: true }).then(() =>{
if(SessionStore.user.Authorization){
if(pathBeforeGoOut != "/auth") {
this.httpErrorHandle.httpsSucessMessagge('sessonExpired')
}
+11 -3
View File
@@ -242,7 +242,6 @@
>
<div class="schedule-time" *ngIf="!event.event.IsAllDayEvent">
<div *ngIf="event.startMany && !event.middle" class="time-start labelb">Início</div>
<div *ngIf="event.endMany && !event.middle " class="time-end labelb">Fim</div>
@@ -254,8 +253,17 @@
</div>
<div class="schedule-time" *ngIf="event.event.IsAllDayEvent">
<div class="time-start">Todo </div>
<div class="time-end text-center">o dia</div>
<div *ngIf="event.middle" class="time-start">Todo </div>
<div *ngIf="event.middle" class="time-end text-center">o dia</div>
<div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-start">Todo </div>
<div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-end text-center">o dia </div>
<div *ngIf="event.endMany && !event.middle" class="time-start">{{event.event.StartDate | date: 'HH:mm'}}</div>
<div *ngIf="event.endMany && !event.middle" class="time-end"> {{event.event.EndDate | date: 'HH:mm'}} </div>
</div>
<div class="schedule-details">
<div class="description">
+13
View File
@@ -32,6 +32,8 @@ import { EventTrigger } from 'src/app/services/eventTrigger.service';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
import { RouteService } from 'src/app/services/route.service';
import { Plugins } from '@capacitor/core';
import { ChangeDetectorRef } from '@angular/core';
const { App } = Plugins;
@@ -128,6 +130,7 @@ export class ChatPage implements OnInit {
private RochetChatConnectorService: RochetChatConnectorService,
private zone: NgZone,
public RouteService: RouteService,
private ChangeDetectorRef: ChangeDetectorRef
) {
this.headers = new HttpHeaders();;
@@ -175,8 +178,18 @@ export class ChatPage implements OnInit {
}
});
this.ChatSystemService.setMainChangeDetector(()=> {
this.changeDetector()
})
}
changeDetector = () => {
console.log('run detection')
this.ChangeDetectorRef.detectChanges()
}
ngOnDestroy() {
// this.setStatus('offline');
this.routerSubscription?.unsubscribe();
@@ -1,6 +1,6 @@
<ion-header class="ion-no-border">
<ion-toolbar class="header-toolbar">
<div class="main-header">
<div class="main-header" *ngIf="ChatSystemService.getGroupRoom(roomId)">
<div class="header-top">
<!-- <app-btn-modal-dismiss></app-btn-modal-dismiss> -->
<div class="left">
@@ -45,7 +45,7 @@
</ion-header>
<ion-content>
<ion-content *ngIf="ChatSystemService.getGroupRoom(roomId)">
<div (click)="handleClick()" class="messages overflow-y-auto" #scrollMe>
<div class="welcome-text">
@@ -277,7 +277,7 @@
</ion-content>
<ion-footer>
<ion-footer *ngIf="ChatSystemService.getGroupRoom(roomId)">
<div class="typing" *ngIf="ChatSystemService.getGroupRoom(roomId).otherUserType == true">
<ngx-letters-avatar *ngIf="showAvatar" [avatarName]="ChatSystemService.getGroupRoom(roomId).name" [width]="30"
@@ -36,7 +36,6 @@ import { FileValidatorService } from "src/app/services/file/file-validator.servi
import { sanitize } from "sanitize-filename-ts";
import { FilePicker } from '@capawesome/capacitor-file-picker';
@Component({
selector: 'app-group-messages',
templateUrl: './group-messages.page.html',
@@ -109,7 +108,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
private file: File,
private fileOpener: FileOpener,
public RouteService: RouteService,
private FileValidatorService: FileValidatorService
private FileValidatorService: FileValidatorService,
private ChangeDetectorRef: ChangeDetectorRef
) {
this.ChatSystemService.getUser()
@@ -138,6 +138,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
open() {
try {
this.ChatSystemService.getGroupRoom(this.roomId).loadHistory({});
@@ -145,6 +147,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.ChatSystemService.openRoom(this.roomId)
this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
this.ChatSystemService.getGroupRoom(this.roomId).setChangeDetector(()=> {
this.changeDetector()
})
} catch (error) {
setTimeout(() => {
this.open()
@@ -152,6 +157,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
changeDetector = () => {
console.log('run detection page')
this.ChangeDetectorRef.detectChanges()
}
ngOnInit() {
this.loggedUser = this.loggedUserChat;
+11 -2
View File
@@ -36,6 +36,7 @@ import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-co
import { FileValidatorService } from "src/app/services/file/file-validator.service"
import { sanitize } from "sanitize-filename-ts";
import { FilePicker } from '@capawesome/capacitor-file-picker';
import { ChangeDetectorRef } from '@angular/core';
@@ -122,7 +123,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private fileOpener: FileOpener,
private router: Router,
public RochetChatConnectorService: RochetChatConnectorService,
private FileValidatorService: FileValidatorService
private FileValidatorService: FileValidatorService,
private ChangeDetectorRef: ChangeDetectorRef
) {
try {
@@ -141,6 +143,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.ChatSystemService.getDmRoom(this.roomId).loadHistory({})
this.ChatSystemService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.ChatSystemService.openRoom(this.roomId)
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
this.changeDetector()
})
setTimeout(() => {
this.scrollToBottomClicked()
@@ -148,8 +154,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
} catch (error) {
//alert(error)
}
}
changeDetector = () => {
console.log('run detection page')
this.ChangeDetectorRef.detectChanges()
}
ngOnInit() {
@@ -95,7 +95,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -99,7 +99,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -87,7 +87,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -165,7 +165,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -55,7 +55,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -125,7 +125,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -102,7 +102,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -209,7 +209,7 @@
</div>
<div class="item-bottom-detail d-flex align-items-center">
<div class="item-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="item-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm'
@@ -647,7 +647,7 @@
TaskService.pedidosstore.listParecerCount.length}} correspondência nova</span>
</p>
<p *ngIf="p.userPermission([p.permissionList.Gabinete.pr_tasks])" class="text-center exp-card-title ">
Pedidos de Parecer solicitados por mim <br>
Parecer solicitados por mim <br>
<span class="new-task-count" *ngIf="TaskService.pedidosstore.listParecerCount.length >=2">{{
TaskService.pedidosstore.listParecerCount.length}} correspondências novas</span>
<span class="new-task-count" *ngIf="TaskService.pedidosstore.listParecerCount.length ==1">{{
@@ -121,7 +121,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -160,7 +160,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
+12 -4
View File
@@ -144,9 +144,18 @@ export class LoginPage implements OnInit {
if (attempt.ChatData) {
await this.authService.loginToChatWs();
this.ChatService.setheader()
this.ChatSystemService.loadChat();
try {
await MessageModel.deleteAll();
await DeleteMessageModel.deleteAll();
this.ChatSystemService.clearChat();
this.NotificationHolderService.clear()
await this.authService.loginToChatWs();
this.ChatService.setheader()
} catch(error) {
console.log("faild to clear chat")
}
}
@@ -181,7 +190,6 @@ export class LoginPage implements OnInit {
if (attempt.ChatData) {
await this.authService.loginToChatWs();
this.ChatService.setheader();
this.ChatSystemService.loadChat();
}
this.storageService.remove("Notifications")
this.getToken();
@@ -40,7 +40,7 @@
<ion-img *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'image'" [(ngModel)]="capturedImage"
name="image" ngDefaultControl [src]="'data:image/jpg;base64,' + seleted.FileBase64"
name="image" ngDefaultControl [src]="seleted.FileBase64"
(click)="imageSize(capturedImage)" style="height: 69px;"></ion-img>
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video'" width="70" height="70"
@@ -906,7 +906,7 @@ console.log(stringGerada);
}
} else {
fileObject = {
FileBase64: content.data,
FileBase64: 'data:image/jpeg;base64,' + content.data,
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
OriginalFileName: 'image'
}
@@ -1005,7 +1005,7 @@ console.log(stringGerada);
try {
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
fileObject = {
FileBase64: this.removeTextBeforeSlash(content.data, ','),
FileBase64: 'data:image/jpeg;base64,' +this.removeTextBeforeSlash(content.data, ','),
FileExtension: FileExtension,
OriginalFileName: 'shared',
}
@@ -20,6 +20,7 @@ import { PublicationVideoManagerService } from "src/app/services/publication/pub
import { StopvideoService } from "src/app/services/stopvideo.service"
import { Result } from 'neverthrow';
import { App } from '@capacitor/app';
import { ActiveTabService } from 'src/app/services/active-tab.service';
@Component({
selector: 'app-view-publications',
templateUrl: './view-publications.page.html',
@@ -69,7 +70,8 @@ export class ViewPublicationsPage implements OnInit {
public checkFileType: checkFileTypeService,
private publicationVideoManagerService: PublicationVideoManagerService,
public stopvideoService: StopvideoService,
private platform: Platform,) {
private platform: Platform,
public activeTabService: ActiveTabService) {
/* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */
@@ -118,6 +120,13 @@ export class ViewPublicationsPage implements OnInit {
})
// console.log(this.publicationFolderService.publicationList[this.folderId])
setTimeout(()=> {
this.doRefresh({})
}, 1500)
}
+9
View File
@@ -16,6 +16,8 @@ export class ActiveTabService {
gabineteDetails: false
}
updatePublications = () => {}
constructor(
private router: Router,
public HeaderSettingsService: HeaderSettingsService) {
@@ -47,6 +49,13 @@ export class ActiveTabService {
} else if (pathName.startsWith('/home/publications')) {
this.pages.publication = true
if(pathName.includes("/publications/")) {
if(this.updatePublications) {
this.updatePublications()
}
}
} else if (pathName.startsWith('/home/chat')) {
this.pages.chat = true
}
+4 -9
View File
@@ -67,8 +67,6 @@ export class ListBoxService {
// object[momentG(new Date(e.start), 'MMMM yyyy')].push(e)
// }
// console.log({object})
// const daysStringNum = Object.keys(object).reverse()
// const daysObject = {}
@@ -77,13 +75,8 @@ export class ListBoxService {
// daysObject[day] = object[day]
// }
// console.log({daysObject})
return this.display(newStracture, selectedDate).year
// console.log({daysObject})
// const daysStringNum = Object.keys(daysObject)
// for(const day of daysStringNum) {
@@ -105,6 +98,8 @@ export class ListBoxService {
}
display(list: CustomCalendarEvent[], selectedDate) {
let days = {};
const year: Year[] = []
@@ -171,14 +166,14 @@ export class ListBoxService {
// last push
const EndEvent = this.transForm(cloneEvent, {startMany: false, endMany: true, middle: false})
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
days[otherDays].push(EndEvent) ; this.push(cloneEvent, year)
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
}
} else {
const EndEvent = this.transForm(cloneEvent, {startMany: false,endMany: true, middle: true})
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
days[otherDays].push(EndEvent) ; this.push(cloneEvent, year)
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
}
}
+10 -1
View File
@@ -183,6 +183,7 @@ export class AuthService {
setTimeout(() => {
if (SessionStore.user.ChatData?.data) {
this.RochetChatConnectorService.logout();
this.RochetChatConnectorService.connect();
this.RochetChatConnectorService.login().then((message: any) => {
console.log('Chat login', message)
@@ -190,6 +191,7 @@ export class AuthService {
SessionStore.user.RochetChatUserId = message.result.id
SessionStore.save()
this.ChatSystemService.loadChat()
this.RochetChatConnectorService.setStatus('online')
window['RochetChatConnectorService'] = this.RochetChatConnectorService
setTimeout(() => {
@@ -199,7 +201,14 @@ export class AuthService {
}).catch((error) => {
// console.error(SessionStore.user.ChatData, 'web socket login',error)
console.error(SessionStore.user.ChatData, 'web socket login', error)
if(window.location.pathname.includes('/home/')) {
setTimeout(() => {
this.loginToChatWs();
}, 4000)
}
})
}
-55
View File
@@ -392,61 +392,6 @@ export class ChatService {
async refreshtoken() {
if(this.headers && SessionStore.user.ChatData) {
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
let options = {
headers: this.headers
};
try {
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
}
}
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
this.timerEventTriggerDateLastUpdate = new Date();
} catch (error) {
if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) {
this.RochetChatConnectorService.registerCallback({
requestId: 'refreshtoken',
type: 'reConnect',
funx: async () => {
this.resetTimer();
await this.refreshtoken();
return true
}
})
} else {
if(SessionStore.user.Authorization != '') {
setTimeout(async () => {
this.resetTimer();
await this.refreshtoken();
}, 60000)
}
}
}
} else if(!SessionStore.user.ChatData) {
// do nothing
} else if (!this.headers) {
this.setheader()
this.refreshtoken()
}
}
+9 -2
View File
@@ -48,6 +48,7 @@ export class ChatSystemService {
loadingUsers = false
onRoomsLoad = new Subscribe({ execute: false, deleteOnExecute: true })
private mainChangeDetector: Function = () => {}
constructor(
@@ -66,7 +67,7 @@ export class ChatSystemService {
private AttachmentsService: AttachmentsService,
private NetworkServiceService: NetworkServiceService,
private ViewedMessageService: ViewedMessageService,
private notificationService: NotificationsService
private notificationService: NotificationsService,
) {
@@ -148,9 +149,15 @@ export class ChatSystemService {
});
}
} catch(error) {}
}
setMainChangeDetector(x:Function) {
this.mainChangeDetector = x
}
runMainChangeDetector() {
console.log("change")
// this.mainChangeDetector()
}
loadChat() {
+8 -2
View File
@@ -25,6 +25,7 @@ import { ChatSystemService } from './chat-system.service';
import { ViewedMessageService } from './viewed-message.service'
import * as FIFOProcessQueue from 'fifo-process-queue';
import { NotificationsService } from '../notifications.service';
import { ChangeDetectorRef } from '@angular/core';
@Injectable({
providedIn: 'root'
@@ -84,6 +85,7 @@ export class RoomService {
sortRoomList = () => { }
chatServiceDeleteRoom = (roomId) => { }
private changeDetector: Function = () => {}
constructor(
public RochetChatConnectorService: RochetChatConnectorService,
@@ -190,6 +192,11 @@ export class RoomService {
}
setChangeDetector(x:Function) {
console.log("set change detector")
this.changeDetector = x
}
get online() {
if (!this.isGroup) {
@@ -372,8 +379,6 @@ export class RoomService {
}
this.messageUnread = true
// this.sortRoomList()
setTimeout(() => {
this.scrollDown()
}, 50)
@@ -386,6 +391,7 @@ export class RoomService {
this.name = ChatMessage.msg
}
// this.changeDetector()
setTimeout(() => {
done()
}, 5)
+17 -2
View File
@@ -14,9 +14,10 @@ import { notificationObject } from '../models/notifications';
import { Capacitor } from '@capacitor/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
import { ChatService } from 'src/app/services/chat.service';
import { FCM } from '@capacitor-community/fcm';
import { ChatSystemService } from './chat/chat-system.service';
import {ChatController} from 'src/app/controller/chat'
@Injectable({
providedIn: 'root'
@@ -42,6 +43,8 @@ export class NotificationsService {
notificationReceived: EventEmitter<void> = new EventEmitter<void>();
token = ''
ChatController = ChatController
constructor(
private http: HttpClient,
private storageService: StorageService,
@@ -199,6 +202,7 @@ export class NotificationsService {
this.active = true
console.log('NOtification Listener', notification)
this.storenotification(notification)
this.chatNotification(notification)
}
@@ -206,11 +210,13 @@ export class NotificationsService {
} else {
this.afMessaging.messages.subscribe((notification) => {
console.log(notification)
this.storenotification(notification)
this.notificationReceived.emit();
this.eventtrigger.publishSomeData({
notification: "recive"
})
this.chatNotification(notification)
// Handle the received message, e.g., show a notification
});
}
@@ -393,4 +399,13 @@ export class NotificationsService {
// })()
}
chatNotification(_notification) {
const notification = this.NotificationHolderService.stractureNotificationObject(_notification)
if (notification?.notification?.data?.Service === "chat" || notification?.Service === "chat") {
this.ChatController.ChatSystemService.runMainChangeDetector()
}
}
}
@@ -390,32 +390,32 @@ export class ObjectMergeNotification{
watchCount = 0
constructor() {
this.socket.onDisconnectCallback(()=> {
console.log("run watch")
this.runWatch = true
this.watch()
})
// this.socket.onDisconnectCallback(()=> {
// console.log("run watch")
// this.runWatch = true
// this.watch()
// })
this.socket.onConnectCallback(()=> {
// this.socket.onConnectCallback(()=> {
console.log("open trigger")
this.runWatch = false
})
// console.log("open trigger")
// this.runWatch = false
// })
this.socket.subscribe((data: socketResponse) => {
if(data.IsCompleted == true) {
console.log("==================!!!====================")
try {
this.callbacks[data.Guid](data)
delete this.callbacks[data.Guid]
} catch (error) {}
} else {
console.log("else", data)
}
})
// this.socket.subscribe((data: socketResponse) => {
// if(data.IsCompleted == true) {
// console.log("==================!!!====================")
// try {
// this.callbacks[data.Guid](data)
// delete this.callbacks[data.Guid]
// } catch (error) {}
// } else {
// console.log("else", data)
// }
// })
this.socket.connect();
this.watch()
// this.socket.connect();
// this.watch()
}
connect() {
@@ -30,7 +30,7 @@ import { SessionStore } from 'src/app/store/session.service';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { PermissionService } from 'src/app/services/permission.service';
import { FileValidatorService } from "src/app/services/file/file-validator.service"
import { ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'app-group-messages',
templateUrl: './group-messages.page.html',
@@ -46,7 +46,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
documents: SearchList[] = [];
room: any = new Array();
roomName: any;
members: any;
capturedImage: any;
@@ -58,8 +57,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
currentPosition: any;
startPosition: number;
scrollToBottomBtn = false;
roomCountDownDate: string;
roomCountDownTime: string;
isAdmin = false;
@Input() roomId: string;
@@ -106,14 +103,13 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
private platform: Platform,
private fileOpener: FileOpener,
public p: PermissionService,
private FileValidatorService: FileValidatorService
private FileValidatorService: FileValidatorService,
private ChangeDetectorRef: ChangeDetectorRef
) {
this.ChatSystemService.getUser()
this.loggedUserChat = SessionStore.user.ChatData['data'];
this.isGroupCreated = true;
this.roomCountDownDate = "";
this.roomCountDownTime = "";
}
ngOnChanges(changes: SimpleChanges): void {
@@ -124,7 +120,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.ChatSystemService.openRoom(this.roomId)
this.ChatSystemService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
this.ChatSystemService.getGroupRoom(this.roomId).setChangeDetector(()=> {
this.changeDetector()
})
this.showAvatar = false
setTimeout(() => {
@@ -136,6 +134,12 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
changeDetector = () => {
console.log('run detection shared')
this.ChangeDetectorRef.detectChanges()
}
ngOnInit() {
this.loggedUser = this.loggedUserChat;
//setTimeout(() => {
@@ -151,10 +155,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
return this.timeService.showDateDuration(start);
}
countDownDate() {
return this.timeService.countDownDateTimer(this.roomCountDownDate, this.roomId);
}
setStatus(status: string) {
let body = {
message: '',
@@ -377,28 +377,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.ChatSystemService.getGroupRoom(this.roomId).loadHistory({});
}
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
this.room = room['room'];
if (this.room.name) {
try {
this.roomName = this.room.name.split('-').join(' ');
} catch (error) {
this.roomName = this.room.name;
}
}
if(SessionStore.user.ChatData.data.userId == this.room.u._id){
this.isAdmin = true
} else {
this.isAdmin = false
}
if (this.room.customFields.countDownDate) {
this.roomCountDownDate = this.room.customFields.countDownDate;
}
this.getGroupContacts(this.room);
}
@@ -536,14 +514,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
else {
if(res?.data?.name) {
try {
this.roomName = res.data.name.split('-').join(' ');
} catch (error) {
this.roomName = res.data.name
}
}
};
+14 -1
View File
@@ -34,6 +34,7 @@ import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { ChatMessageDebuggingPage } from 'src/app/shared/popover/chat-message-debugging/chat-message-debugging.page';
import { PermissionService } from 'src/app/services/permission.service';
import { FileValidatorService } from "src/app/services/file/file-validator.service"
import { ChangeDetectorRef } from '@angular/core';
const IMAGE_DIR = 'stored-images';
@@ -123,7 +124,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private platform: Platform,
private fileOpener: FileOpener,
public p: PermissionService,
private FileValidatorService: FileValidatorService
private FileValidatorService: FileValidatorService,
private ChangeDetectorRef: ChangeDetectorRef
) {
// update
this.checkAudioPermission()
@@ -138,6 +140,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.ChatSystemService.openRoom(this.roomId)
this.ChatSystemService.getDmRoom(this.roomId)
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
this.changeDetector()
})
this.showAvatar = false
@@ -154,6 +161,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
changeDetector = () => {
console.log('run detection shared')
this.ChangeDetectorRef.detectChanges()
}
async ChatMessageDebuggingPage() {
const modal = await this.modalController.create({
@@ -165,7 +165,7 @@
</div>
<div class="item-bottom-detail d-flex align-items-center">
<div class="item-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="item-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -91,7 +91,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -128,7 +128,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -40,7 +40,7 @@
</div>
<ion-label>
<p class="d-flex mt-10 activity-instanceName" ><span class="label">{{ task.activityInstanceName }}</span></p>
<p class="d-flex mt-10 activity-instanceName" ><span class="label">{{ task.WorkflowName }}</span></p>
</ion-label>
</div>
</div>
@@ -29,7 +29,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label">{{task.activityInstanceName}}</span>
<span class="label">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -136,7 +136,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label mr-10">{{task.activityInstanceName}}</span>
<span class="label mr-10">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
@@ -175,7 +175,7 @@
</div>
<div class="exp-middle-detail">
<div class="exp-workflow">
<span class="label mr-10">{{task.activityInstanceName}}</span>
<span class="label mr-10">{{task.WorkflowName}}</span>
</div>
<div class="exp-date">
<ion-label>{{ task.taskStartDate || task.TaskStartDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
+10
View File
@@ -43,6 +43,16 @@ export class HeaderPage implements OnInit {
notificationCount: number = 0;
profilePicture = "";
hideHeader = false
hideHeaderValidation() {
const result = this.HeaderSettingsService.hideHeader && this.ActiveTabService.pages.gabineteDetails
if(result != this.hideHeader) {
this.hideHeader = true
}
}
constructor(
private router: Router,
@@ -64,18 +64,13 @@
</div>
<ion-img *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'image'"
name="image" ngDefaultControl [src]="seleted.url" style="height: 69px;"></ion-img>
name="image" ngDefaultControl [src]="'data:image/jpg;base64,' + seleted.Base64" style="height: 69px;"></ion-img>
<video class="sdf" *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkDesktop() == true" width="70" height="70"
preload="metadata" webkit-playsinline="webkit-playsinline">
<source type="video/mp4" [src]="seleted.url">
</video>
<video class="sdfsdf" *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkTableDivice() == true" width="70" height="70"
preload="metadata" webkit-playsinline="webkit-playsinline">
<source type="video/mp4" [src]="'data:video/mp4;base64,' + seleted.Base64">
</video>
</div>
</div>
@@ -402,6 +402,7 @@ export class NewPublicationPage implements OnInit {
let time = new Date()
if (this.publicationFormMV.form.Files.length >= 1) {
const loader = this.toastService.loading()
const upload = await this.publicationFormMV.uploadVideosFiles()
@@ -410,8 +411,10 @@ export class NewPublicationPage implements OnInit {
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
e.FileExtension = "mp4"
e.Base64 = ""
e.Base64 = ''
}
return e
})
@@ -420,7 +423,7 @@ export class NewPublicationPage implements OnInit {
const publication: any = Object.assign({}, this.publicationFormMV.form)
publication.Files = publication.Files.map( (e:PublicationAttachmentEntity) => ({
FileBase64: e.url,
FileBase64: e.Base64,
FileExtension: e.FileExtension,
OriginalFileName: e.OriginalFileName || 'foto'
}))
@@ -428,7 +431,7 @@ export class NewPublicationPage implements OnInit {
publication.DocumentId = null;
publication.ProcessId = this.folderId
const loader = this.toastService.loading()
try {
@@ -114,6 +114,74 @@ export class NotificationHolderService {
}
stractureNotificationObject(notification) {
const element = notification
let notificationObject;
if (element.notification) {
notificationObject = {
id: notification?.id || uuidv4(),
title: element.notification.title,
Service: element.data.Service,
Object: element.data.Object,
IdObject: element.data.IdObject,
FolderId: element.data.FolderId,
body: element.notification.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,
read: false,
}
} else if (element.data) {
notificationObject = {
id: notification?.id || uuidv4(),
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,
read: false,
}
} else {
{
notificationObject = {
id: notification?.id || uuidv4(),
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,
read: false,
}
}
}
notificationObject.hashCode = (SHA1(notification)).toString()
return notificationObject
}
addNotification(notification) {
+1 -1
View File
@@ -4,4 +4,4 @@ import { environment as doneITProd } from './suport/doneIt'
import { DevDev } from './suport/dev'
export const environment: Environment = oaprProd;
export const environment: Environment = DevDev;