Skip to content

Commit

Permalink
Merge branch 'main' into more-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaoverton committed Mar 20, 2024
2 parents aba4930 + 783ce24 commit e4ae293
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ rev = "f46fbd5450505644ed9970cef1ae14164699981f"
[dependencies.ontodev_valve]
# path = "../ontodev_demo/valve.rs"
git = "https://github.com/ontodev/valve.rs"
rev = "e22939a15cbeaaae0cde9787b02f779cb371af77"
rev = "d97a34848bf9cc541d6b86564a2f019b1fe3d724"

[dependencies.ontodev_sqlrest]
git = "https://github.com/ontodev/sqlrest.rs"
Expand Down
2 changes: 1 addition & 1 deletion src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ async fn get_page(
}

let mut tables = Map::new();
for key in table_map.keys() {
for key in &valve.config.table_order {
if key == "history" {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ <h1 class="modal-title fs-5" id="{{ name|id }}ModalLabel">{{ value.label or name
</a>
</li>
{% endif %}
{% if table.table in ["table", "column"] and col == "table" %}
{% if table.table in ["table", "column", "message"] and col == "table" %}
<li>
<a class="dropdown-item replace-link" href="{{ cell.value }}">
<i class="bi bi-arrow-right"></i>
Expand Down
21 changes: 9 additions & 12 deletions src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn action(
.ok_or("Valve is not initialized.".to_string())?;
let table_map = {
let mut table_map = SerdeMap::new();
for table in get_tables(valve) {
for table in &valve.config.table_order {
if table == "history" {
continue;
}
Expand Down Expand Up @@ -503,7 +503,7 @@ async fn tree(
.valve
.as_ref()
.ok_or("Valve is not initialized.".to_string())?;
for table in get_tables(&valve) {
for table in &valve.config.table_order {
if table == "history" {
continue;
}
Expand Down Expand Up @@ -646,7 +646,7 @@ async fn tree2(
.valve
.as_ref()
.ok_or("Valve is not initialized.".to_string())?;
for table in get_tables(&valve) {
for table in &valve.config.table_order {
if table == "history" {
continue;
}
Expand Down Expand Up @@ -750,7 +750,7 @@ async fn table(
};

// TODO: properly detect LDTab tables
if !get_tables(valve).contains(&table) {
if !valve.config.table_order.contains(&table) {
let url = format!("{table}/owl:Class");
return Ok(Redirect::permanent(&url).into_response());
}
Expand Down Expand Up @@ -816,8 +816,9 @@ async fn table(
let mut form_map = None;
let columns = get_columns(&table, valve)?;
if request_type == RequestType::POST {
// Override view, which isn't passed in POST. This value will then be picked up below.
view = String::from("form");
if view == "" {
view = String::from("form");
}
let mut new_row = SerdeMap::new();
for column in &columns {
if column != "row_number" {
Expand Down Expand Up @@ -925,7 +926,7 @@ async fn table(
// Used to display a drop-down or menu of some kind containing all the available tables:
let table_map = {
let mut table_map = SerdeMap::new();
for table in get_tables(valve) {
for table in &valve.config.table_order {
if table == "history" {
continue;
}
Expand Down Expand Up @@ -1245,7 +1246,7 @@ fn render_row_from_database(
// Used to display a drop-down or menu containing all of the tables:
let table_map = {
let mut table_map = SerdeMap::new();
for table in get_tables(valve) {
for table in &valve.config.table_order {
if table == "history" {
continue;
}
Expand Down Expand Up @@ -1361,10 +1362,6 @@ fn get_messages(row: &SerdeMap) -> Result<HashMap<String, Vec<String>>, String>
Ok(messages)
}

fn get_tables(valve: &Valve) -> Vec<String> {
valve.config.table.keys().cloned().collect::<Vec<_>>()
}

fn get_columns(table: &str, valve: &Valve) -> Result<Vec<String>, String> {
match valve
.config
Expand Down

0 comments on commit e4ae293

Please sign in to comment.