changes and changes

This commit is contained in:
Eudes Inácio
2023-11-20 14:12:32 +01:00
parent 92cc1841e7
commit 7bd1370c0b
12 changed files with 174 additions and 47 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { checkFileTypeService } from './checkFileType.service';
describe('checkFileTypeService', () => {
let service: checkFileTypeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(checkFileTypeService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+36
View File
@@ -0,0 +1,36 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class checkFileTypeService {
constructor(private router: Router) {
}
checkFileType(fileType) {
// Convert to lowercase to handle case-insensitivity
const lowerCaseType = fileType.toLowerCase();
// Define image and video extensions/types
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp','tiff','tif',
'image/jpg', 'image/jpeg', 'image/png', 'image/gif', 'image/bmp','image/tiff','image/tif', 'image/*']; // Add more if needed
const videoExtensions = ['mp4', 'webm', 'mpg', 'mpeg', 'ogg',
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg', 'video/*']; // Add more if needed
// Check if it's an image
if (imageExtensions.includes(lowerCaseType)) {
return 'image';
}
// Check if it's a video
if (videoExtensions.includes(lowerCaseType)) {
return 'video';
}
// If it's neither image nor video
return 'null';
}
}
+15 -12
View File
@@ -17,12 +17,12 @@ export class HttpErrorHandle {
) {
case 0:
const result = await this.backgroundService.offline()
if(result) {
if (result) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
}
break;
case 400:
this.toastService._badRequest('Lamentamos, mas houve um problema com sua solicitação. Por favor, tente novamente')
@@ -55,12 +55,12 @@ export class HttpErrorHandle {
) {
case 0:
const result = await this.backgroundService.offline()
if(result) {
if (result) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
}
break;
case 400:
this.toastService._badRequest('Lamentamos, mas houve um problema com sua solicitação. Por favor, tente novamente')
@@ -93,12 +93,15 @@ export class HttpErrorHandle {
case 'diplomaAsDraft':
this.toastService._badRequest('Este diploma não contem um draft para ser assinado!')
break;
default:
this.toastService._badRequest('')
break;
}
case 'filetype':
this.toastService._badRequest('Formato de ficheiro inválido!')
break;
default:
this.toastService._badRequest('')
break;
}
}
httpsSucessMessagge(service: string, callback?: any) {
switch (service) {
@@ -210,7 +213,7 @@ export class HttpErrorHandle {
case 'Draft Concluído':
this.toastService._successMessage('Documento Concluído!');
break;
case 'new event to aprove':
case 'new event to aprove':
this.toastService._successMessage('Enviado para os eventos para aprovação!');
break;
+13
View File
@@ -149,6 +149,19 @@ export class PublicationsService {
};
return this.http.get<any>(`${geturl}`, options);
}
GetPublicationWithArrayOfFilesById( publicationId:any){
const geturl = environment.apiURL + 'presidentialActions/v2/posts/'+ publicationId;
let params = new HttpParams();
params = params.set("id", publicationId);
let options = {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options);
}
// my own tries
+2 -6
View File
@@ -36,13 +36,9 @@ export class SendIntentService {
private onReceive = this.callbackScheduler.function<any>((result)=> {
let resultUrl = decodeURIComponent(result.url);
Filesystem.readFile({path: resultUrl}).then(async (content) => {
this.Router.navigateByUrl("/home/publications");
this.Router.navigateByUrl("/home/publications");
window["sharedContent"] = content.data;
})
window["sharedContent"] = result;
})
}