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