mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
src/app/guards/auth.guard.ts
This commit is contained in:
@@ -6,7 +6,6 @@ import { PermissionService } from '../services/permission.service';
|
|||||||
import { LocalstoreService } from '../store/localstore.service';
|
import { LocalstoreService } from '../store/localstore.service';
|
||||||
import { SessionStore } from '../store/session.service';
|
import { SessionStore } from '../store/session.service';
|
||||||
import { RouteService } from 'src/app/services/route.service'
|
import { RouteService } from 'src/app/services/route.service'
|
||||||
import { InformationPage } from 'src/app/modals/information/information.page'
|
|
||||||
import { FirstEnterService } from 'src/app/services/first-enter.service'
|
import { FirstEnterService } from 'src/app/services/first-enter.service'
|
||||||
// import { ModalController } from '@ionic/angular';
|
// import { ModalController } from '@ionic/angular';
|
||||||
import { AlertController, Platform } from '@ionic/angular';
|
import { AlertController, Platform } from '@ionic/angular';
|
||||||
@@ -20,9 +19,7 @@ export class AuthGuard implements CanActivate {
|
|||||||
public p: PermissionService,
|
public p: PermissionService,
|
||||||
private RouteService: RouteService,
|
private RouteService: RouteService,
|
||||||
private FirstEnterService: FirstEnterService,
|
private FirstEnterService: FirstEnterService,
|
||||||
private InformationPage: InformationPage,
|
|
||||||
private alertController: AlertController,
|
private alertController: AlertController,
|
||||||
// private modalController: ModalController,
|
|
||||||
){}
|
){}
|
||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { HttpEventType } from '@angular/common/http';
|
|||||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
|
import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
|
||||||
import { ChatSystemService } from './chat-system.service';
|
import { ChatSystemService } from './chat-system.service';
|
||||||
|
import { resolve } from 'dns';
|
||||||
|
import { async } from '@angular/core/testing';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -149,6 +151,12 @@ export class MessageService {
|
|||||||
|
|
||||||
async send(): Promise<any> {
|
async send(): Promise<any> {
|
||||||
|
|
||||||
|
if(this.messageSend) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
resolve('solve')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.sendAttempt++;
|
this.sendAttempt++;
|
||||||
this.manualRetry = false
|
this.manualRetry = false
|
||||||
|
|
||||||
@@ -164,26 +172,10 @@ export class MessageService {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.uploadingFile = true
|
let uploadSuccessfully = await this.sendRequestAttachment()
|
||||||
|
|
||||||
let uploadSuccessfully = false
|
|
||||||
if(this.hasSendAttachment == false) {
|
|
||||||
try {
|
|
||||||
uploadSuccessfully = await this.NfService.beforeSendAttachment(this)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('beforeSendAttachment uploadSuccessfully',error)
|
|
||||||
}
|
|
||||||
this.UploadAttachmentsTemp++
|
|
||||||
}
|
|
||||||
|
|
||||||
this.uploadingFile = false
|
|
||||||
|
|
||||||
if(uploadSuccessfully) {
|
if(uploadSuccessfully) {
|
||||||
|
|
||||||
this.hasSendAttachment = true
|
|
||||||
this.errorUploadingAttachment = false
|
|
||||||
this.temporaryData = {}
|
|
||||||
|
|
||||||
const params = {roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, localReference: this.localReference}
|
const params = {roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, localReference: this.localReference}
|
||||||
await this.sendRequest(params)
|
await this.sendRequest(params)
|
||||||
|
|
||||||
@@ -199,19 +191,23 @@ export class MessageService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
} else if(uploadSuccessfully == false && this.UploadAttachmentsTemp == 1) {
|
} else if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) {
|
||||||
this.send().catch((error) =>{
|
this.RochetChatConnectorService.registerCallback({
|
||||||
console.error(error)
|
type: 'reConnect',
|
||||||
|
funx: async ()=> {
|
||||||
|
|
||||||
|
await this.send().catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
} else if (this.UploadAttachmentsTemp <= 3) {
|
||||||
else if(uploadSuccessfully == false) {
|
setTimeout(async () => {
|
||||||
|
return await this.send()
|
||||||
this.errorUploadingAttachment = true
|
}, 3000)
|
||||||
|
} else if (this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
|
||||||
return new Promise((resolve, reject) => {
|
this.manualRetry = true
|
||||||
reject(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -221,6 +217,31 @@ export class MessageService {
|
|||||||
|
|
||||||
functionTimer = null;
|
functionTimer = null;
|
||||||
|
|
||||||
|
async sendRequestAttachment() {
|
||||||
|
this.uploadingFile = true
|
||||||
|
|
||||||
|
let uploadSuccessfully = false
|
||||||
|
if(this.hasSendAttachment == false) {
|
||||||
|
try {
|
||||||
|
uploadSuccessfully = await this.NfService.beforeSendAttachment(this)
|
||||||
|
this.UploadAttachmentsTemp++
|
||||||
|
this.uploadingFile = false
|
||||||
|
this.manualRetry = false
|
||||||
|
this.errorUploadingAttachment = false
|
||||||
|
this.hasSendAttachment = true
|
||||||
|
this.temporaryData = {}
|
||||||
|
} catch (error) {
|
||||||
|
this.uploadingFile = false
|
||||||
|
this.errorUploadingAttachment = true
|
||||||
|
console.error('beforeSendAttachment error:', error)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return uploadSuccessfully
|
||||||
|
}
|
||||||
|
|
||||||
async sendRequest(params) {
|
async sendRequest(params) {
|
||||||
if(params?.attachments) {
|
if(params?.attachments) {
|
||||||
if(params?.attachments[0]?.image_url) {
|
if(params?.attachments[0]?.image_url) {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { versionData } from '../../version/git-version'
|
import { versionData } from '../../version/git-version'
|
||||||
export const environment = {
|
export const environment = {
|
||||||
apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
|
//apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
|
||||||
//apiURL: 'https://gd-api.oapr.gov.ao/api/',
|
//apiURL: 'https://gd-api.oapr.gov.ao/api/',
|
||||||
//apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/',
|
apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/',
|
||||||
// apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
|
// apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
|
||||||
// apiChatUrl: 'http://192.168.0.29:3000/api/v1/',
|
// apiChatUrl: 'http://192.168.0.29:3000/api/v1/',
|
||||||
// apiWsChatUrl: 'wss://192.168.0.29:3000/websocket',
|
// apiWsChatUrl: 'wss://192.168.0.29:3000/websocket',
|
||||||
//apiChatUrl: 'https://gd-chat.oapr.gov.ao/api/v1/',
|
//apiChatUrl: 'https://gd-chat.oapr.gov.ao/api/v1/',
|
||||||
apiWsChatUrl: 'wss://gd-chat.oapr.gov.ao/websocket',
|
//apiWsChatUrl: 'wss://gd-chat.oapr.gov.ao/websocket',
|
||||||
apiChatUrl: 'https://gdchat-dev.dyndns.info/api/v1/',
|
apiChatUrl: 'https://gdchat-dev.dyndns.info/api/v1/',
|
||||||
//apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket',
|
apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket',
|
||||||
production: true,
|
production: true,
|
||||||
domain: 'paulo.pinto@gabinetedigital.local',
|
domain: 'paulo.pinto@gabinetedigital.local',
|
||||||
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto@gabinetedigital.local
|
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto@gabinetedigital.local
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "f7aae9aa0",
|
"shortSHA": "fcc8bc6b7",
|
||||||
"SHA": "f7aae9aa00ab6135903a56b1ecbfcfeab8d4a9e9",
|
"SHA": "fcc8bc6b74ab3eca00dc78400c7bb2d1a8ab40bd",
|
||||||
"branch": "develop_bitOut-fix",
|
"branch": "develop_bitOut-fix",
|
||||||
"lastCommitAuthor": "'Peter Maquiran'",
|
"lastCommitAuthor": "'Peter Maquiran'",
|
||||||
"lastCommitTime": "'Mon Jan 2 15:42:15 2023 +0100'",
|
"lastCommitTime": "'Tue Jan 3 21:08:49 2023 +0100'",
|
||||||
"lastCommitMessage": "improve publicações",
|
"lastCommitMessage": "improve",
|
||||||
"lastCommitNumber": "4606",
|
"lastCommitNumber": "4607",
|
||||||
"change": "",
|
"change": "",
|
||||||
"changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/app-routing.module.ts\n\tmodified: src/app/guards/auth.guard.ts\n\tmodified: src/app/home/home-routing.module.ts\n\tnew file: src/app/modals/information/information-routing.module.ts\n\tnew file: src/app/modals/information/information.module.ts\n\tnew file: src/app/modals/information/information.page.html\n\tnew file: src/app/modals/information/information.page.scss\n\tnew file: src/app/modals/information/information.page.spec.ts\n\tnew file: src/app/modals/information/information.page.ts\n\tnew file: src/app/models/notifications.ts\n\tmodified: src/app/pages/chat/chat.page.ts\n\tmodified: src/app/pages/events/events.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tdeleted: src/app/resolvers/userData.resolver.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/chat.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/environments/environment.ts",
|
"changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/guards/auth.guard.ts\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/environments/environment.ts",
|
||||||
"changeAuthor": "peter.maquiran"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user