mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-06 16:09:41 +00:00
fix: add variables to dashboards (#1091)
This commit is contained in:
@@ -41,6 +41,7 @@ pub struct Dashboard {
|
||||
pub panels: Vec<Panel>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub layouts: Option<Vec<Layout>>,
|
||||
pub variables: Option<Variables>,
|
||||
}
|
||||
|
||||
fn datetime_now() -> DateTime<FixedOffset> {
|
||||
@@ -129,6 +130,41 @@ pub struct PanelConfig {
|
||||
promql_legend: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Variables {
|
||||
pub list: Vec<List>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct List {
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub name: String,
|
||||
pub label: String,
|
||||
#[serde(rename = "query_data")]
|
||||
pub query_data: Option<QueryData>,
|
||||
pub value: Option<String>,
|
||||
pub options: Option<Vec<CustomFieldsOption>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct QueryData {
|
||||
#[serde(rename = "stream_type")]
|
||||
pub stream_type: StreamType,
|
||||
pub stream: String,
|
||||
pub field: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CustomFieldsOption {
|
||||
pub label: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -283,6 +319,7 @@ mod tests {
|
||||
},
|
||||
],
|
||||
),
|
||||
variables: None,
|
||||
}
|
||||
"##]].assert_debug_eq(&dashboard);
|
||||
}
|
||||
@@ -450,6 +487,7 @@ mod tests {
|
||||
},
|
||||
],
|
||||
),
|
||||
variables: None,
|
||||
}
|
||||
"##]].assert_debug_eq(&dashboard);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user