Skip to content

Commit

Permalink
Merge remote-tracking branch 'milQuant/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
lsteinmann committed Nov 23, 2023
2 parents 4e9a7d3 + 9370edd commit 993ec21
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 16 deletions.
28 changes: 12 additions & 16 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# milQuant 1.1.0 _2023-11-23_
* Added a button that refreshes the index, so that newly added resources can be seen as well.
* Added the 'Activity' tab which shows latest and overall changes to the database by *Place* and user.
* All buttons are now disabled while shiny is busy to avoid unnecessary queries.
* Moved the database query to each tab. Now only the data that is needed in each tab is queried from Field Desktop, hopefully reducing overall loading time and memory usage.
* Redesigned the *overview*-plot in Plotly. It now displays the complete project database with the exception of *Type*- and *Image*-categories.
Expand All @@ -8,34 +9,29 @@
* From now on, (almost) all plots are produced in Plotly directly to make better use of Plotlys features.
* Corrected typos, minor text and made some layout changes.


# milQuant 1.0.3 _2023-10-30_
* uses [idaifieldR 0.3.2](https://github.com/lsteinmann/idaifieldR/releases/tag/v0.3.2)
* change the plot download buttons and handlers to a module: fixes non-reactive plot download

# milQuant 1.0.2 _skipped/internal_
* use [idaifieldR 0.3.1](https://github.com/lsteinmann/idaifieldR/releases/tag/v0.3.1)

# milQuant 1.0.1 _2023-03-08_
* clean up main.js a lot, restructure directory
* restructure the menu bar at the top and add links to GitHub, the Miletus Excavation Homepage, and an about-window
* add a modal for default settings to the topmenu so users have custom default connection settingson their computer and don't need to reenter password
* remove bug where app would exit on every output from shiny
* add electron-updater/autoUpdater
* from milQuant:
* the connection settings (name/pw) are reusable (with milQuant-dist)
* improved plot legends and added bar plot display options
* fixed period order in pottery & quant B plots
* fixed issue with dates
* use plotly for all graphs
* add a workflow overview
* add object table to pottery plot
* project, operation and trench(es) are saved and restored on exit by button

# milQuant 1.0.1 _2023-03-05_
* the connection settings (name/pw) are reusable (with milQuant-dist)
* improved plot legends and added bar plot display options
* fixed period order in pottery & quant B plots
* fixed issue with dates
* use plotly for all graphs
* add a workflow overview
* add object table to pottery plot
* project, operation and trench(es) are saved and restored on exit by button

# milQuant 1.0.0 _2023-02-21_
* first "release" (version number changed to be same as the standalone version)
* no more fluidPage()
* fixed if-condition for trench selection
* proper installer for standalone app

# milQuant 0.2.3 _2023-02-18_

Expand Down
4 changes: 4 additions & 0 deletions shiny/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ source("source/tab_modules/workflow_module.R")
source("source/tab_modules/potteryQA_module.R")
source("source/tab_modules/potteryQB_module.R")
source("source/tab_modules/db_overview_module.R")
source("source/tab_modules/db_activity_module.R")

# each tab / ui element group
source("source/tabs/home_tab.R")
Expand All @@ -46,6 +47,7 @@ sidebar <- dashboardSidebar(
container = tags$p))),
actionButton("refreshIndex", "Refresh Index", icon = icon("refresh")),
menuItem("Project overview", tabName = "db_overview_tab", icon = icon("graduation-cap")),
menuItem("Activity", tabName = "db_activity_tab", icon = icon("people-arrows")),
uiOutput("selected_operations"),
uiOutput("selected_trenches"),

