This commit is contained in:
tiago.kayaya
2021-08-23 16:40:45 +01:00
58 changed files with 502 additions and 237 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { FileLoaderService } from './file-loader.service';
describe('FileLoaderService', () => {
let service: FileLoaderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FileLoaderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { FileType } from 'src/app/models/fileType';
interface createInput {
type?: string
accept: typeof FileType[]
}
@Injectable({
providedIn: 'root'
})
export class FileLoaderService {
nice : typeof FileType
constructor() { }
createInput(param:createInput): HTMLInputElement {
let input = document.createElement('input');
input.type = param.type || 'file';
input.accept = param.accept.join(', ')
// input.onchange = () => {
// // you can use this method to get file and perform respective operations
// let files = Array.from(input.files);
// console.log(files);
// };
input.click();
return input
}
getFirstFile(input: HTMLInputElement) {
let files = Array.from(input.files);
return files[0]
}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { FileToBase64Service } from './file-to-base64.service';
describe('FileToBase64Service', () => {
let service: FileToBase64Service;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FileToBase64Service);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class FileToBase64Service {
constructor() { }
convert(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
}
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NetworkService } from './network.service';
describe('NavigationService', () => {
let service: NetworkService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetworkService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+31
View File
@@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import { Network } from '@ionic-native/network/ngx';
import { Platform } from '@ionic/angular';
import { fromEvent, merge, of, Observable } from 'rxjs';
import { mapTo } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class NetworkService {
constructor(
private network: Network) { }
checkNetworkConnection(){
this.network.onConnect().subscribe((value) => {
document.body.style.setProperty(`--color`, "#0782C9");
console.log('network connected!',value);
});
}
checkNetworkDisconnection(){
this.network.onDisconnect().subscribe((value) => {
document.body.style.setProperty(`--color`, "#eeeb30");
console.log('network was disconnected :-('),value;
});
}
}
+3 -2
View File
@@ -5,6 +5,7 @@ import { AuthService } from '../services/auth.service';
import { User } from '../models/user.model';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators'
import { Publication } from '../models/publication';
@Injectable({
providedIn: 'root'
@@ -38,7 +39,7 @@ export class PublicationsService {
return this.http.get<any>(`${geturl}`, options);
}
UpdatePresidentialAction(body:any){
UpdatePresidentialAction(body:any) {
const geturl = environment.apiURL + 'presidentialActions';
let options = {
@@ -86,7 +87,7 @@ export class PublicationsService {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options)
return this.http.get<Publication[]>(`${geturl}`, options)
}
GetPublicationById( publicationId:any){
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PublicationService } from './publication.service';
describe('PublicationService', () => {
let service: PublicationService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PublicationService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class PublicationService {
constructor() { }
}
@@ -24,9 +24,14 @@ export class SynchroService {
public conected = false
private url: string = ''
callback = function(){}
private _connected = false;
constructor(){}
get connected() {
return this._connected
}
setUrl() {
let header ={
@@ -55,7 +60,13 @@ export class SynchroService {
}
private onopen = () =>{
document.body.style.setProperty(`--color`, "#0782C9");
document.body.style.setProperty(`--color2`, "#45BAFF");
document.body.style.setProperty(`--color3`, "#0782C9");
document.body.style.setProperty(`--color4`, "#0782c9f0");
document.body.style.setProperty(`--color5`, "#45BAFF");
console.log('open ======================= welcome to socket server')
this._connected = true
}
@@ -85,7 +96,14 @@ export class SynchroService {
// event.code is usually 1006 in this case
console.log('[close] Connection died');
console.log('Reconnect')
document.body.style.setProperty(`--color`, "#ffb703");
document.body.style.setProperty(`--color2`, "#ffb703");
document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703");
this._connected = false
this.connect()
}
}, 100);
}