Test Gitea Runner functionality

This commit is contained in:
Warren
2026-05-30 14:08:55 +08:00
parent 596d8d5e27
commit b362e9b3f1
44 changed files with 1 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
use async_trait::async_trait;
use serde_json::{json, Value};
use crate::filetree::mode::{DisplayMode, FilterOption, SortOption};
use crate::filetree::FileTree;
pub struct GridLgMode;
#[async_trait]
impl DisplayMode for GridLgMode {
fn name(&self) -> &'static str {
"grid_lg"
}
fn render(&self, tree: &FileTree) -> Value {
let nodes: Vec<Value> = tree
.nodes
.iter()
.map(|n| {
json!({
"node_id": n.node_id,
"label": n.label,
"aliases": n.aliases,
"file_uuid": n.file_uuid,
"node_type": n.node_type.as_str(),
"icon": n.icon,
"color": n.color,
"bg_color": n.bg_color,
"sort_order": n.sort_order,
})
})
.collect();
json!({
"mode": "grid_lg",
"user_id": tree.user_id,
"cell_size": 192,
"nodes": nodes,
})
}
fn sort_options(&self) -> Vec<SortOption> {
vec![
SortOption {
key: "name_asc".into(),
label: "Name A-Z".into(),
},
SortOption {
key: "name_desc".into(),
label: "Name Z-A".into(),
},
SortOption {
key: "date_desc".into(),
label: "Newest First".into(),
},
SortOption {
key: "type".into(),
label: "By Type".into(),
},
]
}
fn filter_options(&self) -> Vec<FilterOption> {
vec![
FilterOption {
key: "all".into(),
label: "All".into(),
},
FilterOption {
key: "folder".into(),
label: "Folders".into(),
},
FilterOption {
key: "file".into(),
label: "Files".into(),
},
FilterOption {
key: "video".into(),
label: "Video Files".into(),
},
]
}
}

View File

@@ -0,0 +1,72 @@
use async_trait::async_trait;
use serde_json::{json, Value};
use crate::filetree::mode::{DisplayMode, FilterOption, SortOption};
use crate::filetree::FileTree;
pub struct GridSmMode;
#[async_trait]
impl DisplayMode for GridSmMode {
fn name(&self) -> &'static str {
"grid_sm"
}
fn render(&self, tree: &FileTree) -> Value {
let nodes: Vec<Value> = tree
.nodes
.iter()
.map(|n| {
json!({
"node_id": n.node_id,
"label": n.label,
"node_type": n.node_type.as_str(),
"icon": n.icon,
"color": n.color,
"bg_color": n.bg_color,
})
})
.collect();
json!({
"mode": "grid_sm",
"user_id": tree.user_id,
"cell_size": 96,
"nodes": nodes,
})
}
fn sort_options(&self) -> Vec<SortOption> {
vec![
SortOption {
key: "name_asc".into(),
label: "Name A-Z".into(),
},
SortOption {
key: "name_desc".into(),
label: "Name Z-A".into(),
},
SortOption {
key: "date_desc".into(),
label: "Newest First".into(),
},
]
}
fn filter_options(&self) -> Vec<FilterOption> {
vec![
FilterOption {
key: "all".into(),
label: "All".into(),
},
FilterOption {
key: "folder".into(),
label: "Folders".into(),
},
FilterOption {
key: "file".into(),
label: "Files".into(),
},
]
}
}

View File

@@ -0,0 +1,87 @@
use async_trait::async_trait;
use serde_json::{json, Value};
use crate::filetree::mode::{DisplayMode, FilterOption, SortOption};
use crate::filetree::FileTree;
pub struct ListMode;
#[async_trait]
impl DisplayMode for ListMode {
fn name(&self) -> &'static str {
"list"
}
fn render(&self, tree: &FileTree) -> Value {
let nodes: Vec<Value> = tree
.nodes
.iter()
.map(|n| {
json!({
"node_id": n.node_id,
"label": n.label,
"aliases": n.aliases,
"file_uuid": n.file_uuid,
"sha256": n.sha256,
"parent_id": n.parent_id,
"node_type": n.node_type.as_str(),
"icon": n.icon,
"color": n.color,
"bg_color": n.bg_color,
"file_size": n.file_size,
"registered_at": n.registered_at,
"sort_order": n.sort_order,
})
})
.collect();
json!({
"mode": "list",
"user_id": tree.user_id,
"columns": ["icon", "label", "node_type", "updated_at"],
"nodes": nodes,
})
}
fn sort_options(&self) -> Vec<SortOption> {
vec![
SortOption {
key: "name_asc".into(),
label: "Name A-Z".into(),
},
SortOption {
key: "name_desc".into(),
label: "Name Z-A".into(),
},
SortOption {
key: "date_desc".into(),
label: "Newest First".into(),
},
SortOption {
key: "date_asc".into(),
label: "Oldest First".into(),
},
SortOption {
key: "type".into(),
label: "By Type".into(),
},
]
}
fn filter_options(&self) -> Vec<FilterOption> {
vec![
FilterOption {
key: "all".into(),
label: "All".into(),
},
FilterOption {
key: "folder".into(),
label: "Folders".into(),
},
FilterOption {
key: "file".into(),
label: "Files".into(),
},
]
}
}

View File

@@ -0,0 +1,4 @@
pub mod grid_lg;
pub mod grid_sm;
pub mod list;
pub mod tree;

View File

@@ -0,0 +1,82 @@
use async_trait::async_trait;
use serde_json::{json, Value};
use crate::filetree::mode::{DisplayMode, FilterOption, SortOption};
use crate::filetree::FileTree;
pub struct TreeMode;
#[async_trait]
impl DisplayMode for TreeMode {
fn name(&self) -> &'static str {
"tree"
}
fn render(&self, tree: &FileTree) -> Value {
let nodes: Vec<Value> = tree
.nodes
.iter()
.map(|n| {
json!({
"node_id": n.node_id,
"label": n.label,
"aliases": n.aliases,
"file_uuid": n.file_uuid,
"sha256": n.sha256,
"parent_id": n.parent_id,
"node_type": n.node_type.as_str(),
"icon": n.icon,
"color": n.color,
"bg_color": n.bg_color,
"file_size": n.file_size,
"registered_at": n.registered_at,
"children": n.children,
})
})
.collect();
json!({
"mode": "tree",
"user_id": tree.user_id,
"nodes": nodes,
})
}
fn sort_options(&self) -> Vec<SortOption> {
vec![
SortOption {
key: "name_asc".into(),
label: "Name A-Z".into(),
},
SortOption {
key: "name_desc".into(),
label: "Name Z-A".into(),
},
SortOption {
key: "date_desc".into(),
label: "Newest First".into(),
},
SortOption {
key: "date_asc".into(),
label: "Oldest First".into(),
},
]
}
fn filter_options(&self) -> Vec<FilterOption> {
vec![
FilterOption {
key: "all".into(),
label: "All".into(),
},
FilterOption {
key: "folder".into(),
label: "Folders".into(),
},
FilterOption {
key: "file".into(),
label: "Files".into(),
},
]
}
}