Updated pic and small adjustments on the code.

This commit is contained in:
Vesa Juvonen 2016-10-28 15:46:57 +03:00
parent 354704dca4
commit 590fd08b0c
6 changed files with 43 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -6,16 +6,17 @@
"node": ">=0.10.0" "node": ">=0.10.0"
}, },
"dependencies": { "dependencies": {
"@microsoft/sp-client-base": "~0.3.0", "@microsoft/sp-client-base": "~0.4.0",
"@microsoft/sp-client-preview": "~0.4.0", "@microsoft/sp-client-preview": "~0.5.0",
"office-ui-fabric-react": "0.36.0", "office-ui-fabric-react": "0.36.0",
"react": "0.14.8", "react": "0.14.8",
"react-dom": "0.14.8" "react-dom": "0.14.8",
"swagger-client": "^2.1.23"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/sp-build-web": "~0.6.0", "@microsoft/sp-build-web": "~0.7.0",
"@microsoft/sp-module-interfaces": "~0.3.0", "@microsoft/sp-module-interfaces": "~0.4.0",
"@microsoft/sp-webpart-workbench": "~0.4.0", "@microsoft/sp-webpart-workbench": "~0.5.0",
"gulp": "~3.9.1" "gulp": "~3.9.1"
}, },
"scripts": { "scripts": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -7,8 +7,7 @@
.chatHeader { .chatHeader {
padding:10px; padding:10px;
background-color: #c7e0f4; background-color: #c7e0f4;
color: #000; color: #fff;
font-weight: bold;
} }
.messagesRow { .messagesRow {

View File

@ -17,8 +17,8 @@
"placeholderText": "Your message", "placeholderText": "Your message",
"title": "Chat", "title": "Chat",
"directLineSecret": "", "directLineSecret": "",
"titleBarBackgroundColor": "c7e0f4", "titleBarBackgroundColor": "3C3C3C",
"botMessagesBackgroundColor": "c8c8c8", "botMessagesBackgroundColor": "f4f4f4",
"botMessagesForegroundColor": "000000", "botMessagesForegroundColor": "000000",
"userMessagesBackgroundColor": "c7e0f4", "userMessagesBackgroundColor": "c7e0f4",
"userMessagesForegroundColor": "000000" "userMessagesForegroundColor": "000000"

View File

@ -21,23 +21,24 @@ export default class BotFrameworkChat extends React.Component<IBotFrameworkChatP
return ( return (
<div className={styles.botFrameworkChat}> <div className={styles.botFrameworkChat}>
<div className={styles.container}> <div className={styles.container}>
<div className={css('ms-Grid-row ms-font-xl', styles.chatHeader) } style={{ backgroundColor: '#' + this.props.titleBarBackgroundColor }} > <div className={css('ms-Grid-row ms-font-xl', styles.chatHeader)} style={{ backgroundColor: '#' + this.props.titleBarBackgroundColor }} >
{ this.props.title } {this.props.title}
</div> </div>
<div className={css('ms-Grid-row', styles.messagesRow) } > <div className={css('ms-Grid-row', styles.messagesRow)} >
<div className='ms-Grid-col ms-u-sm12' ref='messageHistoryDiv' dangerouslySetInnerHTML={{ __html: this.getMessagesHtml() }}> <div className='ms-Grid-col ms-u-sm12' ref='messageHistoryDiv' dangerouslySetInnerHTML={{ __html: this.getMessagesHtml() }}>
</div> </div>
</div> </div>
<div className={css('ms-Grid-row') }> <div className={css('ms-Grid-row')}>
<TextField id='MessageBox' onKeyUp={ (e) => this.tbKeyUp(e) } onKeyDown={ (e) => this.tbKeyDown(e) } <TextField id='MessageBox' onKeyUp={(e) => this.tbKeyUp(e)} onKeyDown={(e) => this.tbKeyDown(e)}
value={this.currentMessageText} placeholder={ this.props.placeholderText } className={ css('ms-fontSize-m', styles.messageBox) } /> value={this.currentMessageText} placeholder={this.props.placeholderText} className={css('ms-fontSize-m', styles.messageBox)} />
</div> </div>
</div> </div>
</div> </div>
); );
} }
public componentDidMount(): void { public componentDidUpdate(prevProps: IBotFrameworkChatWebPartProps, prevState: {}, prevContext: any): void {
if (this.props.directLineSecret !== prevProps.directLineSecret) {
if (this.props.directLineSecret) { if (this.props.directLineSecret) {
var Swagger = require('swagger-client'); var Swagger = require('swagger-client');
var directLineSpec = require('./directline-swagger.json'); var directLineSpec = require('./directline-swagger.json');
@ -69,6 +70,7 @@ export default class BotFrameworkChat extends React.Component<IBotFrameworkChatP
this.printMessage = this.printMessage.bind(this); this.printMessage = this.printMessage.bind(this);
} }
} }
}
public getMessagesHtml() { public getMessagesHtml() {
return this.messagesHtml; return this.messagesHtml;