Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
added chat log model and serializer
Ronald A. Richardson7874edf0f3d2
diff --git a/console/app/models/chat-channel.js b/console/app/models/chat-channel.jsindex 00056715..c8ef7b54 100644--- a/console/app/models/chat-channel.js+++ b/console/app/models/chat-channel.js@@ -3,14 +3,16 @@ import { computed } from '@ember/object';import { getOwner } from '@ember/application';import { format, formatDistanceToNow, isValid as isValidDate } from 'date-fns';-export default class ChatChannel extends Model {+export default class ChatChannelModel extends Model {/** @ids */@attr('string') public_id;@attr('string') company_uuid;/** @attributes */@attr('string') name;+ @attr('string') title;@attr('string') slug;+ @attr('array') feed;@attr('array') meta;/** @relationships */@@ -18,7 +20,7 @@ export default class ChatChannel extends Model {@hasMany('chat-message', { async: false }) messages;@hasMany('chat-attachment', { async: true }) attachments;@hasMany('chat-presence', { async: true }) presences;- @belongsTo('chat-message', { async: false }) lastMessage;+ @belongsTo('chat-message', { async: false }) last_message;/** @dates */@attr('date') created_at;@@ -64,7 +66,7 @@ export default class ChatChannel extends Model {return store.query('chat-participant', { chat_channel_uuid: this.id }).then((participants) => {this.set('participants', participants);- return participants+ return participants;});}@@ -74,7 +76,7 @@ export default class ChatChannel extends Model {return store.query('chat-message', { chat_channel_uuid: this.id }).then((messages) => {this.set('messages', messages);- return messages+ return messages;});}@@ -84,7 +86,7 @@ export default class ChatChannel extends Model {return store.query('chat-attachment', { chat_channel_uuid: this.id }).then((attachments) => {this.set('attachments', attachments);- return attachments+ return attachments;});}}diff --git a/console/app/models/chat-log.js b/console/app/models/chat-log.jsnew file mode 100644index 00000000..6436eb50--- /dev/null+++ b/console/app/models/chat-log.js@@ -0,0 +1,55 @@+import Model, { belongsTo } from '@ember-data/model';+import { computed } from '@ember/object';+import { getOwner } from '@ember/application';+import { format, formatDistanceToNow, isValid as isValidDate } from 'date-fns';++export default class ChatLogModel extends Model {+ /** @ids */+ @attr('string') company_uuid;+ @attr('string') chat_channel_uuid;+ @attr('string') initiator_uuid;++ /** @attributes */+ @attr('string') content;+ @attr('string') resolved_content;+ @attr('string') event_type;+ @attr('string') status;+ @attr('array') meta;++ /** @dates */+ @attr('date') created_at;+ @attr('date') updated_at;++ /** @computed */+ @computed('updated_at') get updatedAgo() {+ if (!isValidDate(this.updated_at)) {+ return null;+ }++ return formatDistanceToNow(this.updated_at);+ }++ @computed('updated_at') get updatedAt() {+ if (!isValidDate(this.updated_at)) {+ return null;+ }++ return formatDate(this.updated_at, 'PP HH:mm');+ }++ @computed('created_at') get createdAgo() {+ if (!isValidDate(this.created_at)) {+ return null;+ }++ return formatDistanceToNow(this.created_at);+ }++ @computed('created_at') get createdAt() {+ if (!isValidDate(this.created_at)) {+ return null;+ }++ return formatDate(this.created_at, 'PP HH:mm');+ }+}diff --git a/console/app/serializers/chat-channel.js b/console/app/serializers/chat-channel.jsindex a3cb2791..9ee32fab 100644--- a/console/app/serializers/chat-channel.js+++ b/console/app/serializers/chat-channel.js@@ -11,6 +11,7 @@ export default class ChatChannelSerializer extends ApplicationSerializer.extend(return {participants: { embedded: 'always' },messages: { embedded: 'always' },+ last_message: { embedded: 'always' },};}}diff --git a/console/tests/unit/models/chat-log-test.js b/console/tests/unit/models/chat-log-test.jsnew file mode 100644index 00000000..f52b4584--- /dev/null+++ b/console/tests/unit/models/chat-log-test.js@@ -0,0 +1,14 @@+import { module, test } from 'qunit';++import { setupTest } from '@fleetbase/console/tests/helpers';++module('Unit | Model | chat log', function (hooks) {+ setupTest(hooks);++ // Replace this with your real tests.+ test('it exists', function (assert) {+ let store = this.owner.lookup('service:store');+ let model = store.createRecord('chat-log', {});+ assert.ok(model);+ });+});