@volo/abp.ng.chat 7.4.0-rc.1 → 7.4.0-rc.3
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/config/components/chat-tab.component.d.ts +28 -0
- package/config/enums/chat-module-tab-names.d.ts +3 -0
- package/config/enums/delete-message.enums.d.ts +9 -0
- package/config/models/deleteMessage.model.d.ts +10 -0
- package/config/providers/chat-module-settings.provider.d.ts +8 -0
- package/config/providers/index.d.ts +1 -0
- package/esm2022/config/chat-config.module.mjs +3 -1
- package/esm2022/config/components/chat-tab.component.mjs +64 -0
- package/esm2022/config/enums/chat-module-tab-names.mjs +2 -0
- package/esm2022/config/enums/delete-message.enums.mjs +2 -0
- package/esm2022/config/models/deleteMessage.model.mjs +2 -0
- package/esm2022/config/providers/chat-module-settings.provider.mjs +24 -0
- package/esm2022/config/providers/index.mjs +2 -1
- package/esm2022/config/services/chat-config.service.mjs +6 -4
- package/esm2022/lib/chat.module.mjs +5 -4
- package/esm2022/lib/components/chat-contacts.component.mjs +31 -22
- package/esm2022/lib/components/chat.component.mjs +60 -26
- package/esm2022/proxy/lib/proxy/volo/chat/conversations/conversation.service.mjs +17 -7
- package/esm2022/proxy/lib/proxy/volo/chat/conversations/models.mjs +1 -1
- package/esm2022/proxy/lib/proxy/volo/chat/messages/chat-deleting-conversations.enum.mjs +8 -0
- package/esm2022/proxy/lib/proxy/volo/chat/messages/chat-deleting-messages.enum.mjs +9 -0
- package/esm2022/proxy/lib/proxy/volo/chat/messages/index.mjs +3 -1
- package/esm2022/proxy/lib/proxy/volo/chat/messages/models.mjs +1 -1
- package/esm2022/proxy/lib/proxy/volo/chat/settings/models.mjs +1 -1
- package/esm2022/proxy/lib/proxy/volo/chat/settings/settings.service.mjs +12 -3
- package/esm2022/proxy/lib/proxy/volo/chat/users/contact.service.mjs +5 -5
- package/esm2022/proxy/lib/proxy/volo/chat/users/models.mjs +1 -1
- package/fesm2022/volo-abp.ng.chat-config.mjs +87 -7
- package/fesm2022/volo-abp.ng.chat-config.mjs.map +1 -1
- package/fesm2022/volo-abp.ng.chat-proxy.mjs +47 -13
- package/fesm2022/volo-abp.ng.chat-proxy.mjs.map +1 -1
- package/fesm2022/volo-abp.ng.chat.mjs +114 -68
- package/fesm2022/volo-abp.ng.chat.mjs.map +1 -1
- package/lib/chat.module.d.ts +2 -1
- package/lib/components/chat-contacts.component.d.ts +8 -5
- package/lib/components/chat.component.d.ts +15 -7
- package/package.json +8 -4
- package/proxy/lib/proxy/volo/chat/conversations/conversation.service.d.ts +8 -6
- package/proxy/lib/proxy/volo/chat/conversations/models.d.ts +3 -0
- package/proxy/lib/proxy/volo/chat/messages/chat-deleting-conversations.enum.d.ts +5 -0
- package/proxy/lib/proxy/volo/chat/messages/chat-deleting-messages.enum.d.ts +6 -0
- package/proxy/lib/proxy/volo/chat/messages/index.d.ts +2 -0
- package/proxy/lib/proxy/volo/chat/messages/models.d.ts +5 -0
- package/proxy/lib/proxy/volo/chat/settings/models.d.ts +7 -0
- package/proxy/lib/proxy/volo/chat/settings/settings.service.d.ts +5 -3
- package/proxy/lib/proxy/volo/chat/users/contact.service.d.ts +3 -3
- package/proxy/lib/proxy/volo/chat/users/models.d.ts +1 -0
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import * as i3 from '@abp/ng.core';
|
|
2
|
-
import {
|
|
2
|
+
import { SubscriptionService, trackBy, PagedResultRequestDto, RouterOutletComponent, AuthGuard, PermissionGuard, ReplaceableRouteContainerComponent, LazyModuleFactory, CoreModule } from '@abp/ng.core';
|
|
3
|
+
import * as i4$1 from '@abp/ng.theme.shared';
|
|
3
4
|
import { ThemeSharedModule } from '@abp/ng.theme.shared';
|
|
4
5
|
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';
|
|
6
|
+
import { Injectable, Component, Input, inject, EventEmitter, Output, ViewChild, NgModule } from '@angular/core';
|
|
7
|
+
import * as i1$2 from '@angular/router';
|
|
7
8
|
import { RouterModule } from '@angular/router';
|
|
8
9
|
import * as i2 from '@volo/abp.ng.chat/config';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import * as
|
|
10
|
+
import { ChatConfigService } from '@volo/abp.ng.chat/config';
|
|
11
|
+
import { take, Subject, fromEvent } from 'rxjs';
|
|
12
|
+
import { finalize, take as take$1, debounceTime, takeUntil } from 'rxjs/operators';
|
|
13
|
+
import * as i1$1 from '@volo/abp.ng.chat/proxy';
|
|
14
|
+
import { ConversationService as ConversationService$1, ChatMessageSide as ChatMessageSide$1, ChatDeletingMessages, ChatDeletingConversations } from '@volo/abp.ng.chat/proxy';
|
|
15
|
+
import * as i1 from '@angular/common';
|
|
16
|
+
import * as i6 from '@angular/forms';
|
|
17
|
+
import * as i4 from '@ng-bootstrap/ng-bootstrap';
|
|
18
|
+
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
|
|
13
19
|
|
|
14
20
|
var ChatMessageSide;
|
|
15
21
|
(function (ChatMessageSide) {
|
|
@@ -17,28 +23,6 @@ var ChatMessageSide;
|
|
|
17
23
|
ChatMessageSide[ChatMessageSide["Receiver"] = 2] = "Receiver";
|
|
18
24
|
})(ChatMessageSide || (ChatMessageSide = {}));
|
|
19
25
|
|
|
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
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, deps: [{ token: i3.RestService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
35
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, providedIn: 'root' }); }
|
|
36
|
-
}
|
|
37
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, decorators: [{
|
|
38
|
-
type: Injectable,
|
|
39
|
-
args: [{ providedIn: 'root' }]
|
|
40
|
-
}], ctorParameters: function () { return [{ type: i3.RestService }]; } });
|
|
41
|
-
|
|
42
26
|
class ContactService {
|
|
43
27
|
constructor(restService) {
|
|
44
28
|
this.restService = restService;
|
|
@@ -108,7 +92,7 @@ class ConversationAvatarComponent {
|
|
|
108
92
|
[ngStyle]="avatarBgStyle"
|
|
109
93
|
>
|
|
110
94
|
{{ avatarText }}
|
|
111
|
-
</div>`, isInline: true, styles: [".avatar{height:48px;width:48px;line-height:48px;font-size:16px;font-weight:700;text-align:center;text-transform:uppercase}.avatar.small{height:36px;width:36px;line-height:37px;font-size:14px}\n"], dependencies: [{ kind: "directive", type:
|
|
95
|
+
</div>`, isInline: true, styles: [".avatar{height:48px;width:48px;line-height:48px;font-size:16px;font-weight:700;text-align:center;text-transform:uppercase}.avatar.small{height:36px;width:36px;line-height:37px;font-size:14px}\n"], dependencies: [{ kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] }); }
|
|
112
96
|
}
|
|
113
97
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationAvatarComponent, decorators: [{
|
|
114
98
|
type: Component,
|
|
@@ -126,6 +110,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImpor
|
|
|
126
110
|
}] } });
|
|
127
111
|
|
|
128
112
|
class ChatContactsComponent {
|
|
113
|
+
constructor() {
|
|
114
|
+
this.contactService = inject(ContactService);
|
|
115
|
+
this.chatConfigService = inject(ChatConfigService);
|
|
116
|
+
this.subscription = inject(SubscriptionService);
|
|
117
|
+
this.chatConversationService = inject(ConversationService$1);
|
|
118
|
+
this.selected = new EventEmitter();
|
|
119
|
+
this.allContacts = [];
|
|
120
|
+
this.selectedContact = {};
|
|
121
|
+
this.filter = '';
|
|
122
|
+
this.getContactName = getContactName;
|
|
123
|
+
this.trackByUserId = trackBy('userId');
|
|
124
|
+
}
|
|
129
125
|
get contacts() {
|
|
130
126
|
return this.allContacts
|
|
131
127
|
.filter(contact => contact.lastMessage)
|
|
@@ -134,17 +130,6 @@ class ChatContactsComponent {
|
|
|
134
130
|
get otherContacts() {
|
|
135
131
|
return this.allContacts.filter(contact => !contact.lastMessage);
|
|
136
132
|
}
|
|
137
|
-
constructor(contactService, chatConfigService, subscription) {
|
|
138
|
-
this.contactService = contactService;
|
|
139
|
-
this.chatConfigService = chatConfigService;
|
|
140
|
-
this.subscription = subscription;
|
|
141
|
-
this.selected = new EventEmitter();
|
|
142
|
-
this.allContacts = [];
|
|
143
|
-
this.selectedContact = {};
|
|
144
|
-
this.filter = '';
|
|
145
|
-
this.getContactName = getContactName;
|
|
146
|
-
this.trackByUserId = trackBy('userId');
|
|
147
|
-
}
|
|
148
133
|
listenToNewMessages() {
|
|
149
134
|
this.subscription.addOne(this.chatConfigService.message$, (message = {}) => {
|
|
150
135
|
const index = this.allContacts.findIndex(cont => cont.userId === message.senderUserId);
|
|
@@ -206,13 +191,20 @@ class ChatContactsComponent {
|
|
|
206
191
|
markSelectedContactAsRead() {
|
|
207
192
|
this.selectedContact.unreadMessageCount = 0;
|
|
208
193
|
}
|
|
209
|
-
|
|
210
|
-
|
|
194
|
+
deleteConversation(contact) {
|
|
195
|
+
this.chatConversationService.deleteConversation({ targetUserId: contact.userId }).pipe(take(1)).subscribe(() => {
|
|
196
|
+
this.get();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatContactsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
200
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.6", type: ChatContactsComponent, selector: "abp-chat-contacts", inputs: { startConversation: "startConversation", conversationDeletable: "conversationDeletable" }, outputs: { selected: "selected" }, providers: [SubscriptionService], usesOnChanges: true, ngImport: i0, template: "<div class=\"card w-100 mb-3 mb-md-0\">\r\n <div class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <div class=\"mb-2 rounded-2\">\r\n <div class=\"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\"\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-3 min-vh-100\" 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</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 cursor-pointer position-relative px-2 border-2 rounded-2 mb-1 mt-0 {{\r\n selectedContact.userId === contact.userId ? 'active' : ''\r\n }}\"\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\">\r\n <div class=\"d-flex align-items-center justify-content-between mb-0\">\r\n <h5 class=\"mb-0 mt-1\">\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 </h5>\r\n <small class=\"last-message-date\">{{ contact.lastMessageDate | date:'HH:mm' }}</small>\r\n </div>\r\n <p class=\"mb-0 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 *ngIf=\"conversationDeletable\" ngbDropdown class=\"dropdown position-absolute bottom-0 end-0\">\r\n <button class=\"btn p-1 down-arrow\" \r\n id=\"dropdownBasic1\" ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteConversation(contact)\">Delete</button>\r\n </div>\r\n </div>\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)}.dropdown-toggle:after{display:none}.dropdown{border-color:transparent}.down-arrow{border:none;opacity:0}.media:hover .down-arrow{opacity:100%}.list-group{padding-right:7px}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:var(--lpx-navbar-color)}::-webkit-scrollbar-thumb{background:var(--lpx-primary)}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3.InputEventDebounceDirective, selector: "[input.debounce]", inputs: ["debounce"], outputs: ["input.debounce"] }, { kind: "directive", type: i4.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "popperOptions", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { kind: "directive", type: i4.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { kind: "directive", type: i4.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { kind: "directive", type: i4.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }, { kind: "component", type: ConversationAvatarComponent, selector: "abp-conversation-avatar", inputs: ["contact", "small"] }, { kind: "pipe", type: i1.SlicePipe, name: "slice" }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { kind: "pipe", type: i3.LocalizationPipe, name: "abpLocalization" }] }); }
|
|
211
201
|
}
|
|
212
202
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatContactsComponent, decorators: [{
|
|
213
203
|
type: Component,
|
|
214
|
-
args: [{ selector: 'abp-chat-contacts', providers: [SubscriptionService], template: "<div class=\"card w-100 mb-3 mb-md-0\">\r\n <div class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <div class=\"mb-2 rounded-2\">\r\n <div class=\"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\"\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-3\" 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</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 cursor-pointer px-2 border-2 rounded-2 mb-1 mt-0 {{\r\n selectedContact.userId === contact.userId ? 'active' : ''\r\n }}\"\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\">\r\n <div class=\"d-flex align-items-center justify-content-between mb-0\">\r\n <h5 class=\"mb-0 mt-1\">\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 </h5>\r\n <small class=\"last-message-date\">{{ contact.lastMessageDate | date }}</small>\r\n </div>\r\n <p class=\"mb-0 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"] }]
|
|
215
|
-
}],
|
|
204
|
+
args: [{ selector: 'abp-chat-contacts', providers: [SubscriptionService], template: "<div class=\"card w-100 mb-3 mb-md-0\">\r\n <div class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <div class=\"mb-2 rounded-2\">\r\n <div class=\"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\"\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-3 min-vh-100\" 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</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 cursor-pointer position-relative px-2 border-2 rounded-2 mb-1 mt-0 {{\r\n selectedContact.userId === contact.userId ? 'active' : ''\r\n }}\"\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\">\r\n <div class=\"d-flex align-items-center justify-content-between mb-0\">\r\n <h5 class=\"mb-0 mt-1\">\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 </h5>\r\n <small class=\"last-message-date\">{{ contact.lastMessageDate | date:'HH:mm' }}</small>\r\n </div>\r\n <p class=\"mb-0 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 *ngIf=\"conversationDeletable\" ngbDropdown class=\"dropdown position-absolute bottom-0 end-0\">\r\n <button class=\"btn p-1 down-arrow\" \r\n id=\"dropdownBasic1\" ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteConversation(contact)\">Delete</button>\r\n </div>\r\n </div>\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)}.dropdown-toggle:after{display:none}.dropdown{border-color:transparent}.down-arrow{border:none;opacity:0}.media:hover .down-arrow{opacity:100%}.list-group{padding-right:7px}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:var(--lpx-navbar-color)}::-webkit-scrollbar-thumb{background:var(--lpx-primary)}\n"] }]
|
|
205
|
+
}], propDecorators: { startConversation: [{
|
|
206
|
+
type: Input
|
|
207
|
+
}], conversationDeletable: [{
|
|
216
208
|
type: Input
|
|
217
209
|
}], selected: [{
|
|
218
210
|
type: Output
|
|
@@ -345,18 +337,24 @@ class ChatComponent {
|
|
|
345
337
|
get selectedContactMessages() {
|
|
346
338
|
return this.userMessages.get(this.selectedContact.userId) || [];
|
|
347
339
|
}
|
|
348
|
-
constructor(conversationService, chatConfigService, configState, httpWaitService) {
|
|
340
|
+
constructor(conversationService, chatConfigService, configState, httpWaitService, chatSettingsService, confirmation) {
|
|
349
341
|
this.conversationService = conversationService;
|
|
350
342
|
this.chatConfigService = chatConfigService;
|
|
351
343
|
this.configState = configState;
|
|
352
344
|
this.httpWaitService = httpWaitService;
|
|
345
|
+
this.chatSettingsService = chatSettingsService;
|
|
346
|
+
this.confirmation = confirmation;
|
|
353
347
|
this.selectedContact = {};
|
|
354
348
|
this.unreadMessageCount = 0;
|
|
355
349
|
this.userMessages = new Map();
|
|
356
|
-
this.chatMessageSide = ChatMessageSide;
|
|
350
|
+
this.chatMessageSide = ChatMessageSide$1;
|
|
357
351
|
this.clickedStartMessage = false;
|
|
352
|
+
this.conversationDeletable = false;
|
|
353
|
+
this.messageDeletable = false;
|
|
354
|
+
this.messageDeletableWithPeriod = false;
|
|
358
355
|
this.trackByMessageDate = trackBy('messageDate');
|
|
359
356
|
this.destroy$ = new Subject();
|
|
357
|
+
this.options = ['AbpIdentity::ExternalUser'];
|
|
360
358
|
this.onScroll = (event) => {
|
|
361
359
|
if (this.allMessagesLoaded ||
|
|
362
360
|
this.pagingLoading ||
|
|
@@ -368,7 +366,7 @@ class ChatComponent {
|
|
|
368
366
|
}
|
|
369
367
|
this.pagingLoading = true;
|
|
370
368
|
this.conversationService
|
|
371
|
-
.
|
|
369
|
+
.getConversation({
|
|
372
370
|
skipCount: this.selectedContactMessages.length,
|
|
373
371
|
maxResultCount: 50,
|
|
374
372
|
targetUserId: this.selectedContact.userId,
|
|
@@ -393,6 +391,14 @@ class ChatComponent {
|
|
|
393
391
|
},
|
|
394
392
|
]);
|
|
395
393
|
}
|
|
394
|
+
ngOnInit() {
|
|
395
|
+
this.chatSettingsService.get().pipe(take$1(1)).subscribe(val => {
|
|
396
|
+
this.conversationDeletable = val.deletingMessages === ChatDeletingMessages.Enabled && val.deletingConversations === ChatDeletingConversations.Enabled;
|
|
397
|
+
this.messageDeletable = val.deletingMessages === ChatDeletingMessages.Enabled;
|
|
398
|
+
this.messageDeletableWithPeriod = val.deletingMessages === ChatDeletingMessages.EnabledWithDeletionPeriod;
|
|
399
|
+
this.messageDeletePeriod = val.messageDeletionPeriod;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
396
402
|
listenToChatBoxScroll() {
|
|
397
403
|
if (this.chatBoxRef) {
|
|
398
404
|
fromEvent(this.chatBoxRef.nativeElement, 'scroll')
|
|
@@ -409,10 +415,10 @@ class ChatComponent {
|
|
|
409
415
|
const isSelected = this.selectedContact.userId === senderUserId;
|
|
410
416
|
this.userMessages.get(senderUserId).push({
|
|
411
417
|
message: text,
|
|
412
|
-
messageDate:
|
|
413
|
-
side: ChatMessageSide.Receiver,
|
|
418
|
+
messageDate: Date(),
|
|
419
|
+
side: ChatMessageSide$1.Receiver,
|
|
414
420
|
isRead: isSelected,
|
|
415
|
-
readDate: isSelected ?
|
|
421
|
+
readDate: isSelected ? Date() : null,
|
|
416
422
|
});
|
|
417
423
|
this.scrollToEnd();
|
|
418
424
|
});
|
|
@@ -430,7 +436,7 @@ class ChatComponent {
|
|
|
430
436
|
getConversation(scrollToEnd) {
|
|
431
437
|
this.allMessagesLoaded = false;
|
|
432
438
|
this.conversationService
|
|
433
|
-
.
|
|
439
|
+
.getConversation({
|
|
434
440
|
skipCount: 0,
|
|
435
441
|
maxResultCount: 50,
|
|
436
442
|
targetUserId: this.selectedContact.userId,
|
|
@@ -449,19 +455,15 @@ class ChatComponent {
|
|
|
449
455
|
this.unreadMessageCount = 0;
|
|
450
456
|
this.loading = true;
|
|
451
457
|
this.conversationService
|
|
452
|
-
.
|
|
458
|
+
.sendMessage({ message: this.message, targetUserId: this.selectedContact.userId })
|
|
453
459
|
.pipe(finalize(() => (this.loading = false)))
|
|
454
|
-
.subscribe(() => {
|
|
460
|
+
.subscribe((message) => {
|
|
455
461
|
this.chatContactsComponent.changeLastMessageOfSelectedContact(this.message);
|
|
456
462
|
if (!this.userMessages.has(this.selectedContact.userId)) {
|
|
457
463
|
this.userMessages.set(this.selectedContact.userId, []);
|
|
458
464
|
}
|
|
459
465
|
this.userMessages.get(this.selectedContact.userId).push({
|
|
460
|
-
message
|
|
461
|
-
isRead: true,
|
|
462
|
-
readDate: now,
|
|
463
|
-
messageDate: now,
|
|
464
|
-
side: ChatMessageSide.Sender,
|
|
466
|
+
...message
|
|
465
467
|
});
|
|
466
468
|
this.message = '';
|
|
467
469
|
this.scrollToEnd();
|
|
@@ -469,7 +471,7 @@ class ChatComponent {
|
|
|
469
471
|
}
|
|
470
472
|
markConversationAsRead() {
|
|
471
473
|
this.conversationService
|
|
472
|
-
.
|
|
474
|
+
.markConversationAsRead({ targetUserId: this.selectedContact.userId })
|
|
473
475
|
.subscribe(() => {
|
|
474
476
|
this.chatContactsComponent.markSelectedContactAsRead();
|
|
475
477
|
this.selectedContact.unreadMessageCount = 0;
|
|
@@ -512,13 +514,35 @@ class ChatComponent {
|
|
|
512
514
|
startConversation() {
|
|
513
515
|
this.clickedStartMessage = true;
|
|
514
516
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
+
deleteMessage(message) {
|
|
518
|
+
this.conversationService.deleteMessage({ targetUserId: this.selectedContact.userId, messageId: message.id }).pipe(take$1(1)).subscribe({
|
|
519
|
+
next: (val) => {
|
|
520
|
+
const newArray = this.userMessages.get(this.selectedContact.userId).filter((val) => {
|
|
521
|
+
return val.id !== message.id;
|
|
522
|
+
});
|
|
523
|
+
this.userMessages.set(this.selectedContact.userId, newArray);
|
|
524
|
+
},
|
|
525
|
+
error: (err) => {
|
|
526
|
+
const error = err.error?.error?.message;
|
|
527
|
+
this.confirmation.warn(error, "AbpUi::Warning", {
|
|
528
|
+
hideCancelBtn: true,
|
|
529
|
+
yesText: 'AbpUi::Ok',
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
showDeleteDropdown(message) {
|
|
535
|
+
const readDate = new Date(message.readDate).getTime();
|
|
536
|
+
const now = new Date().getTime();
|
|
537
|
+
return (now - readDate) > this.messageDeletePeriod ? false : true;
|
|
538
|
+
}
|
|
539
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatComponent, deps: [{ token: i1$1.ConversationService }, { token: i2.ChatConfigService }, { token: i3.ConfigStateService }, { token: i3.HttpWaitService }, { token: i1$1.SettingsService }, { token: i4$1.ConfirmationService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
540
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.6", 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\">\r\n <!-- Users box-->\r\n <div class=\"col-12 col-md-5 col-lg-4 d-flex align-items-stretch\">\r\n <abp-chat-contacts\r\n class=\"d-flex w-100\"\r\n (selected)=\"onSelectContact($event)\"\r\n [startConversation]=\"clickedStartMessage\"\r\n [conversationDeletable]=\"conversationDeletable\"\r\n ></abp-chat-contacts>\r\n </div>\r\n <!-- /Users box-->\r\n\r\n <!-- Chat Box-->\r\n\r\n <div class=\"col-12 col-md-7 col-lg-8 d-flex align-items-stretch\">\r\n <div class=\"card w-100 mb-0\">\r\n <div *ngIf=\"selectedContact.userId\" class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <abp-chat-message-title [selectedContact]=\"selectedContact\"></abp-chat-message-title>\r\n\r\n <div #chatBox id=\"chat-conversation-wrapper\" class=\"chat-box mb-2\">\r\n <div class=\"chat-box-container\" 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'\r\n | abpLocalization: '' + unreadMessageCount\r\n }}\r\n </ng-template>\r\n </span>\r\n </h3>\r\n </div>\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=\"card shadow-sm rounded py-1 px-2 py-lg-2 px-lg-3 mb-1 {{\r\n data.isSender ? 'bg-primary' : 'bg-light'\r\n }}\"\r\n >\r\n <p\r\n class=\"message-text 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 {{\r\n data.isSender ? 'left' : 'right'\r\n }}\"\r\n >\r\n {{ message.messageDate | date: getDateFormat(message.messageDate) }}\r\n </p>\r\n\r\n <div *ngIf=\"messageDeletable\" ngbDropdown class=\"dropdown position-absolute top-0 end-0\">\r\n <button class=\"btn p-1 text-light down-arrow\" \r\n ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteMessage(message)\">Delete</button>\r\n </div>\r\n </div>\r\n <div *ngIf=\"messageDeletableWithPeriod && showDeleteDropdown(message)\" ngbDropdown class=\"dropdown position-absolute top-0 end-0\">\r\n <button class=\"btn p-1 text-light down-arrow\" \r\n ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteMessage(message)\">Delete</button>\r\n </div>\r\n </div>\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\r\n *ngIf=\"selectedContact?.userId\"\r\n id=\"send-message-form\"\r\n class=\"bg-light rounded-3 m-0\"\r\n >\r\n <div class=\"p-2 p-lg-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\"\r\n [(ngModel)]=\"message\"\r\n (keydown.enter)=\"sendWithEnter($event)\"\r\n ></textarea>\r\n <div class=\"form-check float-start mt-2\">\r\n <input\r\n type=\"checkbox\"\r\n class=\"form-check-input border shadow-sm\"\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\" aria-hidden=\"true\"></i>\r\n\r\n <ng-template #loadingIcon>\r\n <i class=\"fas fa-spinner fa-spin ms-2\" aria-hidden=\"true\"></i>\r\n </ng-template>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!selectedContact.userId\" class=\"card-body pt-5 pb-5 text-center\">\r\n <i class=\"fa fa-commenting-o fs-2\" aria-hidden=\"true\"></i>\r\n <p class=\"pb-3\">{{ 'Chat::NoMessageYet' | abpLocalization }}</p>\r\n <p>{{ 'Chat::NoMessageYetMessage' | abpLocalization }}</p>\r\n <button (click)=\"startConversation()\" type=\"button\" class=\"btn btn-primary\">\r\n {{ 'Chat::StartConversation' | abpLocalization }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n <!-- /Chat Box-->\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".chat-box{height:calc(100vh - 390px);overflow-y:scroll}.message-text{white-space:pre-line}.message-date{position:absolute;opacity:.35;width:100px;top:1px}.message-date.left{left:-110px;text-align:right}.message-date.right{right:-110px}.dropdown-toggle:after{display:none}.dropdown{border-color:transparent}.down-arrow{border:none;opacity:0}.media-body:hover .down-arrow{opacity:100%}.chat-box-container{padding-right:7px}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:var(--lpx-navbar-color)}::-webkit-scrollbar-thumb{background:var(--lpx-primary)}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i4.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "popperOptions", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { kind: "directive", type: i4.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { kind: "directive", type: i4.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { kind: "directive", type: i4.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }, { kind: "component", type: ChatContactsComponent, selector: "abp-chat-contacts", inputs: ["startConversation", "conversationDeletable"], outputs: ["selected"] }, { kind: "component", type: ChatMessageTitleComponent, selector: "abp-chat-message-title", inputs: ["selectedContact"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { kind: "pipe", type: i3.LocalizationPipe, name: "abpLocalization" }] }); }
|
|
517
541
|
}
|
|
518
542
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatComponent, decorators: [{
|
|
519
543
|
type: Component,
|
|
520
|
-
args: [{ selector: 'abp-chat', 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\">\r\n <!-- Users box-->\r\n <div class=\"col-12 col-md-5 col-lg-4 d-flex align-items-stretch\">\r\n <abp-chat-contacts\r\n class=\"d-flex w-100\"\r\n (selected)=\"onSelectContact($event)\"\r\n [startConversation]=\"clickedStartMessage\"\r\n ></abp-chat-contacts>\r\n </div>\r\n <!-- /Users box-->\r\n\r\n <!-- Chat Box-->\r\n\r\n <div class=\"col-12 col-md-7 col-lg-8 d-flex align-items-stretch\">\r\n <div class=\"card w-100 mb-0\">\r\n <div *ngIf=\"selectedContact.userId\" class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <abp-chat-message-title [selectedContact]=\"selectedContact\"></abp-chat-message-title>\r\n\r\n <div #chatBox id=\"chat-conversation-wrapper\" class=\"chat-box mb-2\">\r\n <div class=\"chat-box-container\" 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'\r\n | abpLocalization: '' + unreadMessageCount\r\n }}\r\n </ng-template>\r\n </span>\r\n </h3>\r\n </div>\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=\"card shadow-sm rounded py-1 px-2 py-lg-2 px-lg-3 mb-1 {{\r\n data.isSender ? 'bg-primary' : 'bg-light'\r\n }}\"\r\n >\r\n <p\r\n class=\"message-text 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 {{\r\n data.isSender ? 'left' : 'right'\r\n }}\"\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\r\n *ngIf=\"selectedContact?.userId\"\r\n id=\"send-message-form\"\r\n class=\"bg-light rounded-3 m-0\"\r\n >\r\n <div class=\"p-2 p-lg-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\"\r\n [(ngModel)]=\"message\"\r\n (keydown.enter)=\"sendWithEnter($event)\"\r\n ></textarea>\r\n <div class=\"form-check float-start mt-2\">\r\n <input\r\n type=\"checkbox\"\r\n class=\"form-check-input border shadow-sm\"\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\" aria-hidden=\"true\"></i>\r\n\r\n <ng-template #loadingIcon>\r\n <i class=\"fas fa-spinner fa-spin ms-2\" aria-hidden=\"true\"></i>\r\n </ng-template>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!selectedContact.userId\" class=\"card-body pt-5 pb-5 text-center\">\r\n <i class=\"fa fa-commenting-o fs-2\" aria-hidden=\"true\"></i>\r\n <p class=\"pb-3\">{{ 'Chat::NoMessageYet' | abpLocalization }}</p>\r\n <p>{{ 'Chat::NoMessageYetMessage' | abpLocalization }}</p>\r\n <button (click)=\"startConversation()\" type=\"button\" class=\"btn btn-primary\">\r\n {{ 'Chat::StartConversation' | abpLocalization }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n <!-- /Chat Box-->\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".chat-box{height:calc(100vh - 390px);overflow-y:scroll}.message-text{white-space:pre-line}.message-date{position:absolute;opacity:.35;width:100px;top:1px}.message-date.left{left:-110px;text-align:right}.message-date.right{right:-110px}\n"] }]
|
|
521
|
-
}], ctorParameters: function () { return [{ type: ConversationService }, { type: i2.ChatConfigService }, { type: i3.ConfigStateService }, { type: i3.HttpWaitService }]; }, propDecorators: { chatBoxRef: [{
|
|
544
|
+
args: [{ selector: 'abp-chat', 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\">\r\n <!-- Users box-->\r\n <div class=\"col-12 col-md-5 col-lg-4 d-flex align-items-stretch\">\r\n <abp-chat-contacts\r\n class=\"d-flex w-100\"\r\n (selected)=\"onSelectContact($event)\"\r\n [startConversation]=\"clickedStartMessage\"\r\n [conversationDeletable]=\"conversationDeletable\"\r\n ></abp-chat-contacts>\r\n </div>\r\n <!-- /Users box-->\r\n\r\n <!-- Chat Box-->\r\n\r\n <div class=\"col-12 col-md-7 col-lg-8 d-flex align-items-stretch\">\r\n <div class=\"card w-100 mb-0\">\r\n <div *ngIf=\"selectedContact.userId\" class=\"card-body p-1 p-md-2 p-lg-3\">\r\n <abp-chat-message-title [selectedContact]=\"selectedContact\"></abp-chat-message-title>\r\n\r\n <div #chatBox id=\"chat-conversation-wrapper\" class=\"chat-box mb-2\">\r\n <div class=\"chat-box-container\" 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'\r\n | abpLocalization: '' + unreadMessageCount\r\n }}\r\n </ng-template>\r\n </span>\r\n </h3>\r\n </div>\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=\"card shadow-sm rounded py-1 px-2 py-lg-2 px-lg-3 mb-1 {{\r\n data.isSender ? 'bg-primary' : 'bg-light'\r\n }}\"\r\n >\r\n <p\r\n class=\"message-text 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 {{\r\n data.isSender ? 'left' : 'right'\r\n }}\"\r\n >\r\n {{ message.messageDate | date: getDateFormat(message.messageDate) }}\r\n </p>\r\n\r\n <div *ngIf=\"messageDeletable\" ngbDropdown class=\"dropdown position-absolute top-0 end-0\">\r\n <button class=\"btn p-1 text-light down-arrow\" \r\n ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteMessage(message)\">Delete</button>\r\n </div>\r\n </div>\r\n <div *ngIf=\"messageDeletableWithPeriod && showDeleteDropdown(message)\" ngbDropdown class=\"dropdown position-absolute top-0 end-0\">\r\n <button class=\"btn p-1 text-light down-arrow\" \r\n ngbDropdownToggle><i class=\"bi bi-chevron-down\"></i></button>\r\n <div ngbDropdownMenu>\r\n <button ngbDropdownItem (click)=\"deleteMessage(message)\">Delete</button>\r\n </div>\r\n </div>\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\r\n *ngIf=\"selectedContact?.userId\"\r\n id=\"send-message-form\"\r\n class=\"bg-light rounded-3 m-0\"\r\n >\r\n <div class=\"p-2 p-lg-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\"\r\n [(ngModel)]=\"message\"\r\n (keydown.enter)=\"sendWithEnter($event)\"\r\n ></textarea>\r\n <div class=\"form-check float-start mt-2\">\r\n <input\r\n type=\"checkbox\"\r\n class=\"form-check-input border shadow-sm\"\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\" aria-hidden=\"true\"></i>\r\n\r\n <ng-template #loadingIcon>\r\n <i class=\"fas fa-spinner fa-spin ms-2\" aria-hidden=\"true\"></i>\r\n </ng-template>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!selectedContact.userId\" class=\"card-body pt-5 pb-5 text-center\">\r\n <i class=\"fa fa-commenting-o fs-2\" aria-hidden=\"true\"></i>\r\n <p class=\"pb-3\">{{ 'Chat::NoMessageYet' | abpLocalization }}</p>\r\n <p>{{ 'Chat::NoMessageYetMessage' | abpLocalization }}</p>\r\n <button (click)=\"startConversation()\" type=\"button\" class=\"btn btn-primary\">\r\n {{ 'Chat::StartConversation' | abpLocalization }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n <!-- /Chat Box-->\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [".chat-box{height:calc(100vh - 390px);overflow-y:scroll}.message-text{white-space:pre-line}.message-date{position:absolute;opacity:.35;width:100px;top:1px}.message-date.left{left:-110px;text-align:right}.message-date.right{right:-110px}.dropdown-toggle:after{display:none}.dropdown{border-color:transparent}.down-arrow{border:none;opacity:0}.media-body:hover .down-arrow{opacity:100%}.chat-box-container{padding-right:7px}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:var(--lpx-navbar-color)}::-webkit-scrollbar-thumb{background:var(--lpx-primary)}\n"] }]
|
|
545
|
+
}], ctorParameters: function () { return [{ type: i1$1.ConversationService }, { type: i2.ChatConfigService }, { type: i3.ConfigStateService }, { type: i3.HttpWaitService }, { type: i1$1.SettingsService }, { type: i4$1.ConfirmationService }]; }, propDecorators: { chatBoxRef: [{
|
|
522
546
|
type: ViewChild,
|
|
523
547
|
args: ['chatBox', { static: false }]
|
|
524
548
|
}], chatContactsComponent: [{
|
|
@@ -548,7 +572,7 @@ const routes = [
|
|
|
548
572
|
];
|
|
549
573
|
class ChatRoutingModule {
|
|
550
574
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
551
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.6", ngImport: i0, type: ChatRoutingModule, imports: [i1.RouterModule], exports: [RouterModule] }); }
|
|
575
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.6", ngImport: i0, type: ChatRoutingModule, imports: [i1$2.RouterModule], exports: [RouterModule] }); }
|
|
552
576
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatRoutingModule, imports: [RouterModule.forChild(routes), RouterModule] }); }
|
|
553
577
|
}
|
|
554
578
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatRoutingModule, decorators: [{
|
|
@@ -579,21 +603,43 @@ class ChatModule {
|
|
|
579
603
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.6", ngImport: i0, type: ChatModule, declarations: [ChatComponent,
|
|
580
604
|
ChatContactsComponent,
|
|
581
605
|
ConversationAvatarComponent,
|
|
582
|
-
ChatMessageTitleComponent], imports: [CoreModule, ThemeSharedModule, ChatRoutingModule], exports: [ChatComponent,
|
|
606
|
+
ChatMessageTitleComponent], imports: [CoreModule, ThemeSharedModule, ChatRoutingModule, NgbDropdownModule], exports: [ChatComponent,
|
|
583
607
|
ChatContactsComponent,
|
|
584
608
|
ConversationAvatarComponent,
|
|
585
609
|
ChatMessageTitleComponent] }); }
|
|
586
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatModule, imports: [CoreModule, ThemeSharedModule, ChatRoutingModule] }); }
|
|
610
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatModule, imports: [CoreModule, ThemeSharedModule, ChatRoutingModule, NgbDropdownModule] }); }
|
|
587
611
|
}
|
|
588
612
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ChatModule, decorators: [{
|
|
589
613
|
type: NgModule,
|
|
590
614
|
args: [{
|
|
591
615
|
declarations,
|
|
592
|
-
imports: [CoreModule, ThemeSharedModule, ChatRoutingModule],
|
|
616
|
+
imports: [CoreModule, ThemeSharedModule, ChatRoutingModule, NgbDropdownModule],
|
|
593
617
|
exports: [...declarations],
|
|
594
618
|
}]
|
|
595
619
|
}] });
|
|
596
620
|
|
|
621
|
+
class ConversationService {
|
|
622
|
+
constructor(restService) {
|
|
623
|
+
this.restService = restService;
|
|
624
|
+
this.apiName = 'Chat';
|
|
625
|
+
}
|
|
626
|
+
sendMessageByInput(body) {
|
|
627
|
+
return this.restService.request({ url: '/api/chat/conversation/send-message', method: 'POST', body }, { apiName: this.apiName });
|
|
628
|
+
}
|
|
629
|
+
getConversationByInput(params = {}) {
|
|
630
|
+
return this.restService.request({ url: '/api/chat/conversation/conversation', method: 'GET', params }, { apiName: this.apiName });
|
|
631
|
+
}
|
|
632
|
+
markConversationAsReadByInput(body) {
|
|
633
|
+
return this.restService.request({ url: '/api/chat/conversation/mark-conversation-as-read', method: 'POST', body }, { apiName: this.apiName });
|
|
634
|
+
}
|
|
635
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, deps: [{ token: i3.RestService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
636
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, providedIn: 'root' }); }
|
|
637
|
+
}
|
|
638
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: ConversationService, decorators: [{
|
|
639
|
+
type: Injectable,
|
|
640
|
+
args: [{ providedIn: 'root' }]
|
|
641
|
+
}], ctorParameters: function () { return [{ type: i3.RestService }]; } });
|
|
642
|
+
|
|
597
643
|
class SettingsService {
|
|
598
644
|
constructor(restService) {
|
|
599
645
|
this.restService = restService;
|