@@ -3,6 +3,7 @@ import {ModalService} from '../../../../core/modal/modal.service';
33import {
44 ModalConfirmationComponent
55} from '../../../../shared/components/utm/util/modal-confirmation/modal-confirmation.component' ;
6+ import { replaceCommandTokens } from "../../../../shared/util/replace-command-tokens.util" ;
67import { UtmModulesEnum } from '../../../shared/enum/utm-module.enum' ;
78
89@Component ( {
@@ -31,7 +32,7 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
3132 </div>
3233 <ng-container *ngIf="selectedProtocol && selectedPlatform && selectedAction">
3334 <span class="font-weight-semibold mb-2">{{selectedPlatform.shell}}</span>
34- <app-utm-code-view class="" [code]=command ></app-utm-code-view>
35+ <app-utm-code-view class="" [code]=commands ></app-utm-code-view>
3536 </ng-container>
3637 ` ,
3738 styles : [ `
@@ -49,56 +50,52 @@ import {UtmModulesEnum} from '../../../shared/enum/utm-module.enum';
4950
5051export class LogCollectorComponent {
5152
53+ @Input ( ) agent : string ;
54+ @Input ( ) platforms : any [ ] ;
55+ @Input ( ) hideActions = false ;
56+ @Input ( ) hideProtocols = false ;
5257 @Input ( ) protocols = [
5358 { id : 1 , name : 'TCP' } ,
54- { id : 2 , name : 'UDP' }
59+ { id : 2 , name : 'TCP/TLS' } ,
60+ { id : 3 , name : 'UDP' }
5561 ] ;
5662
5763 actions = [
5864 { id : 1 , name : 'ENABLE' , action : 'enable-integration' } ,
5965 { id : 2 , name : 'DISABLE' , action : 'disable-integration' }
6066 ] ;
6167
62- platforms = [
63- {
64- id : 1 , name : 'WINDOWS (ARM64)' ,
65- command : 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service_arm64.exe" -ArgumentList \'ACTION\', \'AGENTNAME\', \'PORT\' -NoNewWindow -Wait\n' ,
66- shell : 'Windows Powershell terminal as “ADMINISTRATOR”'
67- } ,
68- {
69- id : 2 , name : 'WINDOWS (AMD64)' ,
70- command : 'Start-Process "C:\\Program Files\\UTMStack\\UTMStack Agent\\utmstack_agent_service.exe" -ArgumentList \'ACTION\', \'AGENTNAME\', \'PORT\' -NoNewWindow -Wait\n' ,
71- shell : 'Windows Powershell terminal as “ADMINISTRATOR”'
72- } ,
73- {
74- id : 3 ,
75- name : 'LINUX' , command : 'sudo bash -c "/opt/utmstack-linux-agent/utmstack_agent_service ACTION AGENTNAME PORT"' ,
76- shell : 'Linux bash terminal'
77- }
78- ] ;
79-
80- @Input ( ) agent : string ;
81-
8268 _selectedProtocol : any ;
8369 _selectedPlatform : any ;
8470 _selectedAction : any ;
8571 module = UtmModulesEnum ;
8672
87- constructor ( private modalService : ModalService ) {
88- }
73+ constructor ( private modalService : ModalService ) { }
8974
90- get command ( ) {
91- return this . replaceAll ( this . selectedPlatform . command , {
92- PORT : this . selectedProtocol . name . toLowerCase ( ) ,
93- AGENTNAME : this . agentName ( ) ,
94- ACTION : this . selectedAction . action
95- } ) ;
75+ get commands ( ) {
76+
77+ const protocol = this . selectedProtocol && this . selectedProtocol . name === 'TCP/TLS' ? 'tcp' : this . selectedProtocol . name . toLowerCase ( ) ;
78+
79+ const command = replaceCommandTokens ( this . selectedPlatform . command , {
80+ PROTOCOL : protocol ,
81+ AGENT_NAME : this . agent ,
82+ ACTION : this . selectedAction && this . selectedAction . action || '' ,
83+ TLS : this . selectedProtocol && this . selectedProtocol . name === 'TCP/TLS' ? ' --tls' : ''
84+ } ) ;
85+
86+ if ( this . selectedProtocol && this . selectedProtocol . name === 'TCP/TLS' ) {
87+ const extras = this . selectedPlatform . extraCommands ? this . selectedPlatform . extraCommands : [ ] ;
88+ return [ ...extras , command ] ;
89+ }
90+
91+ return [ command ] ;
9692 }
9793
9894 get selectedPlatform ( ) {
9995 return this . _selectedPlatform ;
10096 }
10197
98+ @Input ( )
10299 set selectedPlatform ( platform ) {
103100 this . _selectedPlatform = platform ;
104101 }
0 commit comments