From 0b1bf60b7176abf943088a9680cad2dff2c6a084 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Tue, 2 Apr 2024 15:17:31 +0800 Subject: [PATCH 01/24] created chat component --- addon/components/chat-container.hbs | 6 +++++ addon/components/chat-container.js | 6 +++++ addon/components/chat-window.hbs | 16 ++++++++++++ addon/components/chat-window.js | 18 +++++++++++++ app/components/chat-container.js | 1 + app/components/chat-window.js | 1 + .../components/chat-container-test.js | 26 +++++++++++++++++++ .../components/chat-window-test.js | 26 +++++++++++++++++++ 8 files changed, 100 insertions(+) create mode 100644 addon/components/chat-container.hbs create mode 100644 addon/components/chat-container.js create mode 100644 addon/components/chat-window.hbs create mode 100644 addon/components/chat-window.js create mode 100644 app/components/chat-container.js create mode 100644 app/components/chat-window.js create mode 100644 tests/integration/components/chat-container-test.js create mode 100644 tests/integration/components/chat-window-test.js diff --git a/addon/components/chat-container.hbs b/addon/components/chat-container.hbs new file mode 100644 index 0000000..8b1250c --- /dev/null +++ b/addon/components/chat-container.hbs @@ -0,0 +1,6 @@ +
+ Chat +{{#each this.chatChannels as |chatChannel|}} + +{{/each}} +
\ No newline at end of file diff --git a/addon/components/chat-container.js b/addon/components/chat-container.js new file mode 100644 index 0000000..3c2d9d8 --- /dev/null +++ b/addon/components/chat-container.js @@ -0,0 +1,6 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; + +export default class ChatContainerComponent extends Component { + @tracked chatChannels = [] +} diff --git a/addon/components/chat-window.hbs b/addon/components/chat-window.hbs new file mode 100644 index 0000000..729d6b0 --- /dev/null +++ b/addon/components/chat-window.hbs @@ -0,0 +1,16 @@ +
+ + {{#if (has-block)}} + {{yield}} + {{else}} + {{n-a @value}} + {{/if}} + + + {{#if this.isCopied}} + Copied! + {{else}} + Click to copy + {{/if}} + +
\ No newline at end of file diff --git a/addon/components/chat-window.js b/addon/components/chat-window.js new file mode 100644 index 0000000..978b54a --- /dev/null +++ b/addon/components/chat-window.js @@ -0,0 +1,18 @@ +import Component from '@glimmer/component'; + +export class ChatWindowComponent extends Component { + @service socket; + @service chat; + @tracked channel; + constructor(owner, { chatChannel }) { + super(...arguments); + this.channel = chatChannel; + this.listen(); + } + + listen() { + this.socket.listen(`chat.${this.channel.public_id}`, (event) => { + console.log('[chat event]', event); + }); + } + } \ No newline at end of file diff --git a/app/components/chat-container.js b/app/components/chat-container.js new file mode 100644 index 0000000..bda94a2 --- /dev/null +++ b/app/components/chat-container.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/ember-ui/components/chat-container'; diff --git a/app/components/chat-window.js b/app/components/chat-window.js new file mode 100644 index 0000000..e0b2abc --- /dev/null +++ b/app/components/chat-window.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/ember-ui/components/chat-window'; diff --git a/tests/integration/components/chat-container-test.js b/tests/integration/components/chat-container-test.js new file mode 100644 index 0000000..5a7061b --- /dev/null +++ b/tests/integration/components/chat-container-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | chat-container', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom().hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom().hasText('template block text'); + }); +}); diff --git a/tests/integration/components/chat-window-test.js b/tests/integration/components/chat-window-test.js new file mode 100644 index 0000000..10654d6 --- /dev/null +++ b/tests/integration/components/chat-window-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | chat-window', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom().hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom().hasText('template block text'); + }); +}); From f93c2c8238af32b205028eefa5bc050bdab6979f Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Tue, 2 Apr 2024 18:02:06 +0800 Subject: [PATCH 02/24] fixed did not appear button --- addon/components/chat-container.hbs | 8 ++++---- addon/components/chat-container.js | 17 ++++++++++++++++- addon/components/chat-window.hbs | 17 ++--------------- addon/components/chat-window.js | 4 +++- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/addon/components/chat-container.hbs b/addon/components/chat-container.hbs index 8b1250c..18fc8ac 100644 --- a/addon/components/chat-container.hbs +++ b/addon/components/chat-container.hbs @@ -1,6 +1,6 @@ -
+
Chat -{{#each this.chatChannels as |chatChannel|}} - -{{/each}} + {{#each this.chatChannels as |chatChannel|}} + + {{/each}}
\ No newline at end of file diff --git a/addon/components/chat-container.js b/addon/components/chat-container.js index 3c2d9d8..8a15ca9 100644 --- a/addon/components/chat-container.js +++ b/addon/components/chat-container.js @@ -1,6 +1,21 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; export default class ChatContainerComponent extends Component { - @tracked chatChannels = [] + @tracked chatChannels = [{ + title: "test", + public_id: "test", + chats: [ + { + owner: "Doljko", + message: "Hello" + } + ] + }]; + @tracked isVisible = false; + + @action openChatbox () { + this.isVisible = true + } } diff --git a/addon/components/chat-window.hbs b/addon/components/chat-window.hbs index 729d6b0..37aa775 100644 --- a/addon/components/chat-window.hbs +++ b/addon/components/chat-window.hbs @@ -1,16 +1,3 @@ -
- - {{#if (has-block)}} - {{yield}} - {{else}} - {{n-a @value}} - {{/if}} - - - {{#if this.isCopied}} - Copied! - {{else}} - Click to copy - {{/if}} - +
+
\ No newline at end of file diff --git a/addon/components/chat-window.js b/addon/components/chat-window.js index 978b54a..9db9725 100644 --- a/addon/components/chat-window.js +++ b/addon/components/chat-window.js @@ -1,6 +1,8 @@ import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { tracked } from '@glimmer/tracking'; -export class ChatWindowComponent extends Component { +export default class ChatWindowComponent extends Component { @service socket; @service chat; @tracked channel; From 340ae0ecfd0c5afd2257a038bb30a08a973e6531 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Wed, 3 Apr 2024 13:28:08 +0800 Subject: [PATCH 03/24] removed function --- addon/components/chat-window.hbs | 8 ++++++-- addon/components/chat-window.js | 19 +------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/addon/components/chat-window.hbs b/addon/components/chat-window.hbs index 37aa775..cdcd7fb 100644 --- a/addon/components/chat-window.hbs +++ b/addon/components/chat-window.hbs @@ -1,3 +1,7 @@ -
- +{{! template-lint-disable no-inline-styles }} +
+
Lanna
+
+ +
\ No newline at end of file diff --git a/addon/components/chat-window.js b/addon/components/chat-window.js index 9db9725..0687977 100644 --- a/addon/components/chat-window.js +++ b/addon/components/chat-window.js @@ -1,20 +1,3 @@ import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; -import { tracked } from '@glimmer/tracking'; -export default class ChatWindowComponent extends Component { - @service socket; - @service chat; - @tracked channel; - constructor(owner, { chatChannel }) { - super(...arguments); - this.channel = chatChannel; - this.listen(); - } - - listen() { - this.socket.listen(`chat.${this.channel.public_id}`, (event) => { - console.log('[chat event]', event); - }); - } - } \ No newline at end of file +export default class ChatWindowComponent extends Component {} From 5b8cb16413b019357d7d3c87124648fd8366aa0e Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Wed, 3 Apr 2024 14:12:09 +0800 Subject: [PATCH 04/24] demo ui --- addon/components/chat-window.hbs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addon/components/chat-window.hbs b/addon/components/chat-window.hbs index cdcd7fb..7fb614e 100644 --- a/addon/components/chat-window.hbs +++ b/addon/components/chat-window.hbs @@ -1,7 +1,15 @@ {{! template-lint-disable no-inline-styles }}
-
Lanna
-
- +
Lanna
+
+ hi,how are you? +
+
+
+ +
+
+
\ No newline at end of file From ec1fa316519086300ffe0062a55970302b77032e Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Wed, 3 Apr 2024 18:12:41 +0800 Subject: [PATCH 05/24] moved locale selector as tray componentm, created basic aht components --- addon/components/chat-container.hbs | 5 +- addon/components/chat-container.js | 18 +- addon/components/chat-tray.hbs | 27 ++ addon/components/chat-tray.js | 29 +++ addon/components/chat-window.hbs | 55 ++++- addon/components/chat-window.js | 38 ++- addon/components/layout/header.hbs | 2 + addon/components/locale-selector-tray.hbs | 30 +++ addon/components/locale-selector-tray.js | 144 +++++++++++ addon/components/notification-tray.hbs | 68 +++--- addon/styles/addon.css | 1 + addon/styles/components/attacher.css | 6 +- addon/styles/components/chat.css | 230 ++++++++++++++++++ addon/styles/components/dashboard.css | 2 +- addon/styles/components/drawer.css | 8 +- addon/styles/components/full-calendar.css | 12 +- addon/styles/components/input.css | 9 +- addon/styles/components/kanban.css | 10 +- addon/styles/components/navbar.css | 8 +- addon/styles/components/notification-tray.css | 4 +- addon/styles/components/otp-input.css | 12 +- addon/styles/components/table.css | 6 +- addon/styles/components/tabs.css | 2 +- addon/styles/components/timeline.css | 2 +- addon/styles/layout/legacy.css | 2 +- addon/styles/layout/next.css | 39 +-- app/components/chat-tray.js | 1 + app/components/locale-selector-tray.js | 1 + .../integration/components/chat-tray-test.js | 26 ++ .../components/locale-selector-tray-test.js | 26 ++ 30 files changed, 709 insertions(+), 114 deletions(-) create mode 100644 addon/components/chat-tray.hbs create mode 100644 addon/components/chat-tray.js create mode 100644 addon/components/locale-selector-tray.hbs create mode 100644 addon/components/locale-selector-tray.js create mode 100644 addon/styles/components/chat.css create mode 100644 app/components/chat-tray.js create mode 100644 app/components/locale-selector-tray.js create mode 100644 tests/integration/components/chat-tray-test.js create mode 100644 tests/integration/components/locale-selector-tray-test.js diff --git a/addon/components/chat-container.hbs b/addon/components/chat-container.hbs index 18fc8ac..26819fe 100644 --- a/addon/components/chat-container.hbs +++ b/addon/components/chat-container.hbs @@ -1,6 +1,5 @@ -
- Chat - {{#each this.chatChannels as |chatChannel|}} +
+ {{#each this.chat.openChannels as |chatChannel|}} {{/each}}
\ No newline at end of file diff --git a/addon/components/chat-container.js b/addon/components/chat-container.js index 8a15ca9..146800d 100644 --- a/addon/components/chat-container.js +++ b/addon/components/chat-container.js @@ -1,21 +1,11 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; import { action } from '@ember/object'; export default class ChatContainerComponent extends Component { - @tracked chatChannels = [{ - title: "test", - public_id: "test", - chats: [ - { - owner: "Doljko", - message: "Hello" - } - ] - }]; - @tracked isVisible = false; - - @action openChatbox () { - this.isVisible = true + @service chat; + constructor(owner) { + super(...arguments); } } diff --git a/addon/components/chat-tray.hbs b/addon/components/chat-tray.hbs new file mode 100644 index 0000000..1c24f18 --- /dev/null +++ b/addon/components/chat-tray.hbs @@ -0,0 +1,27 @@ +
+ + +
+ + {{!-- {{#if this.notifications.length}} +
{{this.notifications.length}}
+ {{/if}} --}} +
+
+ +
+
+
+
+ {{#each this.channels as |channel|}} + + {{/each}} +
+
+
+
+
\ No newline at end of file diff --git a/addon/components/chat-tray.js b/addon/components/chat-tray.js new file mode 100644 index 0000000..2bbcb35 --- /dev/null +++ b/addon/components/chat-tray.js @@ -0,0 +1,29 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { task } from 'ember-concurrency'; + +export default class ChatTrayComponent extends Component { + @service chat; + @service socket; + @tracked channels = []; + + constructor(owner) { + super(...arguments); + this.chat.loadChannels.perform({ + withChannels: (channels) => { + this.channels = channels; + }, + }); + } + + @action openChannel(chatChannelRecord) { + this.chat.openChannel(chatChannelRecord); + } + + @action startChat() { + const chatChannelRecord = this.chat.createChatChannel(); + this.openChannel(chatChannelRecord); + } +} diff --git a/addon/components/chat-window.hbs b/addon/components/chat-window.hbs index 7fb614e..354e24f 100644 --- a/addon/components/chat-window.hbs +++ b/addon/components/chat-window.hbs @@ -1,15 +1,46 @@ -{{! template-lint-disable no-inline-styles }} -
-
Lanna
-
- hi,how are you? -
-
-
- -
-
- + +
+
+
+ {{#each this.channel.participants as |chatParticipant|}} +
{{chatParticipant.name}}
+ {{/each}} +
+
+
+ {{#each this.channel.messages as |chatMessage|}} +
+
+ {{this.user.name}} +
{{chatMessage.sender.name}}
+
+
+
+ {{chatMessage.content}} +
+
{{chatMessage.createdAgo}}
+
+
+ {{/each}} +
+
+
+
+