feat: add createInitActionButton function to ButtonFactory

This commit is contained in:
Ivan K
2025-03-13 10:35:48 +03:00
parent 884bbfee42
commit c79016e456
2 changed files with 11 additions and 19 deletions

View File

@@ -614,6 +614,16 @@ const ButtonFactory = {
});
},
createInitActionButton: function (config) {
return this.createButton({
label: config.label,
additionalClass: `cbi-button-${config.type || ''}`,
onClick: () => safeExec('/etc/init.d/podkop', [config.action])
.then(() => config.reload && location.reload()),
style: config.style
});
},
createModalButton: function (config) {
return this.createButton({
label: config.label,
@@ -668,7 +678,7 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s
action: 'restart',
reload: true
}),
ButtonFactory.createActionButton({
ButtonFactory.createInitActionButton({
label: podkopStatus.enabled ? 'Disable Podkop' : 'Enable Podkop',
type: podkopStatus.enabled ? 'remove' : 'apply',
action: podkopStatus.enabled ? 'disable' : 'enable',

View File

@@ -1965,18 +1965,6 @@ sing_box_add_secure_dns_probe_domain() {
log "DNS probe domain ${domain} configured with override to port ${override_port}"
}
enable() {
log "Enabling podkop service"
/etc/init.d/podkop enable
log "Podkop service enabled"
}
disable() {
log "Disabling podkop service"
/etc/init.d/podkop disable
log "Podkop service disabled"
}
case "$1" in
start)
start
@@ -1988,12 +1976,6 @@ case "$1" in
stop
start
;;
enable)
enable
;;
disable)
disable
;;
main)
main
;;