150150 <img
151151 v-if =" option.autoDetect === 'externalIp'"
152152 class =" buttonOn"
153- :class =" { 'animate-spin pointer-events-none': option.detecting }"
153+ :class =" { 'animate-pulse animate-duration-1000 pointer-events-none': option.detecting }"
154154 src =" /img/icon/service-setting-icons/external-ip-update.png"
155155 :title =" option.detecting ? 'detecting...' : 'detect the external IP of this node'"
156156 alt =" detect"
@@ -316,6 +316,7 @@ import { mapState, mapWritableState } from "pinia";
316316import { useNodeStore } from " @/store/theNode" ;
317317import { useRestartService } from " @/composables/services" ;
318318import { useSetups } from " @/store/setups" ;
319+ import { addCommandEntry , setEnvFlag } from " @/share/serviceYaml" ;
319320
320321export default {
321322 props: {
@@ -420,9 +421,10 @@ export default {
420421 this .item .expertOptions = this .item .expertOptions .map ((option ) => {
421422 switch (option .type ) {
422423 case " select" : {
423- option .changeValue = this .item .yaml .match (new RegExp (option .pattern [0 ]))
424- ? [... this .item .yaml .match (new RegExp (option .pattern [0 ]))][2 ]
425- : " " ;
424+ const match = this .item .yaml .match (new RegExp (option .pattern [0 ]));
425+ // a dropdown can offer another unit than the configuration stores:
426+ // Lodestar's heap is set in MB and offered in GB, see unitFactor
427+ option .changeValue = match ? (option .unitFactor ? Number (match[2 ]) / option .unitFactor : match[2 ]) : " " ;
426428 break ;
427429 }
428430 case " text" : {
@@ -476,30 +478,10 @@ export default {
476478 this .somethingIsChanged (option);
477479 } else if (this .item .service === " NethermindService" ) {
478480 if (! this .item .yaml .includes (" Pruning.AvailableSpaceCheckEnabled=" )) {
479- const matchAllCommands = this .item .yaml .match (new RegExp (/ --[\S ] + / gm ));
480- const lastCommand = matchAllCommands[matchAllCommands .length - 1 ];
481- const matchSpaces = this .item .yaml .match (new RegExp (` (\\ s*- )${ lastCommand} ` ));
482- let spaces = " " ;
483- if (matchSpaces) {
484- spaces = matchSpaces[1 ];
485- }
486- this .item .yaml = this .item .yaml .replace (
487- new RegExp (` ${ lastCommand} ` ),
488- lastCommand + spaces + " --Pruning.AvailableSpaceCheckEnabled=true"
489- );
481+ this .item .yaml = addCommandEntry (this .item .yaml , " --Pruning.AvailableSpaceCheckEnabled=true" ) ?? this .item .yaml ;
490482 }
491483 if (! this .item .yaml .includes (" Pruning.FullPruningDisableLowPriorityWrites=" )) {
492- const matchAllCommands = this .item .yaml .match (new RegExp (/ --[\S ] + / gm ));
493- const lastCommand = matchAllCommands[matchAllCommands .length - 1 ];
494- const matchSpaces = this .item .yaml .match (new RegExp (` (\\ s*- )${ lastCommand} ` ));
495- let spaces = " " ;
496- if (matchSpaces) {
497- spaces = matchSpaces[1 ];
498- }
499- this .item .yaml = this .item .yaml .replace (
500- new RegExp (` ${ lastCommand} ` ),
501- lastCommand + spaces + " --Pruning.FullPruningDisableLowPriorityWrites=false"
502- );
484+ this .item .yaml = addCommandEntry (this .item .yaml , " --Pruning.FullPruningDisableLowPriorityWrites=false" ) ?? this .item .yaml ;
503485 }
504486 } else {
505487 option .changeValue = false ;
@@ -523,9 +505,17 @@ export default {
523505 if (option .changed ) {
524506 switch (option .type ) {
525507 case " select" : {
508+ const value = option .unitFactor ? option .changeValue * option .unitFactor : option .changeValue ;
526509 option .commands .forEach ((command ) => {
527- if (option .changeValue && this .item .yaml .includes (command)) {
528- this .item .yaml = this .item .yaml .replace (new RegExp (option .pattern [0 ]), ` $1${ option .changeValue } $3` );
510+ if (! option .changeValue ) return ;
511+ if (new RegExp (option .pattern [0 ]).test (this .item .yaml )) {
512+ this .item .yaml = this .item .yaml .replace (new RegExp (option .pattern [0 ]), ` $1${ value} $3` );
513+ } else if (option .isENV && option .envName ) {
514+ // a service that does not carry the setting yet, such as a
515+ // Lodestar validator with an empty env block
516+ const withFlag = setEnvFlag (this .item .yaml , option .envName , ` ${ command}${ value} ` );
517+ if (withFlag) this .item .yaml = withFlag;
518+ else console .error (` No env block in the configuration to add ${ option .envName } to` );
529519 }
530520 });
531521 break ;
@@ -543,14 +533,7 @@ export default {
543533 }
544534 }
545535 } else if (option .changeValue == true && ! this .item .yaml .includes (command)) {
546- const matchAllCommands = this .item .yaml .match (new RegExp (/ --[\S ] + / gm ));
547- const lastCommand = matchAllCommands[matchAllCommands .length - 1 ];
548- const matchSpaces = this .item .yaml .match (new RegExp (` (\\ s*- )${ lastCommand} ` ));
549- let spaces = " " ;
550- if (matchSpaces) {
551- spaces = matchSpaces[1 ];
552- }
553- this .item .yaml = this .item .yaml .replace (new RegExp (` ${ lastCommand} ` ), lastCommand + spaces + command);
536+ this .item .yaml = addCommandEntry (this .item .yaml , command) ?? this .item .yaml ;
554537 }
555538 });
556539 break ;
@@ -621,19 +604,13 @@ export default {
621604 console .error (` No env block in the configuration to add ${ command} to` );
622605 }
623606 } else if (option .changeValue && ! this .item .yaml .includes (command)) {
624- let matchAllCommands = this .item .yaml .match (new RegExp (/ --[\S ] + / gm ));
625- if (matchAllCommands) {
626- const lastCommand = matchAllCommands[matchAllCommands .length - 1 ];
627- const matchSpaces = this .item .yaml .match (new RegExp (` (\\ s*- )${ lastCommand} ` ));
628- let spaces = " " ;
629- if (matchSpaces) {
630- spaces = matchSpaces[1 ];
631- }
632-
633- this .item .yaml = this .item .yaml .replace (
634- new RegExp (` ${ lastCommand} ` ),
635- ` ${ lastCommand}${ spaces}${ command}${ option .noEqualSign ? " " : " =" }${ valuePrefix}${ option .changeValue } `
636- );
607+ // a flag belongs in the command list, and only that list is
608+ // searched for where to put it: an env var can hold flags of
609+ // its own, and Lodestar's NODE_OPTIONS used to catch these
610+ const entry = ` ${ command}${ option .noEqualSign ? " " : " =" }${ valuePrefix}${ option .changeValue } ` ;
611+ const withEntry = addCommandEntry (this .item .yaml , entry);
612+ if (withEntry) {
613+ this .item .yaml = withEntry;
637614 } else {
638615 const matchENV = this .item .yaml .match (/ env:([\s ] + )/ );
639616 this .item .yaml = this .item .yaml .replace (
@@ -1237,6 +1214,7 @@ input:checked + .slider:before {
12371214 height: 20px ;
12381215 cursor: pointer;
12391216 justify- self : end;
1217+ align- self : center;
12401218 margin- right: 10px ;
12411219}
12421220.toggleTextBox .buttonOff {
@@ -1245,6 +1223,7 @@ input:checked + .slider:before {
12451223 width: 20px ;
12461224 height: 20px ;
12471225 justify- self : end;
1226+ align- self : center;
12481227 margin- right: 10px ;
12491228 cursor: pointer;
12501229}
0 commit comments