Skip to content

Commit 9946c43

Browse files
committed
small fix: UI now disable endpoint controls correct when endpoint configured on the server (in config.json)
1 parent 2ef77aa commit 9946c43

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

cmd/sql-to-logsql/api/server_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,8 @@ func TestHandleDescribeWithoutEndpoint(t *testing.T) {
367367
rr := httptest.NewRecorder()
368368
srv.ServeHTTP(rr, req)
369369

370-
if rr.Code != http.StatusBadRequest {
371-
t.Fatalf("expected status 400, got %d", rr.Code)
372-
}
373-
if !strings.Contains(rr.Body.String(), "endpoint is required for this statement") {
374-
t.Fatalf("unexpected error message: %s", rr.Body.String())
370+
if rr.Code != http.StatusOK {
371+
t.Fatalf("expected status 200, got %d", rr.Code)
375372
}
376373
}
377374

cmd/sql-to-logsql/web/ui/src/components/logs-endpoint/LogsEndpoint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function LogsEndpoint({
3434
<CardHeader>
3535
<CardTitle>VictoriaLogs endpoint</CardTitle>
3636
{!endpointReadOnly && <CardDescription>You can query data from VictoriaLogs instance or just translate SQl to LogsQL without querying</CardDescription>}
37-
<CardAction className={"flex flex-row gap-2"}>
37+
{!endpointReadOnly && <CardAction className={"flex flex-row gap-2"}>
3838
<Switch
3939
checked={endpointEnabled}
4040
id={"endpointEnabled"}
@@ -46,7 +46,7 @@ export function LogsEndpoint({
4646
<Label htmlFor={"endpointEnabled"} className={"cursor-pointer"}>
4747
Query data from VictoriaLogs
4848
</Label>
49-
</CardAction>
49+
</CardAction>}
5050
</CardHeader>
5151
<CardContent className={"flex flex-row gap-2"}>
5252
<div className={"flex flex-col gap-1 w-3/4"}>

cmd/sql-to-logsql/web/ui/src/components/query-results/QueryResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function QueryResults({ query, data, isLoading, endpointEnabled }: QueryR
3737
</CardDescription>
3838
}
3939
</CardHeader>
40-
{endpointEnabled &&
40+
{!!data &&
4141
<CardContent>
4242
<QueryResultsTable data={data} />
4343
</CardContent>

lib/vlogs/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ func (a *API) Execute(ctx context.Context, si *logsql.StatementInfo, customEC En
4646
}
4747
switch si.Kind {
4848
case logsql.StatementTypeSelect:
49+
if a.ec.Endpoint == "" && customEC.Endpoint == "" {
50+
return nil, nil
51+
}
4952
return a.Query(ctx, si.LogsQL, recEC)
5053
case logsql.StatementTypeDescribe:
54+
if a.ec.Endpoint == "" && customEC.Endpoint == "" {
55+
return nil, nil
56+
}
5157
return a.GetFieldNames(ctx, si.LogsQL, recEC)
5258
case logsql.StatementTypeCreateView, logsql.StatementTypeDropView:
5359
return []byte(si.Data), nil

0 commit comments

Comments
 (0)