Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu committed Feb 16, 2024
1 parent 46076df commit 2c112c2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 58 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.3
require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/davecgh/go-spew v1.1.1
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240214042209-d791fc906236
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240216223058-4ae1f0c8c645
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.8.4
golang.org/x/oauth2 v0.16.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ github.com/grafana/grafana-google-sdk-go v0.2.1 h1:XeFdKnkXBjOJjXc1gf4iMx4h5aCHT
github.com/grafana/grafana-google-sdk-go v0.2.1/go.mod h1:RiITSHwBhqVTTd3se3HQq5Ncs/wzzhTB9OK5N0J0PEU=
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240214042209-d791fc906236 h1:jdxnjX5T2W25kMrNXwAD4WQjLYqha6Isojb5aeehoEw=
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240214042209-d791fc906236/go.mod h1:udcOq6XFvGNKu427UuCSGOO1bMT+JPSa1Cz4YE2xB0o=
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240216223058-4ae1f0c8c645 h1:A0RzKzzeSZWl9pCIfQkRBvm0qVr14aEmSSrVfqmVs4c=
github.com/grafana/grafana-plugin-sdk-go v0.211.1-0.20240216223058-4ae1f0c8c645/go.mod h1:udcOq6XFvGNKu427UuCSGOO1bMT+JPSa1Cz4YE2xB0o=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
Expand Down
37 changes: 0 additions & 37 deletions pkg/models/query_test.go

This file was deleted.

37 changes: 37 additions & 0 deletions pkg/models/schema_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package models

import (
"reflect"
"testing"

"github.com/grafana/grafana-plugin-sdk-go/experimental/schema"
"github.com/stretchr/testify/require"
)

func TestSchemaDefinitions(t *testing.T) {
builder, err := schema.NewSchemaBuilder(
schema.BuilderOptions{
BasePackage: "github.com/grafana/google-sheets-datasource/pkg/models",
CodePath: "./",
},
)
require.NoError(t, err)
err = builder.AddQueries(schema.QueryTypeInfo{
Name: "default",
GoType: reflect.TypeOf(&QueryModel{}),
Examples: []schema.QueryExample{
{
Name: "public query",
QueryPayload: QueryModel{
Spreadsheet: "YourSheetID",
Range: "A1:D6",
},
},
},
})

require.NoError(t, err)

// Update the query schemas resource
builder.UpdateQueryDefinition(t, "../../src/static/schema/query.schema.json")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,49 @@
"kind": "QueryTypeDefinitionList",
"apiVersion": "query.grafana.app/v0alpha1",
"metadata": {
"resourceVersion": "1707880401234"
"resourceVersion": "1708122817819"
},
"items": [
{
"metadata": {
"name": "default",
"resourceVersion": "1707880401234",
"creationTimestamp": "2024-02-14T03:13:21Z"
"resourceVersion": "1708122817819",
"creationTimestamp": "2024-02-16T22:33:37Z"
},
"spec": {
"schema": {
"additionalProperties": false,
"description": "QueryModel represents a spreadsheet query.",
"querySchema": {
"$schema": "https://json-schema.org/draft-04/schema",
"properties": {
"cacheDurationSeconds": {
"description": "Cache duration in seconds",
"type": "integer"
"spreadsheet": {
"type": "string",
"description": "The google sheets spreadsheet ID"
},
"range": {
"description": "A1 notation",
"type": "string"
"type": "string",
"description": "A1 notation"
},
"spreadsheet": {
"description": "The google sheets spreadsheet ID",
"type": "string"
"cacheDurationSeconds": {
"type": "integer",
"description": "Cache duration in seconds"
},
"useTimeFilter": {
"description": "Use the query time range to filer values from the table",
"type": "boolean"
"type": "boolean",
"description": "Use the query time range to filer values from the table"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"spreadsheet"
],
"type": "object"
"description": "QueryModel represents a spreadsheet query."
},
"examples": [
{
"name": "public query",
"query": {
"range": "A1:D6",
"spreadsheet": "YourSheetID"
"queryPayload": {
"spreadsheet": "YourSheetID",
"range": "A1:D6"
}
}
]
Expand Down

0 comments on commit 2c112c2

Please sign in to comment.