Expand Down Expand Up @@ -97,6 +99,7 @@ body <- dashboardBody(
tabItems(
home_tab,
db_overview_tab("db_overview", tabname = "db_overview_tab"),
db_activity_tab("db_activity", tabname = "db_activity_tab"),

worflow_tab("workflow", tabname = "workflow_tab"),

Expand Down Expand Up @@ -149,6 +152,7 @@ server <- function(input, output, session) {

# server code only for overview pages
db_overview_server("db_overview")
db_activity_server("db_activity")

worflow_tab_server("workflow")

Expand Down
145 changes: 145 additions & 0 deletions shiny/source/tab_modules/db_activity_module.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
db_activity_tab <- function(id, tabname) {

ns <- NS(id)

tabItem(
tabName = tabname,
title = "Project database activity",

fluidRow(
box(
width = 9, collapsible = TRUE,
title = "Plot options", solidHeader = TRUE,
column(
width = 4,
airDatepickerInput(
inputId = ns("daterange"),
label = "Select range of dates:",
range = TRUE,
value = c(as.Date("2021-01-01"), Sys.Date())
)
),
column(
width = 4,
uiOutput(ns("user_selection"))
),
column(
width = 4,
prettyRadioButtons(
inputId = ns("action_display"),
label = "Choose the type of action to display",
icon = icon("check"),
inline = TRUE, animation = "jelly",
selected = "both",
choices = list("resource created" = "created",
"resource modified" = "modified",
"both" = "both"))
)
),
box(
title = "Last changed",
width = 3, background = "light-blue",
solidHeader = TRUE, collapsible = TRUE,
"The last 10 changes were made to: ",
textOutput(ns("last_ten_changes")))
),
fluidRow(
box(
title = "Recent database activity", status = "primary",
solidHeader = TRUE, collapsible = FALSE,
width = 12, height = 750,
plotlyOutput(ns("display_plot"), height = 570) %>%
mq_spinner()
)
)
)
}

db_activity_server <- function(id) {

moduleServer(
id,
function(input, output, session) {

ns <- NS(id)

latest_changed_resources <- reactive({
validate(
need(login_connection(), "Not connected."),
need(react_index(), "No project selected.")
)
idf_last_changed(login_connection(), index = react_index(), n = 10)
})

output$last_ten_changes <- renderText(
paste(latest_changed_resources(), collapse = ", ")
)

plot_data <- reactive({
plot_data <- idf_get_changes(connection = login_connection(),
ids = unique(react_index()$identifier)) %>%
mutate(date = as.Date(date)) %>%
left_join(react_index(), by = "identifier")
return(plot_data)
})

output$user_selection <- renderUI({
pickerInput(inputId = ns("user_display"),
label = "Select users to display",
choices = sort(unique(plot_data()$user), decreasing = FALSE),
selected = unique(plot_data()$user),
multiple = TRUE,
options = list("actions-box" = TRUE,
"live-search" = TRUE,
"live-search-normalize" = TRUE,
"live-search-placeholder" = "Search here..."))
})

output$display_plot <- renderPlotly({
validate(
need(react_index(), "No project selected.")
)

if (input$action_display == "both") {
action_display_clean <- c("created", "modified")
} else {
action_display_clean <- input$action_display
}

fig <- plot_data() %>%
filter(date >= input$daterange[1] & date <= input$daterange[2]) %>%
filter(action %in% action_display_clean) %>%
filter(user %in% input$user_display) %>%
mutate(Place = factor(Place,
levels = sort(unique(Place),
decreasing = TRUE))) %>%
plot_ly(x = ~date, color = ~Place,
hovertemplate = paste0("<b>%{fullData.name}</b><br>",
"%{x}<br>",
"count: <b>%{y}</b><br>",
"<extra></extra>"),
type = "histogram")

plot_title <- paste0("Activity in project ", input$selected_project)

x_label <- "date of action"
color_label <- "Place"
y_label <- paste("number of instances resources were",
paste(action_display_clean, collapse = " and "))

fig <- fig %>%
layout(barmode = "stack",
title = plot_title,
xaxis = list(title = x_label),
yaxis = list(title = y_label),
legend = list(title = list(text = color_label)))

fig <- milquant_plotly_layout(fig)

return(fig)
})

}
)

}

0 comments on commit 993ec21

Please sign in to comment.