Skip to content

Commit e7d9a6b

Browse files
author
Rodrigo Chireia
committed
Merge branch 'fix/config_host-to-url' into main
2 parents ce67e59 + a47268c commit e7d9a6b

File tree

6 files changed

+23
-13
lines changed

6 files changed

+23
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.1.0
4+
5+
- support for Grafana provisioning configuration
6+
37
## 1.0.2
48

59
- update plugin's description and bump toolkit version

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "golioth-websocket",
3-
"version": "1.0.2",
4-
"description": "",
3+
"version": "1.1.0",
4+
"description": "A Web Socket Data Source Plugin for Grafana",
55
"scripts": {
66
"start": "yarn watch",
77
"build": "grafana-toolkit plugin:build",
@@ -12,6 +12,11 @@
1212
"sign": "grafana-toolkit plugin:sign"
1313
},
1414
"author": "Golioth",
15+
"contributors": [
16+
{
17+
"name": "@mountainash"
18+
}
19+
],
1520
"license": "Apache-2.0",
1621
"dependencies": {
1722
"@grafana/data": "latest",

pkg/plugin/ws_data_proxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ func (wsdp *wsDataProxy) proxyMessage() {
9595
}
9696
}
9797

98-
// encodeURl is hard coded with some variables like scheme and x-api-key but will be definetly refactored after changes in the config editor
98+
// encodeURL is hard coded with some variables like scheme and x-api-key but will be definetly refactored after changes in the config editor
9999
func (wsdp *wsDataProxy) encodeURL(req *backend.RunStreamRequest) (string, error) {
100100
var reqJsonData map[string]interface{}
101101

102102
if err := json.Unmarshal(req.PluginContext.DataSourceInstanceSettings.JSONData, &reqJsonData); err != nil {
103103
return "", fmt.Errorf("failed to read JSON Data Source Instance Settings: %s", err.Error())
104104
}
105105

106-
host := reqJsonData["host"].(string)
106+
host := req.PluginContext.DataSourceInstanceSettings.URL
107107

108108
wsUrl, err := url.Parse(host)
109109
if err != nil {
110-
return "", fmt.Errorf("failed to parse host string from Config Editor: %s", err.Error())
110+
return "", fmt.Errorf("failed to parse host string from the Plugin's Config Editor: %s", err.Error())
111111
}
112112

113113
wsUrl.Path = path.Join(wsUrl.Path, req.Path)

src/components/ConfigEditor.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ const { FormField } = LegacyForms
1010
type Props = DataSourcePluginOptionsEditorProps<DataSourceOptions>
1111

1212
export const ConfigEditor: FC<Props> = ({ options, onOptionsChange }) => {
13-
const { jsonData } = options
13+
const { url, jsonData } = options
14+
1415
const onHostChange = (event: ChangeEvent<HTMLInputElement>) => {
15-
const jsonData = {
16-
...options.jsonData,
17-
host: event.target.value,
16+
const newOptions = {
17+
...options,
18+
url: event.target.value,
1819
}
19-
onOptionsChange({ ...options, jsonData })
20+
onOptionsChange({ ...newOptions, jsonData })
2021
}
2122

2223
return (
@@ -29,7 +30,7 @@ export const ConfigEditor: FC<Props> = ({ options, onOptionsChange }) => {
2930
labelWidth={10}
3031
inputWidth={30}
3132
onChange={onHostChange}
32-
value={jsonData.host || ''}
33+
value={url || ''}
3334
placeholder='wss://api.domain.io/v1/ws/'
3435
/>
3536
</div>

src/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"path": "img/assets/grafana-websockets-plugin-streaming.png"
4343
}
4444
],
45-
"version": "1.0.2",
45+
"version": "1.1.0",
4646
"updated": "%TODAY%"
4747
},
4848
"dependencies": {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const defaultQuery: Partial<Query> = {
2424
}
2525

2626
export interface DataSourceOptions extends DataSourceJsonData {
27-
host?: string
27+
url?: string
2828
}
2929

3030
export interface SecureJsonData {

0 commit comments

Comments
 (0)