@hivegpt/hiveai-angular 0.0.141 → 0.0.144

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms'), require('@angular/material/icon'), require('@angular/material/sidenav')) :
3
- typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/forms', '@angular/material/icon', '@angular/material/sidenav'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt['hiveai-angular'] = {}), global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.ng.common, global.ng.forms, global.ng.material.icon, global.ng.material.sidenav));
5
- }(this, (function (exports, http, i0, platformBrowser, rxjs, operators, common, forms, icon, sidenav) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('rxjs/webSocket'), require('@angular/common'), require('@angular/forms'), require('@angular/material/icon'), require('@angular/material/sidenav')) :
3
+ typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', 'rxjs/webSocket', '@angular/common', '@angular/forms', '@angular/material/icon', '@angular/material/sidenav'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt['hiveai-angular'] = {}), global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.rxjs.webSocket, global.ng.common, global.ng.forms, global.ng.material.icon, global.ng.material.sidenav));
5
+ }(this, (function (exports, http, i0, platformBrowser, rxjs, operators, webSocket, common, forms, icon, sidenav) { 'use strict';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -507,7 +507,8 @@
507
507
  USERS_API: 'https://es-user.social27.com/api',
508
508
  BASE_URL: 'https://agent-api.hivegpt.ai',
509
509
  AGENTS_API: 'https://hive-ai.social27.com/api',
510
- API_KEY: 'b621eb3f-0bd2-41d5-a48c-a8f8ab7d38f8'
510
+ API_KEY: 'b621eb3f-0bd2-41d5-a48c-a8f8ab7d38f8',
511
+ SocketUrl: 'https://notif-v2-api.social27.com/api/notifications'
511
512
  };
512
513
  var dev_environment = {
513
514
  USERS_API: 'https://pre-user.social27.com/api',
@@ -551,8 +552,48 @@
551
552
  ];
552
553
  ConversationService.ctorParameters = function () { return []; };
553
554
 
555
+ var SocketService = /** @class */ (function () {
556
+ function SocketService() {
557
+ this.connect();
558
+ }
559
+ SocketService.prototype.connect = function () {
560
+ var _this = this;
561
+ var url = prod_environment;
562
+ this.socket$ = webSocket.webSocket('ws://' + url.SocketUrl);
563
+ this.socket$.subscribe(function (message) { return _this.onMessage(message); }, function (err) { return console.error('WebSocket error', err); }, function () { return console.warn('WebSocket closed'); });
564
+ };
565
+ SocketService.prototype.onMessage = function (message) {
566
+ console.log('Received message:', message);
567
+ // Handle incoming messages
568
+ };
569
+ SocketService.prototype.sendMessage = function (message) {
570
+ this.socket$.next(message);
571
+ };
572
+ SocketService.prototype.close = function () {
573
+ this.socket$.complete();
574
+ };
575
+ SocketService.prototype.onEvent = function (eventName) {
576
+ var _this = this;
577
+ return new rxjs.Observable(function (observer) {
578
+ _this.socket$.subscribe(function (message) {
579
+ if (message.event === eventName) {
580
+ observer.next(message.data);
581
+ }
582
+ });
583
+ });
584
+ };
585
+ return SocketService;
586
+ }());
587
+ SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(); }, token: SocketService, providedIn: "root" });
588
+ SocketService.decorators = [
589
+ { type: i0.Injectable, args: [{
590
+ providedIn: 'root'
591
+ },] }
592
+ ];
593
+ SocketService.ctorParameters = function () { return []; };
594
+
554
595
  var ChatDrawerComponent = /** @class */ (function () {
555
- function ChatDrawerComponent(cdr, http, sanitizer, elementRef, renderer, conversation
596
+ function ChatDrawerComponent(cdr, http, sanitizer, elementRef, renderer, socketService, conversation
556
597
  // private platform: Platform
557
598
  ) {
558
599
  var _this = this;
@@ -561,6 +602,7 @@
561
602
  this.sanitizer = sanitizer;
562
603
  this.elementRef = elementRef;
563
604
  this.renderer = renderer;
605
+ this.socketService = socketService;
564
606
  this.conversation = conversation;
565
607
  this.bodyOverflowClass = 'body-overflow-hidden';
566
608
  this.isCollapsedTrue = false;
@@ -681,6 +723,40 @@
681
723
  });
682
724
  this.fetchAgents();
683
725
  this.cdr.markForCheck();
726
+ this.initializeSocketAndListen();
727
+ };
728
+ ChatDrawerComponent.prototype.initializeSocketAndListen = function () {
729
+ var _this = this;
730
+ this.eventSubscription = this.socketService.onEvent('webresult').subscribe(function (data) {
731
+ console.log('Event received webresult:', data);
732
+ _this.handleEvent(data, 'webresult');
733
+ });
734
+ this.eventSubscription = this.socketService.onEvent('answer').subscribe(function (data) {
735
+ console.log('Event received answer:', data);
736
+ _this.handleEvent(data, 'answer');
737
+ });
738
+ this.eventSubscription = this.socketService.onEvent('graph').subscribe(function (data) {
739
+ console.log('Event received graph:', data);
740
+ _this.handleEvent(data, 'graph');
741
+ });
742
+ };
743
+ ChatDrawerComponent.prototype.handleEvent = function (data, type) {
744
+ switch (type) {
745
+ case 'webresult':
746
+ break;
747
+ case 'answer':
748
+ break;
749
+ case 'graph':
750
+ break;
751
+ default:
752
+ break;
753
+ }
754
+ };
755
+ ChatDrawerComponent.prototype.ngOnDestroy = function () {
756
+ if (this.eventSubscription) {
757
+ this.eventSubscription.unsubscribe();
758
+ }
759
+ this.socketService.close();
684
760
  };
685
761
  ChatDrawerComponent.prototype.changeTemperature = function (newTemperature) {
686
762
  if (this.loading)
@@ -1481,12 +1557,16 @@
1481
1557
  this.onDrawerClosed();
1482
1558
  };
1483
1559
  ChatDrawerComponent.prototype.onDrawerClosed = function () {
1484
- this.isDrawerOpen = true;
1485
- // Use ngClass to dynamically apply the class
1486
- var button = document.getElementById('botcloseplaygroundbutton');
1487
- if (button) {
1488
- button.style.display = 'block';
1489
- }
1560
+ var _this = this;
1561
+ setTimeout(function () {
1562
+ _this.isDrawerOpen = true;
1563
+ _this.cdr.detectChanges(); // Trigger change detection if needed
1564
+ // Use ngClass to dynamically apply the class
1565
+ var button = document.getElementById('botcloseplaygroundbutton');
1566
+ if (button) {
1567
+ button.style.display = 'block';
1568
+ }
1569
+ }, 0);
1490
1570
  };
1491
1571
  ChatDrawerComponent.prototype.toggleDrawer = function (todo) {
1492
1572
  this.isDrawerOpen = todo;
@@ -1515,6 +1595,7 @@
1515
1595
  { type: platformBrowser.DomSanitizer },
1516
1596
  { type: i0.ElementRef },
1517
1597
  { type: i0.Renderer2 },
1598
+ { type: SocketService },
1518
1599
  { type: ConversationService }
1519
1600
  ]; };
1520
1601
  ChatDrawerComponent.propDecorators = {
@@ -1789,9 +1870,10 @@
1789
1870
  exports.ChatBotComponent = ChatBotComponent;
1790
1871
  exports.ChatDrawerComponent = ChatDrawerComponent;
1791
1872
  exports.HiveGptModule = HiveGptModule;
1792
- exports.ɵa = ConversationService;
1793
- exports.ɵb = VideoPlayerComponent;
1794
- exports.ɵc = SafeHtmlPipe;
1873
+ exports.ɵa = SocketService;
1874
+ exports.ɵb = ConversationService;
1875
+ exports.ɵc = VideoPlayerComponent;
1876
+ exports.ɵd = SafeHtmlPipe;
1795
1877
 
1796
1878
  Object.defineProperty(exports, '__esModule', { value: true });
1797
1879