@gdacm/grafana-items 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +81 -0
- package/dist/index.js +1168 -0
- package/dist/index.js.map +1 -0
- package/dist/items/Annotation.d.ts +17 -0
- package/dist/items/Annotations.d.ts +12 -0
- package/dist/items/BarChart.d.ts +15 -0
- package/dist/items/Color.d.ts +8 -0
- package/dist/items/Dashboard.d.ts +46 -0
- package/dist/items/DataTransformation.d.ts +8 -0
- package/dist/items/Datasource.d.ts +9 -0
- package/dist/items/DatasourceInfinity.d.ts +8 -0
- package/dist/items/FieldConfig.d.ts +17 -0
- package/dist/items/FieldConfigCustom.d.ts +8 -0
- package/dist/items/FieldConfigCustomBarChart.d.ts +31 -0
- package/dist/items/FieldConfigCustomGauge.d.ts +8 -0
- package/dist/items/FieldConfigCustomGeomap.d.ts +10 -0
- package/dist/items/FieldConfigCustomStat.d.ts +8 -0
- package/dist/items/FieldConfigCustomTable.d.ts +16 -0
- package/dist/items/FieldConfigCustomTableCellOptions.d.ts +8 -0
- package/dist/items/FieldConfigCustomTableFooter.d.ts +12 -0
- package/dist/items/FieldConfigCustomText.d.ts +8 -0
- package/dist/items/FieldConfigCustomTimeSerie.d.ts +54 -0
- package/dist/items/FieldConfigDefault.d.ts +31 -0
- package/dist/items/FieldConfigOverride.d.ts +18 -0
- package/dist/items/Gauge.d.ts +14 -0
- package/dist/items/Geomap.d.ts +14 -0
- package/dist/items/GrafanaItem.d.ts +18 -0
- package/dist/items/GridPos.d.ts +12 -0
- package/dist/items/HideFrom.d.ts +10 -0
- package/dist/items/Influxdb.d.ts +8 -0
- package/dist/items/LineStyle.d.ts +8 -0
- package/dist/items/Link.d.ts +22 -0
- package/dist/items/Mapping.d.ts +8 -0
- package/dist/items/OverrideMatcher.d.ts +11 -0
- package/dist/items/OverrideMatcherOptionsByNames.d.ts +15 -0
- package/dist/items/OverrideProperty.d.ts +9 -0
- package/dist/items/Panel.d.ts +57 -0
- package/dist/items/PanelOptions.d.ts +8 -0
- package/dist/items/PanelOptionsBarChart.d.ts +30 -0
- package/dist/items/PanelOptionsGauge.d.ts +30 -0
- package/dist/items/PanelOptionsGaugeEffect.d.ts +10 -0
- package/dist/items/PanelOptionsGaugeReduceOptions.d.ts +15 -0
- package/dist/items/PanelOptionsGeomap.d.ts +32 -0
- package/dist/items/PanelOptionsGeomapBasemap.d.ts +14 -0
- package/dist/items/PanelOptionsGeomapControls.d.ts +13 -0
- package/dist/items/PanelOptionsGeomapLayer.d.ts +19 -0
- package/dist/items/PanelOptionsGeomapLayerConfig.d.ts +12 -0
- package/dist/items/PanelOptionsGeomapLayerConfigStyle.d.ts +31 -0
- package/dist/items/PanelOptionsGeomapLayerLocation.d.ts +8 -0
- package/dist/items/PanelOptionsGeomapTooltip.d.ts +8 -0
- package/dist/items/PanelOptionsGeomapView.d.ts +14 -0
- package/dist/items/PanelOptionsStat.d.ts +8 -0
- package/dist/items/PanelOptionsTable.d.ts +14 -0
- package/dist/items/PanelOptionsTableSortBy.d.ts +9 -0
- package/dist/items/PanelOptionsText.d.ts +12 -0
- package/dist/items/PanelOptionsTextCode.d.ts +10 -0
- package/dist/items/PanelOptionsTimeSeries.d.ts +16 -0
- package/dist/items/ScaleDistribution.d.ts +8 -0
- package/dist/items/Stacking.d.ts +9 -0
- package/dist/items/Stat.d.ts +14 -0
- package/dist/items/StyleColor.d.ts +8 -0
- package/dist/items/StyleRotation.d.ts +11 -0
- package/dist/items/StyleSize.d.ts +10 -0
- package/dist/items/StyleSymbol.d.ts +10 -0
- package/dist/items/StyleSymbolAlign.d.ts +9 -0
- package/dist/items/StyleTextConfig.d.ts +12 -0
- package/dist/items/Table.d.ts +14 -0
- package/dist/items/Target.d.ts +17 -0
- package/dist/items/TargetInfinity.d.ts +20 -0
- package/dist/items/Template.d.ts +29 -0
- package/dist/items/TemplateCurrent.d.ts +9 -0
- package/dist/items/TemplateOption.d.ts +10 -0
- package/dist/items/Templating.d.ts +12 -0
- package/dist/items/Testdata.d.ts +8 -0
- package/dist/items/TextPanel.d.ts +14 -0
- package/dist/items/ThresholdStyle.d.ts +8 -0
- package/dist/items/Thresholds.d.ts +14 -0
- package/dist/items/ThresholdsStep.d.ts +9 -0
- package/dist/items/TimePicker.d.ts +12 -0
- package/dist/items/TimeRange.d.ts +10 -0
- package/dist/items/TimeSeries.d.ts +15 -0
- package/dist/items/VizLegendOptions.d.ts +22 -0
- package/dist/items/VizTextDisplayOptions.d.ts +10 -0
- package/dist/items/VizTooltipOptions.d.ts +12 -0
- package/package.json +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1168 @@
|
|
|
1
|
+
//#region src/utils/json.js
|
|
2
|
+
/**
|
|
3
|
+
* Sort the keys of an object for consistent JSON representation.
|
|
4
|
+
* @param {{[key: String]: any}} obj - The object to sort.
|
|
5
|
+
* @returns {{[key: String]: any}} - The object with sorted keys.
|
|
6
|
+
*/
|
|
7
|
+
var sortKeys = (obj) => {
|
|
8
|
+
return Object.fromEntries(Object.keys(obj).sort().map((key) => [key, obj[key]]));
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Convert an object to a JSON representation, sorting keys for consistency.
|
|
12
|
+
* @param {GrafanaItem|{[key: String]: any}|Array<GrafanaItem|{[key: String]: any}|Number|String|Boolean>|Number|String|Boolean|null|undefined} obj - The object to convert to JSON.
|
|
13
|
+
* @returns {Object|null|undefined} - The JSON representation of the object with sorted keys.
|
|
14
|
+
*/
|
|
15
|
+
var asJson = (obj) => {
|
|
16
|
+
if (obj instanceof GrafanaItem) return sortKeys(obj.asJson());
|
|
17
|
+
if (Array.isArray(obj)) return obj.map((item) => asJson(item));
|
|
18
|
+
if (Number.isInteger(obj) || typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || Number.isFinite(obj)) return obj;
|
|
19
|
+
if (obj === null || obj === void 0) return obj;
|
|
20
|
+
return sortKeys(obj);
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/utils/typesDefinition.js
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import("@gdacm/base-types").GenericMetaOptions} GenericMetaOptions
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} MetaClassInfo
|
|
29
|
+
* @property {string[]} methods - The methods defined for the class
|
|
30
|
+
* @property {((instance: GrafanaItem)=>void)[]} onInits - The onInit functions defined for the class
|
|
31
|
+
* @property {string|undefined} parentName - The name of the parent class
|
|
32
|
+
* @property {Function|undefined} parent - The parent class constructor
|
|
33
|
+
* @property {String[]} typeNamesToInclude - The type names to include in the generated type definition
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @type {Map<typeof GrafanaItem, MetaClassInfo>}
|
|
37
|
+
*/
|
|
38
|
+
var types = /* @__PURE__ */ new Map();
|
|
39
|
+
/**
|
|
40
|
+
* @param {typeof GrafanaItem} cls
|
|
41
|
+
*/
|
|
42
|
+
function defineClass(cls) {
|
|
43
|
+
if (!types.has(cls)) {
|
|
44
|
+
/** @type {Function|undefined} */
|
|
45
|
+
let parent = Object.getPrototypeOf(cls);
|
|
46
|
+
if (parent && !parent.name) parent = void 0;
|
|
47
|
+
/** @type {((instance: GrafanaItem)=>void)[]} */
|
|
48
|
+
let onInitsParent = [];
|
|
49
|
+
if (parent && parent.name) onInitsParent = getMetaClassInfo(parent).onInits;
|
|
50
|
+
/** @type {MetaClassInfo} */
|
|
51
|
+
const metaClassInfo = {
|
|
52
|
+
methods: [],
|
|
53
|
+
onInits: [...onInitsParent],
|
|
54
|
+
parentName: parent?.name,
|
|
55
|
+
parent,
|
|
56
|
+
typeNamesToInclude: []
|
|
57
|
+
};
|
|
58
|
+
cls.prototype._onInit = function() {
|
|
59
|
+
for (const onInit of metaClassInfo.onInits) onInit(this);
|
|
60
|
+
};
|
|
61
|
+
types.set(cls, metaClassInfo);
|
|
62
|
+
}
|
|
63
|
+
return new GrafanaItemClassBuilder(cls);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param {typeof GrafanaItem} cls
|
|
68
|
+
* @returns {MetaClassInfo}
|
|
69
|
+
*/
|
|
70
|
+
function getMetaClassInfo(cls) {
|
|
71
|
+
const metaClassInfo = types.get(cls);
|
|
72
|
+
if (metaClassInfo === void 0) throw new Error(`MetaClassInfo not found for class ${cls.name}`);
|
|
73
|
+
return metaClassInfo;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param {typeof GrafanaItem} cls
|
|
77
|
+
* @param {string} name
|
|
78
|
+
*/
|
|
79
|
+
function hasPrototype(cls, name) {
|
|
80
|
+
return cls.prototype[name] !== void 0;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @param {typeof GrafanaItem} cls
|
|
84
|
+
* @param {string} name
|
|
85
|
+
* @param {Function} value
|
|
86
|
+
*/
|
|
87
|
+
function setPrototype(cls, name, value) {
|
|
88
|
+
cls.prototype[name] = value;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @param {typeof GrafanaItem} cls
|
|
92
|
+
* @param {string} name
|
|
93
|
+
* @param {(self: GrafanaItem) => any} getter
|
|
94
|
+
*/
|
|
95
|
+
function setGetter(cls, name, getter) {
|
|
96
|
+
Object.defineProperty(cls.prototype, name, {
|
|
97
|
+
get() {
|
|
98
|
+
return getter(this);
|
|
99
|
+
},
|
|
100
|
+
enumerable: false,
|
|
101
|
+
configurable: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @param {typeof GrafanaItem} cls
|
|
106
|
+
* @param {string} name
|
|
107
|
+
* @param {(instance: GrafanaItem, value: any) => void} setter
|
|
108
|
+
*/
|
|
109
|
+
function setSetter(cls, name, setter) {
|
|
110
|
+
Object.defineProperty(cls.prototype, name, {
|
|
111
|
+
set(value) {
|
|
112
|
+
return setter(this, value);
|
|
113
|
+
},
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @param {typeof GrafanaItem} cls
|
|
120
|
+
* @param {string} name
|
|
121
|
+
* @param {(self: GrafanaItem) => any} getter
|
|
122
|
+
* @param {(instance: GrafanaItem, value: any) => void} setter
|
|
123
|
+
*/
|
|
124
|
+
function setGetterAndSetter(cls, name, getter, setter) {
|
|
125
|
+
Object.defineProperty(cls.prototype, name, {
|
|
126
|
+
get() {
|
|
127
|
+
return getter(this);
|
|
128
|
+
},
|
|
129
|
+
set(value) {
|
|
130
|
+
return setter(this, value);
|
|
131
|
+
},
|
|
132
|
+
enumerable: false,
|
|
133
|
+
configurable: true
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @param {typeof GrafanaItem} cls
|
|
138
|
+
* @param {string} key
|
|
139
|
+
* @param {Function} type
|
|
140
|
+
* @param {Object} [option]
|
|
141
|
+
* @param {string} [option.name]
|
|
142
|
+
* @param {(instance: GrafanaItem) => void} [option.onInit]
|
|
143
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
144
|
+
* @param {String} [option.typeName]
|
|
145
|
+
*/
|
|
146
|
+
function defineValue(cls, key, type, option) {
|
|
147
|
+
const metaClassInfo = getMetaClassInfo(cls);
|
|
148
|
+
const name = option?.name ? option.name : key;
|
|
149
|
+
const caseName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
150
|
+
const typeName = option?.typeName ? option.typeName : type.name;
|
|
151
|
+
if (metaClassInfo.typeNamesToInclude.includes(type.name) === false) {
|
|
152
|
+
if ([
|
|
153
|
+
"String",
|
|
154
|
+
"Number",
|
|
155
|
+
"Boolean",
|
|
156
|
+
"Array",
|
|
157
|
+
"Object"
|
|
158
|
+
].indexOf(type.name) === -1) metaClassInfo.typeNamesToInclude.push(type.name);
|
|
159
|
+
}
|
|
160
|
+
const setName = `set${caseName}`;
|
|
161
|
+
if (!hasPrototype(cls, setName)) {
|
|
162
|
+
setPrototype(
|
|
163
|
+
cls,
|
|
164
|
+
setName,
|
|
165
|
+
/**
|
|
166
|
+
* @this GrafanaItem
|
|
167
|
+
* @template T
|
|
168
|
+
* @param {T} value
|
|
169
|
+
* @returns {GrafanaItem}
|
|
170
|
+
*/
|
|
171
|
+
function(value) {
|
|
172
|
+
return this._setValue(key, value);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
metaClassInfo.methods.push(`${setName}(${name}: ${typeName}): this;`);
|
|
176
|
+
}
|
|
177
|
+
if (option?.onInit) metaClassInfo.onInits.push(option.onInit);
|
|
178
|
+
if (option?.onDefault) metaClassInfo.onInits.push(function(instance) {
|
|
179
|
+
instance._setValue(key, option?.onDefault?.(instance.metaOptions));
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @param {typeof GrafanaItem} cls
|
|
184
|
+
* @param {string} key
|
|
185
|
+
* @param {Function} type
|
|
186
|
+
* @param {Object} [option]
|
|
187
|
+
* @param {string} [option.name]
|
|
188
|
+
* @param {(instance: GrafanaItem) => void} [option.onInit]
|
|
189
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
190
|
+
* @param {Boolean} [option.setNew]
|
|
191
|
+
* @param {String} [option.typeName]
|
|
192
|
+
*/
|
|
193
|
+
function defineObject(cls, key, type, option) {
|
|
194
|
+
const metaClassInfo = getMetaClassInfo(cls);
|
|
195
|
+
const name = option?.name ? option.name : key;
|
|
196
|
+
const setNew = option?.setNew ?? false;
|
|
197
|
+
const caseName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
198
|
+
const typeName = option?.typeName ? option.typeName : type.name;
|
|
199
|
+
if (metaClassInfo.typeNamesToInclude.includes(type.name) === false) {
|
|
200
|
+
if ([
|
|
201
|
+
"String",
|
|
202
|
+
"Number",
|
|
203
|
+
"Boolean",
|
|
204
|
+
"Array",
|
|
205
|
+
"Object"
|
|
206
|
+
].indexOf(type.name) === -1) metaClassInfo.typeNamesToInclude.push(type.name);
|
|
207
|
+
}
|
|
208
|
+
const setName = `set${caseName}`;
|
|
209
|
+
if (hasPrototype(cls, setName) === false) {
|
|
210
|
+
setPrototype(
|
|
211
|
+
cls,
|
|
212
|
+
setName,
|
|
213
|
+
/**
|
|
214
|
+
* @this GrafanaItem
|
|
215
|
+
* @template T
|
|
216
|
+
* @param {T} value
|
|
217
|
+
* @returns {GrafanaItem}
|
|
218
|
+
*/
|
|
219
|
+
function(value) {
|
|
220
|
+
return this._setObject(key, value);
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
metaClassInfo.methods.push(`${setName}(${name}: ${typeName}): this;`);
|
|
224
|
+
}
|
|
225
|
+
const setNewName = `setNew${caseName}`;
|
|
226
|
+
if (hasPrototype(cls, setNewName) === false && setNew) {
|
|
227
|
+
setPrototype(
|
|
228
|
+
cls,
|
|
229
|
+
setNewName,
|
|
230
|
+
/**
|
|
231
|
+
* @this GrafanaItem
|
|
232
|
+
* @template {GrafanaItem} T
|
|
233
|
+
* @param {(item: T) => T} [onNewCreated]
|
|
234
|
+
* @returns {GrafanaItem}
|
|
235
|
+
*/
|
|
236
|
+
function(onNewCreated) {
|
|
237
|
+
if (!onNewCreated) onNewCreated = (item) => item;
|
|
238
|
+
return this._setObject(key, onNewCreated(new type(this.metaOptions)));
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
metaClassInfo.methods.push(`${setNewName}(onNewCreated: ((item: ${typeName}) => ${typeName}) | undefined): this;`);
|
|
242
|
+
}
|
|
243
|
+
setPrototype(
|
|
244
|
+
cls,
|
|
245
|
+
`with${caseName}`,
|
|
246
|
+
/**
|
|
247
|
+
* @this GrafanaItem
|
|
248
|
+
* @template {GrafanaItem} T
|
|
249
|
+
* @param {(item: T) => void} onWith
|
|
250
|
+
* @returns {GrafanaItem}
|
|
251
|
+
*/
|
|
252
|
+
function(onWith) {
|
|
253
|
+
const item = this._getObject(key);
|
|
254
|
+
if (item) onWith(item);
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
metaClassInfo.methods.push(`with${caseName}(onWith: (item: ${typeName}) => void): this;`);
|
|
259
|
+
setGetter(cls, name, (self) => self._getObject(key));
|
|
260
|
+
metaClassInfo.methods.push(`get ${name}(): ${typeName};`);
|
|
261
|
+
if (option?.onInit) metaClassInfo.onInits.push(option?.onInit);
|
|
262
|
+
if (option?.onDefault) {
|
|
263
|
+
/**
|
|
264
|
+
* @param {GrafanaItem} instance
|
|
265
|
+
*/
|
|
266
|
+
const onInit = (instance) => {
|
|
267
|
+
instance._setObject(key, option?.onDefault?.(instance.metaOptions));
|
|
268
|
+
};
|
|
269
|
+
metaClassInfo.onInits.push(onInit);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @param {typeof GrafanaItem} cls
|
|
274
|
+
* @param {string} key
|
|
275
|
+
* @param {Function} type
|
|
276
|
+
* @param {Object} [option]
|
|
277
|
+
* @param {string} [option.name]
|
|
278
|
+
* @param {string} [option.itemName]
|
|
279
|
+
* @param {boolean} [option.setEmpty]
|
|
280
|
+
* @param {(instance: GrafanaItem) => void} [option.onInit]
|
|
281
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
282
|
+
*/
|
|
283
|
+
function defineArray(cls, key, type, option) {
|
|
284
|
+
const metaClassInfo = getMetaClassInfo(cls);
|
|
285
|
+
const name = option?.name ? option.name : key;
|
|
286
|
+
const caseName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
287
|
+
const itemName = option?.itemName ? option.itemName : name.endsWith("s") ? name.slice(0, -1) : `${name}Item`;
|
|
288
|
+
if (metaClassInfo.typeNamesToInclude.includes(type.name) === false) {
|
|
289
|
+
if (type.name !== "String" && type.name !== "Number" && type.name !== "Boolean") metaClassInfo.typeNamesToInclude.push(type.name);
|
|
290
|
+
}
|
|
291
|
+
const caseItemName = itemName.charAt(0).toUpperCase() + itemName.slice(1);
|
|
292
|
+
const initName = `init${caseName}`;
|
|
293
|
+
if (hasPrototype(cls, initName) === false) {
|
|
294
|
+
setPrototype(
|
|
295
|
+
cls,
|
|
296
|
+
initName,
|
|
297
|
+
/**
|
|
298
|
+
* @this GrafanaItem
|
|
299
|
+
* @returns {GrafanaItem}
|
|
300
|
+
*/
|
|
301
|
+
function() {
|
|
302
|
+
return this._initArray(key);
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
metaClassInfo.methods.push(`init${caseName}(): this;`);
|
|
306
|
+
}
|
|
307
|
+
setGetter(cls, name, (self) => self._getArray(key));
|
|
308
|
+
metaClassInfo.methods.push(`get ${name}(): ${type.name}[];`);
|
|
309
|
+
const addName = `add${caseItemName}`;
|
|
310
|
+
if (hasPrototype(cls, addName) === false) {
|
|
311
|
+
setPrototype(
|
|
312
|
+
cls,
|
|
313
|
+
addName,
|
|
314
|
+
/**
|
|
315
|
+
* @this GrafanaItem
|
|
316
|
+
* @template T
|
|
317
|
+
* @param {T} item
|
|
318
|
+
* @returns {GrafanaItem}
|
|
319
|
+
*/
|
|
320
|
+
function(item) {
|
|
321
|
+
return this._addArrayItem(key, item);
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
metaClassInfo.methods.push(`${addName}(${itemName}: ${type.name}): this;`);
|
|
325
|
+
}
|
|
326
|
+
const addNewName = `addNew${caseItemName}`;
|
|
327
|
+
if (hasPrototype(cls, addNewName) === false) {
|
|
328
|
+
setPrototype(
|
|
329
|
+
cls,
|
|
330
|
+
addNewName,
|
|
331
|
+
/**
|
|
332
|
+
* @this GrafanaItem
|
|
333
|
+
* @template T
|
|
334
|
+
* @param {(item: T) => T} onNewCreated
|
|
335
|
+
* @returns {GrafanaItem}
|
|
336
|
+
*/
|
|
337
|
+
function(onNewCreated) {
|
|
338
|
+
return this._addArrayItem(key, onNewCreated(new type(this.metaOptions)));
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
metaClassInfo.methods.push(`${addNewName}(onNewCreated: (item: ${type.name}) => ${type.name}): this;`);
|
|
342
|
+
}
|
|
343
|
+
const withName = `with${caseName}`;
|
|
344
|
+
setPrototype(
|
|
345
|
+
cls,
|
|
346
|
+
withName,
|
|
347
|
+
/**
|
|
348
|
+
* @this GrafanaItem
|
|
349
|
+
* @template T
|
|
350
|
+
* @param {(array: T[]) => void} onWith
|
|
351
|
+
* @returns {GrafanaItem}
|
|
352
|
+
*/
|
|
353
|
+
function(onWith) {
|
|
354
|
+
const array = this._getArray(key);
|
|
355
|
+
if (array) onWith(array);
|
|
356
|
+
return this;
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
metaClassInfo.methods.push(`${withName}(onWith: (${name}: ${type.name}[]) => void): this;`);
|
|
360
|
+
if (option?.onInit) metaClassInfo.onInits.push(option.onInit);
|
|
361
|
+
if (option?.setEmpty) {
|
|
362
|
+
/**
|
|
363
|
+
* @param {GrafanaItem} instance
|
|
364
|
+
*/
|
|
365
|
+
const onInitArray = (instance) => {
|
|
366
|
+
instance._initArray(key);
|
|
367
|
+
};
|
|
368
|
+
metaClassInfo.onInits.push(onInitArray);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* @template {typeof GrafanaItem} T
|
|
373
|
+
* @param {typeof GrafanaItem} cls
|
|
374
|
+
* @param {string|undefined} method
|
|
375
|
+
* @param {Object} [option]
|
|
376
|
+
* @param {(typeof GrafanaItem)[]} [option.typesToInclude]
|
|
377
|
+
* @param {string} [option.name]
|
|
378
|
+
* @param {Function} [option.code]
|
|
379
|
+
* @param {(instance: GrafanaItem) => void} [option.constr]
|
|
380
|
+
* @param {string} [option.getterSetterType]
|
|
381
|
+
* @param {(self: GrafanaItem) => any} [option.getter]
|
|
382
|
+
* @param {(self: GrafanaItem, value: any) => void} [option.setter]
|
|
383
|
+
*/
|
|
384
|
+
function defineMemberInternal(cls, method, option) {
|
|
385
|
+
const { typesToInclude, name, code, constr, getterSetterType, getter, setter } = option || {};
|
|
386
|
+
const metaClassInfo = getMetaClassInfo(cls);
|
|
387
|
+
if (method !== void 0) metaClassInfo.methods.push(method);
|
|
388
|
+
if (typesToInclude !== void 0) {
|
|
389
|
+
for (const type of typesToInclude) if (metaClassInfo.typeNamesToInclude.includes(type.name) === false) metaClassInfo.typeNamesToInclude.push(type.name);
|
|
390
|
+
}
|
|
391
|
+
let codeCount = 0;
|
|
392
|
+
if (code !== void 0) codeCount++;
|
|
393
|
+
if (constr !== void 0) codeCount++;
|
|
394
|
+
if (getter !== void 0 || setter !== void 0) codeCount++;
|
|
395
|
+
if (codeCount > 1) throw new Error(`You can only provide either code or constructor or getter/setter, not all. (codeCount:${codeCount})`);
|
|
396
|
+
if (code !== void 0 && name === void 0) throw new Error("You must provide a name when providing code.");
|
|
397
|
+
if (constr !== void 0 && name !== void 0) throw new Error("You cannot provide a name when providing constructor.");
|
|
398
|
+
if ((getter !== void 0 || setter !== void 0) && name === void 0) throw new Error("You must provide a name when providing getter or setter.");
|
|
399
|
+
if (codeCount == 1) {
|
|
400
|
+
if (code !== void 0) {
|
|
401
|
+
if (!name) throw new Error("You must provide a name when providing code.");
|
|
402
|
+
setPrototype(
|
|
403
|
+
cls,
|
|
404
|
+
name,
|
|
405
|
+
/**
|
|
406
|
+
* @this {GrafanaItem}
|
|
407
|
+
* @param {...any} args
|
|
408
|
+
* @returns {any}
|
|
409
|
+
*/
|
|
410
|
+
function(...args) {
|
|
411
|
+
return code(this, ...args);
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
if (constr !== void 0) metaClassInfo.onInits.push((instance) => constr(instance));
|
|
416
|
+
if (getter !== void 0 && setter === void 0) {
|
|
417
|
+
if (!name) throw new Error("You must provide a name when providing getter or setter.");
|
|
418
|
+
setGetter(cls, name, getter);
|
|
419
|
+
metaClassInfo.methods.push(`get ${name}(): ${getterSetterType};`);
|
|
420
|
+
}
|
|
421
|
+
if (getter === void 0 && setter !== void 0) {
|
|
422
|
+
if (!name) throw new Error("You must provide a name when providing getter or setter.");
|
|
423
|
+
setSetter(cls, name, setter);
|
|
424
|
+
metaClassInfo.methods.push(`set ${name}(value: ${getterSetterType});`);
|
|
425
|
+
}
|
|
426
|
+
if (getter !== void 0 && setter !== void 0) {
|
|
427
|
+
if (!name) throw new Error("You must provide a name when providing getter or setter.");
|
|
428
|
+
setGetterAndSetter(cls, name, getter, setter);
|
|
429
|
+
metaClassInfo.methods.push(`get ${name}(): ${getterSetterType};`);
|
|
430
|
+
metaClassInfo.methods.push(`set ${name}(value: ${getterSetterType});`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @param {typeof GrafanaItem} cls
|
|
436
|
+
* @param {(instance: GrafanaItem) => void} code
|
|
437
|
+
*/
|
|
438
|
+
function defineConstructor(cls, code) {
|
|
439
|
+
defineMemberInternal(cls, "constructor(metaOptions: GenericMetaOptions)", { constr: code });
|
|
440
|
+
}
|
|
441
|
+
var GrafanaItemClassBuilder = class {
|
|
442
|
+
/**
|
|
443
|
+
* @param {typeof GrafanaItem} cls
|
|
444
|
+
*/
|
|
445
|
+
constructor(cls) {
|
|
446
|
+
this.cls = cls;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* @param {typeof GrafanaItem} parent
|
|
450
|
+
* @returns
|
|
451
|
+
*/
|
|
452
|
+
setParent(parent) {
|
|
453
|
+
this.parent = parent;
|
|
454
|
+
return this;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @param {string} key
|
|
458
|
+
* @param {Function} type
|
|
459
|
+
* @param {Object} [option]
|
|
460
|
+
* @param {string} [option.name]
|
|
461
|
+
* @param {(instance: InstanceType<typeof GrafanaItem>) => void} [option.onInit]
|
|
462
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
463
|
+
* @param {String} [option.typeName]
|
|
464
|
+
* @return {this}
|
|
465
|
+
*/
|
|
466
|
+
defineValue(key, type, option) {
|
|
467
|
+
defineValue(this.cls, key, type, option);
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* @param {string} key
|
|
472
|
+
* @param {Function} type
|
|
473
|
+
* @param {Object} [option]
|
|
474
|
+
* @param {string} [option.name]
|
|
475
|
+
* @param {(instance: GrafanaItem) => void} [option.onInit]
|
|
476
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
477
|
+
* @param {Boolean} [option.setNew]
|
|
478
|
+
* @param {String} [option.typeName]
|
|
479
|
+
* @return {this}
|
|
480
|
+
*/
|
|
481
|
+
defineObject(key, type, option) {
|
|
482
|
+
defineObject(this.cls, key, type, option);
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @param {string} key
|
|
487
|
+
* @param {Function} type
|
|
488
|
+
* @param {Object} [option]
|
|
489
|
+
* @param {string} [option.name]
|
|
490
|
+
* @param {string} [option.itemName]
|
|
491
|
+
* @param {boolean} [option.setEmpty]
|
|
492
|
+
* @param {(instance: GrafanaItem) => void} [option.onInit]
|
|
493
|
+
* @param {(metaOptions: GenericMetaOptions) => InstanceType<typeof GrafanaItem>} [option.onDefault]
|
|
494
|
+
* @return {this}
|
|
495
|
+
*/
|
|
496
|
+
defineArray(key, type, option) {
|
|
497
|
+
defineArray(this.cls, key, type, option);
|
|
498
|
+
return this;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* @param {string} method
|
|
502
|
+
* @param {Object} [option]
|
|
503
|
+
* @param {(typeof GrafanaItem)[]} [option.typesToInclude]
|
|
504
|
+
* @return {this}
|
|
505
|
+
*/
|
|
506
|
+
defineMember(method, option) {
|
|
507
|
+
defineMemberInternal(this.cls, method, option);
|
|
508
|
+
return this;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* @template {typeof GrafanaItem} T
|
|
512
|
+
* @param {(instance: InstanceType<T>) => void} code
|
|
513
|
+
* @return {this}
|
|
514
|
+
*/
|
|
515
|
+
defineConstructor(code) {
|
|
516
|
+
defineConstructor(this.cls, code);
|
|
517
|
+
return this;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* @param {string} name
|
|
521
|
+
* @param {string} args
|
|
522
|
+
* @param {Object} option
|
|
523
|
+
* @param {(typeof GrafanaItem)[]} [option.typesToInclude]
|
|
524
|
+
* @param {Function} option.code
|
|
525
|
+
* @return {this}
|
|
526
|
+
*/
|
|
527
|
+
defineMethod(name, args, option) {
|
|
528
|
+
defineMemberInternal(this.cls, `${name}${args}`, {
|
|
529
|
+
...option,
|
|
530
|
+
name
|
|
531
|
+
});
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* @template {typeof GrafanaItem} T
|
|
536
|
+
* @param {string} name
|
|
537
|
+
* @param {string} type
|
|
538
|
+
* @param {Object} option
|
|
539
|
+
* @param {(typeof GrafanaItem)[]} [option.typesToInclude]
|
|
540
|
+
* @param {(instance: InstanceType<T>) => any} [option.getter]
|
|
541
|
+
* @param {(instance: InstanceType<T>, value: any) => void} [option.setter]
|
|
542
|
+
* @return {this}
|
|
543
|
+
*/
|
|
544
|
+
defineGetterSetter(name, type, option) {
|
|
545
|
+
const getter = option.getter;
|
|
546
|
+
const setter = option.setter;
|
|
547
|
+
defineMemberInternal(this.cls, void 0, {
|
|
548
|
+
...option,
|
|
549
|
+
getter,
|
|
550
|
+
setter,
|
|
551
|
+
name,
|
|
552
|
+
getterSetterType: type
|
|
553
|
+
});
|
|
554
|
+
return this;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* @param {(instance: this) => void} code
|
|
558
|
+
*/
|
|
559
|
+
with(code) {
|
|
560
|
+
code(this);
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* @returns {typeof GrafanaItem}
|
|
565
|
+
*/
|
|
566
|
+
get asClass() {
|
|
567
|
+
return this.cls;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* @param {string} name
|
|
572
|
+
* @param {typeof GrafanaItem} parent
|
|
573
|
+
* @returns {GrafanaItemClassBuilder}
|
|
574
|
+
*/
|
|
575
|
+
var defineGrafanaItemClass = (name, parent) => {
|
|
576
|
+
const cls = class extends parent {};
|
|
577
|
+
Object.defineProperty(cls, "name", { value: name });
|
|
578
|
+
return defineClass(cls).setParent(parent);
|
|
579
|
+
};
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/items/GrafanaItem.js
|
|
582
|
+
var GrafanaItem = class {
|
|
583
|
+
/**
|
|
584
|
+
* @param {import("../../../base-types/src/index.js").MetaOptions<import("../../../base-types/src/index.js").GenericOptions>} metaOptions An object with options
|
|
585
|
+
*/
|
|
586
|
+
constructor(metaOptions) {
|
|
587
|
+
this._metaOptions = metaOptions || {};
|
|
588
|
+
this._grafanaValues = {};
|
|
589
|
+
this._grafanaArrays = {};
|
|
590
|
+
this._grafanaObjects = {};
|
|
591
|
+
this._onInit();
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* @returns {Object} The meta options of the Grafana item
|
|
595
|
+
*/
|
|
596
|
+
get metaOptions() {
|
|
597
|
+
return this._metaOptions;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* @param {(metaOptions: Object) => void} code
|
|
601
|
+
* @returns {this}
|
|
602
|
+
*/
|
|
603
|
+
withMetaOptions(code) {
|
|
604
|
+
code(this.metaOptions);
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* @param {(item: this) => void} code
|
|
609
|
+
* @returns {this}
|
|
610
|
+
*/
|
|
611
|
+
with(code) {
|
|
612
|
+
code(this);
|
|
613
|
+
return this;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
*
|
|
617
|
+
* @template T
|
|
618
|
+
* @param {string} key
|
|
619
|
+
* @param {T} value
|
|
620
|
+
* @returns
|
|
621
|
+
*/
|
|
622
|
+
_setValue(key, value) {
|
|
623
|
+
this._grafanaValues[key] = asJson(value);
|
|
624
|
+
return this;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
*
|
|
628
|
+
* @template T
|
|
629
|
+
* @param {string} key
|
|
630
|
+
* @param {T} value
|
|
631
|
+
* @returns
|
|
632
|
+
*/
|
|
633
|
+
_getValue(key) {
|
|
634
|
+
return this._grafanaValues[key];
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* @returns {Object} The JSON representation of the Grafana item
|
|
638
|
+
*/
|
|
639
|
+
asJson() {
|
|
640
|
+
const values = { ...this._grafanaValues };
|
|
641
|
+
for (const key in this._grafanaArrays) values[key] = this._grafanaArrays[key].map((item) => asJson(item));
|
|
642
|
+
for (const key in this._grafanaObjects) values[key] = asJson(this._grafanaObjects[key]);
|
|
643
|
+
return asJson(values);
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* @param {string} key
|
|
647
|
+
*/
|
|
648
|
+
_initArray(key) {
|
|
649
|
+
this._getArray(key);
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* @template T
|
|
654
|
+
* @param {string} key
|
|
655
|
+
* @return {T[]}
|
|
656
|
+
*/
|
|
657
|
+
_getArray(key) {
|
|
658
|
+
if (!this._grafanaArrays[key]) this._grafanaArrays[key] = [];
|
|
659
|
+
return this._grafanaArrays[key];
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* @template T
|
|
663
|
+
* @param {string} key
|
|
664
|
+
* @param {T} item
|
|
665
|
+
* @returns {this}
|
|
666
|
+
*/
|
|
667
|
+
_addArrayItem(key, item) {
|
|
668
|
+
this._getArray(key).push(item);
|
|
669
|
+
return this;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* @template T
|
|
673
|
+
* @param {string} key
|
|
674
|
+
* @param {T} value
|
|
675
|
+
* @returns {this}
|
|
676
|
+
*/
|
|
677
|
+
_setObject(key, value) {
|
|
678
|
+
this._grafanaObjects[key] = value;
|
|
679
|
+
return this;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* @template T
|
|
683
|
+
* @param {string} key
|
|
684
|
+
* @returns {T|undefined}
|
|
685
|
+
*/
|
|
686
|
+
_getObject(key) {
|
|
687
|
+
if (!this._grafanaObjects[key]) this._grafanaObjects[key] = void 0;
|
|
688
|
+
return this._grafanaObjects[key];
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
*
|
|
692
|
+
* @template T
|
|
693
|
+
* @param {string} key
|
|
694
|
+
* @param {(item: T) => void} code
|
|
695
|
+
* @returns {this}
|
|
696
|
+
*/
|
|
697
|
+
_withObject(key, code) {
|
|
698
|
+
const obj = this._getObject(key);
|
|
699
|
+
if (obj) code(obj);
|
|
700
|
+
return this;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
defineClass(GrafanaItem).defineMember("constructor(metaOptions: GenericMetaOptions)").defineMember("get metaOptions(): GenericMetaOptions").defineMember("withMetaOptions(code: (metaOptions: GenericMetaOptions) => void): this").defineMember("with(code: (item: this) => void): this").defineMember("asJson(): Object;").defineMember("_onInit(): void;").defineMember("_setValue<T>(key: string, value: T): this;").defineMember("_getValue<T>(key: string): T;").defineMember("_initArray(key: string): this;").defineMember("_getArray<T>(key: string): T[];").defineMember("_addArrayItem<T>(key: string, item: T): this;").defineMember("_setObject<T>(key: string, value: T): this;").defineMember("_getObject<T>(key: string): T;").defineMember("_withObject<T>(key: string, code: (item: T) => void): this;");
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/items/OverrideMatcher.js
|
|
706
|
+
var OverrideMatcher = defineGrafanaItemClass("OverrideMatcher", GrafanaItem).defineValue("id", String).defineObject("options", Object).asClass;
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/items/OverrideMatcherOptionsByNames.js
|
|
709
|
+
var OverrideMatcherOptionsByNames = defineGrafanaItemClass("OverrideMatcherOptionsByNames", GrafanaItem).defineValue("mode", String).defineArray("names", String).defineValue("prefix", String).defineValue("readOnly", Boolean).asClass;
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/items/OverrideProperty.js
|
|
712
|
+
var OverrideProperty = defineGrafanaItemClass("OverrideProperty", GrafanaItem).defineValue("id", String).defineValue("value", Object).asClass;
|
|
713
|
+
//#endregion
|
|
714
|
+
//#region src/items/Datasource.js
|
|
715
|
+
var Datasource = defineGrafanaItemClass("Datasource", GrafanaItem).defineValue("type", String).defineValue("uid", String).asClass;
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region src/items/Annotation.js
|
|
718
|
+
var Annotation = defineGrafanaItemClass("Annotation", GrafanaItem).defineValue("builtIn", Number).defineObject("datasource", Datasource, { setNew: true }).defineValue("enable", Boolean).defineValue("hide", Boolean).defineValue("iconColor", String).defineValue("name", String).defineValue("type", String).asClass;
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/items/Annotations.js
|
|
721
|
+
var Annotations = defineGrafanaItemClass("Annotations", GrafanaItem).defineArray("list", Annotation, { itemName: "annotation" }).asClass;
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/items/Color.js
|
|
724
|
+
var Color = defineGrafanaItemClass("Color", GrafanaItem).defineValue("mode", String).asClass;
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/items/TimeRange.js
|
|
727
|
+
var TimeRange = defineGrafanaItemClass("TimeRange", GrafanaItem).defineValue("from", String).defineValue("to", String).defineMethod("setRange", "(from: string, to: string): this;", {
|
|
728
|
+
/**
|
|
729
|
+
* @param {TimeRange} timeRange
|
|
730
|
+
* @param {string} from
|
|
731
|
+
* @param {string} to
|
|
732
|
+
* @returns {TimeRange}
|
|
733
|
+
*/
|
|
734
|
+
code: (timeRange, from, to) => {
|
|
735
|
+
timeRange.setFrom(from);
|
|
736
|
+
timeRange.setTo(to);
|
|
737
|
+
return timeRange;
|
|
738
|
+
} }).asClass;
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/items/GridPos.js
|
|
741
|
+
var GridPos = defineGrafanaItemClass("GridPos", GrafanaItem).defineValue("x", Number).defineValue("y", Number).defineValue("w", Number).defineValue("h", Number).defineMethod("setPos", "(x: number, y: number, w: number, h: number): this;", {
|
|
742
|
+
/**
|
|
743
|
+
* @param {GridPos} gridPos
|
|
744
|
+
* @param {number} x
|
|
745
|
+
* @param {number} y
|
|
746
|
+
* @param {number} w
|
|
747
|
+
* @param {number} h
|
|
748
|
+
* @returns {GridPos}
|
|
749
|
+
*/
|
|
750
|
+
code: (gridPos, x, y, w, h) => {
|
|
751
|
+
gridPos.setX(x);
|
|
752
|
+
gridPos.setY(y);
|
|
753
|
+
gridPos.setW(w);
|
|
754
|
+
gridPos.setH(h);
|
|
755
|
+
return gridPos;
|
|
756
|
+
} }).asClass;
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region src/items/FieldConfigCustom.js
|
|
759
|
+
var FieldConfigCustom = defineGrafanaItemClass("FieldConfigCustom", GrafanaItem).asClass;
|
|
760
|
+
//#endregion
|
|
761
|
+
//#region src/items/Mapping.js
|
|
762
|
+
var Mapping = defineGrafanaItemClass("Mapping", GrafanaItem).asClass;
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/items/ThresholdsStep.js
|
|
765
|
+
var ThresholdsStep = defineGrafanaItemClass("ThresholdsStep", GrafanaItem).defineValue("value", Number).defineValue("color", String).asClass;
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/items/Thresholds.js
|
|
768
|
+
var Thresholds = defineGrafanaItemClass("Thresholds", GrafanaItem).defineValue("mode", String).defineArray("steps", ThresholdsStep).defineMethod("addStepWithValueAndColor", "(value: number, color: string): this;", {
|
|
769
|
+
/**
|
|
770
|
+
* @param {Thresholds} thresholds
|
|
771
|
+
* @param {number} value
|
|
772
|
+
* @param {string} color
|
|
773
|
+
* @returns {Thresholds}
|
|
774
|
+
*/
|
|
775
|
+
code: (thresholds, value, color) => {
|
|
776
|
+
const step = new ThresholdsStep(thresholds.metaOptions).setValue(value).setColor(color);
|
|
777
|
+
return thresholds.addStep(step);
|
|
778
|
+
} }).asClass;
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/items/FieldConfigDefault.js
|
|
781
|
+
var FieldConfigDefault = defineGrafanaItemClass("FieldConfigDefault", GrafanaItem).defineObject("color", Color, { setNew: true }).defineObject("custom", FieldConfigCustom, {}).defineValue("decimals", Number).defineValue("fieldMinMax", Boolean).defineArray("mappings", Mapping).defineValue("max", Number).defineValue("min", Number).defineObject("thresholds", Thresholds, { onDefault: (options) => new Thresholds(options).setMode("absolute") }).defineValue("unit", String).defineMethod("setColorMode", "(mode: string): this;", {
|
|
782
|
+
/**
|
|
783
|
+
* @param {FieldConfigDefault} fieldConfigDefault
|
|
784
|
+
* @param {String} mode
|
|
785
|
+
* @returns {FieldConfigDefault}
|
|
786
|
+
*/
|
|
787
|
+
code: (fieldConfigDefault, mode) => {
|
|
788
|
+
if (fieldConfigDefault.color === void 0) fieldConfigDefault.setNewColor();
|
|
789
|
+
fieldConfigDefault.color.setMode(mode);
|
|
790
|
+
return fieldConfigDefault;
|
|
791
|
+
} }).asClass;
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/items/FieldConfigOverride.js
|
|
794
|
+
var FieldConfigOverride = defineGrafanaItemClass("FieldConfigOverride", GrafanaItem).defineValue("__systemRef", String, { name: "systemRef" }).defineObject("matcher", OverrideMatcher, { setNew: true }).defineArray("properties", OverrideProperty, { itemName: "property" }).asClass;
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/items/HideFrom.js
|
|
797
|
+
var HideFrom = defineGrafanaItemClass("HideFrom", GrafanaItem).defineValue("legend", Boolean).defineValue("tooltip", Boolean).defineValue("viz", Boolean).asClass;
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region src/items/FieldConfig.js
|
|
800
|
+
var FieldConfig = defineGrafanaItemClass("FieldConfig", GrafanaItem).defineObject("defaults", FieldConfigDefault, {}).defineArray("overrides", FieldConfigOverride).defineMethod("addNewOverrideHideSeriesFrom", "(names: string[]): this", {
|
|
801
|
+
/**
|
|
802
|
+
* @param {FieldConfig} fieldConfig
|
|
803
|
+
* @param {String[]} names
|
|
804
|
+
* @returns {FieldConfigOverride}
|
|
805
|
+
*/
|
|
806
|
+
code: (fieldConfig, names) => {
|
|
807
|
+
/**
|
|
808
|
+
* @param {OverrideMatcherOptionsByNames} matcher
|
|
809
|
+
* @returns {OverrideMatcherOptionsByNames}
|
|
810
|
+
*/
|
|
811
|
+
const reduceForNames = (matcher) => names.reduce((matcher, name) => matcher.addName(name), matcher);
|
|
812
|
+
return fieldConfig.addNewOverride((override) => override.setSystemRef("hideSeriesFrom").setNewMatcher((overrideMatcher) => overrideMatcher.setId("byNames").setOptions(reduceForNames(new OverrideMatcherOptionsByNames()).setMode("exclude").setPrefix("All except:").setReadOnly(true))).addNewProperty((property) => property.setId("custom.hideFrom").setValue(new HideFrom().setLegend(false).setTooltip(true).setViz(true))));
|
|
813
|
+
} }).asClass;
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/items/Target.js
|
|
816
|
+
var Target = defineGrafanaItemClass("Target", GrafanaItem).defineValue("alias", String).defineValue("refId", String).defineValue("query", String).defineObject("datasource", Datasource, { setNew: true }).defineValue("seriesCount", Number).defineValue("scenarioId", String).defineValue("stringInput", String).asClass;
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/items/Link.js
|
|
819
|
+
var Link = defineGrafanaItemClass("Link", GrafanaItem).defineConstructor((instance) => instance.setType("link")).defineValue("asDropdown", Boolean).defineValue("icon", String).defineValue("includeVars", Boolean).defineValue("keepTime", Boolean).defineArray("tags", String, { setEmpty: true }).defineValue("targetBlank", Boolean).defineValue("title", String).defineValue("tooltip", String).defineValue("type", String).defineValue("url", String).asClass;
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region src/items/DataTransformation.js
|
|
822
|
+
var DataTransformation = defineGrafanaItemClass("DataTransformation", GrafanaItem).asClass;
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/items/Panel.js
|
|
825
|
+
var Panel = defineGrafanaItemClass("Panel", GrafanaItem).defineValue("cacheTimeout", String).defineObject("datasource", Datasource, { onDefault: (options) => void 0 }).defineValue("description", String).defineObject("fieldConfig", FieldConfig, { onDefault: (options) => new FieldConfig(options) }).defineObject("gridPos", GridPos, { setNew: true }).defineMethod("setPos", "(x: number, y: number, w: number, h: number): this;", {
|
|
826
|
+
/**
|
|
827
|
+
* @param {Panel} panel
|
|
828
|
+
* @param {number} x
|
|
829
|
+
* @param {number} y
|
|
830
|
+
* @param {number} w
|
|
831
|
+
* @param {number} h
|
|
832
|
+
*/
|
|
833
|
+
code: (panel, x, y, w, h) => {
|
|
834
|
+
return panel.setNewGridPos((gridPos) => gridPos.setPos(x, y, w, h));
|
|
835
|
+
} }).defineValue("hideTimeOverride", Boolean).defineValue("id", Number).defineValue("interval", String).defineArray("links", Link).defineValue("maxDataPoints", Number).defineValue("maxPerRow", Number).defineObject("options", Object).defineValue("pluginVersion", String).defineValue("queryCachingTTL", Number).defineValue("repeat", String).defineValue("repeatDirection", String).defineArray("targets", Target).defineMethod("addTargetWithParams", "(refId: string, query: string, datasource: Datasource): this;", {
|
|
836
|
+
/**
|
|
837
|
+
* @param {Panel} panel
|
|
838
|
+
* @param {string} refId
|
|
839
|
+
* @param {string} query
|
|
840
|
+
* @param {Datasource} datasource
|
|
841
|
+
*/
|
|
842
|
+
code: (panel, refId, query, datasource) => {
|
|
843
|
+
return panel.addTarget(new Target(panel.metaOptions).setRefId(refId).setQuery(query).setDatasource(datasource));
|
|
844
|
+
} }).defineValue("timeFrom", String).defineValue("timeShift", String).defineArray("transformations", DataTransformation).defineValue("type", String, { onDefault: (options) => "" }).defineValue("title", String, { onDefault: (options) => "" }).asClass;
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/items/TemplateCurrent.js
|
|
847
|
+
var TemplateCurrent = defineGrafanaItemClass("TemplateCurrent", GrafanaItem).defineValue("text", Object).defineValue("value", Object).asClass;
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region src/items/TemplateOption.js
|
|
850
|
+
var TemplateOption = defineGrafanaItemClass("TemplateOption", GrafanaItem).defineValue("selected", Boolean).defineValue("text", String).defineValue("value", String).asClass;
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region src/items/Template.js
|
|
853
|
+
var Template = defineGrafanaItemClass("Template", GrafanaItem).defineObject("current", TemplateCurrent, { setNew: true }).defineValue("definition", String).defineValue("description", String).defineValue("hide", Number).defineValue("label", String).defineValue("multi", Boolean).defineValue("name", String).defineArray("options", TemplateOption).defineValue("query", Object).defineValue("refresh", Number).defineValue("regex", String).defineValue("sort", Number).defineValue("type", String).defineValue("useTags", Boolean).asClass;
|
|
854
|
+
//#endregion
|
|
855
|
+
//#region src/items/Templating.js
|
|
856
|
+
var Templating = defineGrafanaItemClass("Templating", GrafanaItem).defineArray("list", Template, { itemName: "template" }).asClass;
|
|
857
|
+
//#endregion
|
|
858
|
+
//#region src/items/TimePicker.js
|
|
859
|
+
var TimePicker = defineGrafanaItemClass("TimePicker", GrafanaItem).defineArray("refresh_intervals", String, { itemName: "refreshInterval" }).asClass;
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region src/torefactor/index.js
|
|
862
|
+
/**
|
|
863
|
+
* @typedef {import("@gdacm/base-types").GenericMetaOptions} GenericMetaOptions
|
|
864
|
+
*/
|
|
865
|
+
/**
|
|
866
|
+
* @param {GenericMetaOptions} options
|
|
867
|
+
* @returns {Annotations}
|
|
868
|
+
*/
|
|
869
|
+
var getAnnotations = (options) => new Annotations(options).addNewAnnotation((annotation) => annotation.setBuiltIn(1).setNewDatasource((datasource) => datasource.setType("grafana").setUid("-- Grafana --")).setEnable(true).setHide(true).setIconColor("rgba(0, 211, 255, 1)").setName("Annotations & Alerts").setType("dashboard"));
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/items/Dashboard.js
|
|
872
|
+
var Dashboard = defineGrafanaItemClass("Dashboard", GrafanaItem).setParent(GrafanaItem).defineObject("annotations", Annotations, { onDefault: (options) => getAnnotations(options) }).defineValue("editable", Boolean).defineValue("fiscalYearStartMonth", Number).defineValue("graphTooltip", Number).defineArray("links", Link, { itemName: "link" }).defineValue("liveNow", Boolean).defineMethod("addPanel", "(panel: Panel): this;", {
|
|
873
|
+
/**
|
|
874
|
+
* @param {Dashboard} dashboard
|
|
875
|
+
* @param {Panel} panel
|
|
876
|
+
* @returns {Dashboard}
|
|
877
|
+
*/
|
|
878
|
+
code: (dashboard, panel) => {
|
|
879
|
+
const max = dashboard.panels.reduce((acc, panel) => {
|
|
880
|
+
const id = panel._getValue("id");
|
|
881
|
+
if (id >= acc) return id;
|
|
882
|
+
else return acc;
|
|
883
|
+
}, 0);
|
|
884
|
+
panel._setValue("id", max + 1);
|
|
885
|
+
return dashboard._addArrayItem("panels", panel);
|
|
886
|
+
} }).defineArray("panels", Panel, { itemName: "panel" }).defineValue("preload", Boolean).defineValue("schemaVersion", Number).defineValue("refresh", String).defineValue("tags", Array, {
|
|
887
|
+
onDefault: (options) => [],
|
|
888
|
+
typeName: "Array<String>"
|
|
889
|
+
}).defineObject("templating", Templating, { onDefault: (options) => new Templating(options) }).defineObject("time", TimeRange, { onDefault: (options) => new TimeRange(options) }).defineMethod("setTimeRange", "(from: string, to: string): this;", {
|
|
890
|
+
/**
|
|
891
|
+
* @param {Dashboard} dashboard
|
|
892
|
+
* @param {string} from
|
|
893
|
+
* @param {string} to
|
|
894
|
+
* @returns {Dashboard}
|
|
895
|
+
*/
|
|
896
|
+
code: (dashboard, from, to) => {
|
|
897
|
+
dashboard.time.setRange(from, to);
|
|
898
|
+
return dashboard;
|
|
899
|
+
} }).defineObject("timepicker", TimePicker, { onDefault: (options) => new TimePicker(options) }).defineValue("timezone", String, { onDefault: (options) => "browser" }).defineValue("title", String, { onDefault: (options) => "" }).defineValue("uid", String).asClass;
|
|
900
|
+
//#endregion
|
|
901
|
+
//#region src/items/properties/datasource.js
|
|
902
|
+
/**
|
|
903
|
+
* @param {GrafanaItemClassBuilder} builder
|
|
904
|
+
* @param {string} typeName
|
|
905
|
+
* @param {Object} [options]
|
|
906
|
+
* @param {(instance: Datasource) => void} [options.onInit]
|
|
907
|
+
*/
|
|
908
|
+
var defineDatasource = (builder, typeName, options) => {
|
|
909
|
+
const { onInit } = options ?? {};
|
|
910
|
+
builder.defineConstructor((instance) => {
|
|
911
|
+
const self = instance;
|
|
912
|
+
self.setType(typeName);
|
|
913
|
+
if (onInit) onInit(self);
|
|
914
|
+
});
|
|
915
|
+
};
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/items/DatasourceInfinity.js
|
|
918
|
+
var DatasourceInfinity = defineGrafanaItemClass("DatasourceInfinity", Datasource).with((builder) => defineDatasource(builder, "yesoreyeram-infinity-datasource")).asClass;
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/items/ScaleDistribution.js
|
|
921
|
+
var ScaleDistribution = defineGrafanaItemClass("ScaleDistribution", GrafanaItem).defineValue("type", String).asClass;
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/items/properties/axisConfig.js
|
|
924
|
+
/**
|
|
925
|
+
* @param {GrafanaItemClassBuilder} builder
|
|
926
|
+
*/
|
|
927
|
+
var defineAxisConfig = (builder) => {
|
|
928
|
+
builder.defineValue("axisBorderShow", Boolean).defineValue("axisCenteredZero", Boolean).defineValue("axisColorMode", String).defineValue("axisGridShow", Boolean).defineValue("axisLabel", String).defineValue("axisPlacement", String).defineValue("axisSoftMax", Number).defineValue("axisSoftMin", Number).defineValue("axisWidth", Number).defineObject("scaleDistribution", ScaleDistribution, { onDefault: (options) => new ScaleDistribution(options).setType("linear") });
|
|
929
|
+
};
|
|
930
|
+
//#endregion
|
|
931
|
+
//#region src/items/properties/hideableFieldConfig.js
|
|
932
|
+
/**
|
|
933
|
+
* @param {GrafanaItemClassBuilder} builder
|
|
934
|
+
*/
|
|
935
|
+
var defineHideableFieldConfig = (builder) => {
|
|
936
|
+
builder.defineObject("hideFrom", HideFrom, { onDefault: (options) => new HideFrom(options).setLegend(false).setTooltip(false).setViz(false) });
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/items/ThresholdStyle.js
|
|
940
|
+
var ThresholdStyle = defineGrafanaItemClass("ThresholdStyle", GrafanaItem).defineValue("mode", String).asClass;
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/items/FieldConfigCustomBarChart.js
|
|
943
|
+
var FieldConfigCustomBarChart = defineGrafanaItemClass("FieldConfigCustomBarChart", FieldConfigCustom).with((builder) => defineAxisConfig(builder)).defineValue("fillOpacity", Number).defineValue("gradientMode", String).with((builder) => defineHideableFieldConfig(builder)).defineValue("lineWidth", Number).defineObject("thresholdsStyle", ThresholdStyle, { onDefault: (options) => new ThresholdStyle(options).setMode("off") }).defineMethod("setThresholdsStyleMode", "(mode: string): this;", {
|
|
944
|
+
/**
|
|
945
|
+
* @param {FieldConfigCustomBarChart} fieldConfigCustomBarChart
|
|
946
|
+
* @param {String} mode
|
|
947
|
+
* @returns {FieldConfigCustomBarChart}
|
|
948
|
+
*/
|
|
949
|
+
code: (fieldConfigCustomBarChart, mode) => {
|
|
950
|
+
fieldConfigCustomBarChart.thresholdsStyle.setMode(mode);
|
|
951
|
+
return fieldConfigCustomBarChart;
|
|
952
|
+
} }).asClass;
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region src/items/FieldConfigCustomGauge.js
|
|
955
|
+
var FieldConfigCustomGauge = defineGrafanaItemClass("FieldConfigCustomGauge", FieldConfigCustom).asClass;
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/items/FieldConfigCustomGeomap.js
|
|
958
|
+
var FieldConfigCustomGeomap = defineGrafanaItemClass("FieldConfigCustomGeomap", FieldConfigCustom).defineObject("hideFrom", HideFrom, { onDefault: (options) => new HideFrom(options).setLegend(false).setTooltip(false).setViz(false) }).asClass;
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/items/LineStyle.js
|
|
961
|
+
var LineStyle = defineGrafanaItemClass("LineStyle", GrafanaItem).defineValue("fill", String).asClass;
|
|
962
|
+
//#endregion
|
|
963
|
+
//#region src/items/Stacking.js
|
|
964
|
+
var Stacking = defineGrafanaItemClass("Stacking", GrafanaItem).defineValue("group", String).defineValue("mode", String).asClass;
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/items/FieldConfigCustomTimeSerie.js
|
|
967
|
+
var FieldConfigCustomTimeSerie = defineGrafanaItemClass("FieldConfigCustomTimeSerie", FieldConfigCustom).with((builder) => defineAxisConfig(builder)).defineValue("barAlignment", Number).defineValue("barMaxWidth", Number).defineValue("barWidthFactor", Number).defineValue("drawStyle", String).defineValue("fillBelowTo", String).defineValue("fillColor", String).defineValue("fillOpacity", Number).defineValue("gradientMode", String).with((builder) => defineHideableFieldConfig(builder)).defineValue("insertNulls", Boolean).defineValue("lineInterpolation", String).defineObject("lineStyle", LineStyle, { onDefault: (options) => new LineStyle(options).setFill("solid") }).defineMethod("setLineStyleFill", "(fill: string): this;", {
|
|
968
|
+
/**
|
|
969
|
+
* @param {FieldConfigCustomTimeSerie} fieldConfigCustomTimeSerie
|
|
970
|
+
* @param {String} fill
|
|
971
|
+
* @returns {FieldConfigCustomTimeSerie}
|
|
972
|
+
*/
|
|
973
|
+
code: (fieldConfigCustomTimeSerie, fill) => {
|
|
974
|
+
fieldConfigCustomTimeSerie.lineStyle.setFill(fill);
|
|
975
|
+
return fieldConfigCustomTimeSerie;
|
|
976
|
+
} }).defineValue("lineWidth", Number).defineValue("pointColor", String).defineValue("pointSize", Number).defineValue("pointSymbol", String).defineValue("showPoints", String).defineValue("showValues", Boolean).defineValue("spanNulls", Boolean).defineObject("stacking", Stacking, { onDefault: (options) => new Stacking(options).setGroup("A").setMode("none") }).defineObject("thresholdsStyle", ThresholdStyle, { onDefault: (options) => new ThresholdStyle(options).setMode("off") }).defineMethod("setThresholdsStyleMode", "(mode: string): this;", {
|
|
977
|
+
/**
|
|
978
|
+
* @param {FieldConfigCustomTimeSerie} fieldConfigCustomTimeSerie
|
|
979
|
+
* @param {String} mode
|
|
980
|
+
* @returns {FieldConfigCustomTimeSerie}
|
|
981
|
+
*/
|
|
982
|
+
code: (fieldConfigCustomTimeSerie, mode) => {
|
|
983
|
+
fieldConfigCustomTimeSerie.thresholdsStyle.setMode(mode);
|
|
984
|
+
return fieldConfigCustomTimeSerie;
|
|
985
|
+
} }).asClass;
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/items/FieldConfigCustomTableCellOptions.js
|
|
988
|
+
var FieldConfigCustomTableCellOptions = defineGrafanaItemClass("FieldConfigCustomTableCellOptions", GrafanaItem).defineValue("type", String).asClass;
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/items/FieldConfigCustomTableFooter.js
|
|
991
|
+
var FieldConfigCustomTableFooter = defineGrafanaItemClass("FieldConfigCustomTableFooter", GrafanaItem).defineArray("reducers", String).asClass;
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region src/items/FieldConfigCustomTable.js
|
|
994
|
+
var FieldConfigCustomTable = defineGrafanaItemClass("FieldConfigCustomTable", FieldConfigCustom).defineValue("align", String).defineObject("cellOptions", FieldConfigCustomTableCellOptions, { onDefault: (options) => new FieldConfigCustomTableCellOptions(options) }).defineObject("footer", FieldConfigCustomTableFooter, { onDefault: (options) => new FieldConfigCustomTableFooter(options) }).defineValue("inspect", Boolean).asClass;
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/items/Influxdb.js
|
|
997
|
+
var Influxdb = defineGrafanaItemClass("Influxdb", Datasource).with((builder) => defineDatasource(builder, "influxdb")).asClass;
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/items/PanelOptions.js
|
|
1000
|
+
var PanelOptions = defineGrafanaItemClass("PanelOptions", GrafanaItem).asClass;
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region src/items/VizLegendOptions.js
|
|
1003
|
+
var VizLegendOptions = defineGrafanaItemClass("VizLegendOptions", GrafanaItem).defineValue("asTable", Boolean).defineArray("calcs", String).defineValue("displayMode", String).defineValue("isVisible", Boolean).defineValue("limit", Number).defineValue("overflow", String).defineValue("placement", String).defineValue("showLegend", Boolean).defineValue("sortBy", String).defineValue("sortDesc", Boolean).defineValue("width", Number).asClass;
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region src/items/VizTooltipOptions.js
|
|
1006
|
+
var VizTooltipOptions = defineGrafanaItemClass("VizTooltipOptions", GrafanaItem).defineValue("hideZeros", Boolean).defineValue("maxHeight", Number).defineValue("maxWidth", Number).defineValue("mode", String).defineValue("sort", String).asClass;
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/items/VizTextDisplayOptions.js
|
|
1009
|
+
var VizTextDisplayOptions = defineGrafanaItemClass("VizTextDisplayOptions", GrafanaItem).defineValue("percentSize", Number).defineValue("titleSize", Number).defineValue("valueSize", Number).asClass;
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/items/PanelOptionsBarChart.js
|
|
1012
|
+
var PanelOptionsBarChart = defineGrafanaItemClass("PanelOptionsBarChart", PanelOptions).defineValue("barRadius", Number).defineValue("barWidth", Number).defineValue("colorByField", String).defineValue("fullHighlight", Boolean).defineValue("groupWidth", Number).defineObject("legend", VizLegendOptions, { onDefault: (options) => new VizLegendOptions(options).setDisplayMode("list").setPlacement("bottom").setShowLegend(false) }).defineValue("orientation", String).defineValue("showValue", String).defineValue("stacking", String).defineObject("text", VizTextDisplayOptions).defineObject("tooltip", VizTooltipOptions, { onDefault: (options) => new VizTooltipOptions(options).setHideZeros(false).setMode("single").setSort("none") }).defineValue("xField", String).defineValue("xTickLabelMaxLength", Number).defineValue("xTickLabelRotation", Number).defineValue("xTickLabelSpacing", Number).asClass;
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region src/items/PanelOptionsGaugeEffect.js
|
|
1015
|
+
var PanelOptionsGaugeEffect = defineGrafanaItemClass("PanelOptionsGaugeEffect", GrafanaItem).defineValue("barGlow", Boolean).defineValue("centerGlow", Boolean).defineValue("gradient", Boolean).asClass;
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/items/PanelOptionsGaugeReduceOptions.js
|
|
1018
|
+
var PanelOptionsGaugeReduceOptions = defineGrafanaItemClass("PanelOptionsGaugeReduceOptions", GrafanaItem).defineArray("calcs", String, { setEmpty: true }).defineValue("fields", String).defineValue("limit", Number).defineValue("values", Boolean).asClass;
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region src/items/PanelOptionsGauge.js
|
|
1021
|
+
var PanelOptionsGauge = defineGrafanaItemClass("PanelOptionsGauge", PanelOptions).defineValue("barShape", String).defineValue("barWidthFactor", Number).defineObject("effects", PanelOptionsGaugeEffect, { setNew: true }).defineValue("endpointMarker", String).defineValue("minVizHeight", Number).defineValue("minVizWidth", Number).defineValue("orientation", String).defineObject("reduceOptions", PanelOptionsGaugeReduceOptions, { setNew: true }).defineValue("segmentCount", Number).defineValue("segmentSpacing", Number).defineValue("shape", String).defineValue("showThresholdLabels", Boolean).defineValue("showThresholdMarkers", Boolean).defineValue("sizing", String).defineValue("sparkline", Boolean).defineValue("textMode", String).asClass;
|
|
1022
|
+
//#endregion
|
|
1023
|
+
//#region src/items/PanelOptionsGeomapBasemap.js
|
|
1024
|
+
var PanelOptionsGeomapBasemap = defineGrafanaItemClass("PanelOptionsGeomapBasemap", GrafanaItem).defineObject("config", Object, { setNew: true }).defineValue("name", String).defineValue("noRepeat", Boolean).defineValue("type", String).asClass;
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/items/PanelOptionsGeomapControls.js
|
|
1027
|
+
var PanelOptionsGeomapControls = defineGrafanaItemClass("PanelOptionsGeomapControls", GrafanaItem).defineValue("mouseWheelZoom", Boolean).defineValue("showAttribution", Boolean).defineValue("showDebug", Boolean).defineValue("showMeasure", Boolean).defineValue("showScale", Boolean).defineValue("showZoom", Boolean).asClass;
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/items/StyleColor.js
|
|
1030
|
+
var StyleColor = defineGrafanaItemClass("StyleColor", GrafanaItem).defineValue("fixed", String).asClass;
|
|
1031
|
+
//#endregion
|
|
1032
|
+
//#region src/items/StyleRotation.js
|
|
1033
|
+
var StyleRotation = defineGrafanaItemClass("StyleRotation", GrafanaItem).defineValue("fixed", Number).defineValue("max", Number).defineValue("min", Number).defineValue("mode", String).asClass;
|
|
1034
|
+
//#endregion
|
|
1035
|
+
//#region src/items/StyleSize.js
|
|
1036
|
+
var StyleSize = defineGrafanaItemClass("StyleSize", GrafanaItem).defineValue("fixed", Number).defineValue("max", Number).defineValue("min", Number).asClass;
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/items/StyleSymbol.js
|
|
1039
|
+
var StyleSymbol = defineGrafanaItemClass("StyleSymbol", GrafanaItem).defineValue("field", String).defineValue("fixed", String).defineValue("mode", String).asClass;
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/items/StyleSymbolAlign.js
|
|
1042
|
+
var StyleSymbolAlign = defineGrafanaItemClass("StyleSymbolAlign", GrafanaItem).defineValue("horizontal", String).defineValue("vertical", String).asClass;
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/items/StyleTextConfig.js
|
|
1045
|
+
var StyleTextConfig = defineGrafanaItemClass("StyleTextConfig", GrafanaItem).defineValue("fontSize", Number).defineValue("offsetX", Number).defineValue("offsetY", Number).defineValue("textAlign", String).defineValue("textBaseline", String).asClass;
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/items/PanelOptionsGeomapLayerConfigStyle.js
|
|
1048
|
+
var PanelOptionsGeomapLayerConfigStyle = defineGrafanaItemClass("PanelOptionsGeomapLayerConfigStyle", GrafanaItem).defineObject("color", StyleColor, { onDefault: (options) => new StyleColor(options) }).defineValue("opacity", Number, { onDefault: (options) => 1 }).defineObject("rotation", StyleRotation, { onDefault: (options) => new StyleRotation(options) }).defineObject("size", StyleSize, { onDefault: (options) => new StyleSize(options) }).defineObject("symbol", StyleSymbol, { onDefault: (options) => new StyleSymbol(options) }).defineObject("symbolAlign", StyleSymbolAlign, { onDefault: (options) => new StyleSymbolAlign(options) }).defineObject("textConfig", StyleTextConfig, { onDefault: (options) => new StyleTextConfig(options) }).asClass;
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region src/items/PanelOptionsGeomapLayerConfig.js
|
|
1051
|
+
var PanelOptionsGeomapLayerConfig = defineGrafanaItemClass("PanelOptionsGeomapLayerConfig", GrafanaItem).defineValue("showLegend", Boolean).defineObject("style", PanelOptionsGeomapLayerConfigStyle, {
|
|
1052
|
+
onDefault: (options) => new PanelOptionsGeomapLayerConfigStyle(options),
|
|
1053
|
+
setNew: true
|
|
1054
|
+
}).asClass;
|
|
1055
|
+
//#endregion
|
|
1056
|
+
//#region src/items/PanelOptionsGeomapLayerLocation.js
|
|
1057
|
+
var PanelOptionsGeomapLayerLocation = defineGrafanaItemClass("PanelOptionsGeomapLayerLocation", GrafanaItem).defineValue("mode", String).asClass;
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/items/PanelOptionsGeomapLayer.js
|
|
1060
|
+
var PanelOptionsGeomapLayer = defineGrafanaItemClass("PanelOptionsGeomapLayer", GrafanaItem).defineObject("config", PanelOptionsGeomapLayerConfig, { setNew: true }).defineObject("location", PanelOptionsGeomapLayerLocation, { setNew: true }).defineValue("name", String).defineValue("tooltip", Boolean).defineValue("type", String).asClass;
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region src/items/PanelOptionsGeomapTooltip.js
|
|
1063
|
+
var PanelOptionsGeomapTooltip = defineGrafanaItemClass("PanelOptionsGeomapTooltip", GrafanaItem).defineValue("mode", String).asClass;
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/items/PanelOptionsGeomapView.js
|
|
1066
|
+
var PanelOptionsGeomapView = defineGrafanaItemClass("PanelOptionsGeomapView", GrafanaItem).defineValue("allLayers", Boolean).defineValue("id", String).defineValue("lat", Number).defineValue("lon", Number).defineValue("noRepeat", Boolean).defineValue("shared", Boolean).defineValue("zoom", Number).asClass;
|
|
1067
|
+
//#endregion
|
|
1068
|
+
//#region src/items/PanelOptionsGeomap.js
|
|
1069
|
+
var PanelOptionsGeomap = defineGrafanaItemClass("PanelOptionsGeomap", PanelOptions).defineObject("basemap", PanelOptionsGeomapBasemap, { setNew: true }).defineObject("controls", PanelOptionsGeomapControls, { setNew: true }).defineArray("layers", PanelOptionsGeomapLayer).defineObject("tooltip", PanelOptionsGeomapTooltip, { setNew: true }).defineObject("view", PanelOptionsGeomapView, { setNew: true }).asClass;
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region src/items/PanelOptionsStat.js
|
|
1072
|
+
var PanelOptionsStat = defineGrafanaItemClass("PanelOptionsStat", PanelOptions).asClass;
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region src/items/PanelOptionsTableSortBy.js
|
|
1075
|
+
var PanelOptionsTableSortBy = defineGrafanaItemClass("PanelOptionsTableSortBy", GrafanaItem).defineValue("desc", Boolean).defineValue("displayName", String).asClass;
|
|
1076
|
+
//#endregion
|
|
1077
|
+
//#region src/items/PanelOptionsTable.js
|
|
1078
|
+
var PanelOptionsTable = defineGrafanaItemClass("PanelOptionsTable", PanelOptions).defineValue("cellHeight", String).defineValue("showHeader", Boolean).defineArray("sortBy", PanelOptionsTableSortBy).asClass;
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/items/PanelOptionsTextCode.js
|
|
1081
|
+
var PanelOptionsTextCode = defineGrafanaItemClass("PanelOptionsTextCode", GrafanaItem).defineValue("language", String).defineValue("showLineNumbers", Boolean).defineValue("showMiniMap", Boolean).asClass;
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/items/PanelOptionsText.js
|
|
1084
|
+
var PanelOptionsText = defineGrafanaItemClass("PanelOptionsText", PanelOptions).defineObject("code", PanelOptionsTextCode, { onDefault: (options) => new PanelOptionsTextCode(options) }).defineValue("content", String).defineValue("mode", String).asClass;
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region src/items/PanelOptionsTimeSeries.js
|
|
1087
|
+
var PanelOptionsTimeSeries = defineGrafanaItemClass("PanelOptionsTimeSeries", PanelOptions).defineValue("disableKeyboardEvents", Boolean).defineObject("legend", VizLegendOptions, { onDefault: (options) => new VizLegendOptions(options).setDisplayMode("list").setPlacement("bottom").setShowLegend(false) }).defineValue("orientation", String).defineObject("tooltip", VizTooltipOptions, { onDefault: (options) => new VizTooltipOptions(options).setHideZeros(false).setMode("single").setSort("none") }).asClass;
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region src/items/TargetInfinity.js
|
|
1090
|
+
var TargetInfinity = defineGrafanaItemClass("TargetInfinity", Target).defineObject("columns", Object).defineObject("computed_columns", Object, { name: "computedColumns" }).defineValue("format", String).defineValue("parser", String).defineValue("source", String).defineValue("type", String).defineValue("uql", String).defineValue("url", String).defineValue("url_options", Object, { name: "urlOptions" }).asClass;
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region src/items/Testdata.js
|
|
1093
|
+
var Testdata = defineGrafanaItemClass("Testdata", Datasource).with((builder) => defineDatasource(builder, "grafana-testdata-datasource")).asClass;
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/items/FieldConfigCustomText.js
|
|
1096
|
+
var FieldConfigCustomText = defineGrafanaItemClass("FieldConfigCustomText", FieldConfigCustom).asClass;
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/items/properties/panel.js
|
|
1099
|
+
/**
|
|
1100
|
+
* @param {GrafanaItemClassBuilder} builder
|
|
1101
|
+
* @param {string} typeName
|
|
1102
|
+
* @param {typeof FieldConfigCustom} fieldConfigCustom
|
|
1103
|
+
* @param {typeof PanelOptions} panelOptions
|
|
1104
|
+
* @param {Object} [options]
|
|
1105
|
+
* @param {(instance: Panel) => void} [options.onInit]
|
|
1106
|
+
*/
|
|
1107
|
+
var definePanel = (builder, typeName, fieldConfigCustom, panelOptions, options) => {
|
|
1108
|
+
const { onInit } = options ?? {};
|
|
1109
|
+
builder.defineConstructor((instance) => {
|
|
1110
|
+
const self = instance;
|
|
1111
|
+
self.setType(typeName).withFieldConfig((fieldConfig) => fieldConfig.setDefaults(new FieldConfigDefault(instance.metaOptions).setCustom(new fieldConfigCustom(instance.metaOptions))));
|
|
1112
|
+
if (onInit) onInit(self);
|
|
1113
|
+
}).defineGetterSetter("custom", `${fieldConfigCustom.name}`, {
|
|
1114
|
+
typesToInclude: [fieldConfigCustom],
|
|
1115
|
+
getter: (instance) => instance.fieldConfig.defaults.custom
|
|
1116
|
+
}).defineMethod(`withCustom`, `(code: (custom: ${fieldConfigCustom.name}) => void): this`, {
|
|
1117
|
+
typesToInclude: [fieldConfigCustom],
|
|
1118
|
+
/**
|
|
1119
|
+
* @param {Panel} instance
|
|
1120
|
+
* @param {(custom: FieldConfigCustom) => void} code
|
|
1121
|
+
* */
|
|
1122
|
+
code: (instance, code) => {
|
|
1123
|
+
code(instance.fieldConfig.defaults.custom);
|
|
1124
|
+
return instance;
|
|
1125
|
+
}
|
|
1126
|
+
}).defineObject("options", panelOptions, {
|
|
1127
|
+
setNew: true,
|
|
1128
|
+
onDefault: (options) => new panelOptions(options)
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
//#endregion
|
|
1132
|
+
//#region src/items/TextPanel.js
|
|
1133
|
+
var TextPanel = defineGrafanaItemClass("TextPanel", Panel).with((builder) => definePanel(builder, "text", FieldConfigCustomText, PanelOptionsText)).asClass;
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/items/BarChart.js
|
|
1136
|
+
var BarChart = defineGrafanaItemClass("BarChart", Panel).with((instance) => definePanel(instance, "barchart", FieldConfigCustomBarChart, PanelOptionsBarChart, { onInit: (instance) => {
|
|
1137
|
+
instance.fieldConfig.defaults.setColorMode("palette-classic");
|
|
1138
|
+
} })).defineMethod("setThresholdsStyleArea", "(): this", { code: (instance) => {
|
|
1139
|
+
instance.custom.thresholdsStyle.setMode("area");
|
|
1140
|
+
return instance;
|
|
1141
|
+
} }).asClass;
|
|
1142
|
+
//#endregion
|
|
1143
|
+
//#region src/items/Gauge.js
|
|
1144
|
+
var Gauge = defineGrafanaItemClass("Gauge", Panel).with((builder) => definePanel(builder, "gauge", FieldConfigCustomGauge, PanelOptionsGauge, { onInit: (instance) => {
|
|
1145
|
+
instance.fieldConfig.defaults.setColorMode("palette-classic");
|
|
1146
|
+
} })).asClass;
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/items/Geomap.js
|
|
1149
|
+
var Geomap = defineGrafanaItemClass("Geomap", Panel).with((builder) => definePanel(builder, "geomap", FieldConfigCustomGeomap, PanelOptionsGeomap)).asClass;
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region src/items/FieldConfigCustomStat.js
|
|
1152
|
+
var FieldConfigCustomStat = defineGrafanaItemClass("FieldConfigCustomStat", FieldConfigCustom).asClass;
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/items/Stat.js
|
|
1155
|
+
var Stat = defineGrafanaItemClass("Stat", Panel).with((builder) => definePanel(builder, "stat", FieldConfigCustomStat, PanelOptionsStat, { onInit: (instance) => instance.fieldConfig.defaults.setColorMode("palette-classic") })).asClass;
|
|
1156
|
+
//#endregion
|
|
1157
|
+
//#region src/items/Table.js
|
|
1158
|
+
var Table = defineGrafanaItemClass("Table", Panel).with((builder) => definePanel(builder, "table", FieldConfigCustomTable, PanelOptionsTable, { onInit: (instance) => instance.withCustom((custom) => custom.setAlign("auto").setCellOptions(new FieldConfigCustomTableCellOptions(instance.metaOptions)).withCellOptions((cellOptions) => cellOptions.setType("auto")).setFooter(new FieldConfigCustomTableFooter(instance.metaOptions)).setInspect(false)) })).asClass;
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/items/TimeSeries.js
|
|
1161
|
+
var TimeSeries = defineGrafanaItemClass("TimeSeries", Panel).with((builder) => definePanel(builder, "timeseries", FieldConfigCustomTimeSerie, PanelOptionsTimeSeries, { onInit: (instance) => instance.fieldConfig.defaults.setColorMode("palette-classic") })).defineMethod("setThresholdsStyleArea", "(): this", { code: (instance) => {
|
|
1162
|
+
instance.custom.thresholdsStyle.setMode("area");
|
|
1163
|
+
return instance;
|
|
1164
|
+
} }).asClass;
|
|
1165
|
+
//#endregion
|
|
1166
|
+
export { Annotation, Annotations, BarChart, Color, Dashboard, DataTransformation, Datasource, DatasourceInfinity, FieldConfig, FieldConfigCustom, FieldConfigCustomBarChart, FieldConfigCustomGauge, FieldConfigCustomGeomap, FieldConfigCustomTable, FieldConfigCustomTableCellOptions, FieldConfigCustomTableFooter, FieldConfigCustomTimeSerie, FieldConfigDefault, FieldConfigOverride, Gauge, Geomap, GrafanaItem, GridPos, HideFrom, Influxdb, LineStyle, Link, Mapping, OverrideMatcher, OverrideMatcherOptionsByNames, OverrideProperty, Panel, PanelOptions, PanelOptionsBarChart, PanelOptionsGauge, PanelOptionsGaugeEffect, PanelOptionsGaugeReduceOptions, PanelOptionsGeomap, PanelOptionsGeomapBasemap, PanelOptionsGeomapControls, PanelOptionsGeomapLayer, PanelOptionsGeomapLayerConfig, PanelOptionsGeomapLayerConfigStyle, PanelOptionsGeomapLayerLocation, PanelOptionsGeomapTooltip, PanelOptionsGeomapView, PanelOptionsStat, PanelOptionsTable, PanelOptionsTableSortBy, PanelOptionsText, PanelOptionsTextCode, PanelOptionsTimeSeries, ScaleDistribution, Stacking, Stat, StyleColor, StyleRotation, StyleSize, StyleSymbol, StyleSymbolAlign, StyleTextConfig, Table, Target, TargetInfinity, Template, TemplateCurrent, TemplateOption, Templating, Testdata, TextPanel, ThresholdStyle, Thresholds, ThresholdsStep, TimePicker, TimeRange, TimeSeries, VizLegendOptions, VizTextDisplayOptions, VizTooltipOptions };
|
|
1167
|
+
|
|
1168
|
+
//# sourceMappingURL=index.js.map
|