@@ -5,6 +5,7 @@ import {UtmModuleGroupConfService} from '../../shared/services/utm-module-group-
55import { UtmModuleGroupConfType } from '../../shared/type/utm-module-group-conf.type' ;
66import { UtmToastService } from '../../../shared/alert/utm-toast.service' ;
77import { ModuleChangeStatusBehavior } from '../../shared/behavior/module-change-status.behavior' ;
8+ import { finalize } from 'rxjs/operators' ;
89
910interface ProviderConfig {
1011 id : string ;
@@ -297,7 +298,12 @@ export class GuideSocAiComponent implements OnInit {
297298
298299 private loadConfig ( ) {
299300 this . loading = true ;
300- this . moduleGroupService . query ( { moduleId : this . integrationId } ) . subscribe ( response => {
301+ this . moduleGroupService . query ( { moduleId : this . integrationId } ) . pipe (
302+ finalize ( ( ) => {
303+ this . loading = false ;
304+ this . cdr . detectChanges ( ) ;
305+ } )
306+ ) . subscribe ( response => {
301307 const groups = response . body || [ ] ;
302308 if ( groups . length > 0 ) {
303309 this . groupId = groups [ 0 ] . id ;
@@ -422,44 +428,44 @@ export class GuideSocAiComponent implements OnInit {
422428 const changes : UtmModuleGroupConfType [ ] = [ ] ;
423429
424430 // Set provider
425- this . pushChange ( changes , 'utmstack.socai.provider' , this . activeProvider ) ;
431+ this . pushChange ( changes , 'utmstack.socai.provider' , this . activeProvider , 'text' ) ;
426432
427433 // Set model
428- this . pushChange ( changes , 'utmstack.socai.model' , this . getModelValue ( ) ) ;
434+ this . pushChange ( changes , 'utmstack.socai.model' , this . getModelValue ( ) , 'text' ) ;
429435
430436 // Set URL for providers that need it (azure, ollama, custom)
431437 if ( this . formValues [ 'url' ] ) {
432- this . pushChange ( changes , 'utmstack.socai.url' , this . formValues [ 'url' ] ) ;
438+ this . pushChange ( changes , 'utmstack.socai.url' , this . formValues [ 'url' ] , 'text' ) ;
433439 }
434440
435441 // Set maxTokens
436442 if ( this . formValues [ 'maxTokens' ] ) {
437- this . pushChange ( changes , 'utmstack.socai.maxTokens' , this . formValues [ 'maxTokens' ] ) ;
443+ this . pushChange ( changes , 'utmstack.socai.maxTokens' , this . formValues [ 'maxTokens' ] , 'text' ) ;
438444 }
439445
440446 // Set behavior toggles
441- this . pushChange ( changes , 'utmstack.socai.autoAnalyze' , this . formValues [ 'autoAnalyze' ] || 'false' ) ;
442- this . pushChange ( changes , 'utmstack.socai.incidentCreation' , this . formValues [ 'incidentCreation' ] || 'false' ) ;
443- this . pushChange ( changes , 'utmstack.socai.changeAlertStatus' , this . formValues [ 'changeAlertStatus' ] || 'false' ) ;
447+ this . pushChange ( changes , 'utmstack.socai.autoAnalyze' , this . formValues [ 'autoAnalyze' ] || 'false' , 'text' ) ;
448+ this . pushChange ( changes , 'utmstack.socai.incidentCreation' , this . formValues [ 'incidentCreation' ] || 'false' , 'text' ) ;
449+ this . pushChange ( changes , 'utmstack.socai.changeAlertStatus' , this . formValues [ 'changeAlertStatus' ] || 'false' , 'text' ) ;
444450
445451 // Build auth headers
446452 if ( this . activeProvider === 'custom' ) {
447453 // Custom provider: user manages auth type and headers directly
448- this . pushChange ( changes , 'utmstack.socai.authType' , this . formValues [ 'authType' ] || 'custom-headers' ) ;
449- this . pushChange ( changes , 'utmstack.socai.customHeaders' , this . formValues [ 'customHeaders' ] || '{}' ) ;
454+ this . pushChange ( changes , 'utmstack.socai.authType' , this . formValues [ 'authType' ] || 'custom-headers' , 'text' ) ;
455+ this . pushChange ( changes , 'utmstack.socai.customHeaders' , this . formValues [ 'customHeaders' ] || '{}' , 'text' ) ;
450456 } else if ( this . activeProvider === 'ollama' ) {
451457 // Ollama: no auth needed
452- this . pushChange ( changes , 'utmstack.socai.authType' , 'none' ) ;
453- this . pushChange ( changes , 'utmstack.socai.customHeaders' , '{}' ) ;
458+ this . pushChange ( changes , 'utmstack.socai.authType' , 'none' , 'text' ) ;
459+ this . pushChange ( changes , 'utmstack.socai.customHeaders' , '{}' , 'text' ) ;
454460 } else {
455461 // Known providers: build auth header from API key
456462 const authConfig = this . providerAuthHeaders [ this . activeProvider ] ;
457463 if ( authConfig && this . formValues [ 'apiKey' ] && this . formValues [ 'apiKey' ] !== '*****' ) {
458464 // User entered a new API key — build auth headers
459465 const headers : { [ k : string ] : string } = { } ;
460466 headers [ authConfig . headerName ] = authConfig . headerValuePrefix + this . formValues [ 'apiKey' ] ;
461- this . pushChange ( changes , 'utmstack.socai.authType' , 'custom-headers' ) ;
462- this . pushChange ( changes , 'utmstack.socai.customHeaders' , JSON . stringify ( headers ) ) ;
467+ this . pushChange ( changes , 'utmstack.socai.authType' , 'custom-headers' , 'text' ) ;
468+ this . pushChange ( changes , 'utmstack.socai.customHeaders' , JSON . stringify ( headers ) , 'text' ) ;
463469 }
464470 // If apiKey is '*****', don't touch customHeaders — keep existing value in DB
465471 }
@@ -486,7 +492,12 @@ export class GuideSocAiComponent implements OnInit {
486492 ) ;
487493 }
488494
489- private pushChange ( changes : UtmModuleGroupConfType [ ] , confKey : string , value : string ) {
495+ private pushChange (
496+ changes : UtmModuleGroupConfType [ ] ,
497+ confKey : string ,
498+ value : string ,
499+ confDataType : 'list' | 'password' | 'file' | 'bool' | 'select' | 'text' = 'text'
500+ ) {
490501 const existing = this . getConf ( confKey ) ;
491502 if ( existing ) {
492503 changes . push ( {
@@ -495,6 +506,19 @@ export class GuideSocAiComponent implements OnInit {
495506 confOptions : existing . confOptions ? JSON . stringify ( existing . confOptions ) : existing . confOptions ,
496507 confVisibility : existing . confVisibility ? JSON . stringify ( existing . confVisibility ) : existing . confVisibility ,
497508 } ) ;
509+ } else {
510+ changes . push ( {
511+ id : undefined ,
512+ groupId : this . groupId ,
513+ confKey,
514+ confValue : value ,
515+ confName : confKey . split ( '.' ) [ 2 ] || confKey ,
516+ confDataType,
517+ confDescription : '' ,
518+ confRequired : true ,
519+ confOptions : undefined ,
520+ confVisibility : undefined ,
521+ } ) ;
498522 }
499523 }
500524
0 commit comments