UNPKG

@totvs-agro/mobile-components

Version:

Componentes Mobile Totvs (Front-End) para utilização dos estilos do T-Faces e Ionic v3

119 lines (114 loc) 6.33 kB
import { HttpClient } from '@angular/common/http'; import { Component, Input } from '@angular/core'; import { Camera } from '@ionic-native/camera'; import { ActionSheetController, Events } from 'ionic-angular'; import { TotvsNotificationProvider } from '../../providers/totvs-notification-provider'; import { TotvsTranslateProvider } from '../../providers/translate/totvs-translate-provider'; var HTML_TEMPLATE = "\n<ion-item class=\"avatar-container\" no-lines>\n <ion-avatar class=\"avatar\">\n <img *ngIf=\"!user_foto\" src=\"./assets/imgs/noimg.png\">\n <img *ngIf=\"user_foto\" [src]=\"user_foto\">\n </ion-avatar>\n\n <span (click)=\"opcoesFoto()\">\n <thf-icon name=\"camera\" class=\"photo-edit\"></thf-icon>\n </span>\n</ion-item>\n"; var PerfilImageComponent = /** @class */ (function () { function PerfilImageComponent(_http, _actionSheetCtrl, _translate, _camera, _events, _notification) { /*this._events.subscribe(TopicsEventsPublishComponents.PROFILE_CROP_IMAGE, (imagePath: string) => { this.callback(imagePath); });*/ this._http = _http; this._actionSheetCtrl = _actionSheetCtrl; this._translate = _translate; this._camera = _camera; this._events = _events; this._notification = _notification; } PerfilImageComponent.prototype.opcoesFoto = function () { var _this = this; var actionSheet = this._actionSheetCtrl.create({ title: this._translate.instant("COMMON.SETTINGS.OPTIONS"), buttons: [ { text: this._translate.instant("COMMON.SETTINGS.CAMERA"), icon: 'camera', handler: function () { var options = { quality: 50, destinationType: _this._camera.DestinationType.DATA_URL, encodingType: _this._camera.EncodingType.JPEG, mediaType: _this._camera.MediaType.PICTURE, correctOrientation: true }; _this.selecionaFoto(options); } }, { text: this._translate.instant("COMMON.SETTINGS.GALLERY"), icon: 'image', handler: function () { var options = { quality: 50, destinationType: _this._camera.DestinationType.DATA_URL, sourceType: _this._camera.PictureSourceType.PHOTOLIBRARY, saveToPhotoAlbum: false, correctOrientation: true }; _this.selecionaFoto(options); } } /*, { text: this._translate.instant("COMMON.SETTINGS.REMOVER_FOTO"), icon: 'close', handler: async () => { let user = (await this._repository.findAll(DataStore.USER))[0]; if (user.photoId) { await this._repository.delete(DataStore.IMAGE, user.photoId); user.photoId = undefined; await this._repository.upsert(DataStore.USER, user); } let pendingChange: SyncPending = { store: DataStore.USER, action: SyncAction.SAVE, direction: SyncDirection.SEND, rowId: user._id, timestamp: new Date(), status: SyncStatus.PENDING, _id: GeneratedId.getId() } await this._repository.upsert(DataStore.SYNC_PENDING, pendingChange); this._events.publish(TopicsEventsPublish.PROFILE_CROP_IMAGE, undefined); } }*/ ] }); actionSheet.present(); }; PerfilImageComponent.prototype.selecionaFoto = function (options) { var _this = this; this._notification.presentLoading(); this._camera.getPicture(options).then(function (imageData) { _this._notification.dismissLoading(); //this._events.publish(TopicsEventsPublishComponents.PROFILE_CROP_IMAGE, imageData); _this.callback(imageData); //console.log({ 'teste': imageData }); //this.navCtrl.push('PerfilImageEditPage', { // image: { encoding: base64File }, //}); //this._sanitizer.bypassSecurityTrustUrl(base64File); }).catch(function (err) { _this._notification.dismissLoading(); console.log(err); }); }; PerfilImageComponent.decorators = [ { type: Component, args: [{ selector: 'perfil-image', template: HTML_TEMPLATE },] }, ]; /** @nocollapse */ PerfilImageComponent.ctorParameters = function () { return [ { type: HttpClient, }, { type: ActionSheetController, }, { type: TotvsTranslateProvider, }, { type: Camera, }, { type: Events, }, { type: TotvsNotificationProvider, }, ]; }; PerfilImageComponent.propDecorators = { "callback": [{ type: Input, args: ['callback',] },], "user_foto": [{ type: Input, args: ['user_foto',] },], }; return PerfilImageComponent; }()); export { PerfilImageComponent }; //# sourceMappingURL=perfil-image.js.map