@hivegpt/hiveai-angular 0.0.375 → 0.0.380
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/karma.conf.js +32 -32
- package/ng-package.json +6 -6
- package/package.json +20 -20
- package/src/environments/environment.ts +19 -19
- package/src/lib/components/NotificationSocket.ts +37 -37
- package/src/lib/components/bot-html-editor/bot-html-editor.component.css +9 -9
- package/src/lib/components/bot-html-editor/bot-html-editor.component.html +11 -11
- package/src/lib/components/bot-html-editor/bot-html-editor.component.spec.ts +25 -25
- package/src/lib/components/bot-html-editor/bot-html-editor.component.ts +152 -152
- package/src/lib/components/bot.service.ts +51 -51
- package/src/lib/components/chat-drawer/chat-drawer.component.html +1586 -1586
- package/src/lib/components/chat-drawer/chat-drawer.component.scss +2906 -2906
- package/src/lib/components/chat-drawer/chat-drawer.component.ts +2143 -2143
- package/src/lib/components/chatbot/chatbot.component.html +37 -37
- package/src/lib/components/chatbot/chatbot.component.scss +97 -97
- package/src/lib/components/chatbot/chatbot.component.ts +44 -44
- package/src/lib/components/conversation.service.spec.ts +16 -16
- package/src/lib/components/conversation.service.ts +54 -54
- package/src/lib/components/socket-service.service.spec.ts +16 -16
- package/src/lib/components/socket-service.service.ts +77 -77
- package/src/lib/components/translations/translation.service.ts +221 -254
- package/src/lib/components/video-player/video-player.component.html +51 -51
- package/src/lib/components/video-player/video-player.component.scss +262 -262
- package/src/lib/components/video-player/video-player.component.ts +148 -148
- package/src/lib/hivegpt.module.ts +18 -18
- package/src/lib/models/video.ts +36 -36
- package/src/lib/pipes/safe-html.pipe.ts +16 -16
- package/src/lib/utils/utils.ts +37 -37
- package/src/public-api.ts +7 -7
- package/tsconfig.lib.json +25 -25
- package/tsconfig.lib.prod.json +10 -10
- package/tsconfig.spec.json +17 -17
- package/tslint.json +17 -17
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
<button mat-icon-button class="chat-button" color="primary" (click)="toggle()">
|
|
2
|
-
<mat-icon>chat</mat-icon>
|
|
3
|
-
</button>
|
|
4
|
-
|
|
5
|
-
<ng-container *ngIf="visible">
|
|
6
|
-
<hivegpt-chat-drawer
|
|
7
|
-
[apiKey]="apiKey"
|
|
8
|
-
[bgBubbleAi]="bgBubbleAi"
|
|
9
|
-
[bgBubbleUser]="bgBubbleUser"
|
|
10
|
-
[bgGradient]="bgGradient"
|
|
11
|
-
[botName]="botName"
|
|
12
|
-
[closeButtonbgColor]="closeButtonbgColor"
|
|
13
|
-
[closeButtonColor]="closeButtonColor"
|
|
14
|
-
[credentials]="credentials"
|
|
15
|
-
[dateTextColor]="dateTextColor"
|
|
16
|
-
[dateTimeColor]="dateTimeColor"
|
|
17
|
-
[eventId]="eventId"
|
|
18
|
-
[eventName]="eventName"
|
|
19
|
-
[formFieldBgColor]="formFieldBgColor"
|
|
20
|
-
[formFieldTextColor]="formFieldTextColor"
|
|
21
|
-
[fullView]="fullView"
|
|
22
|
-
[greeting]="greeting"
|
|
23
|
-
[gradientColors]="gradientColors"
|
|
24
|
-
[messageTextColorAi]="messageTextColorAi"
|
|
25
|
-
[messageTextColorUser]="messageTextColorUser"
|
|
26
|
-
[sendButtonColor]="sendButtonColor"
|
|
27
|
-
[sendButtonTextColor]="sendButtonTextColor"
|
|
28
|
-
[showClose]="showClose"
|
|
29
|
-
[thumbsDownMessages]="thumbsDownMessages"
|
|
30
|
-
[thumbsUpMessage]="thumbsUpMessage"
|
|
31
|
-
[unknownResponses]="unknownResponses"
|
|
32
|
-
[useOpenAi]="useOpenAi"
|
|
33
|
-
[userId]="userId"
|
|
34
|
-
[botId]="botId"
|
|
35
|
-
>
|
|
36
|
-
</hivegpt-chat-drawer>
|
|
37
|
-
</ng-container>
|
|
1
|
+
<button mat-icon-button class="chat-button" color="primary" (click)="toggle()">
|
|
2
|
+
<mat-icon>chat</mat-icon>
|
|
3
|
+
</button>
|
|
4
|
+
|
|
5
|
+
<ng-container *ngIf="visible">
|
|
6
|
+
<hivegpt-chat-drawer
|
|
7
|
+
[apiKey]="apiKey"
|
|
8
|
+
[bgBubbleAi]="bgBubbleAi"
|
|
9
|
+
[bgBubbleUser]="bgBubbleUser"
|
|
10
|
+
[bgGradient]="bgGradient"
|
|
11
|
+
[botName]="botName"
|
|
12
|
+
[closeButtonbgColor]="closeButtonbgColor"
|
|
13
|
+
[closeButtonColor]="closeButtonColor"
|
|
14
|
+
[credentials]="credentials"
|
|
15
|
+
[dateTextColor]="dateTextColor"
|
|
16
|
+
[dateTimeColor]="dateTimeColor"
|
|
17
|
+
[eventId]="eventId"
|
|
18
|
+
[eventName]="eventName"
|
|
19
|
+
[formFieldBgColor]="formFieldBgColor"
|
|
20
|
+
[formFieldTextColor]="formFieldTextColor"
|
|
21
|
+
[fullView]="fullView"
|
|
22
|
+
[greeting]="greeting"
|
|
23
|
+
[gradientColors]="gradientColors"
|
|
24
|
+
[messageTextColorAi]="messageTextColorAi"
|
|
25
|
+
[messageTextColorUser]="messageTextColorUser"
|
|
26
|
+
[sendButtonColor]="sendButtonColor"
|
|
27
|
+
[sendButtonTextColor]="sendButtonTextColor"
|
|
28
|
+
[showClose]="showClose"
|
|
29
|
+
[thumbsDownMessages]="thumbsDownMessages"
|
|
30
|
+
[thumbsUpMessage]="thumbsUpMessage"
|
|
31
|
+
[unknownResponses]="unknownResponses"
|
|
32
|
+
[useOpenAi]="useOpenAi"
|
|
33
|
+
[userId]="userId"
|
|
34
|
+
[botId]="botId"
|
|
35
|
+
>
|
|
36
|
+
</hivegpt-chat-drawer>
|
|
37
|
+
</ng-container>
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
/* width */
|
|
2
|
-
::-webkit-scrollbar {
|
|
3
|
-
width: 5px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/* Track */
|
|
7
|
-
::-webkit-scrollbar-track {
|
|
8
|
-
background: #f1f1f1;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* Handle */
|
|
12
|
-
::-webkit-scrollbar-thumb {
|
|
13
|
-
background: #e5ccbc;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* Handle on hover */
|
|
17
|
-
::-webkit-scrollbar-thumb:hover {
|
|
18
|
-
background: #e5ccbc;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.spinner {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
gap: 2px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.spinner>div {
|
|
30
|
-
width: 5px;
|
|
31
|
-
height: 5px;
|
|
32
|
-
background-color: #173330;
|
|
33
|
-
border-radius: 100%;
|
|
34
|
-
display: inline-block;
|
|
35
|
-
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
|
|
36
|
-
animation: bouncedelay 1400ms ease-in-out infinite;
|
|
37
|
-
/* Prevent first frame from flickering when animation starts */
|
|
38
|
-
-webkit-animation-fill-mode: both;
|
|
39
|
-
animation-fill-mode: both;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.spinner .bounce1 {
|
|
43
|
-
-webkit-animation-delay: -0.32s;
|
|
44
|
-
animation-delay: -0.32s;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.spinner .bounce2 {
|
|
48
|
-
-webkit-animation-delay: -0.16s;
|
|
49
|
-
animation-delay: -0.16s;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@-webkit-keyframes bouncedelay {
|
|
53
|
-
|
|
54
|
-
0%,
|
|
55
|
-
80%,
|
|
56
|
-
100% {
|
|
57
|
-
transform: scale(0);
|
|
58
|
-
-webkit-transform: scale(0);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
40% {
|
|
62
|
-
transform: scale(1);
|
|
63
|
-
-webkit-transform: scale(1);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@keyframes bouncedelay {
|
|
68
|
-
|
|
69
|
-
0%,
|
|
70
|
-
80%,
|
|
71
|
-
100% {
|
|
72
|
-
transform: scale(0);
|
|
73
|
-
-webkit-transform: scale(0);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
40% {
|
|
77
|
-
transform: scale(1);
|
|
78
|
-
-webkit-transform: scale(1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.chat-button {
|
|
84
|
-
position: fixed;
|
|
85
|
-
bottom: 20px;
|
|
86
|
-
right: 20px;
|
|
87
|
-
background: #17235B;
|
|
88
|
-
border: #17235B;
|
|
89
|
-
border-radius: 50%;
|
|
90
|
-
width: 50px;
|
|
91
|
-
height: 50px;
|
|
92
|
-
font-size: 24px;
|
|
93
|
-
color: #fff;
|
|
94
|
-
display: inline-flex;
|
|
95
|
-
align-items: center;
|
|
96
|
-
justify-content: center;
|
|
97
|
-
}
|
|
1
|
+
/* width */
|
|
2
|
+
::-webkit-scrollbar {
|
|
3
|
+
width: 5px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/* Track */
|
|
7
|
+
::-webkit-scrollbar-track {
|
|
8
|
+
background: #f1f1f1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Handle */
|
|
12
|
+
::-webkit-scrollbar-thumb {
|
|
13
|
+
background: #e5ccbc;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Handle on hover */
|
|
17
|
+
::-webkit-scrollbar-thumb:hover {
|
|
18
|
+
background: #e5ccbc;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
.spinner {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
gap: 2px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.spinner>div {
|
|
30
|
+
width: 5px;
|
|
31
|
+
height: 5px;
|
|
32
|
+
background-color: #173330;
|
|
33
|
+
border-radius: 100%;
|
|
34
|
+
display: inline-block;
|
|
35
|
+
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
|
|
36
|
+
animation: bouncedelay 1400ms ease-in-out infinite;
|
|
37
|
+
/* Prevent first frame from flickering when animation starts */
|
|
38
|
+
-webkit-animation-fill-mode: both;
|
|
39
|
+
animation-fill-mode: both;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.spinner .bounce1 {
|
|
43
|
+
-webkit-animation-delay: -0.32s;
|
|
44
|
+
animation-delay: -0.32s;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.spinner .bounce2 {
|
|
48
|
+
-webkit-animation-delay: -0.16s;
|
|
49
|
+
animation-delay: -0.16s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@-webkit-keyframes bouncedelay {
|
|
53
|
+
|
|
54
|
+
0%,
|
|
55
|
+
80%,
|
|
56
|
+
100% {
|
|
57
|
+
transform: scale(0);
|
|
58
|
+
-webkit-transform: scale(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
40% {
|
|
62
|
+
transform: scale(1);
|
|
63
|
+
-webkit-transform: scale(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@keyframes bouncedelay {
|
|
68
|
+
|
|
69
|
+
0%,
|
|
70
|
+
80%,
|
|
71
|
+
100% {
|
|
72
|
+
transform: scale(0);
|
|
73
|
+
-webkit-transform: scale(0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
40% {
|
|
77
|
+
transform: scale(1);
|
|
78
|
+
-webkit-transform: scale(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
.chat-button {
|
|
84
|
+
position: fixed;
|
|
85
|
+
bottom: 20px;
|
|
86
|
+
right: 20px;
|
|
87
|
+
background: #17235B;
|
|
88
|
+
border: #17235B;
|
|
89
|
+
border-radius: 50%;
|
|
90
|
+
width: 50px;
|
|
91
|
+
height: 50px;
|
|
92
|
+
font-size: 24px;
|
|
93
|
+
color: #fff;
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
@Component({
|
|
3
|
-
selector: 'hivegpt-chatbot',
|
|
4
|
-
templateUrl: './chatbot.component.html',
|
|
5
|
-
styleUrls: ['./chatbot.component.scss'],
|
|
6
|
-
})
|
|
7
|
-
export class ChatBotComponent {
|
|
8
|
-
@Input() userId!: string;
|
|
9
|
-
@Input() apiKey!: string;
|
|
10
|
-
@Input() botName!: string;
|
|
11
|
-
@Input() botSkills!: string;
|
|
12
|
-
@Input() botId!: string;
|
|
13
|
-
@Input() closeButtonColor!: string;
|
|
14
|
-
@Input() gradientColors!: string[];
|
|
15
|
-
@Input() greeting!: string;
|
|
16
|
-
@Input() sendButtonColor!: string;
|
|
17
|
-
@Input() useOpenAi!: boolean;
|
|
18
|
-
@Input() showClose!: boolean;
|
|
19
|
-
@Input() bgGradient!: string[];
|
|
20
|
-
@Input() sendButtonTextColor!: string;
|
|
21
|
-
@Input() fullView!: boolean;
|
|
22
|
-
@Input() bgBubbleAi!: string;
|
|
23
|
-
@Input() bgBubbleUser!: string;
|
|
24
|
-
@Input() closeButtonbgColor!: string;
|
|
25
|
-
@Input() messageTextColorAi!: string;
|
|
26
|
-
@Input() messageTextColorUser!: string;
|
|
27
|
-
@Input() dateTimeColor!: string;
|
|
28
|
-
@Input() dateTextColor!: string;
|
|
29
|
-
@Input() formFieldBgColor!: string;
|
|
30
|
-
@Input() formFieldTextColor!: string;
|
|
31
|
-
@Input() thumbsUpMessage!: string;
|
|
32
|
-
@Input() thumbsDownMessages!: string[];
|
|
33
|
-
@Input() timezone!: string;
|
|
34
|
-
@Input() eventName!: string;
|
|
35
|
-
@Input() credentials!: [];
|
|
36
|
-
@Input() unknownResponses!: [];
|
|
37
|
-
@Input() rules!: string;
|
|
38
|
-
@Input() eventId!: string;
|
|
39
|
-
visible = false;
|
|
40
|
-
|
|
41
|
-
toggle() {
|
|
42
|
-
this.visible = !this.visible;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
@Component({
|
|
3
|
+
selector: 'hivegpt-chatbot',
|
|
4
|
+
templateUrl: './chatbot.component.html',
|
|
5
|
+
styleUrls: ['./chatbot.component.scss'],
|
|
6
|
+
})
|
|
7
|
+
export class ChatBotComponent {
|
|
8
|
+
@Input() userId!: string;
|
|
9
|
+
@Input() apiKey!: string;
|
|
10
|
+
@Input() botName!: string;
|
|
11
|
+
@Input() botSkills!: string;
|
|
12
|
+
@Input() botId!: string;
|
|
13
|
+
@Input() closeButtonColor!: string;
|
|
14
|
+
@Input() gradientColors!: string[];
|
|
15
|
+
@Input() greeting!: string;
|
|
16
|
+
@Input() sendButtonColor!: string;
|
|
17
|
+
@Input() useOpenAi!: boolean;
|
|
18
|
+
@Input() showClose!: boolean;
|
|
19
|
+
@Input() bgGradient!: string[];
|
|
20
|
+
@Input() sendButtonTextColor!: string;
|
|
21
|
+
@Input() fullView!: boolean;
|
|
22
|
+
@Input() bgBubbleAi!: string;
|
|
23
|
+
@Input() bgBubbleUser!: string;
|
|
24
|
+
@Input() closeButtonbgColor!: string;
|
|
25
|
+
@Input() messageTextColorAi!: string;
|
|
26
|
+
@Input() messageTextColorUser!: string;
|
|
27
|
+
@Input() dateTimeColor!: string;
|
|
28
|
+
@Input() dateTextColor!: string;
|
|
29
|
+
@Input() formFieldBgColor!: string;
|
|
30
|
+
@Input() formFieldTextColor!: string;
|
|
31
|
+
@Input() thumbsUpMessage!: string;
|
|
32
|
+
@Input() thumbsDownMessages!: string[];
|
|
33
|
+
@Input() timezone!: string;
|
|
34
|
+
@Input() eventName!: string;
|
|
35
|
+
@Input() credentials!: [];
|
|
36
|
+
@Input() unknownResponses!: [];
|
|
37
|
+
@Input() rules!: string;
|
|
38
|
+
@Input() eventId!: string;
|
|
39
|
+
visible = false;
|
|
40
|
+
|
|
41
|
+
toggle() {
|
|
42
|
+
this.visible = !this.visible;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { ConversationService } from './conversation.service';
|
|
4
|
-
|
|
5
|
-
describe('ConversationService', () => {
|
|
6
|
-
let service: ConversationService;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
TestBed.configureTestingModule({});
|
|
10
|
-
service = TestBed.inject(ConversationService);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should be created', () => {
|
|
14
|
-
expect(service).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ConversationService } from './conversation.service';
|
|
4
|
+
|
|
5
|
+
describe('ConversationService', () => {
|
|
6
|
+
let service: ConversationService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(ConversationService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Observable, Subject } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
@Injectable({
|
|
5
|
-
providedIn: 'root',
|
|
6
|
-
})
|
|
7
|
-
export class ConversationService {
|
|
8
|
-
private conversationStorageKeyPrefix = 'conversationKey_';
|
|
9
|
-
private sessionStorageKeyPrefix = 'sessionKey_';
|
|
10
|
-
|
|
11
|
-
private userSpecificNotification: Subject<any> = new Subject<any>();
|
|
12
|
-
|
|
13
|
-
constructor() { }
|
|
14
|
-
|
|
15
|
-
generateKey(): string {
|
|
16
|
-
const timestamp = Math.floor(new Date().getTime() / 1000).toString(16);
|
|
17
|
-
const randomHex = 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => {
|
|
18
|
-
return Math.floor(Math.random() * 16).toString(16);
|
|
19
|
-
});
|
|
20
|
-
return timestamp + randomHex;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getKey(botId: string, resetKey: boolean = false): string {
|
|
24
|
-
const storageKey = `${this.conversationStorageKeyPrefix}${botId}`;
|
|
25
|
-
let value = localStorage.getItem(storageKey);
|
|
26
|
-
|
|
27
|
-
if (!value || resetKey) {
|
|
28
|
-
value = this.generateKey();
|
|
29
|
-
localStorage.setItem(storageKey, value);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getSessionKey(sessionId: string, resetKey: boolean = false): string {
|
|
36
|
-
const storageKey = `${this.sessionStorageKeyPrefix}${sessionId}`;
|
|
37
|
-
let value = localStorage.getItem(storageKey);
|
|
38
|
-
|
|
39
|
-
if (!value || resetKey) {
|
|
40
|
-
value = this.generateKey();
|
|
41
|
-
localStorage.setItem(storageKey, value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
sendValidatedUserData(message: any) {
|
|
48
|
-
this.userSpecificNotification.next(message);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getUserSpecificNotification(): Observable<any> {
|
|
52
|
-
return this.userSpecificNotification.asObservable();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { Observable, Subject } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: 'root',
|
|
6
|
+
})
|
|
7
|
+
export class ConversationService {
|
|
8
|
+
private conversationStorageKeyPrefix = 'conversationKey_';
|
|
9
|
+
private sessionStorageKeyPrefix = 'sessionKey_';
|
|
10
|
+
|
|
11
|
+
private userSpecificNotification: Subject<any> = new Subject<any>();
|
|
12
|
+
|
|
13
|
+
constructor() { }
|
|
14
|
+
|
|
15
|
+
generateKey(): string {
|
|
16
|
+
const timestamp = Math.floor(new Date().getTime() / 1000).toString(16);
|
|
17
|
+
const randomHex = 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => {
|
|
18
|
+
return Math.floor(Math.random() * 16).toString(16);
|
|
19
|
+
});
|
|
20
|
+
return timestamp + randomHex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getKey(botId: string, resetKey: boolean = false): string {
|
|
24
|
+
const storageKey = `${this.conversationStorageKeyPrefix}${botId}`;
|
|
25
|
+
let value = localStorage.getItem(storageKey);
|
|
26
|
+
|
|
27
|
+
if (!value || resetKey) {
|
|
28
|
+
value = this.generateKey();
|
|
29
|
+
localStorage.setItem(storageKey, value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getSessionKey(sessionId: string, resetKey: boolean = false): string {
|
|
36
|
+
const storageKey = `${this.sessionStorageKeyPrefix}${sessionId}`;
|
|
37
|
+
let value = localStorage.getItem(storageKey);
|
|
38
|
+
|
|
39
|
+
if (!value || resetKey) {
|
|
40
|
+
value = this.generateKey();
|
|
41
|
+
localStorage.setItem(storageKey, value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
sendValidatedUserData(message: any) {
|
|
48
|
+
this.userSpecificNotification.next(message);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getUserSpecificNotification(): Observable<any> {
|
|
52
|
+
return this.userSpecificNotification.asObservable();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { SocketServiceService } from './socket-service.service';
|
|
4
|
-
|
|
5
|
-
describe('SocketServiceService', () => {
|
|
6
|
-
let service: SocketServiceService;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
TestBed.configureTestingModule({});
|
|
10
|
-
service = TestBed.inject(SocketServiceService);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should be created', () => {
|
|
14
|
-
expect(service).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SocketServiceService } from './socket-service.service';
|
|
4
|
+
|
|
5
|
+
describe('SocketServiceService', () => {
|
|
6
|
+
let service: SocketServiceService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(SocketServiceService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|