add image to chat

This commit is contained in:
tiago.kayaya
2021-09-13 12:37:58 +01:00
parent 129a709570
commit 9994ba1a5d
10 changed files with 259 additions and 18 deletions
@@ -7,7 +7,7 @@
<div class="buttons">
<button hidden (click)="notImplemented()" full class="btn-cancel" shape="round" >Tirar Fotografia</button>
<button hidden (click)="notImplemented()" class="btn-cancel" shape="round" >Digitalizar Documento</button>
<button hidden (click)="notImplemented()" full class="btn-cancel" shape="round" >Anexar Fotografia</button>
<button (click)="anexarFoto()" full class="btn-cancel" shape="round" >Anexar Fotografia</button>
<button hidden (click)="getDoc()" class="btn-cancel" shape="round" >Anexar Documento</button>
<div class="solid"></div>
<button (click)="bookMeeting()" class="btn-cancel" shape="round" >Marcar reunião</button>
@@ -5,6 +5,9 @@ import { SearchList } from 'src/app/models/search-document';
import { NewEventPage } from 'src/app/pages/agenda/new-event/new-event.page';
import { SearchPage } from 'src/app/pages/search/search.page';
import { AlertService } from 'src/app/services/alert.service';
import { ChatService } from 'src/app/services/chat.service';
import { FileLoaderService } from 'src/app/services/file/file-loader.service';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
import { environment } from 'src/environments/environment';
@Component({
@@ -18,11 +21,17 @@ export class ChatOptionsFeaturesPage implements OnInit {
members: any;
attendees: EventPerson[] = [];
capturedImage:any;
capturedImageTitle:any;
constructor(
private popoverController: PopoverController,
private modalController: ModalController,
private alertService: AlertService,
private navParams: NavParams,
private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service,
private chatService: ChatService,
) {
this.members = this.navParams.get('members');
@@ -59,6 +68,73 @@ export class ChatOptionsFeaturesPage implements OnInit {
}
anexarFoto(){
this.modalController.dismiss('picture');
}
laodPicture() {
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 body = {
"message":
{
"rid": "J5WDHyrYWHQrybbno",
"msg": "this.message",
"attachments": [{
"title": this.capturedImageTitle ,
"text": "description",
"title_link_download": false,
"image_url": this.capturedImage,
}]
}
}
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
},(error) => {
});
//console.log(this.capturedImage)
};
}
sendMessage(){
let body = {
"message":
{
"rid": "J5WDHyrYWHQrybbno",
"msg": "this.message",
/* "attachments": [{
"color": "#ff0000",
"text": "Yay for gruggy!",
"title": "Attachment Example",
"title_link": "https://youtube.com",
"title_link_download": false,
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ee/Chain_link_icon.png",
}] */
}
}
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
},(error) => {
});
}
/* getGroupContacts(room:any){
this.showLoader = true;
//If group is private call getGroupMembers