mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Disabled capacitor and add camera integration
This commit is contained in:
@@ -17,3 +17,4 @@
|
||||
</form>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { environment } from 'src/environments/environment';
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { AuthConnstants } from 'src/app/config/auth-constants';
|
||||
import { PhotoService } from 'src/app/services/photo.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -29,6 +30,7 @@ export class LoginPage implements OnInit {
|
||||
private authService: AuthService,
|
||||
private storageService: StorageService,
|
||||
private toastService: ToastService,
|
||||
private photoService: PhotoService,
|
||||
public alertController: AlertController) { }
|
||||
|
||||
ngOnInit() {
|
||||
@@ -56,7 +58,7 @@ export class LoginPage implements OnInit {
|
||||
loginAction(){
|
||||
|
||||
if(this.validateInput()){
|
||||
this.authService.loginChat2(this.postData).subscribe((res: any) =>{
|
||||
/* this.authService.loginChat2(this.postData).subscribe((res: any) =>{
|
||||
if(res.data){
|
||||
this.storageService.store(AuthConnstants.AUTH, res.data);
|
||||
console.log('Log RockectChat OK');
|
||||
@@ -69,13 +71,13 @@ export class LoginPage implements OnInit {
|
||||
},
|
||||
(error:any) =>{
|
||||
console.log('Network error');
|
||||
})
|
||||
}) */
|
||||
}
|
||||
else{
|
||||
this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async Login(){
|
||||
try {
|
||||
//Go to our home in home/feed.
|
||||
@@ -106,4 +108,7 @@ export class LoginPage implements OnInit {
|
||||
this.presentAlert('Ocorreu um erro ao fazer login. Contacte o administrador de sistema.');
|
||||
}
|
||||
}
|
||||
openCamera(){
|
||||
this.photoService.takePicture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,18 +36,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="photoService.photos.length > 0" class="ion-item-container-no-border">
|
||||
<div *ngIf="capturedImage != ''" class="ion-item-container-no-border">
|
||||
<ion-label class="attached-title">Fotografia Anexada</ion-label>
|
||||
<ion-item lines="none">
|
||||
<ion-thumbnail slot="start">
|
||||
<ion-img [(ngModel)]="pub.FileBase64" name="image" ngDefaultControl [src]="'data:image/png;base64,'+this.photoService.photos[0].webviewPath"></ion-img>
|
||||
<ion-img [(ngModel)]="pub.FileBase64" name="image" ngDefaultControl [src]="'data:image/png;base64,'+capturedImage"></ion-img>
|
||||
</ion-thumbnail>
|
||||
<!-- <ion-thumbnail *ngIf="!publication" slot="start">
|
||||
<ion-img [(ngModel)]="publication.imageUrl" [src]="guestPicture"></ion-img>
|
||||
</ion-thumbnail> -->
|
||||
<ion-label>
|
||||
<p>{{photoService.photos[0].fileName}}</p>
|
||||
<p>size</p>
|
||||
<p>{{capturedImageTitle}}</p>
|
||||
<p hidden>size</p>
|
||||
</ion-label>
|
||||
<ion-icon (click)="clear()" name="close"></ion-icon>
|
||||
</ion-item>
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController, NavParams } from '@ionic/angular';
|
||||
import { AlertController, ModalController, NavParams } from '@ionic/angular';
|
||||
import { GalleryPage } from '../gallery/gallery.page';
|
||||
|
||||
import {Plugins, CameraResultType, CameraSource} from '@capacitor/core';
|
||||
/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { Publication } from 'src/app/models/publication';
|
||||
import { Image } from 'src/app/models/image';
|
||||
import { ThrowStmt } from '@angular/compiler';
|
||||
import { PhotoService } from 'src/app/services/photo.service';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
|
||||
const { Camera } = Plugins;
|
||||
/* const { Camera } = Plugins; */
|
||||
|
||||
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-publication',
|
||||
@@ -35,14 +38,18 @@ export class NewPublicationPage implements OnInit {
|
||||
guestPicture:any;
|
||||
|
||||
capturedImage:any;
|
||||
capturedImageTitle:any;
|
||||
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
public photoService: PhotoService,
|
||||
private navParams: NavParams,
|
||||
private alertService: AlertService,
|
||||
/* private camera: Camera, */
|
||||
private sanitizer: DomSanitizer,
|
||||
private publications: PublicationsService,
|
||||
private camera: Camera,
|
||||
) {
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
this.folderId = this.navParams.get('folderId');
|
||||
@@ -55,7 +62,23 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
}
|
||||
takePictureCodova(){
|
||||
this.photoService.takePicture();
|
||||
const options: CameraOptions = {
|
||||
quality: 100,
|
||||
destinationType: this.camera.DestinationType.DATA_URL,
|
||||
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;
|
||||
this.capturedImage = imageData;
|
||||
this.capturedImageTitle = new Date().getTime();
|
||||
}, (err) => {
|
||||
// Handle error
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* takePictureCapacitor() {
|
||||
@@ -88,21 +111,31 @@ export class NewPublicationPage implements OnInit {
|
||||
async save(){
|
||||
console.log(this.pub.FileBase64);
|
||||
if(this.publicationType == '3'){
|
||||
this.image = {
|
||||
title: this.image.title,
|
||||
url: this.image.url,
|
||||
format: 'png'
|
||||
if(this.capturedImage != ''){
|
||||
this.publication = {
|
||||
DocumentId:this.publication.DocumentId,
|
||||
ProcessId:this.publication.ProcessId,
|
||||
Title: this.pub.Title,
|
||||
Message: this.pub.Message,
|
||||
DatePublication: this.publication.DatePublication,
|
||||
OriginalFileName: this.capturedImageTitle,
|
||||
FileBase64: this.capturedImage,
|
||||
FileExtension: 'jpg',
|
||||
}
|
||||
}
|
||||
this.publication = {
|
||||
DocumentId:this.publication.DocumentId,
|
||||
ProcessId:this.publication.ProcessId,
|
||||
Title: this.pub.Title,
|
||||
Message: this.pub.Message,
|
||||
DatePublication: this.publication.DatePublication,
|
||||
OriginalFileName: '',
|
||||
FileBase64: this.publication.FileBase64,
|
||||
FileExtension: 'jpg',
|
||||
else{
|
||||
this.publication = {
|
||||
DocumentId:this.publication.DocumentId,
|
||||
ProcessId:this.publication.ProcessId,
|
||||
Title: this.pub.Title,
|
||||
Message: this.pub.Message,
|
||||
DatePublication: this.publication.DatePublication,
|
||||
OriginalFileName: '',
|
||||
FileBase64: this.publication.FileBase64,
|
||||
FileExtension: 'jpg',
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Edit');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
||||
@@ -110,19 +143,14 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
else{
|
||||
|
||||
this.image = {
|
||||
title: this.image.title,
|
||||
url: this.image.url,
|
||||
format: 'png'
|
||||
}
|
||||
this.publication = {
|
||||
DocumentId:null,
|
||||
ProcessId:this.folderId,
|
||||
Title: this.pub.Title,
|
||||
Message: this.pub.Message,
|
||||
DatePublication: new Date(),
|
||||
OriginalFileName: 'foto',
|
||||
FileBase64: this.photoService.photos[0].webviewPath,
|
||||
OriginalFileName: this.capturedImageTitle,
|
||||
FileBase64: this.capturedImage,
|
||||
FileExtension: 'jpg',
|
||||
}
|
||||
|
||||
@@ -138,7 +166,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
clear(){
|
||||
this.photoService.photos = [];
|
||||
this.capturedImage = '';
|
||||
}
|
||||
setTitle(){
|
||||
if(this.publicationType == '1'){
|
||||
@@ -165,7 +193,7 @@ export class NewPublicationPage implements OnInit {
|
||||
modal.onDidDismiss();
|
||||
} */
|
||||
|
||||
async takePicture(){
|
||||
/* async takePicture(){
|
||||
const image = await Plugins.Camera.getPhoto({
|
||||
quality: 100,
|
||||
allowEditing: false,
|
||||
@@ -175,7 +203,7 @@ export class NewPublicationPage implements OnInit {
|
||||
console.log(image);
|
||||
|
||||
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
|
||||
}
|
||||
} */
|
||||
openCamera(){
|
||||
/* this.camera.getPicture({
|
||||
sourceType: this.camera.PictureSourceType.CAMERA,
|
||||
|
||||
Reference in New Issue
Block a user