@hivegpt/hiveai-angular 0.0.372 → 0.0.373

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.
Files changed (95) hide show
  1. package/.editorconfig +16 -0
  2. package/README.md +13 -9
  3. package/angular.json +51 -0
  4. package/package.json +51 -14
  5. package/projects/hivegpt/eventsgpt-angular/README.md +23 -0
  6. package/projects/hivegpt/eventsgpt-angular/karma.conf.js +32 -0
  7. package/projects/hivegpt/eventsgpt-angular/ng-package.json +7 -0
  8. package/projects/hivegpt/eventsgpt-angular/package.json +20 -0
  9. package/projects/hivegpt/eventsgpt-angular/src/environments/environment.ts +19 -0
  10. package/projects/hivegpt/eventsgpt-angular/src/lib/components/NotificationSocket.ts +38 -0
  11. package/projects/hivegpt/eventsgpt-angular/src/lib/components/bot-html-editor/bot-html-editor.component.css +10 -0
  12. package/projects/hivegpt/eventsgpt-angular/src/lib/components/bot-html-editor/bot-html-editor.component.html +11 -0
  13. package/projects/hivegpt/eventsgpt-angular/src/lib/components/bot-html-editor/bot-html-editor.component.spec.ts +25 -0
  14. package/projects/hivegpt/eventsgpt-angular/src/lib/components/bot-html-editor/bot-html-editor.component.ts +152 -0
  15. package/projects/hivegpt/eventsgpt-angular/src/lib/components/bot.service.ts +52 -0
  16. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chat-drawer/chat-drawer.component.html +1586 -0
  17. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chat-drawer/chat-drawer.component.scss +2907 -0
  18. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chat-drawer/chat-drawer.component.ts +2143 -0
  19. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chatbot/chatbot.component.html +37 -0
  20. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chatbot/chatbot.component.scss +97 -0
  21. package/projects/hivegpt/eventsgpt-angular/src/lib/components/chatbot/chatbot.component.ts +44 -0
  22. package/projects/hivegpt/eventsgpt-angular/src/lib/components/conversation.service.spec.ts +16 -0
  23. package/projects/hivegpt/eventsgpt-angular/src/lib/components/conversation.service.ts +54 -0
  24. package/projects/hivegpt/eventsgpt-angular/src/lib/components/socket-service.service.spec.ts +16 -0
  25. package/projects/hivegpt/eventsgpt-angular/src/lib/components/socket-service.service.ts +77 -0
  26. package/projects/hivegpt/eventsgpt-angular/src/lib/components/translations/translation.service.ts +268 -0
  27. package/projects/hivegpt/eventsgpt-angular/src/lib/components/video-player/video-player.component.html +51 -0
  28. package/projects/hivegpt/eventsgpt-angular/src/lib/components/video-player/video-player.component.scss +262 -0
  29. package/projects/hivegpt/eventsgpt-angular/src/lib/components/video-player/video-player.component.ts +148 -0
  30. package/projects/hivegpt/eventsgpt-angular/src/lib/hivegpt.module.ts +18 -0
  31. package/projects/hivegpt/eventsgpt-angular/src/lib/models/video.ts +36 -0
  32. package/projects/hivegpt/eventsgpt-angular/src/lib/pipes/safe-html.pipe.ts +16 -0
  33. package/projects/hivegpt/eventsgpt-angular/src/lib/utils/utils.ts +37 -0
  34. package/{public-api.d.ts → projects/hivegpt/eventsgpt-angular/src/public-api.ts} +4 -1
  35. package/projects/hivegpt/eventsgpt-angular/tsconfig.lib.json +25 -0
  36. package/projects/hivegpt/eventsgpt-angular/tsconfig.lib.prod.json +10 -0
  37. package/projects/hivegpt/eventsgpt-angular/tsconfig.spec.json +17 -0
  38. package/projects/hivegpt/eventsgpt-angular/tslint.json +17 -0
  39. package/tsconfig.json +28 -0
  40. package/tslint.json +140 -0
  41. package/wew +0 -0
  42. package/bundles/hivegpt-hiveai-angular.umd.js +0 -3116
  43. package/bundles/hivegpt-hiveai-angular.umd.js.map +0 -1
  44. package/bundles/hivegpt-hiveai-angular.umd.min.js +0 -2
  45. package/bundles/hivegpt-hiveai-angular.umd.min.js.map +0 -1
  46. package/environments/environment.d.ts +0 -15
  47. package/environments/environment.d.ts.map +0 -1
  48. package/esm2015/environments/environment.js +0 -15
  49. package/esm2015/hivegpt-hiveai-angular.js +0 -13
  50. package/esm2015/lib/components/NotificationSocket.js +0 -39
  51. package/esm2015/lib/components/bot-html-editor/bot-html-editor.component.js +0 -112
  52. package/esm2015/lib/components/bot.service.js +0 -50
  53. package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +0 -1743
  54. package/esm2015/lib/components/chatbot/chatbot.component.js +0 -50
  55. package/esm2015/lib/components/conversation.service.js +0 -49
  56. package/esm2015/lib/components/socket-service.service.js +0 -72
  57. package/esm2015/lib/components/translations/translation.service.js +0 -215
  58. package/esm2015/lib/components/video-player/video-player.component.js +0 -123
  59. package/esm2015/lib/hivegpt.module.js +0 -21
  60. package/esm2015/lib/models/video.js +0 -2
  61. package/esm2015/lib/pipes/safe-html.pipe.js +0 -19
  62. package/esm2015/lib/utils/utils.js +0 -36
  63. package/esm2015/public-api.js +0 -7
  64. package/fesm2015/hivegpt-hiveai-angular.js +0 -2512
  65. package/fesm2015/hivegpt-hiveai-angular.js.map +0 -1
  66. package/hivegpt-hiveai-angular.d.ts +0 -13
  67. package/hivegpt-hiveai-angular.d.ts.map +0 -1
  68. package/hivegpt-hiveai-angular.metadata.json +0 -1
  69. package/lib/components/NotificationSocket.d.ts +0 -5
  70. package/lib/components/NotificationSocket.d.ts.map +0 -1
  71. package/lib/components/bot-html-editor/bot-html-editor.component.d.ts +0 -36
  72. package/lib/components/bot-html-editor/bot-html-editor.component.d.ts.map +0 -1
  73. package/lib/components/bot.service.d.ts +0 -12
  74. package/lib/components/bot.service.d.ts.map +0 -1
  75. package/lib/components/chat-drawer/chat-drawer.component.d.ts +0 -255
  76. package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +0 -1
  77. package/lib/components/chatbot/chatbot.component.d.ts +0 -36
  78. package/lib/components/chatbot/chatbot.component.d.ts.map +0 -1
  79. package/lib/components/conversation.service.d.ts +0 -13
  80. package/lib/components/conversation.service.d.ts.map +0 -1
  81. package/lib/components/socket-service.service.d.ts +0 -20
  82. package/lib/components/socket-service.service.d.ts.map +0 -1
  83. package/lib/components/translations/translation.service.d.ts +0 -8
  84. package/lib/components/translations/translation.service.d.ts.map +0 -1
  85. package/lib/components/video-player/video-player.component.d.ts +0 -36
  86. package/lib/components/video-player/video-player.component.d.ts.map +0 -1
  87. package/lib/hivegpt.module.d.ts +0 -3
  88. package/lib/hivegpt.module.d.ts.map +0 -1
  89. package/lib/models/video.d.ts +0 -35
  90. package/lib/models/video.d.ts.map +0 -1
  91. package/lib/pipes/safe-html.pipe.d.ts +0 -8
  92. package/lib/pipes/safe-html.pipe.d.ts.map +0 -1
  93. package/lib/utils/utils.d.ts +0 -3
  94. package/lib/utils/utils.d.ts.map +0 -1
  95. package/public-api.d.ts.map +0 -1
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+
14
+ [*.md]
15
+ max_line_length = off
16
+ trim_trailing_whitespace = false
package/README.md CHANGED
@@ -1,22 +1,26 @@
1
- # EventsgptAngular
1
+ # HivegptEventsgptAngular
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.5.
3
+ This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.4.
4
+
5
+ ## Development server
6
+
7
+ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
4
8
 
