Skip to content

Commit

Permalink
Merge pull request #206 from Hexastack/feat/widget-changes
Browse files Browse the repository at this point in the history
Feat/widget changes
  • Loading branch information
marrouchi authored Oct 12, 2024
2 parents a907058 + 04ce4df commit b11761a
Show file tree
Hide file tree
Showing 35 changed files with 926 additions and 260 deletions.
4 changes: 4 additions & 0 deletions api/src/chat/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
blocks: BlockFull[],
event: EventWrapper<any, any>,
): Promise<BlockFull | undefined> {
if (!blocks.length) {
return undefined;
}

// Search for block matching a given event
let block: BlockFull | undefined = undefined;
const payload = event.getPayload();
Expand Down
2 changes: 1 addition & 1 deletion api/src/chat/services/bot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export class BotService {
});

if (!blocks.length) {
return this.logger.debug('No starting message blocks was found');
this.logger.debug('No starting message blocks was found');
}

// Search for a block match
Expand Down
2 changes: 1 addition & 1 deletion api/src/setting/seeds/setting.seed-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const settingModels: SettingCreateDto[] = [
{
group: 'nlp_settings',
label: 'threshold',
value: 0.9,
value: 0.1,
type: SettingType.number,
config: {
min: 0,
Expand Down
7 changes: 2 additions & 5 deletions api/src/websocket/websocket.gateway.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ describe('WebsocketGateway', () => {
it('should connect successfully', async () => {
ioClient.connect();
await new Promise<void>((resolve) => {
// ioClient.on('connect', () => {
// console.log('connected');
// });
ioClient.on('message', (data) => {
expect(data.statusCode).toBe(200);
ioClient.on('connect', () => {
expect(true).toBe(true);
resolve();
});
});
Expand Down
16 changes: 0 additions & 16 deletions api/src/websocket/websocket.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,6 @@ export class WebsocketGateway
this.logger.debug(`Number of connected clients: ${sockets?.size}`);

this.eventEmitter.emit(`hook:websocket:connection`, client);
// @TODO : Revisit once we don't use anymore in frontend
const response = new SocketResponse();
client.send(
response
.setHeaders({
'access-control-allow-origin':
config.security.cors.allowOrigins.join(','),
vary: 'Origin',
'access-control-allow-credentials':
config.security.cors.allowCredentials.toString(),
})
.status(200)
.json({
success: true,
}),
);
}

async handleDisconnect(client: Socket): Promise<void> {
Expand Down
10 changes: 0 additions & 10 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,3 @@ services:
pull_policy: build
volumes:
- ../frontend/:/app/frontend/

widget:
build:
context: ../widget
target: development
pull_policy: build
volumes:
- ../widget/src:/app/src
ports:
- ${APP_WIDGET_PORT}:5173
12 changes: 12 additions & 0 deletions docker/docker-compose.widget.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.9"

services:
widget:
build:
context: ../widget
target: development
pull_policy: build
volumes:
- ../widget/src:/app/src
ports:
- ${APP_WIDGET_PORT}:5173
13 changes: 13 additions & 0 deletions docker/docker-compose.widget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.9"

services:
widget:
container_name: widget
image: hexastack/hexabot-widget:latest
networks:
- app-network
depends_on:
api:
condition: service_healthy
ports:
- ${APP_WIDGET_PORT}:5173
11 changes: 0 additions & 11 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ services:
volumes:
- mongo-data:/data/db

widget:
container_name: widget
image: hexastack/hexabot-widget:latest
networks:
- app-network
depends_on:
api:
condition: service_healthy
ports:
- ${APP_WIDGET_PORT}:5173

volumes:
mongo-data:
api-data:
Expand Down
4 changes: 2 additions & 2 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
import withTM from "next-transpile-modules";

const nextConfig = withTM(["hexabot-widget"])({
const nextConfig = withTM(["hexabot-chat-widget"])({
async rewrites() {
return [
{
Expand All @@ -11,7 +11,7 @@ const nextConfig = withTM(["hexabot-widget"])({
];
},
webpack(config) {
if (process.env.NODE_ENV==="development") {
if (process.env.NODE_ENV === "development") {
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"axios": "^1.7.7",
"eazychart-css": "^0.2.1-alpha.0",
"eazychart-react": "^0.8.0-alpha.0",
"hexabot-widget": "*",
"hexabot-chat-widget": "*",
"next": "^14.2.13",
"next-transpile-modules": "^10.0.1",
"normalizr": "^3.6.2",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app-components/widget/ChatWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Avatar, Box } from "@mui/material";
import UiChatWidget from "hexabot-widget/src/UiChatWidget";
import UiChatWidget from "hexabot-chat-widget/src/UiChatWidget";
import { usePathname } from "next/navigation";

import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
Expand Down
Loading

0 comments on commit b11761a

Please sign in to comment.