Send many alterations.

This commit is contained in:
Tiago Kayaya
2020-12-11 15:09:53 +01:00
parent 8597d0a0b0
commit 5496953f63
25 changed files with 479 additions and 106 deletions
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PhotoService } from './photo.service';
describe('PhotoService', () => {
let service: PhotoService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PhotoService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+66
View File
@@ -0,0 +1,66 @@
import { Injectable } from '@angular/core';
import { Plugins, CameraResultType, Capacitor, FilesystemDirectory, CameraPhoto, CameraSource } from '@capacitor/core';
import { Photo } from '../models/photo';
import { Platform } from '@ionic/angular';
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
/* const { Camera, Filesystem, Storage } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class PhotoService {
public photos: Photo[] = [];
private PHOTO_STORAGE: string = "photos";
private platform: Platform;
constructor(platform: Platform,
private camera:Camera) {
this.platform = platform;
}
async takePicture(){
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
let base64Image = 'data:image/jpeg;base64,' + imageData;
return base64Image;
}, (err) => {
// Handle error
});
}
/* async addNewToGallery() {
// Take a photo using Capacitor
const capturedPhoto = await Camera.getPhoto({
resultType: CameraResultType.Base64,
source: CameraSource.Camera,
quality: 90,
width: 1080,
height: 720,
});
this.photos.unshift({
fileName: new Date().getTime() + '.png',
webviewPath: capturedPhoto.base64String,
fileFormat: capturedPhoto.format,
});
console.log(capturedPhoto);
console.log(this.photos[0]);
} */
}
+18 -2
View File
@@ -110,7 +110,7 @@ export class PublicationsService {
params = params.set("folderId", folderId);
let options = {
headers: this.headers,
params: params
/* params: params */
};
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
console.log(res);
@@ -123,13 +123,29 @@ export class PublicationsService {
params = params.set("folderId", folderId);
let options = {
headers: this.headers,
params: params
/* params: params */
};
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
console.log(res);
});
}
DeletePublication(folderId:any,publicationId:any){
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts/'+publicationId;
let params = new HttpParams();
params = params.set("folderId", folderId);
params = params.set("id", publicationId);
let options = {
headers: this.headers,
/* params: params */
};
return this.http.delete(`${geturl}`, options).toPromise().then(res =>{
console.log(res);
});
}
}