Skip to content

Commit

Permalink
showed all users in organization
Browse files Browse the repository at this point in the history
  • Loading branch information
doljko committed Apr 4, 2024
1 parent 6d1a594 commit 556ebe4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
23 changes: 19 additions & 4 deletions addon/components/chat-window.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@
{{n-a this.channel.name "Untitled Chat"}}
</div>
<div class="chat-window-controls">
<button type="button" class="chat-window-button" {{on "click" this.addParticipant}}>
<FaIcon @icon="user-plus" @size="sm" />
</button>
<DropdownButton class="chat-window-button" @icon="user-plus" @size="sm" @iconPrefix="fas" @triggerClass="hidden md:flex" as |dd|>
<div class="next-dd-menu mt-1 mx-0" aria-labelledby="user-menu">
<div class="p-1">

{{#each this.participants as |participant|}}
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.addParticipant participant)}}>
<div class="flex-1 flex flex-row items-center">
<div class="w-6">
<FaIcon @icon="desktop" />
</div>
<span>{{participant.name}}</span>
</div>
</a>
{{/each}}

</div>
</div>
</DropdownButton>
<button type="button" class="chat-window-button chat-window-close-button" {{on "click" this.closeChannel}}>
<FaIcon @icon="times" @size="sm" />
</button>
Expand Down Expand Up @@ -34,7 +49,7 @@
</Attach::Tooltip>
</div>
<div class="chat-message-content-bubble-container">
<div class="chat-message-content-bubble {{if (eq chatMessage.sender_uuid this.currentUser.id) "sender-bubble"}}">
<div class="chat-message-content-bubble {{if (eq chatMessage.sender_uuid this.currentUser.id) 'sender-bubble'}}">
{{chatMessage.content}}
</div>
<div class="chat-message-created-at">{{chatMessage.createdAgo}}</div>
Expand Down
17 changes: 16 additions & 1 deletion addon/components/chat-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import { action } from '@ember/object';
export default class ChatWindowComponent extends Component {
@service chat;
@service currentUser;
@service fetch;
@service store;
@tracked channel;
@tracked sender;
@tracked senderIsCreator;
@tracked participants;
@tracked pendingMessageContent = '';

constructor(owner, { channel }) {
super(...arguments);
this.channel = channel;
this.sender = this.getSenderFromParticipants(channel);
this.senderIsCreator = this.sender ? this.sender.id === channel.created_by_uuid : false;
this.participants = this.loadUsers()
}

@action sendMessage() {
Expand All @@ -27,7 +31,18 @@ export default class ChatWindowComponent extends Component {
this.chat.closeChannel(this.channel);
}

@action addParticipant() {}
@action loadUsers() {
return this.store.query('driver', { limit: 25});
}

@action addParticipant(participant){
console.log("Channels : ", this.channel, participant)
this.chat.addParticipant(this.channel, participant)
}

@action removeParticipant(participant) {
this.chat.removeParticipant(this.channel, participant);
}

@action positionWindow(chatWindowElement) {
const chatWindowWidth = chatWindowElement.offsetWidth;
Expand Down

0 comments on commit 556ebe4

Please sign in to comment.