Skip to content

Commit

Permalink
Merge branch 'develop' into feature/RocketChat#228-run-tests-separately
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRoehl committed Feb 16, 2018
2 parents 2780cc6 + 75f78c8 commit 2990cd7
Show file tree
Hide file tree
Showing 44 changed files with 1,448 additions and 224 deletions.
2 changes: 1 addition & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ accounts-password@1.5.0
accounts-twitter@1.4.1
aldeed:simple-schema@1.5.3
allow-deny@1.1.0
assistify:ai@0.1.0
assistify:ai@0.2.0
assistify:defaults@0.0.1
assistify:help-request@0.1.0
autoupdate@1.3.12
Expand Down
2 changes: 1 addition & 1 deletion .scripts/dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM assisitfy/smarti:0.6.1
FROM assisitfy/smarti:0.7.0-BETA
USER root
ADD [\
"https://repo1.maven.org/maven2/edu/stanford/nlp/stanford-corenlp/3.8.0/stanford-corenlp-3.8.0.jar", \
Expand Down
1 change: 0 additions & 1 deletion .scripts/seperateTesting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ rm -rf $tmpPath
mkdir -p $tmpPath
[ -z "$retry_test" ] && retry_test=1
for file in tests/end-to-end/*/*.js; do

failed=1
for i in `seq 1 $retry_test`; do
echo '-------------- '$i' try ---------------'
Expand Down
2 changes: 1 addition & 1 deletion .scripts/smarti.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

docker pull assisitfy/smarti:0.6.1
docker pull assisitfy/smarti:0.7.0-BETA

#docker run -d --net=host assisitfy/smarti:0.6.1

Expand Down
Binary file modified packages/assistify-ai/client/public/assistify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/assistify-ai/client/public/bulb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 97 additions & 4 deletions packages/assistify-ai/client/public/stylesheets/smarti.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,106 @@
.smarti-widget .loading-notification {
margin: 0 20px;

text-align: justify;

font-style: italic;

line-height: 1.4;
}

.content .external-search-content .smarti {
.external-search-content .smarti {
overflow-y: auto;
}

.smarti #widgetContainer {
position: absolute;
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 16px;
color: #3D3D3D;
top: 0;
right: 0;
width: 400px;
height: 100%;
border-right: 1px solid #dfdfdf;
border-left: 1px solid #dfdfdf;
background: #f4f4f4;
overflow: hidden;
line-height: normal;
}

.smarti #widgetContainer #widgetWrapper {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
}

.smarti #widgetContainer #widgetWrapper #widgetHeader {
position: relative;
}

.smarti #widgetContainer #widgetWrapper #widgetHeader .widgetHeaderWrapper {
padding: 15px 15px;
}

.smarti #widgetContainer #widgetWrapper #widgetHeader h4 {
font-size: 20px;
color: #3D3D3D;
letter-spacing: 0;
margin-top: -10px;
/*margin-bottom: 30px;*/
}

.smarti #widgetContainer #widgetWrapper #widgetHeader h4 img {
position: relative;
top: 5px;
height: 30px;
margin-right: 4px;
}

.smarti #widgetContainer #widgetWrapper #widgetBody {
position: relative;
background: #ffffff;
width: 100%;
padding: 10px 10px 10px 10px;
overflow-y: auto;
flex: 1;
}

.smarti #widgetContainer #widgetWrapper #widgetFooter {
position: absolute;
bottom: 0;
background: #f4f4f4;
color: #747474;
opacity: 1;
width: 100%;
text-align: center;
border-top: 1px solid #CBCBCB;
transition: 0.2s;
}

.smarti #widgetContainer #widgetWrapper #widgetFooter .help-request-actions {
margin: 0;
}

.smarti #widgetContainer #widgetWrapper #widgetFooter button {
-o-transition: 0.2s;
-ms-transition: 0.2s;
-moz-transition: 0.2s;
-webkit-transition: 0.2s;
transition: 0.2s;
position: relative;
color: #747474;
text-decoration: none;
padding: 15px 30px 15px 30px;
width: calc(100% - 20px);
font-size: 14px;
margin: 10px;
text-transform: uppercase;
background: #CBCBCB;
border-radius: 3px;
display: inline-block;
text-align: center;
}

