-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new chat component * Fix lint errors
- Loading branch information
1 parent
1ab59a3
commit 465599d
Showing
8 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.chat-container { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.full-chat { | ||
margin-right: 40px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div *ngIf="isExpanded.getValue(); then expandedBlock; else collapsedBlock"></div> | ||
|
||
<ng-template #collapsedBlock> | ||
<dx-chat | ||
id="chat" | ||
width="100%" | ||
height="100%" | ||
[showDayHeaders]="false" | ||
[items]="previewMessages" | ||
[user]="johnDoe" | ||
> | ||
</dx-chat> | ||
|
||
</ng-template> | ||
|
||
<ng-template #expandedBlock> | ||
<div class="options-block"> | ||
<dx-check-box | ||
text="Show Typing Indicator" | ||
[value]="showTyping" | ||
(onValueChanged)="toogleTyping($event)" | ||
></dx-check-box> | ||
<dx-check-box | ||
text="Show Alert" | ||
[value]="showAlert" | ||
(onValueChanged)="toogleErrors($event)" | ||
></dx-check-box> | ||
</div> | ||
<div class="chat-container"> | ||
<dx-chat | ||
class="full-chat" | ||
width="100%" | ||
height="100%" | ||
[typingUsers]="showTyping ? [supportAgent] : []" | ||
[items]="messages" | ||
[user]="johnDoe" | ||
> | ||
<dxi-chat-alert *ngIf="showAlert" message="You have been disconnected"></dxi-chat-alert> | ||
</dx-chat> | ||
<dx-chat | ||
class="empty-chat" | ||
width="100%" | ||
height="auto" | ||
> | ||
<dxi-chat-alert *ngIf="showAlert" message="You have been disconnected"></dxi-chat-alert> | ||
</dx-chat> | ||
</div> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-chat', | ||
templateUrl: './chat.component.html', | ||
styleUrls: ['./chat.component.css'] | ||
}) | ||
export class ChatComponent implements OnDestroy { | ||
isExpanded = new BehaviorSubject<boolean>(false); | ||
widgetGroup = 'chat'; | ||
|
||
showTyping = true; | ||
showAlert = true; | ||
date = new Date('October 11, 2024, 11:51:00'); | ||
|
||
johnDoe = { | ||
id: 'c94c0e76-fb49-4b9b-8f07-9f93ed93b4f3', | ||
name: 'John Doe' | ||
}; | ||
|
||
supportAgent = { | ||
id: 'd16d1a4c-5c67-4e20-b70e-2991c22747c3', | ||
name: 'Support Agent' | ||
}; | ||
|
||
previewMessages = [ | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime()), | ||
author: this.supportAgent, | ||
text: 'Hello, John! How can I assist you today?' | ||
}, | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime() + 2 * 60000), | ||
author: this.johnDoe, | ||
text: 'Hi, I\'m having trouble accessing my account.' | ||
} | ||
]; | ||
|
||
messages = [ | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime()), | ||
author: this.supportAgent, | ||
text: 'Hello, John! How can I assist you today?' | ||
}, | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime() + 2 * 60000), | ||
author: this.johnDoe, | ||
text: 'Hi, I\'m having trouble accessing my account.\nIt says my password is incorrect.' | ||
}, | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime() + 2 * 60000), | ||
author: this.johnDoe, | ||
text: 'My UserID is john.doe1357' | ||
}, | ||
{ | ||
timestamp: new Date().setTime(this.date.getTime() + 10 * 60000), | ||
author: this.supportAgent, | ||
text: '✅ Instructions to restore access have been sent to the email address registered to your account.' | ||
} | ||
]; | ||
|
||
toogleTyping() { | ||
this.showTyping = !this.showTyping; | ||
} | ||
|
||
toogleErrors() { | ||
this.showAlert = !this.showAlert; | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.isExpanded.unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters