Merge branch 'worktree-agent-a58c59406199f7d11'
# Conflicts: # src/dto.rs
This commit is contained in:
+56
@@ -1,4 +1,5 @@
|
||||
use crate::data_value::{MetricPrimitiveKind, RegexToMetricPrimitiveMatcher};
|
||||
use crate::settings::CssEntry;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@@ -52,3 +53,58 @@ pub struct TimelineParams {
|
||||
pub end_ms: Option<i64>,
|
||||
pub bucket_ms: Option<i64>,
|
||||
}
|
||||
|
||||
/// Request body for `POST /api/settings/css`: raw CSS content to import and
|
||||
/// store alongside the settings file.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ImportCssRequest {
|
||||
pub filename: String,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
/// Request body for `POST /api/settings/css/link`: a reference to an
|
||||
/// external CSS path/URL that ottyl doesn't copy or own.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct LinkCssRequest {
|
||||
pub path_or_url: String,
|
||||
}
|
||||
|
||||
/// Response shape for a single CSS entry, used both by the list endpoint and
|
||||
/// by mutation endpoints that return the affected entry. `id` is the entry's
|
||||
/// real id for `Imported` entries, or a stable id derived from the
|
||||
/// linked path/URL for `Linked` entries (see `settings::css_entry_id`) —
|
||||
/// this lets the frontend key/reference both kinds of entries uniformly,
|
||||
/// even though only `Imported` entries are deletable/content-fetchable.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct CssEntryDto {
|
||||
pub id: String,
|
||||
pub kind: CssEntryKind,
|
||||
pub filename: Option<String>,
|
||||
pub path_or_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum CssEntryKind {
|
||||
Imported,
|
||||
Linked,
|
||||
}
|
||||
|
||||
impl From<&CssEntry> for CssEntryDto {
|
||||
fn from(entry: &CssEntry) -> Self {
|
||||
match entry {
|
||||
CssEntry::Imported { id, filename } => CssEntryDto {
|
||||
id: id.clone(),
|
||||
kind: CssEntryKind::Imported,
|
||||
filename: Some(filename.clone()),
|
||||
path_or_url: None,
|
||||
},
|
||||
CssEntry::Linked { path_or_url } => CssEntryDto {
|
||||
id: crate::settings::css_entry_id(entry),
|
||||
kind: CssEntryKind::Linked,
|
||||
filename: None,
|
||||
path_or_url: Some(path_or_url.clone()),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user