.smarti #widgetContainer #widgetWrapper #widgetFooter button:hover {
background: #d5195b;
color: #ffffff;
}
57 changes: 47 additions & 10 deletions packages/assistify-ai/client/views/app/tabbar/smarti.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
<template name="AssistifySmarti">
<div class="external-search-content smarti">
<div id="widgetContainer">
<div id="widgetWrapper">
<div id="widgetHeader">
<div class="widgetHeaderWrapper">
<h4>
<img src="/packages/assistify_ai/client/public/assistify.png" alt="Bulb-icon">
{{_ "Knowledge_Base"}}
</h4>
</div>
</div>
<div id="widgetBody">
<div class="widgetMessage">
<div class="loading-notification">{{loadingNotification}}</div>
</div>
{{#if isLoading }}
{{> loading }}
{{/if}}
</div>
<div id="widgetFooter">
{{#let helpRequest=helpRequestByRoom }}
{{#if helpRequest}}
{{> HelpRequestActions helpRequest }}
{{/if}}
{{/let}}
{{#if isLivechat}}
{{> HelpRequestActions liveChatActions}}
{{/if}}
</div>
</div>
</div>
</div>
</template>

<!--
<template name="AssistifySmarti">
<div class="content external-search-content smarti">
<div class="title">
Expand All @@ -6,19 +42,20 @@ <h2><span class="title-icon"><img
style="margin-right: 10px; margin-bottom: -3px"></span>{{_ "Knowledge_Base"}}</h2>
</div>
{{#let helpRequest=helpRequestByRoom }}
{{#if helpRequest}}
{{> HelpRequestContext helpRequest }}
{{> HelpRequestActions helpRequest }}
{{/if}}
{{/let}}
{{#if isLivechat}}
{{> HelpRequestActions liveChatActions}}
{{/if}}
{{#if helpRequest}}
{{> HelpRequestContext helpRequest }}
{{> HelpRequestActions helpRequest }}
{{/if}}
{{/let}}
{{#if isLivechat}}
{{> HelpRequestActions liveChatActions}}
{{/if}}
<div class="smarti-widget {{loadingClass}}">
<div class="loading-notification">{{loadingNotification}}</div>
{{#if isLoading }}
{{> loading }}
{{/if}}
{{> loading }}
{{/if}}
</div>
</div>
</template>
-->
10 changes: 5 additions & 5 deletions packages/assistify-ai/client/views/app/tabbar/smarti.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Template.AssistifySmarti.onRendered(function() {
const instance = this;

/* in order to avoid duplicated scrollbars, have the outer one hidden */
const parentContainer = this.$(':parent').parent();
parentContainer.css('overflow-y', 'initial');
this.$('.smarti-widget').css('overflow-y', 'auto');
//const parentContainer = this.$(':parent').parent();
//parentContainer.css('overflow-y', 'initial');
//this.$('.smarti-widget').css('overflow-y', 'auto');

function createSmarti() {
if (window.SmartiWidget === undefined) {
Expand All @@ -60,10 +60,10 @@ Template.AssistifySmarti.onRendered(function() {
type: WIDGET_POSTING_TYPE,
cssInputSelector: '.rc-message-box .js-input-message'
},
lang: 'de'
lang: localStorage.getItem('userLanguage').split('-')[0]
};
console.debug('Initializing Smarti with options: ', JSON.stringify(smartiOptions, null, 2));
instance.smarti = new window.SmartiWidget(instance.find('.smarti-widget'), smartiOptions);
instance.smarti = new window.SmartiWidget(instance.find('.smarti #widgetContainer'), smartiOptions);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/assistify-ai/package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'assistify:ai',
version: '0.1.0',
version: '0.2.0',
summary: 'Integration of artificial knowledge',
git: 'http://github.com/assistify/Rocket.Chat',
documentation: 'README.md'
Expand Down Expand Up @@ -51,7 +51,7 @@ Package.onUse(function(api) {

//Assets
api.addAssets('client/public/assistify.png', 'client');
api.addAssets('client/public/assistify-beta.png', 'client');
//api.addAssets('client/public/assistify-beta.png', 'client');

//i18n in Rocket.Chat-package (packages/rocketchat-i18n/i18n

Expand Down
18 changes: 13 additions & 5 deletions packages/assistify-ai/server/SmartiProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,33 @@ export class SmartiProxy {
* @param {String} method - the HTTP method to use
* @param {String} path - the path to call
* @param {Object} [body=null] - the payload to pass (optional)
* @param {Function} onError=null - custom error handler
*
* @returns {Object}
*/
static propagateToSmarti(method, path, body = null) {

const url = encodeURI(`${ SmartiProxy.smartiUrl }${ path }`);
static propagateToSmarti(method, path, body = null, onError = null) {
const url = `${ SmartiProxy.smartiUrl }${ path }`;
const header = {
'X-Auth-Token': SmartiProxy.smartiAuthToken,
'Content-Type': 'application/json; charset=utf-8'
};
try {
SystemLogger.debug('Sending request to Smarti', method, 'to', url, 'body', JSON.stringify(body));
const response = HTTP.call(method, url, {data: body, headers: header});
if (response.statusCode === 200) {
if (response.statusCode === 200 || response.statusCode === 201) {
return response.data || response.content; //.data if it's a json-response
} else {
SystemLogger.debug('Got unexpected result from Smarti', method, 'to', url, 'response', JSON.stringify(response));
}
} catch (error) {
SystemLogger.error('Could not complete', method, 'to', url);
if (onError) {
const recoveryResult = onError(error);
if (recoveryResult !== undefined) {
return recoveryResult;
}
}

SystemLogger.error('Could not complete', method, 'to', url, error.response);
SystemLogger.debug(error);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals RocketChat, SystemLogger */

import {getKnowledgeAdapter} from '../lib/KnowledgeAdapterProvider';
import { getKnowledgeAdapter } from '../lib/KnowledgeAdapterProvider';

RocketChat.callbacks.remove('afterSaveMessage', 'externalWebHook');

Expand All @@ -19,7 +19,8 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
return message;
}

if (!(typeof room.t !== 'undefined' && room.v && room.v.token)) {
//we only want to forward messages from livechat-rooms
if (!(room && (room.t === 'l'))) {
return message;
}

Expand All @@ -28,8 +29,10 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
return;
}

SystemLogger.debug(`Send message ${ message._id } to knowledgeAdapter (Meteor.defer()`);
Meteor.defer(() => {
try {
SystemLogger.debug(`Calling onMessage(${ message._id });`);
knowledgeAdapter.onMessage(message);
} catch (e) {
SystemLogger.error('Error using knowledge provider ->', e);
Expand Down
2 changes: 2 additions & 0 deletions packages/assistify-ai/server/lib/AiApiAdapter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* globals _ */

export class ApiAiAdapter {
constructor(adapterProps) {
this.properties = adapterProps;
Expand Down
Loading

0 comments on commit 2990cd7

Please sign in to comment.