@volo/abp.ng.chat 5.0.0-rc.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/config/package.json +5 -5
- package/esm2020/config/chat-config.module.mjs +36 -0
- package/esm2020/config/components/chat-icon.component.mjs +79 -0
- package/esm2020/config/enums/index.mjs +3 -0
- package/esm2020/config/enums/policy-names.mjs +2 -0
- package/esm2020/config/enums/route-names.mjs +2 -0
- package/esm2020/config/providers/index.mjs +3 -0
- package/esm2020/config/providers/nav-item.provider.mjs +19 -0
- package/esm2020/config/providers/route.provider.mjs +20 -0
- package/esm2020/config/public-api.mjs +6 -0
- package/esm2020/config/services/chat-config.service.mjs +97 -0
- package/esm2020/config/volo-abp.ng.chat-config.mjs +5 -0
- package/esm2020/lib/chat-routing.module.mjs +39 -0
- package/esm2020/lib/chat.module.mjs +32 -0
- package/esm2020/lib/components/chat-contacts.component.mjs +111 -0
- package/esm2020/lib/components/chat.component.mjs +223 -0
- package/esm2020/lib/components/conversation-avatar.component.mjs +85 -0
- package/esm2020/lib/components/index.mjs +4 -0
- package/esm2020/lib/enums/chat-message-side.mjs +6 -0
- package/esm2020/lib/models/chat-contact-dto.mjs +12 -0
- package/esm2020/lib/models/chat-conversation-dto.mjs +12 -0
- package/esm2020/lib/models/chat-message-dto.mjs +12 -0
- package/esm2020/lib/models/chat-target-user-info.mjs +12 -0
- package/esm2020/lib/models/get-contacts-input.mjs +12 -0
- package/esm2020/lib/models/get-conversation-input.mjs +7 -0
- package/esm2020/lib/models/mark-conversation-as-read-input.mjs +12 -0
- package/esm2020/lib/models/send-message-input.mjs +12 -0
- package/esm2020/lib/services/contact.service.mjs +20 -0
- package/esm2020/lib/services/conversation.service.mjs +26 -0
- package/esm2020/proxy/lib/index.mjs +5 -0
- package/esm2020/proxy/lib/proxy/volo/chat/conversations/conversation.service.mjs +34 -0
- package/esm2020/proxy/lib/proxy/volo/chat/conversations/index.mjs +3 -0
- package/esm2020/proxy/lib/proxy/volo/chat/conversations/models.mjs +2 -0
- package/esm2020/proxy/lib/proxy/volo/chat/messages/chat-message-side.enum.mjs +8 -0
- package/esm2020/proxy/lib/proxy/volo/chat/messages/index.mjs +3 -0
- package/esm2020/proxy/lib/proxy/volo/chat/messages/models.mjs +2 -0
- package/esm2020/proxy/lib/proxy/volo/chat/settings/index.mjs +3 -0
- package/esm2020/proxy/lib/proxy/volo/chat/settings/models.mjs +2 -0
- package/esm2020/proxy/lib/proxy/volo/chat/settings/settings.service.mjs +24 -0
- package/esm2020/proxy/lib/proxy/volo/chat/users/contact.service.mjs +28 -0
- package/esm2020/proxy/lib/proxy/volo/chat/users/index.mjs +3 -0
- package/esm2020/proxy/lib/proxy/volo/chat/users/models.mjs +2 -0
- package/esm2020/proxy/public-api.mjs +2 -0
- package/esm2020/proxy/volo-abp.ng.chat-proxy.mjs +5 -0
- package/esm2020/public-api.mjs +3 -0
- package/esm2020/volo-abp.ng.chat.mjs +5 -0
- package/fesm2015/{volo-abp.ng.chat-config.js → volo-abp.ng.chat-config.mjs} +37 -38
- package/fesm2015/volo-abp.ng.chat-config.mjs.map +1 -0
- package/fesm2015/{volo-abp.ng.chat-proxy.js → volo-abp.ng.chat-proxy.mjs} +12 -12
- package/fesm2015/volo-abp.ng.chat-proxy.mjs.map +1 -0
- package/fesm2015/volo-abp.ng.chat.mjs +504 -0
- package/fesm2015/volo-abp.ng.chat.mjs.map +1 -0
- package/fesm2020/volo-abp.ng.chat-config.mjs +236 -0
- package/fesm2020/volo-abp.ng.chat-config.mjs.map +1 -0
- package/fesm2020/volo-abp.ng.chat-proxy.mjs +92 -0
- package/fesm2020/volo-abp.ng.chat-proxy.mjs.map +1 -0
- package/fesm2020/volo-abp.ng.chat.mjs +519 -0
- package/fesm2020/volo-abp.ng.chat.mjs.map +1 -0
- package/package.json +35 -10
- package/proxy/package.json +5 -5
- package/proxy/src/lib/proxy/README.md +17 -0
- package/bundles/volo-abp.ng.chat-config.umd.js +0 -1
- package/bundles/volo-abp.ng.chat-proxy.umd.js +0 -1
- package/bundles/volo-abp.ng.chat.umd.js +0 -1
- package/esm2015/config/chat-config.module.js +0 -1
- package/esm2015/config/components/chat-icon.component.js +0 -1
- package/esm2015/config/enums/index.js +0 -1
- package/esm2015/config/enums/policy-names.js +0 -1
- package/esm2015/config/enums/route-names.js +0 -1
- package/esm2015/config/providers/index.js +0 -1
- package/esm2015/config/providers/nav-item.provider.js +0 -1
- package/esm2015/config/providers/route.provider.js +0 -1
- package/esm2015/config/public-api.js +0 -1
- package/esm2015/config/services/chat-config.service.js +0 -1
- package/esm2015/config/volo-abp.ng.chat-config.js +0 -1
- package/esm2015/lib/chat-routing.module.js +0 -1
- package/esm2015/lib/chat.module.js +0 -1
- package/esm2015/lib/components/chat-contacts.component.js +0 -1
- package/esm2015/lib/components/chat.component.js +0 -1
- package/esm2015/lib/components/conversation-avatar.component.js +0 -1
- package/esm2015/lib/components/index.js +0 -1
- package/esm2015/lib/enums/chat-message-side.js +0 -1
- package/esm2015/lib/models/chat-contact-dto.js +0 -1
- package/esm2015/lib/models/chat-conversation-dto.js +0 -1
- package/esm2015/lib/models/chat-message-dto.js +0 -1
- package/esm2015/lib/models/chat-target-user-info.js +0 -1
- package/esm2015/lib/models/get-contacts-input.js +0 -1
- package/esm2015/lib/models/get-conversation-input.js +0 -1
- package/esm2015/lib/models/mark-conversation-as-read-input.js +0 -1
- package/esm2015/lib/models/send-message-input.js +0 -1
- package/esm2015/lib/services/contact.service.js +0 -1
- package/esm2015/lib/services/conversation.service.js +0 -1
- package/esm2015/proxy/lib/index.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/conversations/conversation.service.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/conversations/index.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/conversations/models.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/messages/chat-message-side.enum.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/messages/index.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/messages/models.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/settings/index.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/settings/models.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/settings/settings.service.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/users/contact.service.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/users/index.js +0 -1
- package/esm2015/proxy/lib/proxy/volo/chat/users/models.js +0 -1
- package/esm2015/proxy/public-api.js +0 -1
- package/esm2015/proxy/volo-abp.ng.chat-proxy.js +0 -1
- package/esm2015/public-api.js +0 -1
- package/esm2015/volo-abp.ng.chat.js +0 -1
- package/fesm2015/volo-abp.ng.chat.js +0 -525
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import * as i3 from '@abp/ng.core';
|
|
2
|
+
import { trackBy, SubscriptionService, RouterOutletComponent, AuthGuard, PermissionGuard, ReplaceableRouteContainerComponent, LazyModuleFactory, CoreModule } from '@abp/ng.core';
|
|
3
|
+
import { ThemeSharedModule } from '@abp/ng.theme.shared';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { Injectable, Component, Input, EventEmitter, Output, ViewChild, NgModule } from '@angular/core';
|
|
6
|
+
import * as i1 from '@angular/router';
|
|
7
|
+
import { RouterModule } from '@angular/router';
|
|
8
|
+
import * as i2 from '@volo/abp.ng.chat/config';
|
|
9
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
10
|
+
import { finalize, debounceTime, takeUntil } from 'rxjs/operators';
|
|
11
|
+
import * as i6 from '@angular/common';
|
|
12
|
+
import * as i7 from '@angular/forms';
|
|
13
|
+
|
|
14
|
+
var ChatMessageSide;
|
|
15
|
+
(function (ChatMessageSide) {
|
|
16
|
+
ChatMessageSide[ChatMessageSide["Sender"] = 1] = "Sender";
|
|
17
|
+
ChatMessageSide[ChatMessageSide["Receiver"] = 2] = "Receiver";
|
|
18
|
+
})(ChatMessageSide || (ChatMessageSide = {}));
|
|
19
|
+
|
|
20
|
+
class ConversationService {
|
|
21
|
+
constructor(restService) {
|
|
22
|
+
this.restService = restService;
|
|
23
|
+
this.apiName = 'Chat';
|
|
24
|
+
}
|
|
25
|
+
sendMessageByInput(body) {
|
|
26
|
+
return this.restService.request({ url: '/api/chat/conversation/send-message', method: 'POST', body }, { apiName: this.apiName });
|
|
27
|
+
}
|
|
28
|
+
getConversationByInput(params = {}) {
|
|
29
|
+
return this.restService.request({ url: '/api/chat/conversation/conversation', method: 'GET', params }, { apiName: this.apiName });
|
|
30
|
+
}
|
|
31
|
+
markConversationAsReadByInput(body) {
|
|
32
|
+
return this.restService.request({ url: '/api/chat/conversation/mark-conversation-as-read', method: 'POST', body }, { apiName: this.apiName });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
ConversationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ConversationService, deps: [{ token: i3.RestService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
36
|
+
ConversationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ConversationService, providedIn: 'root' });
|
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ConversationService, decorators: [{
|
|
38
|
+
type: Injectable,
|
|
39
|
+
args: [{ providedIn: 'root' }]
|
|
40
|
+
}], ctorParameters: function () { return [{ type: i3.RestService }]; } });
|
|
41
|
+
|
|
42
|
+
class ContactService {
|
|
43
|
+
constructor(restService) {
|
|
44
|
+
this.restService = restService;
|
|
45
|
+
this.apiName = 'Chat';
|
|
46
|
+
}
|
|
47
|
+
getContactsByInput(params = {}) {
|
|
48
|
+
return this.restService.request({ url: '/api/chat/contact/contacts', method: 'GET', params }, { apiName: this.apiName });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
ContactService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, deps: [{ token: i3.RestService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
52
|
+
ContactService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, providedIn: 'root' });
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, decorators: [{
|
|
54
|
+
type: Injectable,
|
|
55
|
+
args: [{ providedIn: 'root' }]
|
|
56
|
+
}], ctorParameters: function () { return [{ type: i3.RestService }]; } });
|
|
57
|
+
|
|
58
|
+
class ChatContactDto {
|
|
59
|
+
constructor(initialValues = {}) {
|
|
60
|
+
if (initialValues) {
|
|
61
|
+
for (const key in initialValues) {
|
|
62
|
+
if (initialValues.hasOwnProperty(key)) {
|
|
63
|
+
this[key] = initialValues[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const avatarStyles = [
|
|
71
|
+
{ color: '#ffffff', backgroundColor: '#3cb160' },
|
|
72
|
+
{ color: '#ffffff', backgroundColor: '#c373cc' },
|
|
73
|
+
{ color: '#ffffff', backgroundColor: '#2b78b3' },
|
|
74
|
+
{ color: '#ffffff', backgroundColor: '#6ac79a' },
|
|
75
|
+
{ color: '#ffffff', backgroundColor: '#aeb140' },
|
|
76
|
+
{ color: '#ffffff', backgroundColor: '#b773c0' },
|
|
77
|
+
{ color: '#ffffff', backgroundColor: '#e16d7a' },
|
|
78
|
+
{ color: '#ffffff', backgroundColor: '#ffac2a' },
|
|
79
|
+
{ color: '#ffffff', backgroundColor: '#21bbc7' },
|
|
80
|
+
{ color: '#ffffff', backgroundColor: '#59ab95' },
|
|
81
|
+
];
|
|
82
|
+
class ConversationAvatarComponent {
|
|
83
|
+
get avatarText() {
|
|
84
|
+
if (!this.contact || !this.contact.username)
|
|
85
|
+
return;
|
|
86
|
+
if (this.contact.name && this.contact.surname)
|
|
87
|
+
return this.contact.name[0] + this.contact.surname[0];
|
|
88
|
+
if (this.contact.name)
|
|
89
|
+
return this.contact.name.slice(0, 2);
|
|
90
|
+
return this.contact.username.slice(0, 2);
|
|
91
|
+
}
|
|
92
|
+
get avatarBgStyle() {
|
|
93
|
+
if (!this.contact || !this.contact.username)
|
|
94
|
+
return;
|
|
95
|
+
let hash = 0;
|
|
96
|
+
for (let i = 0; i < this.contact.username.length; i++) {
|
|
97
|
+
hash = this.contact.username.charCodeAt(i) + ((hash << 5) - hash);
|
|
98
|
+
}
|
|
99
|
+
return avatarStyles[Math.abs(hash % 10)];
|
|
100
|
+
}
|
|
101
|
+
get isSmall() {
|
|
102
|
+
return typeof this.small === 'string' || this.small;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
ConversationAvatarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ConversationAvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
106
|
+
ConversationAvatarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: ConversationAvatarComponent, selector: "abp-conversation-avatar", inputs: { contact: "contact", small: "small" }, ngImport: i0, template: `<div
|
|
107
|
+
class="avatar mx-auto rounded-circle"
|
|
108
|
+
[class.small]="isSmall"
|
|
109
|
+
[ngStyle]="avatarBgStyle"
|
|
110
|
+
>
|
|
111
|
+
{{ avatarText }}
|
|
112
|
+
</div>`, isInline: true, styles: [".avatar{height:40px;width:40px;line-height:40px;font-size:16px;font-weight:700;text-align:center;text-transform:uppercase}.avatar.small{height:27px;width:27px;line-height:27px;font-size:14px}\n"], directives: [{ type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ConversationAvatarComponent, decorators: [{
|
|
114
|
+
type: Component,
|
|
115
|
+
args: [{
|
|
116
|
+
selector: 'abp-conversation-avatar',
|
|
117
|
+
template: `<div
|
|
118
|
+
class="avatar mx-auto rounded-circle"
|
|
119
|
+
[class.small]="isSmall"
|
|
120
|
+
[ngStyle]="avatarBgStyle"
|
|
121
|
+
>
|
|
122
|
+
{{ avatarText }}
|
|
123
|
+
</div>`,
|
|
124
|
+
styles: [
|
|
125
|
+
`
|
|
126
|
+
.avatar {
|
|
127
|
+
height: 40px;
|
|
128
|
+
width: 40px;
|
|
129
|
+
line-height: 40px;
|
|
130
|
+
font-size: 16px;
|
|
131
|
+
font-weight: 700;
|
|
132
|
+
text-align: center;
|
|
133
|
+
text-transform: uppercase;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.avatar.small {
|
|
137
|
+
height: 27px;
|
|
138
|
+
width: 27px;
|
|
139
|
+
line-height: 27px;
|
|
140
|
+
font-size: 14px;
|
|
141
|
+
}
|
|
142
|
+
`,
|
|
143
|
+
],
|
|
144
|
+
}]
|
|
145
|
+
}], propDecorators: { contact: [{
|
|
146
|
+
type: Input
|
|
147
|
+
}], small: [{
|
|
148
|
+
type: Input
|
|
149
|
+
}] } });
|
|
150
|
+
|
|
151
|
+
class ChatContactsComponent {
|
|
152
|
+
constructor(contactService, chatConfigService, subscription) {
|
|
153
|
+
this.contactService = contactService;
|
|
154
|
+
this.chatConfigService = chatConfigService;
|
|
155
|
+
this.subscription = subscription;
|
|
156
|
+
this.selected = new EventEmitter();
|
|
157
|
+
this.allContacts = [];
|
|
158
|
+
this.selectedContact = {};
|
|
159
|
+
this.filter = '';
|
|
160
|
+
this.getContactName = getContactName;
|
|
161
|
+
this.trackByUserId = trackBy('userId');
|
|
162
|
+
}
|
|
163
|
+
get contacts() {
|
|
164
|
+
return this.allContacts
|
|
165
|
+
.filter((contact) => contact.lastMessage)
|
|
166
|
+
.sort((a, b) => new Date(a.lastMessageDate).valueOf() > new Date(b.lastMessageDate).valueOf() ? -1 : 1);
|
|
167
|
+
}
|
|
168
|
+
get otherContacts() {
|
|
169
|
+
return this.allContacts.filter((contact) => !contact.lastMessage);
|
|
170
|
+
}
|
|
171
|
+
listenToNewMessages() {
|
|
172
|
+
this.subscription.addOne(this.chatConfigService.message$, (message = {}) => {
|
|
173
|
+
const index = this.allContacts.findIndex((cont) => cont.userId === message.senderUserId);
|
|
174
|
+
const contact = {
|
|
175
|
+
userId: message.senderUserId,
|
|
176
|
+
username: message.senderUsername,
|
|
177
|
+
name: message.senderName,
|
|
178
|
+
surname: message.senderSurname,
|
|
179
|
+
lastMessage: message.text,
|
|
180
|
+
unreadMessageCount: 1,
|
|
181
|
+
lastMessageDate: new Date(),
|
|
182
|
+
lastMessageSide: ChatMessageSide.Receiver,
|
|
183
|
+
};
|
|
184
|
+
if (index > -1) {
|
|
185
|
+
this.allContacts[index] = {
|
|
186
|
+
...contact,
|
|
187
|
+
unreadMessageCount: this.selectedContact.userId === this.allContacts[index].userId
|
|
188
|
+
? 0
|
|
189
|
+
: this.allContacts[index].unreadMessageCount + 1,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
else if (!this.filter) {
|
|
193
|
+
this.allContacts.push(contact);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
ngOnInit() {
|
|
198
|
+
this.get(() => {
|
|
199
|
+
this.selectContact(this.allContacts.length ? this.allContacts[0] : {});
|
|
200
|
+
this.listenToNewMessages();
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
ngOnDestroy() { }
|
|
204
|
+
get(onSuccess) {
|
|
205
|
+
this.contactService
|
|
206
|
+
.getContactsByInput({ includeOtherContacts: !!this.filter, filter: this.filter })
|
|
207
|
+
.subscribe((res) => {
|
|
208
|
+
if (!res.length)
|
|
209
|
+
return;
|
|
210
|
+
this.allContacts = res;
|
|
211
|
+
if (onSuccess)
|
|
212
|
+
onSuccess();
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
selectContact(contact) {
|
|
216
|
+
this.selectedContact = contact;
|
|
217
|
+
this.selected.emit(contact);
|
|
218
|
+
}
|
|
219
|
+
changeLastMessageOfSelectedContact(message) {
|
|
220
|
+
this.selectedContact.lastMessage = message;
|
|
221
|
+
this.selectedContact.lastMessageDate = new Date();
|
|
222
|
+
const index = this.allContacts.findIndex((contact) => contact.userId === this.selectedContact.userId);
|
|
223
|
+
this.allContacts[index] = this.selectedContact;
|
|
224
|
+
}
|
|
225
|
+
markSelectedContactAsRead() {
|
|
226
|
+
this.selectedContact.unreadMessageCount = 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
ChatContactsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatContactsComponent, deps: [{ token: ContactService }, { token: i2.ChatConfigService }, { token: i3.SubscriptionService }], target: i0.ɵɵFactoryTarget.Component });
|
|
230
|
+
ChatContactsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: ChatContactsComponent, selector: "abp-chat-contacts", outputs: { selected: "selected" }, providers: [SubscriptionService], ngImport: i0, template: "<div class=\"border-end\">\r\n <div class=\"p-3 bg-light border-bottom\">\r\n <div class=\"form-row\">\r\n <div class=\"col\">\r\n <input\r\n id=\"contacts-filter\"\r\n type=\"search\"\r\n class=\"form-control form-control-sm\"\r\n autocomplete=\"off\"\r\n spellcheck=\"false\"\r\n [(ngModel)]=\"filter\"\r\n [placeholder]=\"'Chat::SearchInContacts' | abpLocalization\"\r\n [attr.aria-label]=\"'Chat::SearchInContacts' | abpLocalization\"\r\n (input.debounce)=\"get()\"\r\n />\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"messages-box m-0 p-0\">\r\n <div class=\"list-group rounded-0\" id=\"contact-list\">\r\n <ng-container\r\n *ngFor=\"let contact of contacts; let i = index; trackBy: trackByUserId\"\r\n [ngTemplateOutlet]=\"contactTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: contact, index: i }\"\r\n >\r\n </ng-container>\r\n <div\r\n *ngIf=\"otherContacts.length\"\r\n class=\"list-group-item px-2 py-1 bg-light text-muted text-center font-size-sm text-uppercase border-start-0 border-end-0\"\r\n >\r\n <small>{{ 'Chat::OtherContacts' | abpLocalization }}</small>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let contact of otherContacts; let i = index; trackBy: trackByUserId\"\r\n [ngTemplateOutlet]=\"contactTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: contact, index: i }\"\r\n >\r\n </ng-container>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<ng-template #contactTemplate let-contact let-i=\"index\">\r\n <a\r\n (click)=\"selectContact(contact)\"\r\n class=\"chat-contact list-group-item list-group-item-action px-4 rounded-0 border-start-0 pointer {{\r\n selectedContact.userId === contact.userId ? 'active text-white' : ''\r\n }}\"\r\n ><div class=\"media\">\r\n <abp-conversation-avatar [contact]=\"contact\"></abp-conversation-avatar>\r\n <div class=\"media-body ms-2 d-none d-md-block\">\r\n <div class=\"d-flex align-items-center justify-content-between mb-1\">\r\n <h6 class=\"mb-0\">\r\n <small *ngIf=\"contact.unreadMessageCount\" class=\"badge badge-success me-1\">{{\r\n contact.unreadMessageCount\r\n }}</small\r\n >{{ getContactName(contact) }}\r\n </h6>\r\n <small class=\"small font-weight-bold last-message-date\">{{\r\n contact.lastMessageDate | date\r\n }}</small>\r\n </div>\r\n <p class=\"mb-0 text-small last-message\">\r\n {{\r\n contact.lastMessage?.length > 24\r\n ? (contact.lastMessage | slice: 0:23) + '...'\r\n : contact.lastMessage\r\n }}\r\n </p>\r\n </div>\r\n </div>\r\n </a>\r\n</ng-template>\r\n", styles: [".messages-box{overflow-y:scroll;max-height:calc(100vh - 254.34px)}\n"], components: [{ type: ConversationAvatarComponent, selector: "abp-conversation-avatar", inputs: ["contact", "small"] }], directives: [{ type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.InputEventDebounceDirective, selector: "[input.debounce]", inputs: ["debounce"], outputs: ["input.debounce"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "abpLocalization": i3.LocalizationPipe, "date": i6.DatePipe, "slice": i6.SlicePipe } });
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatContactsComponent, decorators: [{
|
|
232
|
+
type: Component,
|
|
233
|
+
args: [{ selector: 'abp-chat-contacts', styles: [
|
|
234
|
+
`
|
|
235
|
+
.messages-box {
|
|
236
|
+
overflow-y: scroll;
|
|
237
|
+
max-height: calc(100vh - 254.34px);
|
|
238
|
+
}
|
|
239
|
+
`,
|
|
240
|
+
], providers: [SubscriptionService], template: "<div class=\"border-end\">\r\n <div class=\"p-3 bg-light border-bottom\">\r\n <div class=\"form-row\">\r\n <div class=\"col\">\r\n <input\r\n id=\"contacts-filter\"\r\n type=\"search\"\r\n class=\"form-control form-control-sm\"\r\n autocomplete=\"off\"\r\n spellcheck=\"false\"\r\n [(ngModel)]=\"filter\"\r\n [placeholder]=\"'Chat::SearchInContacts' | abpLocalization\"\r\n [attr.aria-label]=\"'Chat::SearchInContacts' | abpLocalization\"\r\n (input.debounce)=\"get()\"\r\n />\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"messages-box m-0 p-0\">\r\n <div class=\"list-group rounded-0\" id=\"contact-list\">\r\n <ng-container\r\n *ngFor=\"let contact of contacts; let i = index; trackBy: trackByUserId\"\r\n [ngTemplateOutlet]=\"contactTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: contact, index: i }\"\r\n >\r\n </ng-container>\r\n <div\r\n *ngIf=\"otherContacts.length\"\r\n class=\"list-group-item px-2 py-1 bg-light text-muted text-center font-size-sm text-uppercase border-start-0 border-end-0\"\r\n >\r\n <small>{{ 'Chat::OtherContacts' | abpLocalization }}</small>\r\n </div>\r\n <ng-container\r\n *ngFor=\"let contact of otherContacts; let i = index; trackBy: trackByUserId\"\r\n [ngTemplateOutlet]=\"contactTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: contact, index: i }\"\r\n >\r\n </ng-container>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<ng-template #contactTemplate let-contact let-i=\"index\">\r\n <a\r\n (click)=\"selectContact(contact)\"\r\n class=\"chat-contact list-group-item list-group-item-action px-4 rounded-0 border-start-0 pointer {{\r\n selectedContact.userId === contact.userId ? 'active text-white' : ''\r\n }}\"\r\n ><div class=\"media\">\r\n <abp-conversation-avatar [contact]=\"contact\"></abp-conversation-avatar>\r\n <div class=\"media-body ms-2 d-none d-md-block\">\r\n <div class=\"d-flex align-items-center justify-content-between mb-1\">\r\n <h6 class=\"mb-0\">\r\n <small *ngIf=\"contact.unreadMessageCount\" class=\"badge badge-success me-1\">{{\r\n contact.unreadMessageCount\r\n }}</small\r\n >{{ getContactName(contact) }}\r\n </h6>\r\n <small class=\"small font-weight-bold last-message-date\">{{\r\n contact.lastMessageDate | date\r\n }}</small>\r\n </div>\r\n <p class=\"mb-0 text-small last-message\">\r\n {{\r\n contact.lastMessage?.length > 24\r\n ? (contact.lastMessage | slice: 0:23) + '...'\r\n : contact.lastMessage\r\n }}\r\n </p>\r\n </div>\r\n </div>\r\n </a>\r\n</ng-template>\r\n" }]
|
|
241
|
+
}], ctorParameters: function () { return [{ type: ContactService }, { type: i2.ChatConfigService }, { type: i3.SubscriptionService }]; }, propDecorators: { selected: [{
|
|
242
|
+
type: Output
|
|
243
|
+
}] } });
|
|
244
|
+
function getContactName({ name, surname, username }) {
|
|
245
|
+
if (!name && !surname)
|
|
246
|
+
return username;
|
|
247
|
+
return `${name || ''} ${surname || ''}`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const now = new Date();
|
|
251
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()).valueOf();
|
|
252
|
+
class ChatComponent {
|
|
253
|
+
constructor(conversationService, chatConfigService, configState, httpWaitService) {
|
|
254
|
+
this.conversationService = conversationService;
|
|
255
|
+
this.chatConfigService = chatConfigService;
|
|
256
|
+
this.configState = configState;
|
|
257
|
+
this.httpWaitService = httpWaitService;
|
|
258
|
+
this.selectedContact = {};
|
|
259
|
+
this.unreadMessageCount = 0;
|
|
260
|
+
this.userMessages = new Map();
|
|
261
|
+
this.chatMessageSide = ChatMessageSide;
|
|
262
|
+
this.trackByMessageDate = trackBy('messageDate');
|
|
263
|
+
this.destroy$ = new Subject();
|
|
264
|
+
this.onScroll = (event) => {
|
|
265
|
+
if (this.allMessagesLoaded ||
|
|
266
|
+
this.pagingLoading ||
|
|
267
|
+
!this.selectedContact.lastMessage ||
|
|
268
|
+
this.chatBoxRef.nativeElement.scrollTop > 250 ||
|
|
269
|
+
this.selectedContactMessages.length % 50 !== 0) {
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.pagingLoading = true;
|
|
274
|
+
this.conversationService
|
|
275
|
+
.getConversationByInput({
|
|
276
|
+
skipCount: this.selectedContactMessages.length,
|
|
277
|
+
maxResultCount: 50,
|
|
278
|
+
targetUserId: this.selectedContact.userId,
|
|
279
|
+
})
|
|
280
|
+
.pipe(finalize(() => (this.pagingLoading = false)))
|
|
281
|
+
.subscribe((res) => {
|
|
282
|
+
if (!res.messages.length) {
|
|
283
|
+
this.allMessagesLoaded = true;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
this.userMessages.get(this.selectedContact.userId).unshift(...res.messages.reverse());
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
this.httpWaitService.addFilter([
|
|
290
|
+
{
|
|
291
|
+
method: 'POST',
|
|
292
|
+
endpoint: '/api/chat/conversation/send-message',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
method: 'GET',
|
|
296
|
+
endpoint: '/api/chat/contact/contacts',
|
|
297
|
+
},
|
|
298
|
+
]);
|
|
299
|
+
}
|
|
300
|
+
get contactName() {
|
|
301
|
+
return getContactName(this.selectedContact || {});
|
|
302
|
+
}
|
|
303
|
+
get selectedContactMessages() {
|
|
304
|
+
return this.userMessages.get(this.selectedContact.userId) || [];
|
|
305
|
+
}
|
|
306
|
+
listenToChatBoxScroll() {
|
|
307
|
+
fromEvent(this.chatBoxRef.nativeElement, 'scroll')
|
|
308
|
+
.pipe(debounceTime(150), takeUntil(this.destroy$))
|
|
309
|
+
.subscribe(this.onScroll);
|
|
310
|
+
}
|
|
311
|
+
listenToNewMessages() {
|
|
312
|
+
this.chatConfigService.message$
|
|
313
|
+
.pipe(takeUntil(this.destroy$))
|
|
314
|
+
.subscribe(({ senderUserId, text } = {}) => {
|
|
315
|
+
if (!this.userMessages.has(senderUserId))
|
|
316
|
+
return;
|
|
317
|
+
const isSelected = this.selectedContact.userId === senderUserId;
|
|
318
|
+
this.userMessages.get(senderUserId).push({
|
|
319
|
+
message: text,
|
|
320
|
+
messageDate: new Date(),
|
|
321
|
+
side: ChatMessageSide.Receiver,
|
|
322
|
+
isRead: isSelected,
|
|
323
|
+
readDate: isSelected ? new Date() : null,
|
|
324
|
+
});
|
|
325
|
+
this.scrollToEnd();
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
ngAfterViewInit() {
|
|
329
|
+
this.sendOnEnter =
|
|
330
|
+
(this.configState.getSetting('Volo.Chat.Messaging.SendMessageOnEnter') || '').toLowerCase() !== 'false';
|
|
331
|
+
this.listenToChatBoxScroll();
|
|
332
|
+
this.listenToNewMessages();
|
|
333
|
+
}
|
|
334
|
+
ngOnDestroy() {
|
|
335
|
+
this.destroy$.next();
|
|
336
|
+
this.destroy$.complete();
|
|
337
|
+
}
|
|
338
|
+
getConversation(scrollToEnd) {
|
|
339
|
+
this.allMessagesLoaded = false;
|
|
340
|
+
this.conversationService
|
|
341
|
+
.getConversationByInput({
|
|
342
|
+
skipCount: 0,
|
|
343
|
+
maxResultCount: 50,
|
|
344
|
+
targetUserId: this.selectedContact.userId,
|
|
345
|
+
})
|
|
346
|
+
.subscribe((res) => {
|
|
347
|
+
this.userMessages.set(this.selectedContact.userId, res.messages.reverse());
|
|
348
|
+
if (scrollToEnd)
|
|
349
|
+
this.scrollToEnd();
|
|
350
|
+
if (this.selectedContact.unreadMessageCount)
|
|
351
|
+
this.markConversationAsRead();
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
send() {
|
|
355
|
+
if (!this.message || this.loading)
|
|
356
|
+
return;
|
|
357
|
+
this.unreadMessageCount = 0;
|
|
358
|
+
this.loading = true;
|
|
359
|
+
this.conversationService
|
|
360
|
+
.sendMessageByInput({ message: this.message, targetUserId: this.selectedContact.userId })
|
|
361
|
+
.pipe(finalize(() => (this.loading = false)))
|
|
362
|
+
.subscribe(() => {
|
|
363
|
+
this.chatContactsComponent.changeLastMessageOfSelectedContact(this.message);
|
|
364
|
+
if (!this.userMessages.has(this.selectedContact.userId)) {
|
|
365
|
+
this.userMessages.set(this.selectedContact.userId, []);
|
|
366
|
+
}
|
|
367
|
+
this.userMessages.get(this.selectedContact.userId).push({
|
|
368
|
+
message: this.message,
|
|
369
|
+
isRead: true,
|
|
370
|
+
readDate: now,
|
|
371
|
+
messageDate: now,
|
|
372
|
+
side: ChatMessageSide.Sender,
|
|
373
|
+
});
|
|
374
|
+
this.message = '';
|
|
375
|
+
this.scrollToEnd();
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
markConversationAsRead() {
|
|
379
|
+
this.conversationService
|
|
380
|
+
.markConversationAsReadByInput({ targetUserId: this.selectedContact.userId })
|
|
381
|
+
.subscribe(() => {
|
|
382
|
+
this.chatContactsComponent.markSelectedContactAsRead();
|
|
383
|
+
this.selectedContact.unreadMessageCount = 0;
|
|
384
|
+
setTimeout(() => (this.unreadMessageCount = 0), 5000);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
sendWithEnter(event) {
|
|
388
|
+
if (!this.sendOnEnter)
|
|
389
|
+
return;
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
this.send();
|
|
392
|
+
}
|
|
393
|
+
onSelectContact(contact) {
|
|
394
|
+
this.selectedContact = contact;
|
|
395
|
+
this.unreadMessageCount = contact.unreadMessageCount;
|
|
396
|
+
this.scrollToEnd();
|
|
397
|
+
if (this.userMessages.has(contact.userId) || !contact.lastMessage) {
|
|
398
|
+
if (contact.unreadMessageCount)
|
|
399
|
+
this.markConversationAsRead();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
this.getConversation(true);
|
|
403
|
+
}
|
|
404
|
+
getDateFormat(date) {
|
|
405
|
+
date = new Date(date);
|
|
406
|
+
const messageDay = new Date(date.getFullYear(), date.getMonth(), date.getDate()).valueOf();
|
|
407
|
+
if (messageDay === today)
|
|
408
|
+
return 'shortTime';
|
|
409
|
+
return 'short';
|
|
410
|
+
}
|
|
411
|
+
scrollToEnd() {
|
|
412
|
+
setTimeout(() => {
|
|
413
|
+
const { offsetTop } = (document.querySelector('.unread-message-count-badge-wrapper') ||
|
|
414
|
+
{});
|
|
415
|
+
this.chatBoxRef.nativeElement.scrollTo({
|
|
416
|
+
top: offsetTop ? offsetTop - 60 : this.chatBoxRef.nativeElement.scrollHeight,
|
|
417
|
+
});
|
|
418
|
+
}, 0);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
ChatComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatComponent, deps: [{ token: ConversationService }, { token: i2.ChatConfigService }, { token: i3.ConfigStateService }, { token: i3.HttpWaitService }], target: i0.ɵɵFactoryTarget.Component });
|
|
422
|
+
ChatComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: ChatComponent, selector: "abp-chat", viewQueries: [{ propertyName: "chatBoxRef", first: true, predicate: ["chatBox"], descendants: true }, { propertyName: "chatContactsComponent", first: true, predicate: ChatContactsComponent, descendants: true }], ngImport: i0, template: "<div class=\"row entry-row\">\r\n <div class=\"col-auto\"></div>\r\n <div class=\"col-lg-auto ps-lg-0\"></div>\r\n <div class=\"col\">\r\n <div class=\"text-lg-end pt-2\" id=\"AbpContentToolbar\"></div>\r\n </div>\r\n</div>\r\n\r\n<div id=\"chat_wrapper\">\r\n <div class=\"container-fluid\">\r\n <div class=\"row rounded-lg overflow-hidden shadow bor der\">\r\n <div class=\"col-3 col-md-5 col-lg-4 px-0\">\r\n <abp-chat-contacts (selected)=\"onSelectContact($event)\"></abp-chat-contacts>\r\n </div>\r\n\r\n <!-- Chat Box-->\r\n <div class=\"col-9 col-md-7 col-lg-8 px-0\">\r\n <div class=\"p-3 bg-light border-bottom\">\r\n <div class=\"form-row\">\r\n <div class=\"col\">\r\n <div class=\"form-row\">\r\n <div class=\"col-auto\">\r\n <abp-conversation-avatar\r\n small\r\n [contact]=\"selectedContact\"\r\n ></abp-conversation-avatar>\r\n </div>\r\n <div class=\"col pt-1\" style=\"line-height: 1.2\">\r\n <strong id=\"conversation-title\" class=\"font-weight-bold\">{{ contactName }}</strong\r\n ><br />\r\n <small id=\"conversation-info\"></small>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div #chatBox id=\"chat-conversation-wrapper\" class=\"chat-box m-0 p-0\">\r\n <div class=\"chat-box-container p-4\" [id]=\"'chat-conversation'\">\r\n <ng-container\r\n *ngFor=\"\r\n let message of selectedContactMessages;\r\n let i = index;\r\n trackBy: trackByMessageDate\r\n \"\r\n >\r\n <div\r\n *ngIf=\"selectedContactMessages.length - unreadMessageCount === i\"\r\n class=\"row justify-content-center unread-message-count-badge-wrapper\"\r\n >\r\n <h3>\r\n <span class=\"badge badge-info\">\r\n <ng-container *ngIf=\"unreadMessageCount === 1; else moreThanOne\">\r\n {{ 'Chat::YouHaveAnUnreadMessage' | abpLocalization }}\r\n </ng-container>\r\n\r\n <ng-template #moreThanOne>\r\n {{\r\n 'Chat::YouHave{0}UnreadMessages' | abpLocalization: '' + unreadMessageCount\r\n }}\r\n </ng-template>\r\n </span>\r\n </h3>\r\n </div>\r\n\r\n <div\r\n *ngIf=\"{ isSender: message.side === chatMessageSide.Sender } as data\"\r\n class=\"media w-75 mw-65 w-lp-auto mb-2\"\r\n [class.ms-auto]=\"data.isSender\"\r\n >\r\n <div class=\"media-body position-relative\">\r\n <div\r\n class=\"shadow rounded py-3 px-4 mb-1 {{\r\n data.isSender ? 'bg-primary' : 'bg-light'\r\n }}\"\r\n >\r\n <p\r\n class=\"text-small mb-0 {{ data.isSender ? 'text-white' : 'text-muted' }}\"\r\n [innerHTML]=\"message.message\"\r\n ></p>\r\n </div>\r\n <p\r\n class=\"message-date small text-muted m-0 {{ data.isSender ? 'left' : 'right' }}\"\r\n >\r\n {{ message.messageDate | date: getDateFormat(message.messageDate) }}\r\n </p>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>\r\n\r\n <!-- Typing area -->\r\n <div *ngIf=\"selectedContact?.userId\" id=\"send-message-form\" class=\"bg-light border-top m-0\">\r\n <div class=\"p-3\">\r\n <textarea\r\n id=\"chat-message-box\"\r\n name=\"message\"\r\n type=\"text\"\r\n [placeholder]=\"'Chat::TypeMessage' | abpLocalization\"\r\n class=\"form-control rounded py-2 bg-white\"\r\n [(ngModel)]=\"message\"\r\n (keydown.enter)=\"sendWithEnter($event)\"\r\n ></textarea>\r\n <div class=\"form-checkbox float-start mt-3\">\r\n <input\r\n type=\"checkbox\"\r\n class=\"form-check-input me-1\"\r\n id=\"send-on-enter\"\r\n [(ngModel)]=\"sendOnEnter\"\r\n />\r\n <label class=\"form-check-label\" for=\"send-on-enter\">{{\r\n 'Chat::SendOnEnter' | abpLocalization\r\n }}</label>\r\n </div>\r\n <div class=\"mt-2 text-end\">\r\n <button\r\n [disabled]=\"!message\"\r\n (click)=\"send()\"\r\n id=\"send-message-button\"\r\n type=\"button\"\r\n class=\"btn btn-primary px-3\"\r\n >\r\n {{ 'Chat::Send' | abpLocalization }}\r\n <i *ngIf=\"!loading; else loadingIcon\" class=\"fa fa-paper-plane ms-2\"></i>\r\n\r\n <ng-template #loadingIcon>\r\n <i class=\"fas fa-spinner fa-spin ms-2\"></i>\r\n </ng-template>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".chat-box{height:calc(100vh - 390px);overflow-y:scroll}.message-date{position:absolute;opacity:.35;width:100px;top:1px}.message-date.left{left:-110px;text-align:right}.message-date.right{right:-110px}\n"], components: [{ type: ChatContactsComponent, selector: "abp-chat-contacts", outputs: ["selected"] }, { type: ConversationAvatarComponent, selector: "abp-conversation-avatar", inputs: ["contact", "small"] }], directives: [{ type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i7.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }], pipes: { "abpLocalization": i3.LocalizationPipe, "date": i6.DatePipe } });
|
|
423
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatComponent, decorators: [{
|
|
424
|
+
type: Component,
|
|
425
|
+
args: [{ selector: 'abp-chat', styles: [
|
|
426
|
+
`
|
|
427
|
+
.chat-box {
|
|
428
|
+
height: calc(100vh - 390px);
|
|
429
|
+
overflow-y: scroll;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.message-date {
|
|
433
|
+
position: absolute;
|
|
434
|
+
opacity: 0.35;
|
|
435
|
+
width: 100px;
|
|
436
|
+
top: 1px;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.message-date.left {
|
|
440
|
+
left: -110px;
|
|
441
|
+
text-align: right;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.message-date.right {
|
|
445
|
+
right: -110px;
|
|
446
|
+
}
|
|
447
|
+
`,
|
|
448
|
+
], template: "<div class=\"row entry-row\">\r\n <div class=\"col-auto\"></div>\r\n <div class=\"col-lg-auto ps-lg-0\"></div>\r\n <div class=\"col\">\r\n <div class=\"text-lg-end pt-2\" id=\"AbpContentToolbar\"></div>\r\n </div>\r\n</div>\r\n\r\n<div id=\"chat_wrapper\">\r\n <div class=\"container-fluid\">\r\n <div class=\"row rounded-lg overflow-hidden shadow bor der\">\r\n <div class=\"col-3 col-md-5 col-lg-4 px-0\">\r\n <abp-chat-contacts (selected)=\"onSelectContact($event)\"></abp-chat-contacts>\r\n </div>\r\n\r\n <!-- Chat Box-->\r\n <div class=\"col-9 col-md-7 col-lg-8 px-0\">\r\n <div class=\"p-3 bg-light border-bottom\">\r\n <div class=\"form-row\">\r\n <div class=\"col\">\r\n <div class=\"form-row\">\r\n <div class=\"col-auto\">\r\n <abp-conversation-avatar\r\n small\r\n [contact]=\"selectedContact\"\r\n ></abp-conversation-avatar>\r\n </div>\r\n <div class=\"col pt-1\" style=\"line-height: 1.2\">\r\n <strong id=\"conversation-title\" class=\"font-weight-bold\">{{ contactName }}</strong\r\n ><br />\r\n <small id=\"conversation-info\"></small>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div #chatBox id=\"chat-conversation-wrapper\" class=\"chat-box m-0 p-0\">\r\n <div class=\"chat-box-container p-4\" [id]=\"'chat-conversation'\">\r\n <ng-container\r\n *ngFor=\"\r\n let message of selectedContactMessages;\r\n let i = index;\r\n trackBy: trackByMessageDate\r\n \"\r\n >\r\n <div\r\n *ngIf=\"selectedContactMessages.length - unreadMessageCount === i\"\r\n class=\"row justify-content-center unread-message-count-badge-wrapper\"\r\n >\r\n <h3>\r\n <span class=\"badge badge-info\">\r\n <ng-container *ngIf=\"unreadMessageCount === 1; else moreThanOne\">\r\n {{ 'Chat::YouHaveAnUnreadMessage' | abpLocalization }}\r\n </ng-container>\r\n\r\n <ng-template #moreThanOne>\r\n {{\r\n 'Chat::YouHave{0}UnreadMessages' | abpLocalization: '' + unreadMessageCount\r\n }}\r\n </ng-template>\r\n </span>\r\n </h3>\r\n </div>\r\n\r\n <div\r\n *ngIf=\"{ isSender: message.side === chatMessageSide.Sender } as data\"\r\n class=\"media w-75 mw-65 w-lp-auto mb-2\"\r\n [class.ms-auto]=\"data.isSender\"\r\n >\r\n <div class=\"media-body position-relative\">\r\n <div\r\n class=\"shadow rounded py-3 px-4 mb-1 {{\r\n data.isSender ? 'bg-primary' : 'bg-light'\r\n }}\"\r\n >\r\n <p\r\n class=\"text-small mb-0 {{ data.isSender ? 'text-white' : 'text-muted' }}\"\r\n [innerHTML]=\"message.message\"\r\n ></p>\r\n </div>\r\n <p\r\n class=\"message-date small text-muted m-0 {{ data.isSender ? 'left' : 'right' }}\"\r\n >\r\n {{ message.messageDate | date: getDateFormat(message.messageDate) }}\r\n </p>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </div>\r\n </div>\r\n\r\n <!-- Typing area -->\r\n <div *ngIf=\"selectedContact?.userId\" id=\"send-message-form\" class=\"bg-light border-top m-0\">\r\n <div class=\"p-3\">\r\n <textarea\r\n id=\"chat-message-box\"\r\n name=\"message\"\r\n type=\"text\"\r\n [placeholder]=\"'Chat::TypeMessage' | abpLocalization\"\r\n class=\"form-control rounded py-2 bg-white\"\r\n [(ngModel)]=\"message\"\r\n (keydown.enter)=\"sendWithEnter($event)\"\r\n ></textarea>\r\n <div class=\"form-checkbox float-start mt-3\">\r\n <input\r\n type=\"checkbox\"\r\n class=\"form-check-input me-1\"\r\n id=\"send-on-enter\"\r\n [(ngModel)]=\"sendOnEnter\"\r\n />\r\n <label class=\"form-check-label\" for=\"send-on-enter\">{{\r\n 'Chat::SendOnEnter' | abpLocalization\r\n }}</label>\r\n </div>\r\n <div class=\"mt-2 text-end\">\r\n <button\r\n [disabled]=\"!message\"\r\n (click)=\"send()\"\r\n id=\"send-message-button\"\r\n type=\"button\"\r\n class=\"btn btn-primary px-3\"\r\n >\r\n {{ 'Chat::Send' | abpLocalization }}\r\n <i *ngIf=\"!loading; else loadingIcon\" class=\"fa fa-paper-plane ms-2\"></i>\r\n\r\n <ng-template #loadingIcon>\r\n <i class=\"fas fa-spinner fa-spin ms-2\"></i>\r\n </ng-template>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
|
|
449
|
+
}], ctorParameters: function () { return [{ type: ConversationService }, { type: i2.ChatConfigService }, { type: i3.ConfigStateService }, { type: i3.HttpWaitService }]; }, propDecorators: { chatBoxRef: [{
|
|
450
|
+
type: ViewChild,
|
|
451
|
+
args: ['chatBox', { static: false }]
|
|
452
|
+
}], chatContactsComponent: [{
|
|
453
|
+
type: ViewChild,
|
|
454
|
+
args: [ChatContactsComponent, { static: false }]
|
|
455
|
+
}] } });
|
|
456
|
+
|
|
457
|
+
const routes = [
|
|
458
|
+
{
|
|
459
|
+
path: '',
|
|
460
|
+
component: RouterOutletComponent,
|
|
461
|
+
canActivate: [AuthGuard, PermissionGuard],
|
|
462
|
+
children: [
|
|
463
|
+
{
|
|
464
|
+
path: '',
|
|
465
|
+
component: ReplaceableRouteContainerComponent,
|
|
466
|
+
data: {
|
|
467
|
+
requiredPolicy: 'Chat.Messaging',
|
|
468
|
+
replaceableComponent: {
|
|
469
|
+
defaultComponent: ChatComponent,
|
|
470
|
+
key: 'Chat.ChatComponent',
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
},
|
|
476
|
+
];
|
|
477
|
+
class ChatRoutingModule {
|
|
478
|
+
}
|
|
479
|
+
ChatRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
480
|
+
ChatRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatRoutingModule, imports: [i1.RouterModule], exports: [RouterModule] });
|
|
481
|
+
ChatRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatRoutingModule, imports: [[RouterModule.forChild(routes)], RouterModule] });
|
|
482
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatRoutingModule, decorators: [{
|
|
483
|
+
type: NgModule,
|
|
484
|
+
args: [{
|
|
485
|
+
imports: [RouterModule.forChild(routes)],
|
|
486
|
+
exports: [RouterModule],
|
|
487
|
+
}]
|
|
488
|
+
}] });
|
|
489
|
+
|
|
490
|
+
const declarations = [ChatComponent, ChatContactsComponent, ConversationAvatarComponent];
|
|
491
|
+
class ChatModule {
|
|
492
|
+
static forChild() {
|
|
493
|
+
return {
|
|
494
|
+
ngModule: ChatModule,
|
|
495
|
+
providers: [],
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
static forLazy() {
|
|
499
|
+
return new LazyModuleFactory(ChatModule.forChild());
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
ChatModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
503
|
+
ChatModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatModule, declarations: [ChatComponent, ChatContactsComponent, ConversationAvatarComponent], imports: [CoreModule, ThemeSharedModule, ChatRoutingModule], exports: [ChatComponent, ChatContactsComponent, ConversationAvatarComponent] });
|
|
504
|
+
ChatModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatModule, imports: [[CoreModule, ThemeSharedModule, ChatRoutingModule]] });
|
|
505
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ChatModule, decorators: [{
|
|
506
|
+
type: NgModule,
|
|
507
|
+
args: [{
|
|
508
|
+
declarations,
|
|
509
|
+
imports: [CoreModule, ThemeSharedModule, ChatRoutingModule],
|
|
510
|
+
exports: [...declarations],
|
|
511
|
+
}]
|
|
512
|
+
}] });
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Generated bundle index. Do not edit.
|
|
516
|
+
*/
|
|
517
|
+
|
|
518
|
+
export { ChatComponent, ChatContactsComponent, ChatModule, ConversationAvatarComponent, getContactName };
|
|
519
|
+
//# sourceMappingURL=volo-abp.ng.chat.mjs.map
|