mirror of https://github.com/TaKO8Ki/gobang
implement some handlers
parent
d88a79f0a0
commit
a061efc3bd
@ -1 +1,3 @@
|
||||
/target
|
||||
gobang
|
||||
gobang.yml
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 8.6 MiB |
@ -0,0 +1,13 @@
|
||||
use crate::app::{App, FocusType};
|
||||
use crate::event::Key;
|
||||
use sqlx::mysql::MySqlPool;
|
||||
|
||||
pub async fn handler(_key: Key, app: &mut App) -> anyhow::Result<()> {
|
||||
if let Some(conn) = app.selected_connection() {
|
||||
app.pool.as_ref().unwrap().close().await;
|
||||
let pool = MySqlPool::connect(conn.database_url().as_str()).await?;
|
||||
app.pool = Some(pool);
|
||||
app.focus_type = FocusType::Dabatases(true);
|
||||
}
|
||||
Ok(())
|
||||
}
|
@ -1,11 +1,16 @@
|
||||
use crate::app::App;
|
||||
use crate::app::{App, Database};
|
||||
use crate::event::Key;
|
||||
use crate::utils::get_databases;
|
||||
use sqlx::mysql::MySqlPool;
|
||||
|
||||
pub async fn handler<'a>(_key: Key, app: &mut App<'a>, pool: &MySqlPool) -> anyhow::Result<()> {
|
||||
for db in get_databases(pool).await? {
|
||||
app.databases.push(db)
|
||||
}
|
||||
pub async fn handler(_key: Key, app: &mut App) -> anyhow::Result<()> {
|
||||
app.databases = match app.selected_connection() {
|
||||
Some(conn) => match &conn.database {
|
||||
Some(database) => {
|
||||
vec![Database::new(database.clone(), app.pool.as_ref().unwrap()).await?]
|
||||
}
|
||||
None => get_databases(app.pool.as_ref().unwrap()).await?,
|
||||
},
|
||||
None => vec![],
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue