2022-11-08 13:43:41 +08:00
|
|
|
use crate::{
|
2022-10-22 21:57:44 +08:00
|
|
|
gen_app_id, gen_view_id, gen_workspace_id, AppRevision, ViewDataFormatRevision, ViewLayoutTypeRevision,
|
|
|
|
ViewRevision, WorkspaceRevision,
|
2022-07-04 14:28:41 +08:00
|
|
|
};
|
2021-11-08 15:58:38 +08:00
|
|
|
use chrono::Utc;
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
pub fn create_default_workspace() -> WorkspaceRevision {
|
2022-03-19 16:23:34 +08:00
|
|
|
let time = Utc::now();
|
2022-04-11 15:27:03 +08:00
|
|
|
let workspace_id = gen_workspace_id();
|
2021-11-08 15:58:38 +08:00
|
|
|
let name = "Workspace".to_string();
|
|
|
|
let desc = "".to_string();
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
let apps = vec![create_default_app(workspace_id.to_string(), time)];
|
2021-11-08 15:58:38 +08:00
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
WorkspaceRevision {
|
2022-04-11 20:58:56 +08:00
|
|
|
id: workspace_id,
|
2021-11-08 15:58:38 +08:00
|
|
|
name,
|
|
|
|
desc,
|
|
|
|
apps,
|
|
|
|
modified_time: time.timestamp(),
|
|
|
|
create_time: time.timestamp(),
|
2021-11-27 19:19:41 +08:00
|
|
|
}
|
2021-11-08 15:58:38 +08:00
|
|
|
}
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
fn create_default_app(workspace_id: String, time: chrono::DateTime<Utc>) -> AppRevision {
|
2022-04-11 15:27:03 +08:00
|
|
|
let app_id = gen_app_id();
|
2021-11-13 12:42:30 +08:00
|
|
|
let name = "⭐️ Getting started".to_string();
|
2021-11-08 15:58:38 +08:00
|
|
|
let desc = "".to_string();
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
let views = vec![create_default_view(app_id.to_string(), time)];
|
2021-11-08 15:58:38 +08:00
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
AppRevision {
|
2022-04-11 20:58:56 +08:00
|
|
|
id: app_id,
|
2021-11-08 15:58:38 +08:00
|
|
|
workspace_id,
|
|
|
|
name,
|
|
|
|
desc,
|
|
|
|
belongings: views,
|
|
|
|
version: 0,
|
|
|
|
modified_time: time.timestamp(),
|
|
|
|
create_time: time.timestamp(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
fn create_default_view(app_id: String, time: chrono::DateTime<Utc>) -> ViewRevision {
|
2022-04-11 15:27:03 +08:00
|
|
|
let view_id = gen_view_id();
|
2021-11-08 15:58:38 +08:00
|
|
|
let name = "Read me".to_string();
|
|
|
|
|
2022-06-13 20:59:46 +08:00
|
|
|
ViewRevision {
|
2022-04-11 20:58:56 +08:00
|
|
|
id: view_id,
|
2022-08-18 19:32:08 +08:00
|
|
|
app_id,
|
2021-11-08 15:58:38 +08:00
|
|
|
name,
|
2022-06-13 20:59:46 +08:00
|
|
|
desc: "".to_string(),
|
2022-10-22 21:57:44 +08:00
|
|
|
data_format: ViewDataFormatRevision::DeltaFormat,
|
2021-11-08 15:58:38 +08:00
|
|
|
version: 0,
|
2022-06-13 20:59:46 +08:00
|
|
|
belongings: vec![],
|
2021-11-08 15:58:38 +08:00
|
|
|
modified_time: time.timestamp(),
|
|
|
|
create_time: time.timestamp(),
|
2022-02-28 22:38:53 +08:00
|
|
|
ext_data: "".to_string(),
|
|
|
|
thumbnail: "".to_string(),
|
2022-08-18 19:32:08 +08:00
|
|
|
layout: ViewLayoutTypeRevision::Document,
|
2021-11-08 15:58:38 +08:00
|
|
|
}
|
|
|
|
}
|