-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
module.ts
197 lines (196 loc) · 5.08 KB
/
module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { PanelPlugin, SelectableValue } from '@grafana/data';
import { ButtonPanelOptions } from './types';
import { ButtonPanel } from './ButtonPanel';
import { ButtonParamsEditor } from './ButtonParamsEditor';
import 'static/button-panel.css';
import { getAvailableIcons } from '@grafana/ui';
export const plugin = new PanelPlugin<ButtonPanelOptions>(ButtonPanel).setPanelOptions(builder => {
return builder
.addRadio({
path: 'method',
name: 'Method',
category: ['REST Integration'],
description: 'HTTP method used to communicate with the remote site',
settings: {
options: [
{
value: 'GET',
label: 'GET',
},
{
value: 'POST',
label: 'POST',
},
],
},
defaultValue: 'GET',
})
.addTextInput({
path: 'url',
name: 'URL',
category: ['REST Integration'],
description: 'The URL to call',
defaultValue: 'http://api.example.com/',
})
.addRadio({
path: 'type',
name: 'Type',
category: ['REST Integration'],
description: 'Defines how the parameters are sent to the server',
settings: {
options: [
{
value: 'header',
label: 'Header',
description: 'Send the parameters as request HTTP headers',
},
{
value: 'query',
label: 'Query',
description: 'Send the parameters as `key=value` query parameter',
},
],
},
defaultValue: 'header',
})
.addCustomEditor({
id: 'buttonParams',
path: 'params',
name: 'Parameters',
category: ['REST Integration'],
description: 'The parameters sent with the request',
editor: ButtonParamsEditor,
})
.addTextInput({
path: 'contentType',
name: 'Content-Type',
category: ['REST Integration'],
description: 'Content-Type of the payload',
defaultValue: 'application/json',
showIf: config => config.method === 'POST',
})
.addTextInput({
path: 'payload',
name: 'Payload',
category: ['REST Integration'],
description: 'Optional payload to send with the request',
settings: {
useTextarea: true,
rows: 5,
},
showIf: config => config.method === 'POST',
})
.addSelect({
path: 'variant',
name: 'Variant',
description: 'Button variant used to render',
settings: {
options: [
{
value: 'primary',
label: 'Primary',
},
{
value: 'secondary',
label: 'Secondary',
},
{
value: 'destructive',
label: 'Destructive',
},
{
value: 'link',
label: 'Link',
},
{
value: undefined,
label: 'Custom',
},
],
},
defaultValue: 'primary',
})
.addColorPicker({
path: 'foregroundColor',
name: 'Fackground Color',
description: 'Foreground color of the button',
settings: {
disableNamedColors: true,
},
showIf: config => config.variant === undefined,
})
.addColorPicker({
path: 'backgroundColor',
name: 'Background Color',
description: 'Background color of the button',
settings: {
disableNamedColors: true,
},
showIf: config => config.variant === undefined,
})
.addRadio({
path: 'orientation',
name: 'Orientation',
description: 'Button orientation used to render',
settings: {
options: [
{
value: 'left',
label: 'Left',
},
{
value: 'center',
label: 'Center',
},
{
value: 'right',
label: 'Right',
},
],
},
defaultValue: 'center',
})
.addSelect({
path: 'icon',
name: 'Icon',
description: '',
settings: {
options: getAvailableIcons().map(
(icon): SelectableValue => {
return {
value: icon,
label: icon,
};
}
),
},
defaultValue: 'cog',
})
.addTextInput({
path: 'text',
name: 'Text',
description: 'The description of the button',
defaultValue: 'The default button label',
})
.addBooleanSwitch({
path: 'isAuth',
name: 'Authentication',
category: ['Authentication'],
description: 'Should basic authentication be used?',
defaultValue: false,
})
.addTextInput({
path: 'username',
name: 'Username',
category: ['Authentication'],
description: 'ℹ️ The server MUST provide proper CORS Access-Control-Allow-* headers!',
showIf: config => config.isAuth,
})
.addTextInput({
path: 'password',
name: 'Password',
category: ['Authentication'],
description: '⚠️ The password is NOT stored encrypted in Grafana!',
showIf: config => config.isAuth,
});
});