Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer

This commit is contained in:
Peter Maquiran
2021-11-22 15:46:35 +01:00
68 changed files with 704 additions and 1300 deletions
+4
View File
@@ -211,6 +211,10 @@ const routes = [
{
path: 'group-icons',
loadChildren: () => import('./modals/group-icons/group-icons.module').then( m => m.GroupIconsPageModule)
},
{
path: 'video-allowed',
loadChildren: () => import('./modals/video-allowed/video-allowed.module').then( m => m.VideoAllowedPageModule)
},
+17 -3
View File
@@ -9,6 +9,7 @@ import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'
const moment = _rollupMoment || _moment;
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
@@ -39,7 +40,8 @@ export class AppComponent {
/* private splashScreen: SplashScreen, */
private statusBar: StatusBar,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
this.initializeApp();
}
@@ -50,9 +52,9 @@ export class AppComponent {
/* this.splashScreen.hide(); */
if (this.platform.is("tablet")) {
this.screenOrientation.unlock();
window.screen.orientation.unlock();
} else if( this.platform.is("mobile")) {
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY);
window.screen.orientation.lock('portrait');
console.log('Orientation locked')
}
@@ -65,6 +67,18 @@ export class AppComponent {
console.log("Error creating local database: ", error)
}
}
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
}
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
});
}
@@ -4,33 +4,11 @@
</ion-card-header>
<ion-card-content >
<ion-row>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="removerIcone()" fill="clear" color="light">
<!-- <ion-icon name="remove" slot="start"></ion-icon> -->
<ion-icon class="redla" name="trash-outline"></ion-icon>
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="openGaleria()" fill="clear" color="light">
<!-- <ion-icon name="remove" slot="start"></ion-icon> -->
<ion-icon class="redla" name="flower-outline"></ion-icon>
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="OpenCamera()" fill="clear" color="light">
<ion-icon class="redla" name="camera-outline"></ion-icon>
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="pesquizarWeb()" fill="clear" color="light">
<ion-icon class="redla" name="search-outline"></ion-icon>
</ion-button>
</ion-col>
<ion-item>Iniciar Video Chamada?</ion-item>
</ion-row>
<ion-row>
<ion-item>Iniciar Video Chamada?</ion-item>
</ion-row>
</ion-card-content>
</ion-card>
@@ -28,9 +28,10 @@
<ion-footer color="light">
<ion-row>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="zoom(false)" fill="clear" color="light">
<ion-button (click)="close()" fill="clear" color="light">
<!-- <ion-icon name="remove" slot="start"></ion-icon> -->
<ion-icon class="redla" name="chatbox-outline"></ion-icon>
<ion-icon name="chatbox"></ion-icon>
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
@@ -41,15 +42,15 @@
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="close()" fill="clear" color="light">
<ion-button (click)="getIconGallery()" fill="clear" color="light">
<ion-icon class="redla" name="close-circle-outline"></ion-icon>
<ion-icon name="videocam"></ion-icon>
</ion-button>
</ion-col>
<ion-col size="3" class="ion-text-center">
<ion-button (click)="zoom(true)" fill="clear" color="light">
<ion-icon class="redla" name="alert-circle-outline"></ion-icon>
<ion-icon class="redla" name="alert-circle"></ion-icon>
</ion-button>
</ion-col>
@@ -8,8 +8,9 @@ ion-slides {
.redla{
color: rgb(255, 38, 0);
// background-color: rgb(255, 72, 0);
color: rgb(250, 248, 248);
background-color: rgb(255, 187, 0);
border-radius: 120px;
}
.cardconteudo {
@@ -25,4 +26,28 @@ float: right;
}
.center{
clear: both;
}
}
circle-xmark-solid{
// position: relative;
width: 512px;
height: 515px;
position: absolute;
left: 0%;
right: 0%;
top: 0%;
bottom: 0%;
background: #FCD13A;
}
/* Vector */
@@ -76,8 +76,11 @@ async getIconGallery(){
});
modal.present();
}
openChat(){
}
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { VideoAllowedPage } from './video-allowed.page';
const routes: Routes = [
{
path: '',
component: VideoAllowedPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class VideoAllowedPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { VideoAllowedPageRoutingModule } from './video-allowed-routing.module';
import { VideoAllowedPage } from './video-allowed.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
VideoAllowedPageRoutingModule
],
declarations: [VideoAllowedPage]
})
export class VideoAllowedPageModule {}
@@ -0,0 +1,9 @@
<ion-header>
<ion-toolbar>
<ion-title>videoAllowed</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
</ion-content>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { VideoAllowedPage } from './video-allowed.page';
describe('VideoAllowedPage', () => {
let component: VideoAllowedPage;
let fixture: ComponentFixture<VideoAllowedPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ VideoAllowedPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(VideoAllowedPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-video-allowed',
templateUrl: './video-allowed.page.html',
styleUrls: ['./video-allowed.page.scss'],
})
export class VideoAllowedPage implements OnInit {
modalController: any;
constructor() { }
ngOnInit() {
}
dismiss() {
// using the injected ModalController this page
// can "dismiss" itself and optionally pass back data
this.modalController.dismiss({
'dismissed': true
});
}
}
+9 -1
View File
@@ -30,6 +30,7 @@ import { environment } from 'src/environments/environment';
import { TimeService } from 'src/app/services/functions/time.service';
import { ThemeService } from 'src/app/services/theme.service'
import { DataService } from 'src/app/services/data.service';
import { Crop } from '@ionic-native/crop/ngx';
@Component({
@@ -119,6 +120,7 @@ export class ChatPage implements OnInit {
public ThemeService: ThemeService,
private dataService:DataService,
private router: Router,
private crop: Crop,
){
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.headers = new HttpHeaders();
@@ -549,4 +551,10 @@ hideRefreshButton(){
modal.onDidDismiss();
}
}
// this.crop.crop('path/to/image.jpg', {quality: 75})
// .then(
// newImage => console.log('new image path is: ' + newImage),
// error => console.error('Error cropping image', error)
// );
}
@@ -469,7 +469,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
//this.loadPicture();
}
else if(res['data'] == 'add-picture'){
this.fileService.addPictureToChat(this.roomId);
this.fileService.addPictureToChatMobile(this.roomId);
//this.loadPicture();
}
else if(res['data'] == 'add-document'){
@@ -60,7 +60,7 @@
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments let i = index">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)">
<div>
<div>
<div class="file">
+19 -1
View File
@@ -25,6 +25,8 @@ import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, Cur
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
const IMAGE_DIR = 'stored-images';
@Component({
selector: 'app-messages',
templateUrl: './messages.page.html',
@@ -103,6 +105,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.loadFiles();
VoiceRecorder.requestAudioRecordingPermission();
Filesystem.mkdir({
path: IMAGE_DIR,
directory: Directory.Data,
recursive: true
});
}
ngAfterViewInit() {
@@ -635,11 +642,22 @@ touchStart(card) {
componentProps: {
image: msg.attachments[0].image_url,
username: msg.u.username,
_updatedAt: msg._updatedAt
_updatedAt: msg._updatedAt,
}
});
modal.present();
}
imageSize(img){
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width=300
canvas.height=234
ctx.drawImage(img.attachments[0].image_url, 0, 0, 300, 234);
document.body.appendChild(canvas);
}
}
@@ -214,6 +214,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise();
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Conhecimento')
if (!this.p.userRole(['PR'])) {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas')
@@ -29,7 +29,11 @@
<ion-item lines="none">
<ion-thumbnail slot="start">
<ion-img [(ngModel)]="capturedImage" name="image" ngDefaultControl [src]="photo" (click)="openPreview(photo)" ></ion-img>
<<<<<<< HEAD
<ion-img [(ngModel)]="capturedImage" name="image" ngDefaultControl [src]="capturedImage" (click)="imageSize(capturedImage)" ></ion-img>
=======
<ion-img [(ngModel)]="capturedImage" name="image" ngDefaultControl [src]="capturedImage" ></ion-img>
>>>>>>> 6dcc59980c0116ee04582f93d3d44cc985659ce6
<ion-row>
<ion-col>
<img src="" #imageElement/>
@@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ModalController, NavParams, Platform, LoadingController, IonSlides } from '@ionic/angular';
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, Platform, LoadingController } from '@ionic/angular';
/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
@@ -19,9 +19,6 @@ import { ThemeService } from 'src/app/services/theme.service';
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
import {Photos} from '../new-publication/photos'
import {Storage} from '@capacitor/storage'
const IMAGE_DIR = 'stored-images';
@@ -38,9 +35,6 @@ interface LocalFile {
export class NewPublicationPage implements OnInit {
images: LocalFile[] = [];
files: Set<File>;
// date picker
public date: any;
public disabled = false;
@@ -76,7 +70,7 @@ export class NewPublicationPage implements OnInit {
capturedImage: any = '';
capturedImageTitle: any;
// public photos: any[] = [];
public photos: any[] = [];
constructor(
private modalController: ModalController,
@@ -87,19 +81,16 @@ export class NewPublicationPage implements OnInit {
private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service,
public ThemeService: ThemeService,
private platform: Platform,
private loadingCtrl: LoadingController,
private changeDetectorRef: ChangeDetectorRef,
platform: Platform
) {
this.publicationType = this.navParams.get('publicationType');
this.folderId = this.navParams.get('folderId');
this.publicationTitle = 'Nova Publicação';
this.platform = platform;
}
ngOnInit() {
ngOnInit() {
this.setTitle();
console.log(this.folderId);
Filesystem.mkdir({
@@ -107,56 +98,63 @@ ngOnInit() {
directory: Directory.Data,
recursive: true
});
// await this.loadSaved();
// this.loadPicture()
// this.takePicture();
}
// async takePicture() {
// const image = await Camera.getPhoto({
// quality: 90,
// allowEditing: false,
// resultType: CameraResultType.Uri,
// source: CameraSource.Camera // Camera, Photos or Prompt!
// });
async takePicture() {
const image = await Camera.getPhoto({
quality: 50,
allowEditing: false,
resultType: CameraResultType.Uri,
source: CameraSource.Camera // Camera, Photos or Prompt!
});
// if (image) {
// this.saveImage(image)
// }
if (image) {
this.saveImage(image)
}
// }
}
// convertBlobToBase64s = (blob: Blob) => new Promise((resolve, reject) => {
// const reader = new FileReader;
// reader.onerror = reject;
// reader.onload = () => {
// resolve(reader.result);
// };
// reader.readAsDataURL(blob);
// });
imageSize(image){
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width=300
canvas.height=234
ctx.drawImage(image, 0, 0, 300, 234);
document.body.appendChild(canvas);
}
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
// async laodPicture() {
// const capturedImage = await Camera.getPhoto({
// resultType: CameraResultType.Uri,
// source: CameraSource.Photos,
// quality: 90,
// width: 1080,
// height: 720,
// });
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
});
// const response = await fetch(capturedImage.webPath!);
// const blob = await response.blob();
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
// this.photos.unshift({
// filepath: "soon...",
// webviewPath: capturedImage.webPath
// });
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
// this.capturedImage = await this.convertBlobToBase64s(blob);
// this.capturedImageTitle = new Date().getTime() + '.jpeg';
// }
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
@@ -166,46 +164,11 @@ ngOnInit() {
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name
// // native devices ionic capacitor
// private async readAsBase64(photo: Photo) {
// // "hybrid" will detect Cordova or Capacitor
// if (this.platform.is('hybrid')) {
// // Read the file into base64 format
// const file = await Filesystem.readFile({
// path: photo.path
// });
// return file.data;
// }
// else {
// // Fetch the photo, read as a blob, then convert to base64 format
// const response = await fetch(photo.webPath);
// const blob = await response.blob();
// return await this.convertBlobToBase64(blob) as string;
// }
// }
// Save picture to file on device
private async savePicture(photo: Photo) {
// Convert photo to base64 format, required by Filesystem API to save
const base64Data = await this.readAsBase64(photo);
// Write the file to the data directory
const fileName = new Date().getTime() + '.jpeg';
const savedFile = await Filesystem.writeFile({
path: fileName,
data: base64Data,
directory: Directory.Data
});
if (this.platform.is('hybrid')) {
// Display the new image by rewriting the 'file://' path to HTTP
// Details: https://ionicframework.com/docs/building/webview#file-protocol
return {
filepath: savedFile.uri,
webviewPath: Capacitor.convertFileSrc(savedFile.uri),
console.log(this.capturedImage)
};
} */
@@ -373,7 +336,6 @@ private async savePicture(photo: Photo) {
}
}
close() {
this.modalController.dismiss().then(() => {
@@ -399,18 +361,18 @@ private async savePicture(photo: Photo) {
console.log(this.pub, 'pub')
}
}
// async openGallery() {
// const modal = await this.modalController.create({
// component: GalleryPage,
// componentProps:{
// },
// cssClass: 'new-publication',
// backdropDismiss: false
// });
// await modal.present();
// modal.onDidDismiss();
// }
/* async openGallery() {
const modal = await this.modalController.create({
component: GalleryPage,
componentProps:{
},
cssClass: 'new-publication',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
} */
/* async takePicture(){
const image = await Plugins.Camera.getPhoto({
@@ -424,253 +386,116 @@ private async savePicture(photo: Photo) {
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
} */
// async selectImage() {
// const image = await Camera.getPhoto({
// quality: 90,
// allowEditing: false,
// resultType: CameraResultType.Uri,
// source: CameraSource.Photos // Camera, Photos or Prompt!
// });
// if (image) {
// this.saveImage(image)
// }
// }
// // Create a new file from a capture image
// async saveImage(photo: Photo) {
// const base64Data = await this.readAsBase64(photo);
async selectImage() {
const image = await Camera.getPhoto({
quality: 50,
allowEditing: false,
resultType: CameraResultType.Uri,
source: CameraSource.Photos // Camera, Photos or Prompt!
});
// const fileName = new Date().getTime() + '.jpeg';
// const savedFile = await Filesystem.writeFile({
// path: `${IMAGE_DIR}/${fileName}`,
// data: base64Data,
// directory: Directory.Data
// });
// this.loadFiles();
// }
// private async readAsBase64(photo: Photo) {
// if (this.platform.is('hybrid')) {
// const file = await Filesystem.readFile({
// path: photo.path
// });
// return file.data;
// }
// else {
// // Fetch the photo, read as a blob, then convert to base64 format
// const response = await fetch(photo.webPath);
// const blob = await response.blob();
// return await this.convertBlobToBase64(blob) as string;
// }
// }
// async loadFiles() {
// this.images = [];
// const loading = await this.loadingCtrl.create({
// message: 'Loading data...',
// });
// await loading.present();
// Filesystem.readdir({
// path: IMAGE_DIR,
// directory: Directory.Data,
// }).then(result => {
// console.log('ALL RESULTS', result.files[0])
// let lastphoto = result.files[result.files.length - 1]
// this.loadFileData(lastphoto);
// },
// async (err) => {
// console.log('ERROR FILE DOSENT EXIST', err)
// // Folder does not yet exists!
// await Filesystem.mkdir({
// path: IMAGE_DIR,
// directory: Directory.Data,
// recursive: true
// });
// }
// ).then(_ => {
// loading.dismiss();
// });
// }
// async loadFileData(fileName: string) {
// console.log('ALL PHOTOT FILE', fileName)
// // for (let f of fileNames) {
// const filePath = `${IMAGE_DIR}/${fileName}`;
// const readFile = await Filesystem.readFile({
// path: filePath,
// directory: Directory.Data,
// });
// this.images.push({
// name: fileName,
// path: filePath,
// data: `data:image/jpeg;base64,${readFile.data}`,
// });
// console.log('ALL IMAGE', this.images)
// this.capturedImage = this.images[0].data
// //}
// }
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale/5;
this.changeDetectorRef.detectChanges();
if (image) {
this.saveImage(image)
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
async openPreview(photo) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
cssClass: 'transparent-modal',
componentProps: {
image: photo,
username: photo.u.username,
_updatedAt: photo._updatedAt
// Create a new file from a capture image
async saveImage(photo: Photo) {
const base64Data = await this.readAsBase64(photo);
const fileName = new Date().getTime() + '.jpeg';
const savedFile = await Filesystem.writeFile({
path: `${IMAGE_DIR}/${fileName}`,
data: base64Data,
directory: Directory.Data
});
//this.loadFiles(fileName);
this.loadFileData(fileName);
}
private async readAsBase64(photo: Photo) {
if (this.platform.is('hybrid')) {
const file = await Filesystem.readFile({
path: photo.path
});
return file.data;
}
else {
// Fetch the photo, read as a blob, then convert to base64 format
const response = await fetch(photo.webPath);
const blob = await response.blob();
return await this.convertBlobToBase64(blob) as string;
}
}
async loadFiles(fileName) {
this.images = [];
const loading = await this.loadingCtrl.create({
message: 'Loading data...',
});
await loading.present();
/* Filesystem.readdir({
path: `${IMAGE_DIR}/${fileName}`,
directory: Directory.Data,
}).then(result => {
console.log('ALL RESULTS', result.files)
let lastphoto = result.files[result.files.length - 1]
this.loadFileData(lastphoto);
},
async (err) => {
console.log('ERROR FILE DOSENT EXIST', err)
// Folder does not yet exists!
await Filesystem.mkdir({
path: IMAGE_DIR,
directory: Directory.Data,
recursive: true
});
}
});
modal.present();
).then(_ => {
loading.dismiss();
}); */
}
// async takePictures() {
// const capturedImage = await Camera.getPhoto({
// quality: 90,
// // allowEditing: true,
// resultType: CameraResultType.Uri,
// source: CameraSource.Camera
async loadFileData(fileName: string) {
console.log('ALL PHOTOT FILE', fileName)
// });
// const response = await fetch(capturedImage.webPath!);
// const blob = await response.blob();
const loading = await this.loadingCtrl.create({
message: 'Loading data...',
});
await loading.present();
// this.photos.unshift({
// filepath: "soon...",
// webviewPath: capturedImage.webPath
// });
const filePath = `${IMAGE_DIR}/${fileName}`;
// this.capturedImage = await this.convertBlobToBase64(blob);
// this.capturedImageTitle = new Date().getTime() + '.jpeg';
// let data = {
// image:this.capturedImage,
// name: this.capturedImageTitle
// }
// return data;
// alert(data)
// }
// convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
// const reader = new FileReader;
// reader.onerror = reject;
// reader.onload = () => {
// resolve(reader.result);
// };
// reader.readAsDataURL(blob);
// });
// loadPicture() {
// const input = this.fileLoaderService.createInput({
// accept: ['image/apng', 'image/jpeg', 'image/png']
// })
// input.onchange = async () => {
// const file = this.fileLoaderService.getFirstFile(input)
// console.log(file);
// const imageData = await this.fileToBase64Service.convert(file)
// this.capturedImage = imageData;
// this.capturedImageTitle = file.name;
// let data = {
// image:this.capturedImage,
// name: this.capturedImageTitle
// }
// return data;
// console.log(data)
// };
// }
public photos: Photos[] = [];
private PHOTO_STORAGE: string = "photos";
private platform: Platform;
async takePicture() {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
source: CameraSource.Camera
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
const readFile = await Filesystem.readFile({
path: filePath,
directory: Directory.Data,
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
this.images.push({
name: fileName,
path: filePath,
data: `data:image/jpeg;base64,${readFile.data}`,
});
console.log('ALL IMAGE', this.images)
this.capturedImage = this.images[0].data
loading.dismiss();
}
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
loadPicture() {
}}
}
@@ -16,6 +16,7 @@ import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-f
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ThemeService } from 'src/app/services/theme.service'
import { Crop } from '@ionic-native/crop/ngx';
@Component({
selector: 'app-publications',
@@ -68,7 +69,8 @@ export class PublicationsPage implements OnInit {
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
private platform: Platform,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private crop: Crop,
) {
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
@@ -91,6 +93,8 @@ export class PublicationsPage implements OnInit {
}
hideRefreshButton() {
window.onresize = (event) => {
if (window.innerWidth < 801) {
@@ -452,4 +456,12 @@ export class PublicationsPage implements OnInit {
});
}
// this.crop.crop('path/to/image.jpg', {quality: 75})
// .then(
// newImage => console.log('new image path is: ' + newImage),
// error => console.error('Error cropping image', error)
// );
}
+148 -35
View File
@@ -4,18 +4,29 @@ import { FileToBase64Service } from '../file/file-to-base64.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ChatService } from '../chat.service';
import { ModalController } from '@ionic/angular';
import { ModalController, Platform,LoadingController } from '@ionic/angular';
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from 'src/app/models/search-document';
import { ProcessesService } from '../processes.service';
import { ToastService } from '../toast.service';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
const IMAGE_DIR = 'stored-images';
interface LocalFile {
name: string;
path: string;
data: string;
}
@Injectable({
providedIn: 'root'
})
export class FileService {
images: LocalFile[] = [];
capturedImage:any;
capturedImageTitle:any;
documents:SearchList[] = [];
@@ -23,6 +34,7 @@ export class FileService {
files: Set<File>;
photos: any[] = [];
idroom: any;
constructor(
private fileLoaderService: FileLoaderService,
@@ -32,6 +44,8 @@ export class FileService {
private modalController: ModalController,
private processesService: ProcessesService,
private toastService: ToastService,
private platform: Platform,
private loadingCtrl: LoadingController
) { }
async takePicture() {
@@ -93,59 +107,157 @@ export class FileService {
};
}
//new method1
async saveImage(photo: Photo, roomid: any) {
const base64Data = await this.readAsBase64(photo);
const fileName = new Date().getTime() + '.jpeg';
const savedFile = await Filesystem.writeFile({
path: `${IMAGE_DIR}/${fileName}`,
data: base64Data,
directory: Directory.Data
});
this.loadFiles(roomid);
}
//new method 2
private async readAsBase64(photo: Photo) {
if (this.platform.is('hybrid')) {
const file = await Filesystem.readFile({
path: photo.path
});
return file.data;
}
else {
// Fetch the photo, read as a blob, then convert to base64 format
const response = await fetch(photo.webPath);
const blob = await response.blob();
return await this.convertBlobToBase64(blob) as string;
}
}
//new method 3
async loadFiles(roomid) {
this.images = [];
const loading = await this.loadingCtrl.create({
message: 'Loading data...',
});
await loading.present();
Filesystem.readdir({
path: IMAGE_DIR,
directory: Directory.Data,
}).then(result => {
console.log('ALL RESULTS', result.files[0])
let lastphoto = result.files[result.files.length - 1]
this.loadFileData(lastphoto,roomid);
},
async (err) => {
console.log('ERROR FILE DOSENT EXIST', err)
// Folder does not yet exists!
await Filesystem.mkdir({
path: IMAGE_DIR,
directory: Directory.Data,
recursive: true
});
}
).then(_ => {
loading.dismiss();
});
}
//new method 4
async loadFileData(fileName: string, roomid: any) {
console.log('ALL PHOTOT FILE', fileName)
// for (let f of fileNames) {
const filePath = `${IMAGE_DIR}/${fileName}`;
const readFile = await Filesystem.readFile({
path: filePath,
directory: Directory.Data,
});
this.images.push({
name: fileName,
path: filePath,
data: `data:image/jpeg;base64,${readFile.data}`,
});
console.log('ALL IMAGE', this.images)
this.capturedImage = this.images[0].data
this.capturedImageTitle = new Date().getTime() + '.jpeg';
let body = {
"message":
{
"rid": roomid,
"msg": "",
"attachments": [{
"title": this.capturedImageTitle,
"title_link_download": false,
"image_url": this.capturedImage,
}]
}
}
console.log('BODY TAKE PICTURE CHAT', body)
const loader = this.toastService.loading();
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
loader.remove();
},(error) => {
loader.remove();
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
});
}
async addCameraPictureToChat(roomId){
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
const image = await Camera.getPhoto({
quality: 50,
allowEditing: false,
resultType: CameraResultType.Uri,
source: CameraSource.Camera
source: CameraSource.Camera // Camera, Photos or Prompt!
});
const response = await fetch(capturedImage.webPath!);
if (image) {
await this.saveImage(image,roomId)
}
/* const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
}); */
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
let body = {
"message":
{
"rid": roomId,
"msg": "",
"attachments": [{
"title": this.capturedImageTitle,
"title_link_download": false,
"image_url": this.capturedImage,
}]
}
}
const loader = this.toastService.loading();
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
loader.remove();
},(error) => {
loader.remove();
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
});
//this.capturedImage = this.capturedImage;
}
async addPictureToChatMobile(roomId) {
const capturedImage = await Camera.getPhoto({
quality: 90,
quality: 50,
// allowEditing: true,
resultType: CameraResultType.Uri,
source: CameraSource.Photos
});
const response = await fetch(capturedImage.webPath!);
if (capturedImage) {
await this.saveImage(capturedImage,roomId)
}
/* const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
@@ -177,7 +289,7 @@ export class FileService {
},(error) => {
//loader.remove();
});
}
*/ }
addPictureToChat(roomId) {
@@ -193,7 +305,7 @@ export class FileService {
input.onchange = async () => {
alert('Onchange AQUI')
//alert('Onchange AQUI')
const file = this.fileLoaderService.getFirstFile(input)
@@ -218,6 +330,7 @@ export class FileService {
}
}
console.log('SELECT PICTURE GALLERY', body)
console.log(this.capturedImage)
this.chatService.sendMessage(body).subscribe(res=> {
@@ -44,7 +44,7 @@
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last">
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last" (click)="openPreview(msg)">
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" >
<div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
@@ -1,5 +1,5 @@
import { Component, OnChanges, OnInit, Input, SimpleChanges, Output, EventEmitter, ViewChild, ElementRef, AfterViewChecked, AfterViewInit, OnDestroy} from '@angular/core';
import { ActionSheetController, AnimationController, MenuController, ModalController, PopoverController } from '@ionic/angular';
import { Component, OnChanges, OnInit, Input, SimpleChanges,ChangeDetectorRef,Output, EventEmitter, ViewChild, ElementRef, AfterViewChecked, AfterViewInit, OnDestroy} from '@angular/core';
import { ActionSheetController, AnimationController, IonSlides, MenuController, ModalController, PopoverController } from '@ionic/angular';
import { AlertService } from 'src/app/services/alert.service';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
@@ -19,6 +19,7 @@ import { ProcessesService } from 'src/app/services/processes.service';
import { FileService } from 'src/app/services/functions/file.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
/*
import * as pdfjsLib from 'pdfjs-dist';
@@ -86,7 +87,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
private fileToBase64Service: FileToBase64Service,
private processesService: ProcessesService,
private fileService: FileService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
@@ -767,7 +769,61 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
}
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale/5;
this.changeDetectorRef.detectChanges();
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
async openPreview(img) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
cssClass: 'transparent-modal',
componentProps: {
image: img.attachments[0].image_url,
username: img.u.username,
_updatedAt: img._updatedAt
}
});
modal.present();
}
}
@@ -37,7 +37,7 @@
</ion-refresher-content>
</ion-refresher>
<div class="messages" #scrollMe>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last">
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last" (click)="openPreview(msg)">
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
<div class="message-item-options d-flex justify-content-end">
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
+60 -4
View File
@@ -1,5 +1,5 @@
import { AfterViewChecked, AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { AnimationController, GestureController, ModalController, PopoverController } from '@ionic/angular';
import { AfterViewChecked, AfterViewInit, Component, ElementRef,ChangeDetectorRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { AnimationController, GestureController, IonSlides, ModalController, PopoverController } from '@ionic/angular';
import { AlertService } from 'src/app/services/alert.service';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
@@ -16,6 +16,7 @@ import { FileService } from 'src/app/services/functions/file.service';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
@Component({
selector: 'app-messages',
@@ -71,7 +72,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private fileService: FileService,
private gestureController: GestureController,
private http:HttpClient,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef
) {
this.loggedUser = authService.ValidatedUserChat['data'];
@@ -553,7 +555,61 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.serverLongPull();
});
}sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale/5;
this.changeDetectorRef.detectChanges();
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
async openPreview(msg) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
cssClass: 'transparent-modal',
componentProps: {
image: msg.attachments[0].image_url,
username: msg.u.username,
_updatedAt: msg._updatedAt
}
});
modal.present();
}
}
@@ -66,6 +66,8 @@ export class AllProcessesPage implements OnInit {
let allProcessesList = await this.processesService.GetTasksList("", false).toPromise();
//console.log(allProcessesList);
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Conhecimento')
this.skeletonLoader = true;
this.allProcessesList = [];