Skip to content

Modular logistics and supply chain operating system (LSOS)

created chat models

Doljinsuren Enkhbayar29bd3ce217ac
diff --git a/console/app/models/chat-attachment.js b/console/app/models/chat-attachment.js
new file mode 100644
index 00000000..2dd664e8
--- /dev/null
+++ b/console/app/models/chat-attachment.js
@@ -0,0 +1,22 @@
+import Model, { attr, belongsTo } from '@ember-data/model';
+
+export default class ChatAttachment extends Model {
+ /** @ids */
+ @attr('string') chat_channel_uuid;
+ @attr('string') sender_uuid;
+ @attr('string') file_uuid;
+
+ /** @relationships */
+ @belongsTo('user', { async: true }) sender;
+ @belongsTo('chat-channel', { async: true }) chatChannel;
+ @belongsTo('file', { async: true }) file;
+
+ /** @attributes */
+ @attr('string') chat_channel_uuid;
+ @attr('string') sender_uuid;
+ @attr('string') file_uuid;
+
+ /** @dates */
+ @attr('date') created_at;
+
+}
diff --git a/console/app/models/chat-channel.js b/console/app/models/chat-channel.js
new file mode 100644
index 00000000..205445cf
--- /dev/null
+++ b/console/app/models/chat-channel.js
@@ -0,0 +1,26 @@
+import Model, { attr, hasMany } from '@ember-data/model';
+import { computed } from '@ember/object';
+import { slugify } from 'ember-string';
+
+export default class ChatChannel extends Model {
+ /** @attributes */
+ @attr('string') name;
+ @attr('string') slug;
+ @attr meta;
+
+ /** @relationships */
+ @hasMany('chat-participant', { async: true }) participants;
+ @hasMany('chat-message', { async: true }) messages;
+ @hasMany('chat-attachment', { async: true }) attachments;
+ @hasMany('chat-presence', { async: true }) presences;
+
+ /** @computed */
+ @computed('name') get slugifiedName() {
+ return slugify(this.name);
+ }
+
+ /** @dates */
+ @attr('date') created_at;
+ @attr('date') updated_at;
+ @attr('date') deleted_at;
+}
diff --git a/console/app/models/chat-message.js b/console/app/models/chat-message.js
new file mode 100644
index 00000000..75565cf6
--- /dev/null
+++ b/console/app/models/chat-message.js
@@ -0,0 +1,16 @@
+import Model, { attr, belongsTo } from '@ember-data/model';
+
+export default class ChatMessage extends Model {
+ /** @attributes */
+ @attr('string') content;
+
+ /** @relationships */
+ @belongsTo('user', { async: true }) sender;
+ @belongsTo('chat-channel', { async: true }) chatChannel;
+
+ /** @dates */
+ @attr('date') created_at;
+ @attr('date') updated_at;
+ @attr('date') deleted_at;
+}
+
diff --git a/console/app/models/chat-participant.js b/console/app/models/chat-participant.js
new file mode 100644
index 00000000..d4a324ab
--- /dev/null
+++ b/console/app/models/chat-participant.js
@@ -0,0 +1,12 @@
+import Model, { belongsTo } from '@ember-data/model';
+
+export default class ChatParticipant extends Model {
+ /** @relationships */
+ @belongsTo('user', { async: true }) user;
+ @belongsTo('chat-channel', { async: true }) chatChannel;
+
+ /** @dates */
+ @attr('date') created_at;
+ @attr('date') updated_at;
+ @attr('date') deleted_at;
+}
\ No newline at end of file
diff --git a/console/app/models/chat-presence.js b/console/app/models/chat-presence.js
new file mode 100644
index 00000000..54024e67
--- /dev/null
+++ b/console/app/models/chat-presence.js
@@ -0,0 +1,16 @@
+import Model, { attr, belongsTo } from '@ember-data/model';
+
+export default class ChatPresence extends Model {
+ /** @attributes */
+ @attr('date') lastSeenAt;
+ @attr('boolean') isOnline;
+
+ /** @relationships */
+ @belongsTo('user', { async: true }) user;
+ @belongsTo('chat-channel', { async: true }) chatChannel;
+
+ /** @dates */
+ @attr('date') created_at;
+ @attr('date') updated_at;
+ @attr('date') deleted_at;
+}
\ No newline at end of file
diff --git a/console/app/models/chat-receipt.js b/console/app/models/chat-receipt.js
new file mode 100644
index 00000000..a13a0d91
--- /dev/null
+++ b/console/app/models/chat-receipt.js
@@ -0,0 +1,15 @@
+import Model, { attr, belongsTo } from '@ember-data/model';
+
+export default class ChatReceipt extends Model {
+ /** @attributes */
+ @attr('date') readAt;
+
+ /** @relationships */
+ @belongsTo('user', { async: true }) user;
+ @belongsTo('chat-message', { async: true }) chatMessage;
+
+ /** @dates */
+ @attr('date') created_at;
+ @attr('date') updated_at;
+ @attr('date') deleted_at;
+}
\ No newline at end of file
diff --git a/console/app/templates/console.hbs b/console/app/templates/console.hbs
index 7da8a9de..e8299be3 100644
--- a/console/app/templates/console.hbs
+++ b/console/app/templates/console.hbs
@@ -19,4 +19,5 @@
<EmberWormhole @to="view-header-actions">
<LocaleSelector class="mr-0.5" />
</EmberWormhole>
+<ChatContainer></ChatContainer>
<div id="console-wormhole" />
\ No newline at end of file