{"title":"Плавающий виджет(Чат)","template":"\u003cp-dialog header=\"Отправить файл\" [(visible)]=\"show_files_lookup\" [style]=\"{height: '30vw'}\"\u003e\n \u003cdiv class=\"row\" style=\"width:700px\"\u003e\n\t\u003cjit-page (getComponent)=\"getComponent_files_lookup($event)\" [cache]=\"true\" type=\"page\" *ngIf=\"show_files_lookup\" code=\"files_lookup\"\u003e\u003c/jit-page\u003e\n\t\u003c/div\u003e\n\u003c/p-dialog\u003e\n \n\n\u003cng-container *ngIf=\"currentChat \u0026\u0026 sessioninfo\"\u003e\n\n\n \u003caudio style=\"display:none\" id=\"wachataudio\" controls=\"controls\"\u003e\n \u003csource src=\"/static/sounds/ring/ring01.mp3\" /\u003e\n \u003c/audio\u003e\n \n \u003cdiv class=\"d-lg-flex\"\u003e\n \n \u003cdiv class=\"chat-leftsidebar card\"\u003e\n \u003cdiv class=\"p-1 px-4 bg-light\"\u003e\n \u003cdiv class=\"d-flex align-items-start\"\u003e\n \u003cdiv class=\"align-self-center me-3\"\u003e\n \u003cimg [src]=\"sessioninfo?.avatar_url\" class=\"avatar-xs rounded-circle\" alt=\"avatar\" /\u003e\n \u003c/div\u003e\n \u003cdiv class=\"flex-1\"\u003e\n \u003ch5 class=\"font-size-16 mt-0 mb-1\"\u003e\n \u003ca href=\"#\" class=\"text-reset\"\u003e{{sessioninfo.chat_name}}\n \u003ci class=\"\n mdi mdi-circle\n text-success\n align-middle\n font-size-10\n ms-1\n \"\u003e\u003c/i\u003e\u003c/a\u003e\n \u003c/h5\u003e\n \u003cp class=\"text-muted mb-0 font-size-12\"\u003eAvailable\u003c/p\u003e\n \u003c/div\u003e\n \n \u003cdiv\u003e\n \u003cdiv class=\"dropdown chat-noti-dropdown\" ngbDropdown\u003e\n \u003cbutton class=\"btn dropdown-toggle py-0\" type=\"button\" data-bs-toggle=\"dropdown\" aria-haspopup=\"true\"\n aria-expanded=\"false\" ngbDropdownToggle\u003e\n \u003ci class=\"mdi mdi-dots-horizontal\"\u003e\u003c/i\u003e\n \u003c/button\u003e\n \u003cdiv class=\"dropdown-menu dropdown-menu-end\" ngbDropdownMenu\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eProfile\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eEdit\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eAdd Contact\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eSettings\u003c/a\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"p-1\"\u003e\n \u003cdiv class=\"search-box chat-search-box\"\u003e\n \u003cdiv class=\"position-relative\"\u003e\n \u003cinput type=\"text\" [(ngModel)]=\"searchText\" (keyup)=\"search(searchText)\" class=\"form-control border-light rounded\" placeholder=\"Поиск...\" /\u003e\n \u003ci class=\"mdi mdi-magnify search-icon\"\u003e\u003c/i\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"row\"\u003e\n \u003cdiv class=\"col\"\u003e\n \u003cbutton *ngIf=\"searchText \u0026\u0026 searchText.length\u003e=10\" pButton type=\"button\" (click)=\"startChatByPhone(searchText)\"\u003eНачать чат с {{searchText}}\u003c/button\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv\u003e\n \u003cdiv class=\"border-top\"\u003e\n \u003cdiv class=\"p-1\" data-simplebar \u003e\n \n \n \u003cdiv *ngIf=\"searchText\"\u003e\n \u003ch5 class=\"font-size-13 text-uppercase mb-3\"\u003e\n \u003ci class=\"mdi mdi-account-outline me-1\"\u003e\u003c/i\u003e Результаты поиска\n \u003c/h5\u003e\n \u003cngx-simplebar style=\"position: relative;\" #scrollEle\u003e\n \u003cul class=\"list-unstyled chat-list\"\u003e\n \u003cng-container *ngFor=\"let dialog of dialogs\"\u003e \n \u003cli [class]=\"dialog.id==currentChat.id?'active':''\"\u003e\n \u003ca href=\"javascript: void(0);\" (click)=\"getMessagesByDialog(dialog)\"\u003e\n \u003cdiv class=\"d-flex align-items-start\"\u003e\n \u003cdiv class=\"user-img online align-self-center me-3\" *ngIf=\"dialog.cli_id$avatar\"\u003e\n \u003cimg src=\"{{ dialog.cli_id$avatar }}\" class=\"rounded-circle avatar-xs\" alt=\"avatar\" /\u003e\n \u003cspan class=\"user-status\"\u003e\u003c/span\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"avatar-xs align-self-center me-3\" *ngIf=\"!dialog.cli_id$avatar\"\u003e\n \u003cspan *ngIf=\"dialog \u0026\u0026 dialog.client_name\" class=\"\n avatar-title\n rounded-circle\n bg-primary\n \"\u003e\n {{ dialog.client_name.charAt(0) }}\n \u003c/span\u003e\n \u003c/div\u003e\n \u003cdiv class=\"flex-1 overflow-hidden\"\u003e\n \u003ch5 class=\"text-truncate font-size-14 mb-1\"\u003e\n {{ dialog.client_name }} \n \u003c/h5\u003e\n \u003cp class=\"text-truncate font-size-13 mb-0\"\u003e\n {{ dialog.message }}\n \u003c/p\u003e\n \u003c/div\u003e\n \u003cdiv class=\"font-size-11\"\u003e{{ moment(dialog.time).format('DD.MM.YYYY') }}\u003c/div\u003e\n \u003c/div\u003e\n \u003c/a\u003e\n \u003c/li\u003e\n \u003c/ng-container\u003e\n \u003c/ul\u003e\n \u003c/ngx-simplebar\u003e\n \u003c/div\u003e \n \n \n \u003cdiv *ngIf=\"!searchText\"\u003e\n \u003ch5 class=\"font-size-13 text-uppercase mb-3\"\u003e\n \u003ci class=\"mdi mdi-account-outline me-1\"\u003e\u003c/i\u003e Мои диалоги\n \u003c/h5\u003e\n \u003cngx-simplebar style=\"position: relative;\" #scrollEle\u003e\n \u003cul class=\"list-unstyled chat-list\"\u003e\n \u003cng-container *ngFor=\"let dialog of dialogs\"\u003e \n \u003cli [class]=\"dialog.id==currentChat.id?'active':''\" *ngIf=\"(dialog.user_id == sessioninfo.id || dialog.ts_user_id == sessioninfo.id) \"\u003e\n \u003ca href=\"javascript: void(0);\" (click)=\"getMessagesByDialog(dialog)\"\u003e\n \u003cdiv class=\"d-flex align-items-start\"\u003e\n \u003cdiv class=\"user-img online align-self-center me-3\" *ngIf=\"dialog.cli_id$avatar\"\u003e\n \u003cimg src=\"{{ dialog.cli_id$avatar }}\" class=\"rounded-circle avatar-xs\" alt=\"avatar\" /\u003e\n \u003cspan class=\"user-status\"\u003e\u003c/span\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"avatar-xs align-self-center me-3\" *ngIf=\"!dialog.cli_id$avatar\"\u003e\n \u003cspan *ngIf=\"dialog \u0026\u0026 dialog.client_name\" class=\"\n avatar-title\n rounded-circle\n bg-primary\n \"\u003e\n {{ dialog.client_name.charAt(0) }}\n \u003c/span\u003e\n \u003c/div\u003e\n \u003cdiv class=\"flex-1 overflow-hidden\"\u003e\n \u003ch5 class=\"text-truncate font-size-14 mb-1\"\u003e\n {{ dialog.client_name }} \n \u003c/h5\u003e\n \u003cp class=\"text-truncate font-size-13 mb-0\"\u003e\n {{ dialog.message }}\n \u003c/p\u003e\n \u003c/div\u003e\n \u003cdiv class=\"font-size-11\"\u003e{{ moment(dialog.time).format('DD.MM.YYYY') }}\u003c/div\u003e\n \u003c/div\u003e\n \u003c/a\u003e\n \u003c/li\u003e\n \u003c/ng-container\u003e\n \u003c/ul\u003e\n \u003c/ngx-simplebar\u003e\n \u003c/div\u003e \n \u003cdiv *ngIf=\"!searchText\"\u003e\n \u003ch5 class=\"font-size-13 text-uppercase mb-3\"\u003e\n \u003ci class=\"mdi mdi-account-outline me-1\"\u003e\u003c/i\u003e Все диалоги\n \u003c/h5\u003e\n \u003cngx-simplebar style=\"position: relative; height: 410px\" #scrollEle\u003e\n \u003cul class=\"list-unstyled chat-list\"\u003e\n \u003cng-container *ngFor=\"let dialog of dialogs\"\u003e\n \u003cli [class]=\"dialog.id==currentChat.id?'active':''\" *ngIf=\"dialog.user_id != sessioninfo.id \u0026\u0026 dialog.ts_user_id != sessioninfo.id\"\u003e\n \u003ca href=\"javascript: void(0);\" (click)=\"getMessagesByDialog(dialog)\"\u003e\n \u003cdiv class=\"d-flex align-items-start\"\u003e\n \u003cdiv class=\"user-img online align-self-center me-3\" *ngIf=\"dialog.cli_id$avatar\"\u003e\n \u003cimg src=\"{{ dialog.cli_id$avatar }}\" class=\"rounded-circle avatar-xs\" alt=\"avatar\" /\u003e\n \u003cspan class=\"user-status\"\u003e\u003c/span\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"avatar-xs align-self-center me-3\" *ngIf=\"!dialog.cli_id$avatar\"\u003e\n \u003cspan\n *ngIf=\"dialog \u0026\u0026 dialog.client_name\"\n class=\"\n avatar-title\n rounded-circle\n bg-primary\n \"\u003e\n {{ dialog.client_name.charAt(0) }}\n \u003c/span\u003e\n \u003c/div\u003e\n \u003cdiv class=\"flex-1 overflow-hidden\"\u003e\n \u003ch5 class=\"text-truncate font-size-14 mb-1\"\u003e\n {{ dialog.client_name }} \n \u003c/h5\u003e\n \u003cp class=\"text-truncate font-size-13 mb-0\"\u003e\n {{ dialog.message }}\n \u003c/p\u003e\n \u003c/div\u003e\n \u003cdiv class=\"font-size-11\"\u003e{{ moment(dialog.time).format('DD.MM.YYYY') }}\u003c/div\u003e\n \u003c/div\u003e\n \u003c/a\u003e\n \u003c/li\u003e\n \u003c/ng-container\u003e\n \u003c/ul\u003e\n \u003c/ngx-simplebar\u003e\n \u003c/div\u003e\n \n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"w-100 user-chat mt-4 mt-sm-0 ms-lg-1\" \u003e\n \u003cdiv class=\"card\"\u003e\n \n \n \u003cdiv class=\"p-1 px-lg-4 border-bottom\" *ngIf=\"currentChat \u0026\u0026 currentChat.client_name\"\u003e\n \u003cdiv class=\"row\"\u003e\n \u003cdiv class=\"col-md-12 col-12\"\u003e\n \u003cdiv class=\"d-flex align-items-center\"\u003e\n \u003cdiv class=\"d-block d-lg-none me-2 ms-0\"\u003e\n \u003ca href=\"javascript: void(0);\" class=\"user-chat-remove text-muted font-size-16 p-2\"\u003e\u003ci\n class=\"ri-arrow-left-s-line\"\u003e\u003c/i\u003e\u003c/a\u003e\n \u003c/div\u003e\n \u003cdiv class=\"me-3 ms-0\"\u003e\n \u003cimg *ngIf=\"currentChat \u0026\u0026 currentChat.cli_id$avatar \" src=\"{{ currentChat.cli_id$avatar }}\" class=\"rounded-circle avatar-xs\" alt=\"avatar\" /\u003e\n \n \n \u003cdiv class=\"avatar-xs align-self-center\" *ngIf=\"currentChat \u0026\u0026 !currentChat.cli_id$avatar\"\u003e\n \u003cspan \n *ngIf=\"currentChat \u0026\u0026 currentChat.client_name\"\n class=\"\n avatar-title\n rounded-circle\n bg-primary\n \"\u003e\n {{ currentChat.client_name.charAt(0) }} \n \u003c/span\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"row\"\u003e\n \u003cdiv class=\"col\"\u003e\n \u003ch5 class=\"font-size-16 mb-0\"\u003e\n \u003cspan class=\"text-reset user-profile-show\"\u003e{{currentChat.client_name}} ({{ currentChat.client_phone }})\u003c/span\u003e\n \u003ci class=\"\n mdi mdi-circle\n text-success\n align-middle\n font-size-10\n ms-1\n \"\u003e\u003c/i\u003e\n \u003c/h5\u003e\n \n \u003c/div\u003e\n \u003cdiv class=\"col\" *ngIf=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\"\u003e\n \u003cbutton type=\"button\" (click)='take(currentChat)' pButton\u003eВзять\u003c/button\u003e\n \u003c/div\u003e\n \u003cdiv class=\"col\" *ngIf=\"currentChat.user_id==sessioninfo.id || currentChat.ts_user_id==sessioninfo.id\"\u003e\n \u003cbutton type=\"button\" (click)='transfer(currentChat)' pButton\u003eПередать\u003c/button\u003e\n \u003c/div\u003e \n \n \u003c!--\n \n \u003cdiv class=\"col\" *ngIf=\"currentChat.user_id==sessioninfo.id\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block\" translate\u003eНачать с WhatsApp-шаблона:\u003c/span\u003e\n \n \u003c/div\u003e \n \n \u003cdiv class=\"col\" *ngIf=\"currentChat.user_id==sessioninfo.id\"\u003e\n \u003cbutton pButton (click)=\"startChatRu()\" type=\"button\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block\" translate\u003eRU\u003c/span\u003e\n \u003c/button\u003e\n \u003c/div\u003e \n \u003cdiv class=\"col\" *ngIf=\"currentChat.user_id==sessioninfo.id\"\u003e\n \u003cbutton pButton (click)=\"startChatKz()\" type=\"button\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block\" translate\u003eKZ\u003c/span\u003e\n \u003c/button\u003e \n \u003c/div\u003e\n \n --\u003e\n \n \n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"col-md-8 col-6\"\u003e\n \u003cul class=\"list-inline user-chat-nav text-end mb-0\"\u003e\n \u003cli class=\"list-inline-item\"\u003e\n \u003cdiv class=\"dropdown\" ngbDropdown\u003e\n \u003cbutton class=\"btn nav-btn dropdown-toggle\" type=\"button\" data-bs-toggle=\"dropdown\"\n aria-haspopup=\"true\" aria-expanded=\"false\" ngbDropdownToggle\u003e\n \u003ci class=\"mdi mdi-magnify\"\u003e\u003c/i\u003e\n \u003c/button\u003e\n \u003cdiv class=\"dropdown-menu dropdown-menu-end dropdown-menu-md p-0\" ngbDropdownMenu\u003e\n \u003cform class=\"p-2\"\u003e\n \u003cdiv\u003e\n \u003cinput type=\"text\" class=\"form-control border-light rounded\" placeholder=\"Поиск...\" /\u003e\n \u003c/div\u003e\n \u003c/form\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/li\u003e\n\n \u003cli class=\"list-inline-item\"\u003e\n \u003cdiv class=\"dropdown\" ngbDropdown\u003e\n \u003cbutton class=\"btn nav-btn dropdown-toggle\" type=\"button\" data-bs-toggle=\"dropdown\"\n aria-haspopup=\"true\" aria-expanded=\"false\" ngbDropdownToggle\u003e\n \u003ci class=\"mdi mdi-dots-horizontal\"\u003e\u003c/i\u003e\n \u003c/button\u003e\n \u003cdiv class=\"dropdown-menu dropdown-menu-end\" ngbDropdownMenu\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eProfile\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eArchive\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eMuted\u003c/a\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eDelete\u003c/a\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/li\u003e\n \u003c/ul\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"py-lg-3 px-lg-2\" *ngIf=\"currentChat \u0026\u0026 currentChat.id\"\n style='background-image:url(\"/restapi/getfile?code=images-d35dc30c-e229-4d1d-bf28-5288c9d824ca\u0026attachment=true\")'\n \n \u003e\n \u003cdiv class=\"chat-conversation p-3\"\u003e\n \u003cngx-simplebar style=\"height: 355px;\"\u003e\n \n \u003cul class=\"list-unstyled mb-0\"\u003e\n \u003c!--\u003cli class=\"chat-day-title\"\u003e--\u003e\n \u003c!-- \u003cdiv class=\"title\"\u003eToday\u003c/div\u003e--\u003e\n \u003c!--\u003c/li\u003e--\u003e\n \u003cng-container *ngFor=\"let msg of messages\"\u003e\n \u003cli *ngIf=\"msg.dialog_id == currentChat.dialog_id\" [ngClass]=\"{ 'right': msg.from_cli != 1 }\"\u003e\n \u003cdiv class=\"conversation-list d-flex\" [ngClass]=\"{ 'order-3': msg.from_cli != 1 }\"\u003e\n \u003cdiv class=\"chat-user-img online align-self-start\" [ngClass]=\"{ 'order-3': msg.from_cli != 1 }\"\u003e\n \u003cimg *ngIf=\"msg.from_cli == 1 \u0026\u0026 currentChat \u0026\u0026 currentChat.cli_id$avatar\" src=\"{{ currentChat.cli_id$avatar }}\" class=\"rounded-circle avatar-xs\" [alt]=\"msg.sender_txt\" onerror=\"this.src='assets/img/image-not-found.png'\" /\u003e\n \u003cimg *ngIf=\"msg.from_cli != 1 \u0026\u0026 currentChat \u0026\u0026 msg.sender_user_id$avatar_url\" src=\"{{ msg.sender_user_id$avatar_url }}\" class=\"rounded-circle avatar-xs\" [alt]=\"msg.sender_txt\" onerror=\"this.src='assets/img/image-not-found.png'\" /\u003e\n \n\n \u003cdiv *ngIf=\"!msg.profile \u0026\u0026 msg.sender_txt \u0026\u0026 currentChat \u0026\u0026 !currentChat.cli_id$avatar \u0026\u0026 msg.from_cli == 1\" class=\"avatar-xs align-self-center\"\u003e\n \u003cspan class=\"avatar-title rounded-circle bg-primary\"\u003e {{ msg.sender_txt.charAt(0) }} \u003c/span\u003e\n \u003c/div\u003e\n \n \u003cdiv *ngIf=\"!msg.profile \u0026\u0026 msg.sender_txt \u0026\u0026 currentChat \u0026\u0026 !msg.sender_user_id$avatar_url \u0026\u0026 msg.from_cli != 1\" class=\"avatar-xs align-self-center\"\u003e\n \u003cspan class=\"avatar-title rounded-circle bg-primary\"\u003e {{ msg.sender_txt.charAt(0) }} \u003c/span\u003e\n \u003c/div\u003e \n \n \u003c/div\u003e\n \n \n \n \u003cdiv class=\"ctext-wrap\"\u003e\n \u003cdiv class=\"ctext-wrap-content\" style=\"background-color:white\"\u003e\n \u003cp class=\"mb-0\"\u003e\n {{ msg.msg }}\n \n \u003cng-container *ngIf=\"msg.attachments\"\u003e\n \u003cng-container *ngFor=\"let attachment of msg.attachments\"\u003e\n \n \u003cspan [ngSwitch]=\"attachment.content_type\"\u003e\n \u003ca target=\"_blank\" *ngSwitchCase=\"'image/jpeg'\" download=\"image-damucrm.jpg\" [href]=\"attachment.file.url\"\u003e\u003cimg [src]=\"attachment.file.url\" style=\"width:80%\" class=\"m-1\" /\u003e\u003c/a\u003e\n \u003ca target=\"_blank\" *ngSwitchCase=\"'application/pdf'\" download=\"document.pdf\" [href]=\"attachment.file.url\"\u003e\u003ci class=\"m-1 pi pi-file-pdf\"\u003e\u003c/i\u003e \u003c/a\u003e \n \u003caudio controls *ngSwitchCase=\"'audio/mpeg'\" [src]=\"attachment.file.url\"\u003e\u003c/audio\u003e \n \u003ca target=\"_blank\" *ngSwitchDefault download=\"document.pdf\" [href]=\"attachment.file.url\"\u003e\u003ci class=\"m-1 pi pi-file-pdf\"\u003e\u003c/i\u003e \u003c/a\u003e \n\t\u003c/span\u003e \u003c/ng-container\u003e\n \u003c/ng-container\u003e\n\n \n \u003c!--{{ msg.sender_txt }} == {{appComponent.layout.user_detail.title }}--\u003e\n \u003cspan class=\"d-inline-block font-size-12 text-muted ms-3\"\u003e{{ msg.created_at | localizedDate:'HH:mm' }}\u003c/span\u003e\n \u003c/p\u003e\n \u003c/div\u003e\n \u003cdiv class=\"dropdown align-self-start\" ngbDropdown\u003e\n \u003ca class=\"dropdown-toggle\" href=\"javascript:void(0);\" role=\"button\" data-bs-toggle=\"dropdown\"\n aria-haspopup=\"true\" aria-expanded=\"false\" ngbDropdownToggle\u003e\n \u003cspan class=\"material-icons\"\u003emore_vert\u003c/span\u003e\n \u003c/a\u003e\n \u003cdiv class=\"dropdown-menu\" ngbDropdownMenu\u003e\n \u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eКопировать\u003c/a\u003e\n \u003c!--\u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eSave\u003c/a\u003e--\u003e\n \u003c!--\u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eForward\u003c/a\u003e--\u003e\n \u003c!--\u003ca class=\"dropdown-item\" href=\"javascript:void(0);\"\u003eDelete\u003c/a\u003e--\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cimg *ngIf=\"msg.photo\" style=\"width:200px\" :src=\"{{msg.photo}}\" class=\"rounded2\" [alt]=\"msg.photo\" onerror=\"this.src='assets/img/image-not-found.png'\" /\u003e\n \u003c/li\u003e\n \u003c/ng-container\u003e\n \u003cli id=\"bottom\"\u003e\u003c/li\u003e\n \u003c/ul\u003e\n \u003c/ngx-simplebar\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c!--\u003cdiv class=\"row\"\u003e\n \u003cdiv class=\"col\"\u003e\n \u003clabel\u003eВыберите Канал: \u003c/label\u003e\n \u003cspan class=\"p-buttonset\"\u003e\n \u003cbutton *ngFor=\"let ch of c_c2d_ch\" pButton pRipple type=\"button\" (click)=\"currentCh = ch\" [label]=\"ch.title\" [class]=\"currentCh.id == ch.id ? 'p-button-raised' : 'p-button-raised p-button-text'\"\u003e\u003c/button\u003e\n \u003c/span\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n --\u003e\n \n\n \n \n \u003cdiv class=\"row\" *ngIf=\"currentChat \u0026\u0026 currentChat.id\"\u003e\n \u003cdiv class=\"p-3 chat-input-section\"\u003e\n \u003cdiv class=\"row\"\u003e\n \u003cdiv class=\"col\"\u003e\n \u003cdiv class=\"position-relative\"\u003e\n \u003cdiv class=\"p-inputgroup\"\u003e \n \n \u003cbutton *ngIf=\"currentChat.last_24==1\" title=\"Отправить шаблон\" [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\" (click)=\"choiseTemplate()\" type=\"button\" pButton pRipple\u003e\u003cspan class=\"material-icons\" label=\"\"\u003etext_fields\u003c/span\u003e\u003c/button\u003e\n \u003cbutton *ngIf=\"currentChat.last_24==1\" title=\"Вложить файл\" [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\" (click)=\"attachFileDialog()\" type=\"button\" pButton pRipple\u003e\u003cspan class=\"material-icons\" label=\"\"\u003eattach_file\u003c/span\u003e\u003c/button\u003e\n \u003cbutton *ngIf=\"currentChat.last_24==1 \u0026\u0026 currentChat \u0026\u0026 currentChat.file \u0026\u0026 currentChat.file.filename\" title=\"Вложить файл\" [disabled]=\"currentChat.user_id!=sessioninfo.id\" type=\"button\" pButton pRipple\u003e{{currentChat.file.filename}}\u003c/button\u003e\n \u003cbutton *ngIf=\"currentChat.last_24==1 \u0026\u0026 currentChat.last_24==1 \u0026\u0026 currentChat \u0026\u0026 currentChat.file \u0026\u0026 currentChat.file.filename\" title=\"Удалить файл\" (click)=\"currentChat.file=null\" [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\" type=\"button\" pButton pRipple\u003e\u003cspan class=\"material-icons\" label=\"\"\u003eclear\u003c/span\u003e\u003c/button\u003e\n \u003cinput *ngIf=\"currentChat.last_24==1\" [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\" (keyup.enter)=\"sendMessage(currentChat.new_text)\" [(ngModel)]=\"currentChat.new_text\" [ngModelOptions]=\"{standalone: true}\" name=\"firstField\" [readonly]=\"false\"\n type=\"text\" class=\"form-control chat-input rounded\" placeholder=\"Введите текст\" /\u003e \n \u003cinput *ngIf=\"currentChat.last_24!=1\" [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id\" (keyup.enter)=\"startChatRu(currentChat.new_text)\" [(ngModel)]=\"currentChat.new_text\" [ngModelOptions]=\"{standalone: true}\" name=\"firstField\" [readonly]=\"false\"\n type=\"text\" class=\"form-control chat-input rounded\" placeholder=\"Введите первое сообщение\" /\u003e \n \u003c/div\u003e \n\n \n \u003c!--\u003cdiv *ngIf=\"chatSubmit \u0026\u0026 f.text.errors\" class=\"invalid-feedback\"\u003e\n \u003cspan *ngIf=\"f.text.errors.required\"\u003eThis value is required.\u003c/span\u003e\n \u003c/div\u003e\n --\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"col-auto\" *ngIf=\"currentChat.last_24!=1\"\u003e\n \u003cbutton [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id || (!currentChat.new_text \u0026\u0026 !currentChat.file ) \" (click)=\"startChatKz(currentChat.new_text)\" type=\"button\" class=\"btn btn-primary chat-send w-md waves-effect waves-light\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block me-2\" translate\u003eKZ\u003c/span\u003e\n \u003c!--\u003cspan class=\"material-icons\"\u003esend\u003c/span\u003e--\u003e\n \u003c/button\u003e\n \u003cbutton [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id || (!currentChat.new_text \u0026\u0026 !currentChat.file ) \" (click)=\"startChatRu(currentChat.new_text)\" type=\"button\" class=\"btn btn-primary chat-send w-md waves-effect waves-light\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block me-2\" translate\u003eRU\u003c/span\u003e\n \u003c!--\u003cspan class=\"material-icons\"\u003esend\u003c/span\u003e--\u003e\n \u003c/button\u003e \n \u003c/div\u003e\n \n \u003cdiv class=\"col-auto\" *ngIf=\"currentChat.last_24==1\"\u003e\n \u003cbutton [disabled]=\"currentChat.user_id!=sessioninfo.id \u0026\u0026 currentChat.ts_user_id!=sessioninfo.id || (!currentChat.new_text \u0026\u0026 !currentChat.file ) \" (click)=\"sendMessage(currentChat.new_text)\" type=\"button\" class=\"btn btn-primary chat-send w-md waves-effect waves-light\"\u003e\n \u003cspan class=\"d-none d-sm-inline-block me-2\" translate\u003eSend\u003c/span\u003e\n \u003c!--\u003cspan class=\"material-icons\"\u003esend\u003c/span\u003e--\u003e\n \u003c/button\u003e\n \u003c/div\u003e\n \n \n \u003c/div\u003e\n \u003c/div\u003e\n \n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n\n\n\u003c/ng-container\u003e","json":"const vm = this; \n\nconst {first} = rxjs;\nconst {map,take} = rxjs;\nconst {QueryOptions} = Models;\n\nreturn class GenClass extends vm.constructor {\n \n currentChat = {};\n currentCont = {};\n moment = moment;\n currentCh = {};\n show_files_lookup = false;\n \n text = \"\";\n c_c2d_ch = [];\n cli_id;\n cli_title = \"\";\n messages = [];\n chatData = [{name:\"Eka\",message:\"Привет\",time:\"12:01:22\"}];\n \n //sendMessage(text){\n //alert(\"отправлено\");\n \n //}\n \n search(text){\n this.getDialogsByText(text);\n }\n \n getComponent_files_lookup(event){\n event.chooseCallBack = (data)=\u003e{\n console.log(\"data\",data);\n this.show_files_lookup = false;\n this.currentChat.file = data;\n }\n \n }\n \n attachFileDialog(){\n this.show_files_lookup = true;\n }\n \n startChatByPhone(phone){\n this.appComponent.bpRun(\"c_start_chat_by_phone\",{ phone: phone }, (data) =\u003e this.startChatByPhoneCallBack(data));\n }\n \n startChatByPhoneCallBack(data){\n //\n this.appComponent.layout.flow_widget = true\n //alert(data.output.c_c2d_dialog_id);\n this.currentChat.id=data.output.c_c2d_dialog_id;\n this.getDialogs();\n this.getMessagesByDialog({id:this.currentChat.id});\n //console.log(\"startChatByPhoneCallBack\",data);\n }\n \n choiseCli(){\n \n let dialog_ref = this.dialogService.open(Components.DialogTemplateComponent,{\n header: \"Выбрать клиента\",\n data: {\n data: {},\n type: 'pages',\n code: \"c_cli\",\n getJitComponent: jit_page =\u003e {\n jit_page.goToDetail = (item) =\u003e {\n this.openCli(item.id,item.title,\"\");\n console.log(\"item\",item);\n //this.onChange(file.id);\n //this.onUpload.emit(file);\n \n dialog_ref.close();\n }\n }\n }\n });\n }\n \n choiseTemplate(){\n \n let dialog_ref = this.dialogService.open(Components.DialogTemplateComponent,{\n header: \"Выбрать шаблон\",\n data: {\n data: {},\n type: 'pages',\n code: \"c_r_msg_tpl\",\n getJitComponent: jit_page =\u003e {\n jit_page.goToDetail = (item) =\u003e {\n this.currentChat.new_text = item.template;\n dialog_ref.close();\n }\n }\n }\n });\n }\n \n openChat(phone){\n \n \n this.appComponent.layout.flow_widget = true;\n \n \n this.dbQueryService.restapiPost(\"c_cli_by_phone\",{callID : \"\", phone : phone})\n .pipe(first())\n .subscribe(items =\u003e {\n \t\t\tthis.clients = items.clients;\n if (this.clients \u0026\u0026 this.clients.length==1){\n this.openCli(this.clients[0].id,this.clients[0].title,phone);\n return;\n }\n if (this.clients \u0026\u0026 this.clients.length\u003e1){\n this.currentCont = {};\n this.currentCh = {};\n this.c_cli_cont = [];\n }\n\n });\n \n \n //alert(phone);\n }\n openCli(cli_id,cli_title,phone){\n this.clients = [];\n this.cli_id = cli_id;\n this.cli_title = cli_title;\n this.getCont(cli_id,phone);\n this.getMessages(cli_id); \n }\n getCh() {\n this.dbQueryService.getQuerySelect('c_c2d_ch', '')\n .subscribe((resp) =\u003e {\n if (resp \u0026\u0026 resp.items){\n this.c_c2d_ch = resp.items;\n }\n });\n } \n \n getDialogsByText(text) {\n this.dbQueryService.getQuerySelect('c_c2d_dialog_by_text_for_chat\u0026preparam1='+text, '')\n .subscribe((resp) =\u003e {\n if (resp \u0026\u0026 resp.items){\n this.dialogs = resp.items;\n this.dialogs.forEach(dialog=\u003e{\n if (this.currentChat.id==dialog.id){\n //console.log(\"TEST1\",this.currentChat);\n this.currentChat = dialog;\n //console.log(\"TEST2\",dialog);\n }\n });\n }\n });\n } \n \n getDialogs() {\n this.dbQueryService.getQuerySelect('c_c2d_dialog_open_for_chat', '')\n .subscribe((resp) =\u003e {\n if (resp \u0026\u0026 resp.items){\n this.dialogs = resp.items;\n this.dialogs.forEach(dialog=\u003e{\n if (this.currentChat.id==dialog.id){\n console.log(\"TEST1\",this.currentChat);\n this.currentChat = dialog;\n console.log(\"TEST2\",dialog);\n }\n });\n }\n });\n } \n \n getCont(cli_id,phone) {\n //alert(\"phone\"+phone);\n this.dbQueryService.getQuerySelect('c_cli_cont\u0026flt$c_cli_id$eq='+cli_id, '')\n .subscribe((resp) =\u003e {\n if (resp \u0026\u0026 resp.items){\n this.c_cli_cont = resp.items;\n if (this.c_cli_cont \u0026\u0026 this.c_cli_cont.length==1){\n this.currentCont = this.c_cli_cont[0];\n return;\n }\n if (this.c_cli_cont \u0026\u0026 this.c_cli_cont.length\u003e0){\n this.c_cli_cont.forEach((cont)=\u003e{if (cont.cont == phone) { this.currentCont = cont} });\n }\n }\n });\n } \n \n\n\n \n getMessagesByDialog(dialog) {\n \n this.currentChat = dialog;\n //let options = new QueryOptions(\"c_c2d_msg\u0026flt$dialog_id$eq=\"+dialog.dialog_id+\"\u0026orderBy=id\u0026orderAsc=1\");\n let options = new QueryOptions(\"c_c2d_msg_by_c2d_dialog_id\u0026param1=\"+dialog.id+\"\u0026orderBy=id\u0026orderAsc=1\");\n \n options.perpage = 500;\n options.page = 1;\n this.dbQueryService.getQuery(options)\n .pipe(first())\n .subscribe(items =\u003e {\n this.messages = items.items.map(item=\u003e{ if (item.attachments) {item.attachments = JSON.parse(item.attachments);} return item; });\n \n \n setTimeout(() =\u003e document.getElementById(\"bottom\").scrollIntoView(), 100);\n \n });\n }\n\n takeCallBack(){\n this.getDialogs();\n //this.getMessagesByDialog(this.currentChat);\n } \n \n transferCallBack(){\n this.getDialogs();\n //this.getMessagesByDialog(this.currentChat);\n } \n \n take(chat){\n this.appComponent.bpRun(\"c_c2d_dialog_take\",{ c_c2d_dialog_id : chat.id}, ()=\u003ethis.takeCallBack() );\n }\n \n transfer(chat){\n this.appComponent.bpRun(\"c_c2d_dialog_transfer\",{ dialog_id : chat.id}, ()=\u003ethis.transferCallBack() );\n } \n \n initChat() {\n \n this.getDialogs();\n this.websocketService.connect();\n this.websocketService.open.subscribe(event =\u003e console.log('Соединение'));\n //this.websocketService.close.subscribe(event =\u003e setTimeout(() =\u003e this.initChat(), 5000));\n this.websocketService.messages.subscribe(msg =\u003e {\n if (this.messages){\n \t\t this.messages.push(msg.data);\n \t\t this.getDialogs();\n \t\t //this.getMessagesByDialog(this.currentChat);\n \t\t}\n \t\t\n \t\tif (msg.data.notify) {\n \t\t\tthis.play();\n \t\t}\n \t\tsetTimeout(() =\u003e document.getElementById(\"bottom\").scrollIntoView(), 100);\n \t\t\n });\n }\n\n \n startChatRu(text){\n //this.sendMessage(\"@HSM@\\nhellow|ru\\nbody|text|\"+this.sessioninfo.chat_name+\" \"+text)\n if (text \u0026\u0026 text.trim()==\"\" || !text){\n alert(\"Введите текст, например, ссылку\");\n return;\n } \n this.sendMessage(this.sessioninfo.chat_name+\"|\"+text,{hsm_id : 4, text1 : this.sessioninfo.chat_name, text2 : text})\n \n }\n \n startChatKz(text){\n if (text \u0026\u0026 text.trim()==\"\" || !text){\n alert(\"Введите текст, например, ссылку\");\n return;\n }\n this.sendMessage(this.sessioninfo.chat_name+\"|\"+text,{hsm_id : 3, text1 : this.sessioninfo.chat_name, text2 : text})\n } \n \n sendMessage(text,addinfo) {\n //if (!this.currentCh.id){\n // alert(\"сначала Выберите канал\");\n // return;\n //}\n //if (!this.currentCont.id){\n // alert(\"сначала Выберите контакт\");\n // return;\n //} \n \n //this.text = \"\";\n this.currentChat.new_text = \"\";\n \n return this.dbQueryService.restapiPost(\"c_c2d_msg_send\",{addinfo: addinfo, file: this.currentChat.file,client_id: this.currentChat.client_id, api_id : this.currentChat.api_id, channel_id:this.currentChat.channel_id, c_c2d_dialog_id : this.currentChat.id, dialog_id: this.currentChat.dialog_id, cont: this.currentChat.client_phone, msg : text , r_cli_id : 1})\n .pipe(first())\n .subscribe(items =\u003e {\n //this.chats = items\n console.log(\"send\",items);\n this.currentChat.file = null;\n if (items.error_code!=\"0\"){\n this.messageService.add({severity:'danger', summary: \"Ошибка \"+items.error_text, detail: \"Ошибка \"+ items.error_text }); \n }else{\n setTimeout(() =\u003e document.getElementById(\"bottom\").scrollIntoView(), 100);\n }\n \n \n \n });\n \n }\n \n \n\n ngOnInit() {\n //this.getCh();\n this.initChat();\n \n \n }\n \n}"}