1import { Field } from '@grafana/data';
2
3export interface BaseDimensionConfig<T = any> {
4  fixed: T;
5  field?: string;
6}
7
8export interface DimensionSupplier<T = any> {
9  /**
10   * This means an explicit value was not configured
11   */
12  isAssumed?: boolean;
13
14  /**
15   * The fied used for
16   */
17  field?: Field;
18
19  /**
20   * Explicit value -- if == null, then need a value for each index
21   */
22  fixed?: T;
23
24  /**
25   * A single value -- typically last
26   */
27  value: () => T;
28
29  /**
30   * Supplier for the dimension value
31   */
32  get: (index: number) => T;
33}
34
35export enum ScaleDimensionMode {
36  Linear = 'linear',
37  Quadratic = 'quad',
38}
39
40/** This will map the field value% to a scaled value within the range */
41export interface ScaleDimensionConfig extends BaseDimensionConfig<number> {
42  min: number;
43  max: number;
44}
45
46/** Places that use the value */
47export interface ScaleDimensionOptions {
48  min: number;
49  max: number;
50  step?: number;
51  hideRange?: boolean; // false
52}
53
54export enum ScalarDimensionMode {
55  Mod = 'mod',
56  Clamped = 'clamped',
57}
58export interface ScalarDimensionConfig extends BaseDimensionConfig<number> {
59  mode: ScalarDimensionMode;
60  min: number;
61  max: number;
62}
63
64export interface ScalarDimensionOptions {
65  min: number;
66  max: number;
67}
68
69export interface TextDimensionOptions {
70  // anything?
71}
72
73export enum TextDimensionMode {
74  Fixed = 'fixed',
75  Field = 'field',
76  Template = 'template',
77}
78
79export interface TextDimensionConfig extends BaseDimensionConfig<string> {
80  mode: TextDimensionMode;
81}
82
83export const defaultTextConfig: TextDimensionConfig = Object.freeze({
84  fixed: '',
85  mode: TextDimensionMode.Field,
86  field: '',
87});
88
89/** Use the color value from field configs */
90export interface ColorDimensionConfig extends BaseDimensionConfig<string> {}
91
92/** Places that use the value */
93export interface ResourceDimensionOptions {
94  resourceType: 'icon' | 'image';
95  folderName?: ResourceFolderName;
96  placeholderText?: string;
97  placeholderValue?: string;
98  // If you want your icon to be driven by value of a field
99  showSourceRadio?: boolean;
100}
101
102export enum ResourceDimensionMode {
103  Fixed = 'fixed',
104  Field = 'field',
105  Mapping = 'mapping',
106  // pattern? uses field in the pattern
107}
108
109/** Get the path to a resource (URL) */
110export interface ResourceDimensionConfig extends BaseDimensionConfig<string> {
111  mode: ResourceDimensionMode;
112}
113
114export enum ResourceFolderName {
115  Icon = 'img/icons/unicons',
116  IOT = 'img/icons/iot',
117  Marker = 'img/icons/marker',
118  BG = 'img/bg',
119}
120