5
9
  ## Code scaffolding
6
10
 
7
- Run `ng generate component component-name --project eventsgpt-angular` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project eventsgpt-angular`.
8
- > Note: Don't forget to add `--project eventsgpt-angular` or else it will be added to the default project in your `angular.json` file.
11
+ Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
9
12
 
10
13
  ## Build
11
- Run `npx ng build @hivegpt/hiveai-angular` to build the project. The build artifacts will be stored in the `dist/` directory.
14
+ ## Run `npx ng build` to build
15
+ Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
12
16
 
13
- ## Publishing
17
+ ## Running unit tests
14
18
 
15
- After building your library with `ng build eventsgpt-angular`, go to the dist folder `cd dist/eventsgpt-angular` and run `npm publish`.
19
+ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
16
20
 
17
- ## Running unit tests
21
+ ## Running end-to-end tests
18
22
 
19
- Run `ng test eventsgpt-angular` to execute the unit tests via [Karma](https://karma-runner.github.io).
23
+ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
20
24
 
21
25
  ## Further help
22
26
 
package/angular.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "@hivegpt/hiveai-angular": {
7
+ "projectType": "library",
8
+ "root": "projects/hivegpt/eventsgpt-angular",
9
+ "sourceRoot": "projects/hivegpt/eventsgpt-angular/src",
10
+ "prefix": "lib",
11
+ "architect": {
12
+ "build": {
13
+ "builder": "@angular-devkit/build-angular:ng-packagr",
14
+ "options": {
15
+ "tsConfig": "projects/hivegpt/eventsgpt-angular/tsconfig.lib.json",
16
+ "project": "projects/hivegpt/eventsgpt-angular/ng-package.json"
17
+ },
18
+ "configurations": {
19
+ "production": {
20
+ "tsConfig": "projects/hivegpt/eventsgpt-angular/tsconfig.lib.prod.json"
21
+ }
22
+ }
23
+ },
24
+ "test": {
25
+ "builder": "@angular-devkit/build-angular:karma",
26
+ "options": {
27
+ "main": "projects/hivegpt/eventsgpt-angular/src/test.ts",
28
+ "tsConfig": "projects/hivegpt/eventsgpt-angular/tsconfig.spec.json",
29
+ "karmaConfig": "projects/hivegpt/eventsgpt-angular/karma.conf.js"
30
+ }
31
+ },
32
+ "lint": {
33
+ "builder": "@angular-devkit/build-angular:tslint",
34
+ "options": {
35
+ "tsConfig": [
36
+ "projects/hivegpt/eventsgpt-angular/tsconfig.lib.json",
37
+ "projects/hivegpt/eventsgpt-angular/tsconfig.spec.json"
38
+ ],
39
+ "exclude": [
40
+ "**/node_modules/**"
41
+ ]
42
+ }
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "defaultProject": "@hivegpt/hiveai-angular",
48
+ "cli": {
49
+ "analytics": false
50
+ }
51
+ }
package/package.json CHANGED
@@ -1,20 +1,57 @@
1
1
  {
2
2
  "name": "@hivegpt/hiveai-angular",
3
- "version": "0.0.372",
4
- "peerDependencies": {
5
- "@angular/common": "^10.2.5",
6
- "@angular/core": "^10.2.5",
7
- "microsoft-cognitiveservices-speech-sdk": "^1.17.0"
3
+ "version": "0.0.373",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "test": "ng test",
9
+ "lint": "ng lint",
10
+ "publish:npm": "cd projects/hivegpt/eventsgpt-angular && npm version patch && cd ../../../ && npm run build @hivegpt/hiveai-angular && cd dist/hivegpt/eventsgpt-angular && npm publish --access=public && cd ../../../",
11
+ "publish:complete": "git fetch && git pull && npm run publish:npm && git add . && git commit -m \"publish updated angular package\" && git push"
8
12
  },
13
+ "private": false,
9
14
  "dependencies": {
10
- "tslib": "^2.0.0"
15
+ "@angular/animations": "~12.2.13",
16
+ "@angular/cdk": "^12.2.13",
17
+ "@angular/common": "~12.2.13",
18
+ "@angular/compiler": "~12.2.13",
19
+ "@angular/core": "~12.2.13",
20
+ "@angular/forms": "~12.2.13",
21
+ "@angular/material": "^12.2.13",
22
+ "@angular/platform-browser": "~12.2.13",
23
+ "@angular/platform-browser-dynamic": "~12.2.13",
24
+ "@angular/router": "~12.2.13",
25
+ "@azure/core-auth": "^1.3.0",
26
+ "marked": "^3.0.8",
27
+ "microsoft-cognitiveservices-speech-sdk": "^1.17.0",
28
+ "ngx-quill": "^13.2.0",
29
+ "ngx-socket-io": "^3.2.0",
30
+ "ngx-toastr": "^14.2.1",
31
+ "quill": "^1.3.7",
32
+ "rxjs": "~6.6.0",
33
+ "tslib": "^2.0.0",
34
+ "zone.js": "~0.10.2"
11
35
  },
12
- "main": "bundles/hivegpt-hiveai-angular.umd.js",
13
- "module": "fesm2015/hivegpt-hiveai-angular.js",
14
- "es2015": "fesm2015/hivegpt-hiveai-angular.js",
15
- "esm2015": "esm2015/hivegpt-hiveai-angular.js",
16
- "fesm2015": "fesm2015/hivegpt-hiveai-angular.js",
17
- "typings": "hivegpt-hiveai-angular.d.ts",
18
- "metadata": "hivegpt-hiveai-angular.metadata.json",
19
- "sideEffects": false
36
+ "devDependencies": {
37
+ "@angular-devkit/build-angular": "~12.2.13",
38
+ "@angular/cli": "~12.2.13",
39
+ "@angular/compiler-cli": "~12.2.13",
40
+ "@types/jasmine": "~3.5.0",
41
+ "@types/jasminewd2": "~2.0.3",
42
+ "@types/node": "^12.20.55",
43
+ "codelyzer": "^6.0.0",
44
+ "jasmine-core": "~3.6.0",
45
+ "jasmine-spec-reporter": "~5.0.0",
46
+ "karma": "^6.4.4",
47
+ "karma-chrome-launcher": "~3.1.0",
48
+ "karma-coverage-istanbul-reporter": "~3.0.2",
49
+ "karma-jasmine": "~4.0.0",
50
+ "karma-jasmine-html-reporter": "~1.5.0",
51
+ "ng-packagr": "^10.1.0",
52
+ "protractor": "~7.0.0",
53
+ "ts-node": "~8.3.0",
54
+ "tslint": "~6.1.0",
55
+ "typescript": "~4.3.5"
56
+ }
20
57
  }
@@ -0,0 +1,23 @@
1
+ # EventsgptAngular
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.5.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project eventsgpt-angular` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project eventsgpt-angular`.
8
+ > Note: Don't forget to add `--project eventsgpt-angular` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+ Run `npx ng build @hivegpt/hiveai-angular` to build the project. The build artifacts will be stored in the `dist/` directory.
12
+
13
+ ## Publishing
14
+
15
+ After building your library with `ng build eventsgpt-angular`, go to the dist folder `cd dist/eventsgpt-angular` and run `npm publish`.
16
+
17
+ ## Running unit tests
18
+
19
+ Run `ng test eventsgpt-angular` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
+
21
+ ## Further help
22
+
23
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
@@ -0,0 +1,32 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage-istanbul-reporter'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
17
+ },
18
+ coverageIstanbulReporter: {
19
+ dir: require('path').join(__dirname, '../../../coverage/hivegpt/eventsgpt-angular'),
20
+ reports: ['html', 'lcovonly', 'text-summary'],
21
+ fixWebpackSourcePaths: true
22
+ },
23
+ reporters: ['progress', 'kjhtml'],
24
+ port: 9876,
25
+ colors: true,
26
+ logLevel: config.LOG_INFO,
27
+ autoWatch: true,
28
+ browsers: ['Chrome'],
29
+ singleRun: false,
30
+ restartOnFileChange: true
31
+ });
32
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../../dist/hivegpt/eventsgpt-angular",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@hivegpt/hiveai-angular",
3
+ "version": "0.0.372",
4
+ "peerDependencies": {
5
+ "@angular/common": "^10.2.5",
6
+ "@angular/core": "^10.2.5",
7
+ "microsoft-cognitiveservices-speech-sdk": "^1.17.0"
8
+ },
9
+ "scripts": {
10
+ "ng": "ng",
11
+ "start": "ng serve",
12
+ "build": "ng build",
13
+ "test": "ng test",
14
+ "lint": "ng lint",
15
+ "e2e": "ng e2e"
16
+ },
17
+ "dependencies": {
18
+ "tslib": "^2.0.0"
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+
2
+
3
+ export const prod_environment = {
4
+ USERS_API: 'https://es-user.social27.com/api',
5
+ BASE_URL: 'https://agent-api.hivegpt.ai',
6
+ AGENTS_API: 'https://hive-ai.social27.com/api',
7
+ API_KEY: '82595783-dc9c-4513-8204-709818d51be3',
8
+ SocketUrl: 'https://notif-v2-ws.social27.com/'
9
+ }
10
+
11
+
12
+ export const dev_environment = {
13
+ USERS_API: 'https://pre-user.social27.com/api',
14
+ BASE_URL: 'https://pre-agent-api.hivegpt.ai',
15
+ AGENTS_API: 'https://hive-pre-ai.social27.com/api',
16
+ API_KEY: '66d59244c50b8fb597a101t1',
17
+ SocketUrl: 'https://notif-ws-staging.social27.com/',
18
+ };
19
+
@@ -0,0 +1,38 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Socket, SocketIoConfig } from 'ngx-socket-io';
3
+ import { prod_environment } from '../../environments/environment';
4
+
5
+ @Injectable({
6
+ providedIn: 'root' // This ensures the service is available across the application
7
+ })
8
+ export class NotificationSocket extends Socket {
9
+ constructor() {
10
+ super(socketConfig);
11
+
12
+ // Log connection status
13
+ this.on('connect', () => {
14
+ console.log('Socket connected');
15
+ });
16
+
17
+ this.on('disconnect', () => {
18
+ console.warn('Socket disconnected');
19
+ });
20
+
21
+ this.on('connect_error', (err) => {
22
+ console.error('Socket connection error:', err);
23
+ });
24
+ }
25
+ }
26
+
27
+ const socketConfig: SocketIoConfig = {
28
+ url: prod_environment.SocketUrl,
29
+ options: {
30
+ transports: ['websocket', 'polling'],
31
+ reconnection: true,
32
+ autoConnect: true,
33
+ upgrade: true,
34
+ reconnectionDelay: 1000,
35
+ reconnectionDelayMax: 5000,
36
+ reconnectionAttempts: Infinity
37
+ }
38
+ };
@@ -0,0 +1,10 @@
1
+ .save-btn
2
+ {
3
+ background-color: #f0f0f0;
4
+ border: none;
5
+ color: #333;
6
+ width: 56px;
7
+ position: absolute;
8
+ right: 16px;
9
+ margin-top: 22px;
10
+ }
@@ -0,0 +1,11 @@
1
+ <div style="padding: 12px">
2
+ <div style="margin-top: 42px" class="form-group">
3
+ <input [(ngModel)]="documentName" class="form-control" type="text" />
4
+ <button (click)="saveContent()" class="save-btn">Save</button>
5
+ </div>
6
+
7
+ <quill-editor
8
+ [(ngModel)]="editorContent"
9
+ [modules]="quillConfig"
10
+ ></quill-editor>
11
+ </div>
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BotHtmlEditorComponent } from './bot-html-editor.component';
4
+
5
+ describe('BotHtmlEditorComponent', () => {
6
+ let component: BotHtmlEditorComponent;
7
+ let fixture: ComponentFixture<BotHtmlEditorComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BotHtmlEditorComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(BotHtmlEditorComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,152 @@
1
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef,
5
+ Component,
6
+ ElementRef,
7
+ EventEmitter,
8
+ Input,
9
+ OnChanges,
10
+ OnInit,
11
+ Output,
12
+ QueryList,
13
+ Renderer2,
14
+ SimpleChanges,
15
+ ViewChild,
16
+ ViewChildren,
17
+ } from '@angular/core';
18
+ import { MatDrawer } from '@angular/material/sidenav';
19
+ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
20
+ import { of, Subscription } from 'rxjs';
21
+ import { catchError, switchMap } from 'rxjs/operators';
22
+ import { formatNow, formatTimeStamps } from '../../utils/utils';
23
+ import {
24
+ dev_environment,
25
+ prod_environment,
26
+ } from '../../../environments/environment';
27
+ import { ConversationService } from '../conversation.service';
28
+ import { Observable } from 'rxjs';
29
+ import { SocketService } from '../socket-service.service';
30
+
31
+ @Component({
32
+ selector: 'lib-bot-html-editor',
33
+ templateUrl: './bot-html-editor.component.html',
34
+ styleUrls: ['./bot-html-editor.component.css'],
35
+ })
36
+ export class BotHtmlEditorComponent implements OnInit {
37
+ @Input() editorContent: Observable<string>;
38
+ @Input() isDocInEditMode: any;
39
+ @Input() documentContent: any;
40
+ @Input() conversationId: any;
41
+ @Input() botId: any;
42
+
43
+ documentName: any = 'doc name';
44
+
45
+ environment: {
46
+ USERS_API;
47
+ BASE_URL;
48
+ AGENTS_API;
49
+ };
50
+
51
+ quillConfig = {
52
+ toolbar: [
53
+ [{ header: '1' }, { header: '2' }, { font: [] }],
54
+ [{ list: 'ordered' }, { list: 'bullet' }],
55
+ ['bold', 'italic', 'underline'],
56
+ ['link'],
57
+ ['clean'],
58
+ ],
59
+ };
60
+ constructor(private cdr: ChangeDetectorRef, private http: HttpClient) {}
61
+
62
+ ngOnInit(): void {
63
+ this.environment = prod_environment;
64
+
65
+ setTimeout(() => {
66
+ if (this.isDocInEditMode) {
67
+ console.log('In Edit mode');
68
+ this.filldataInForm();
69
+ } else {
70
+ console.log('In save mode');
71
+ }
72
+ }, 2500);
73
+ }
74
+
75
+ filldataInForm() {
76
+ if (this.documentContent) {
77
+ this.documentName = this.documentContent?.name;
78
+ this.editorContent = this.documentContent?.content;
79
+ this.cdr.detectChanges();
80
+ }
81
+ }
82
+
83
+ saveContent() {
84
+ if (!this.isDocInEditMode) {
85
+ this.saveContent_http().subscribe();
86
+ } else {
87
+ this.saveContent_http().subscribe();
88
+ }
89
+ }
90
+
91
+ saveContent_http() {
92
+ console.log('API call function');
93
+
94
+ const url = `${this.environment.AGENTS_API}/ConversationDocuments?conversationId=${this.conversationId}&botId=${this.botId}`;
95
+ const headers = new HttpHeaders({
96
+ 'Content-Type': 'application/json',
97
+ apiKey: 'WIz/qAm+EEmfOkFaUA/weA==',
98
+ });
99
+
100
+ let data = {
101
+ name: this.documentName,
102
+ content: this.editorContent,
103
+ };
104
+
105
+ return this.http.post(url, data, { headers }).pipe(
106
+ switchMap((res: any) => {
107
+ if (res) {
108
+ // alert('Saved Successfully');
109
+ }
110
+ this.cdr.markForCheck();
111
+
112
+ return of(res);
113
+ }),
114
+ catchError((error) => {
115
+ console.error('Error fetching chatbot config: ', error);
116
+
117
+ return of(null);
118
+ })
119
+ );
120
+ }
121
+
122
+ updateContent_http() {
123
+ console.log('API call function');
124
+
125
+ const url = `${this.environment.AGENTS_API}/ConversationDocuments/rename?conversationId=${this.conversationId}&botId=${this.botId}`;
126
+ const headers = new HttpHeaders({
127
+ 'Content-Type': 'application/json',
128
+ apiKey: 'WIz/qAm+EEmfOkFaUA/weA==',
129
+ });
130
+
131
+ let data = {
132
+ name: this.documentName,
133
+ content: this.editorContent,
134
+ };
135
+
136
+ return this.http.put(url, data, { headers }).pipe(
137
+ switchMap((res: any) => {
138
+ if (res) {
139
+ // alert('Updated Successfully');
140
+ }
141
+ this.cdr.markForCheck();
142
+
143
+ return of(res);
144
+ }),
145
+ catchError((error) => {
146
+ console.error('Error fetching chatbot config: ', error);
147
+
148
+ return of(null);
149
+ })
150
+ );
151
+ }
152
+ }
@@ -0,0 +1,52 @@
1
+ import { HttpClient, HttpParams } from '@angular/common/http';
2
+ import { Injectable } from '@angular/core';
3
+ import { catchError, map } from 'rxjs/operators';
4
+
5
+ import { HttpHeaders } from '@angular/common/http';
6
+ import { Observable, Subject, throwError } from 'rxjs';
7
+ import { AnyRecord } from 'dns';
8
+
9
+ @Injectable({
10
+ providedIn: 'root',
11
+ })
12
+ export class BotsService {
13
+ eventDescription = new Subject();
14
+ bot_api = 'https://agent-api.hivegpt.ai/';
15
+ constructor(private http: HttpClient) { }
16
+
17
+ fetchSpeechAuthorizationToken(botId, apiKey, domain) {
18
+ const headers = new HttpHeaders({
19
+ 'Content-Type': 'application/json',
20
+ 'x-api-key': apiKey,
21
+ 'hive-bot-id': botId,
22
+ 'domain-authority': domain
23
+ });
24
+
25
+ const apiUrl = `${this.bot_api}speech/issue_token`;
26
+ const url = `${apiUrl}`;
27
+ return this.http.get(url, { headers }).pipe(
28
+ map((resp: any) => {
29
+ return resp.token;
30
+ })
31
+ );
32
+ }
33
+
34
+ getWorkflowsByOrgId(orgId: string): Observable<any> {
35
+ const apiUrl = `${this.bot_api}workflows`;
36
+ const url = `${apiUrl}?org_id=${orgId}`;
37
+ return this.http.get(url).pipe(
38
+ map((resp: any) => {
39
+ return resp;
40
+ })
41
+ );
42
+ }
43
+
44
+ getWorkflowExecutionById(executionId: string): Observable<any> {
45
+ const apiUrl = `${this.bot_api}workflows/execution/${executionId}`;
46
+ return this.http.get(apiUrl).pipe(
47
+ map((resp: any) => {
48
+ return resp;
49
+ })
50
+ );
51
+ }
52
+ }