fix: add provider.State to log providers

This commit is contained in:
Yang Luo
2026-04-08 09:52:45 +08:00
parent 0e5f810f2f
commit 85c91c50d3
5 changed files with 67 additions and 39 deletions

View File

@@ -39,6 +39,9 @@ func InitLogProviders() {
if p.Category != "Log" {
continue
}
if p.State == "Disabled" {
continue
}
switch p.Type {
case "System Log", "SELinux Log":
startLogCollector(p)
@@ -132,6 +135,9 @@ func refreshLogProviderRuntime(oldID string, provider *Provider) {
if provider.Category != "Log" {
return
}
if provider.State == "Disabled" {
return
}
switch provider.Type {
case "System Log", "SELinux Log":
@@ -157,7 +163,7 @@ func stopLogProviderRuntime(providerID string) {
// Returns nil if no matching provider is registered.
func GetOpenClawProviderByIP(clientIP string) (*log.OpenClawProvider, error) {
providers := []*Provider{}
err := ormer.Engine.Where("category = ? AND type = ? AND sub_type = ?", "Log", "Agent", "OpenClaw").Find(&providers)
err := ormer.Engine.Where("category = ? AND type = ? AND sub_type = ? AND (state = ? OR state = ?)", "Log", "Agent", "OpenClaw", "Enabled", "").Find(&providers)
if err != nil {
return nil, err
}

View File

@@ -81,6 +81,8 @@ type Provider struct {
ProviderUrl string `xorm:"varchar(200)" json:"providerUrl"`
EnableProxy bool `json:"enableProxy"`
EnablePkce bool `json:"enablePkce"`
State string `xorm:"varchar(100)" json:"state"`
}
func GetMaskedProvider(provider *Provider, isMaskEnabled bool) *Provider {

View File

@@ -347,6 +347,9 @@ func writePermissionLog(objOwner, subOwner, subName, method, urlPath string, all
if provider.Type == "System Log" {
continue
}
if provider.State == "Disabled" {
continue
}
logProvider, err := object.GetLogProviderFromProvider(provider)
if err != nil {
continue

View File

@@ -770,6 +770,7 @@ class ProviderEditPage extends React.Component {
this.updateProviderField("host", "");
this.updateProviderField("port", 0);
this.updateProviderField("title", "");
this.updateProviderField("state", "Enabled");
}
if (defaultType) {
if (this.state.nameNotUserEdited) {

View File

@@ -13,46 +13,62 @@
// limitations under the License.
import React from "react";
import {Col, Input, Row} from "antd";
import {Col, Input, Row, Select} from "antd";
import * as Setting from "../Setting";
import i18next from "i18next";
const {Option} = Select;
export function renderLogProviderFields(provider, updateProviderField) {
if (provider.type === "Agent" && provider.subType === "OpenClaw") {
return (
<React.Fragment>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("provider:Host"), i18next.t("provider:Host - Tooltip"))} :
</Col>
<Col span={22} >
<Input value={provider.host} onChange={e => {
updateProviderField("host", e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("provider:Agent ID"), i18next.t("provider:Agent ID - Tooltip"))} :
</Col>
<Col span={22} >
<Input value={provider.title} onChange={e => {
updateProviderField("title", e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{i18next.t("general:Path")} :
</Col>
<Col span={22} >
<Input value={provider.endpoint} onChange={e => {
updateProviderField("endpoint", e.target.value);
}} />
</Col>
</Row>
</React.Fragment>
);
}
return null;
return (
<React.Fragment>
{provider.type === "Agent" && provider.subType === "OpenClaw" ? (
<React.Fragment>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("provider:Host"), i18next.t("provider:Host - Tooltip"))} :
</Col>
<Col span={22} >
<Input value={provider.host} onChange={e => {
updateProviderField("host", e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("provider:Agent ID"), i18next.t("provider:Agent ID - Tooltip"))} :
</Col>
<Col span={22} >
<Input value={provider.title} onChange={e => {
updateProviderField("title", e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{i18next.t("general:Path")} :
</Col>
<Col span={22} >
<Input value={provider.endpoint} onChange={e => {
updateProviderField("endpoint", e.target.value);
}} />
</Col>
</Row>
</React.Fragment>
) : null}
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("general:State"), i18next.t("general:State - Tooltip"))} :
</Col>
<Col span={22} >
<Select virtual={false} style={{width: "100%"}} value={provider.state || "Enabled"} onChange={value => {
updateProviderField("state", value);
}}>
<Option value="Enabled">{i18next.t("general:Enabled")}</Option>
<Option value="Disabled">{i18next.t("general:Disabled")}</Option>
</Select>
</Col>
</Row>
</React.Fragment>
);
}