Skip to content

Commit 3682255

Browse files
committed
Indenting, casing and naming fix
1 parent 8da3a16 commit 3682255

File tree

6 files changed

+40
-42
lines changed

6 files changed

+40
-42
lines changed

src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
33
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
44
import { FormsModule } from '@angular/forms';
55
import { HttpClientModule } from '@angular/common/http';
6-
import { MatButtonModule, MatInputModule, MatCardModule, MatIconModule } from '@angular/Material';
6+
import { MatButtonModule, MatInputModule, MatCardModule, MatIconModule } from '@angular/material';
77

88
import { AppComponent } from './app.component';
99

src/app/components/ai/ai.component.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<mat-card>
2-
<h1 class="mat-display-1">Angular 5 AI</h1>
2+
<h1 class="mat-display-1">Angular 6 AI</h1>
33

44
<mat-card-content *ngFor="let message of allMessages | async">
5-
<div
6-
class="message"
7-
[ngClass]="{ 'from': message.sentBy === 'bot', 'to': message.sentBy === 'user' }">
8-
{{ message.content }}
5+
<div class="message" [ngClass]="{ 'from': message.sentBy === 'bot', 'to': message.sentBy === 'user' }">
6+
{{ message.content }}
97
</div>
108
</mat-card-content>
119

@@ -15,9 +13,9 @@ <h1 class="mat-display-1">Angular 5 AI</h1>
1513
<mat-icon>keyboard_voice</mat-icon>
1614
</button>
1715
</mat-card-actions>
18-
<mat-input-container>
16+
<mat-form-field>
1917
<input matInput [(ngModel)]="formInput" min="2" placeholder="Your Message..." (keyup.enter)="sendMessageToBot()" type="text">
20-
</mat-input-container>
18+
</mat-form-field>
2119
</div>
2220

2321
<mat-card-actions class="button center">

src/app/components/ai/ai.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
justify-content: center;
3535
}
3636

37-
.mat-input-container {
37+
.mat-form-field {
3838
display: inline;
3939
}
4040

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit, OnDestroy } from '@angular/core';
22

3-
import { Observable } from 'rxjs/Observable';
3+
import { Observable } from 'rxjs/observable';
44
import { scan } from 'rxjs/operators';
55

66
import { AiService } from '../../service/ai.service';
@@ -21,9 +21,9 @@ export class AiComponent implements OnInit, OnDestroy {
2121

2222
ngOnInit() {
2323
this.allMessages = this.ai.conversation.asObservable()
24-
.pipe(
25-
scan((acc, val) => acc.concat(val))
26-
)
24+
.pipe(
25+
scan((acc, val) => acc.concat(val))
26+
)
2727
}
2828

2929
ngOnDestroy() {
@@ -37,21 +37,21 @@ export class AiComponent implements OnInit, OnDestroy {
3737

3838
startTalkingToBot() {
3939
this.ai.voiceConversation()
40-
.subscribe(
41-
(value) => {
42-
this.formInput = value;
43-
// console.log(value);
44-
},
45-
(err) => {
46-
console.log(err);
47-
if (err.error === 'no-speech') {
48-
// console.log("Talking error");
40+
.subscribe(
41+
(value) => {
42+
this.formInput = value;
43+
// console.log(value);
44+
},
45+
(err) => {
46+
console.log(err);
47+
if (err.error === 'no-speech') {
48+
// console.log("Talking error");
49+
this.startTalkingToBot();
50+
}
51+
},
52+
() => {
53+
// console.log("Talking complete");
4954
this.startTalkingToBot();
50-
}
51-
},
52-
() => {
53-
// console.log("Talking complete");
54-
this.startTalkingToBot();
55-
});
56-
}
55+
});
5756
}
57+
}

src/app/model/message.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class Message {
2-
constructor(
3-
public content: string,
4-
public sentBy: string
5-
) {}
6-
}
2+
constructor(
3+
public content: string,
4+
public sentBy: string
5+
) { }
6+
}

src/app/service/ai.service.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { Injectable, NgZone } from '@angular/core';
22
import { environment } from '../../environments/environment';
33
import * as lodash from 'lodash';
44

5-
import { Observable } from 'rxjs/Observable';
5+
import { Observable } from 'rxjs/observable';
66
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
77

88
import { ApiAiClient } from 'api-ai-javascript';
99
import { Message } from '../model/message'
10-
import { IWindow } from '../interface/iwindow'
10+
import { IWindow } from '../interface/Iwindow'
1111

1212
@Injectable()
1313
export class AiService {
@@ -28,11 +28,11 @@ export class AiService {
2828
const userMessage = new Message(msg, 'user');
2929
this.update(userMessage);
3030
return this.client.textRequest(msg)
31-
.then(res => {
32-
const speech = res.result.fulfillment.speech;
33-
const botMessage = new Message(speech, 'bot');
34-
this.update(botMessage);
35-
});
31+
.then(res => {
32+
const speech = res.result.fulfillment.speech;
33+
const botMessage = new Message(speech, 'bot');
34+
this.update(botMessage);
35+
});
3636
}
3737

3838
voiceConversation(): Observable<string> {
@@ -67,7 +67,7 @@ export class AiService {
6767
};
6868

6969
this.speechRecognition.start();
70-
// console.log('Listening...');
70+
// console.log('Listening...');
7171
});
7272
}
7373

0 commit comments

Comments
 (0)