Environment dropdown and actions

This commit is contained in:
Gregory Schier
2023-10-24 09:17:29 -07:00
parent fa16e1f957
commit 8665ca9acb
11 changed files with 201 additions and 35 deletions

View File

@@ -425,10 +425,14 @@ async fn update_environment(
) -> Result<models::Environment, String> {
let pool = &*db_instance.lock().await;
let updated_environment =
models::update_environment(environment.id.as_str(), environment.data.0, pool)
.await
.expect("Failed to update request");
let updated_environment = models::update_environment(
environment.id.as_str(),
environment.name.as_str(),
environment.data.0,
pool,
)
.await
.expect("Failed to update request");
emit_and_return(&window, "updated_model", updated_environment)
}

View File

@@ -254,6 +254,7 @@ pub async fn create_environment(
pub async fn update_environment(
id: &str,
name: &str,
data: HashMap<String, JsonValue>,
pool: &Pool<Sqlite>,
) -> Result<Environment, sqlx::Error> {
@@ -262,9 +263,10 @@ pub async fn update_environment(
sqlx::query!(
r#"
UPDATE environments
SET (data, updated_at) = (?, CURRENT_TIMESTAMP)
SET (name, data, updated_at) = (?, ?, CURRENT_TIMESTAMP)
WHERE id = ?;
"#,
name,
json_data,
id,
)