UNPKG

@fleetbase/fleetops-engine

Version:

Fleet & Transport Management Extension for Fleetbase

42 lines (38 loc) 1.36 kB
import Component from '@glimmer/component'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; export default class SensorFormComponent extends Component { @service fetch; @service currentUser; @service notifications; @action selectTelematic(telematic) { this.args.resource.setProperties({ telematic, telematic_uuid: telematic.id, provider: telematic.provider, }); } @task *handlePhotoUpload(file) { try { yield this.fetch.uploadFile.perform( file, { path: `uploads/${this.currentUser.companyId}/sensors/${this.args.resource.id}`, subject_uuid: this.args.resource.id, subject_type: 'fleet-ops:sensor', type: 'sensor_photo', }, (uploadedFile) => { this.args.resource.setProperties({ photo_uuid: uploadedFile.id, photo_url: uploadedFile.url, photo: uploadedFile, }); } ); } catch (err) { this.notifications.error('Unable to upload photo: ' + err.message); } } }