Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MuraliChandran committed May 3, 2020
1 parent bfa8fe5 commit 75db482
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
16 changes: 13 additions & 3 deletions src/app/chat/chat-widget/chat-widget.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
align-self: flex-start;
flex-direction: row;
max-width: 80%;
white-space: normal;
word-wrap: break-word;
left: 40px;

}

}

*{
box-sizing: border-box;
Expand Down Expand Up @@ -45,6 +44,7 @@
color: #fff;
font-size: 32px;
}

.chat-button-header {
z-index: 1;
font-weight: bold;
Expand Down Expand Up @@ -72,9 +72,11 @@
box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
background: #1976d2;
}

.chat-box-hidden {
display: none;
}

.chat-box-header {
margin-right: 4px;
padding: 15px;
Expand Down Expand Up @@ -105,12 +107,15 @@
float: right;
padding: 4px;
}

.operator-status span {
margin-left: 4px;
}

.operator-status-online {
color: lawngreen;
}

.operator-status-offline {
color: red;
}
Expand Down Expand Up @@ -162,6 +167,7 @@
/**
Received message style
*/

.chat-message-received {
margin-right: 50px;
}
Expand Down Expand Up @@ -195,6 +201,7 @@
/**
Sent message style
*/

.chat-message-sent {
align-self: flex-end;
}
Expand Down Expand Up @@ -233,20 +240,23 @@
.blue .chat-button {
background: #1976d2;
}

.blue .chat-box {
background: #1976d2;
}

.grey .chat-button {
background: #454549;
}

.grey .chat-box {
background: #454549;
}

.red .chat-button {
background: #dd0031;
}

.red .chat-box {
background: #dd0031;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/chat/chat-widget/chat-widget.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

<ng-container *ngIf="m.buttons === true" #mydiv>
<div *ngFor="let b of BT">
<div class="button-row" #mydiv>
<button mat-raised-button color="blue" (click)="buttonclick($event)">
<div #mydiv>
<button mat-raised-button color="warn" (click)="buttonclick($event)" class="button-row">
{{ b.title.title }}
</button>
</div>
Expand Down
23 changes: 16 additions & 7 deletions src/app/chat/chat-widget/chat-widget.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { fadeIn, fadeInOut } from '../animation';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ChatServicesService } from '../chat-services/chat-services.service';


const rand = (max) => Math.floor(Math.random() * max);

@Component({
Expand Down Expand Up @@ -99,12 +98,22 @@ export class ChatWidgetComponent implements OnInit {
buttonclick($event: Event) {
var a = $event.srcElement as HTMLElement;

console.log("a", a.innerText)
var b = a.innerText.replace(/ +/g,"");
console.log("b", b)
//To find the right Payload.
var payloadval: any;
for (var i = 0; i < this.BT.length; i++)
if (this.BT[i].title.title === a.innerText)
for (var i = 0; i < this.BT.length; i++){
var c = this.BT[i].title.title.replace(/(\r\n|\n|\r)/gm,"");
console.log("c",c)
if (c.includes(b)){
payloadval = this.BT[i].title.payload;

console.log("payloadval", payloadval);
}
}
console.log("payloadval",payloadval);


//return empty strings
if (a.innerText.trim() === '') return;

Expand All @@ -129,16 +138,16 @@ export class ChatWidgetComponent implements OnInit {
for (var key in this.val) {
//Bot will respond back
if (this.val[key].text) {
this.botMessage(this.val[key].text, 'text', false);

if (this.val[key].buttons) {
this.botMessage(this.val[key].text, 'text', true);

for (var k in this.val[key].buttons) {
this.addBT(this.val[key].buttons[k]);
}
} else {
this.botMessage(this.val[key].text, 'text', false);
}
}

if (this.val[key].image) {
this.botMessage(this.val[key].image, 'image', false);
} else {
Expand Down

0 comments on commit 75db482

Please sign in to comment.