Skip to content

Commit 536aeb3

Browse files
committed
Use string id; fully working now
1 parent 4e4ba2d commit 536aeb3

File tree

37 files changed

+265
-197
lines changed

37 files changed

+265
-197
lines changed

.Rproj.user/19FD65EA/pcs/files-pane.pper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"ascending": true
66
}
77
],
8-
"path": "C:/Users/asadowsk/repo/police-maintenance/app/view"
8+
"path": "C:/Users/asadowsk/repo/police-maintenance/app"
99
}

.Rproj.user/19FD65EA/pcs/find-replace-in-files.pper

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dialog-state": {
3-
"query": "clock",
3+
"query": "dm_",
44
"path": "",
55
"regex": false,
66
"caseSensitive": false,
@@ -9,7 +9,7 @@
99
"useGitGrep": true,
1010
"excludeGitIgnore": true,
1111
"excludeFilePatterns": [],
12-
"resultsCount": 0,
12+
"resultsCount": 5,
1313
"errorCount": 0,
1414
"replaceErrors": "",
1515
"projectRelative": true
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"left": {
3-
"splitterpos": 122,
4-
"topwindowstate": "MAXIMIZE",
5-
"panelheight": 703,
6-
"windowheight": 741
3+
"splitterpos": 180,
4+
"topwindowstate": "NORMAL",
5+
"panelheight": 1041,
6+
"windowheight": 1079
77
},
88
"right": {
9-
"splitterpos": 502,
9+
"splitterpos": 504,
1010
"topwindowstate": "NORMAL",
11-
"panelheight": 703,
12-
"windowheight": 741
11+
"panelheight": 1041,
12+
"windowheight": 1079
1313
}
1414
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"TabSet1": -1,
3-
"TabSet2": 8,
3+
"TabSet2": 7,
44
"TabZoom": {}
55
}

Dockerfile

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
## Using older version of R due to rhandsontable date bug
22
## renv.lock was changed to reflect 4.2.2
3-
FROM openanalytics/r-ver:4.2.2
3+
FROM rocker/shiny-verse:4.2.2
44

55
LABEL maintainer="Adam Sadowski <asadowsk@uoguelph.ca>"
66

7-
# system libraries of general use
8-
RUN apt-get update && apt-get install --no-install-recommends -y \
9-
pandoc \
10-
pandoc-citeproc \
11-
libcurl4-gnutls-dev \
12-
libcairo2-dev \
13-
libxt-dev \
14-
libssl-dev \
15-
libssh2-1-dev \
16-
libssl1.1 \
17-
&& rm -rf /var/lib/apt/lists/*
18-
19-
# system library dependency
20-
RUN apt-get update && apt-get install -y \
21-
libmpfr-dev \
22-
&& rm -rf /var/lib/apt/lists/*
23-
24-
# install dependencies of the app
25-
COPY renv.lock .
26-
RUN R -q -e "renv::init();renv::restore()"
27-
28-
# copy the app to the image
29-
RUN mkdir /root/police-maintenance
30-
COPY . /root/police-maintenance
31-
32-
COPY Rprofile.site /usr/local/lib/R/etc/
7+
# For igraph from dm (GH issue: may become Suggested)
8+
RUN apt-get -y update \
9+
&& apt-get -y install \
10+
libglpk-dev \
11+
libgmp3-dev \
12+
libxml2-dev \
13+
&& apt-get clean \
14+
&& rm -rf /var/lib/apt/lists/
15+
16+
# renv install
17+
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"
18+
19+
RUN mkdir /home/app
20+
WORKDIR /home/app
21+
22+
# Copy application code
23+
COPY . .
24+
25+
# Install dependencies
26+
RUN Rscript -e 'renv::restore(prompt = FALSE)'
3327

3428
EXPOSE 3838
3529

36-
## Can change to rhino::app() but need to change WORKDIR first as
37-
## rhino::app() does not take a path?
38-
CMD ["R", "-q", "-e", "shiny::runApp('/root/police-maintenance')"]
30+
CMD Rscript /home/app/app.R

app/logic/constant.R

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,3 @@ trade <- dbReadTable(pool, "trade") |>
4949
building <- dbReadTable(pool, "workorder_building") |>
5050
mutate(building = glue("{building_number} - {building_name}"))
5151

52-
trade_factor <- factor(NA_character_, levels = str_sort(trade$trade))
53-
staff_factor <- factor(NA_character_, levels = str_sort(unique(employee$name)))
54-
55-
## Source of the initial database table
56-
#' @export
57-
DF <- tibble(
58-
hour = NA_integer_,
59-
minute = NA_integer_,
60-
am_pm = factor(NA_character_, levels = c("am", "pm")),
61-
date = NA_Date_,
62-
"Work Order #" = NA_integer_,
63-
building = NA_character_,
64-
# building = factor(NA_character_, levels = str_sort(building$building)),
65-
room = NA_integer_,
66-
issue = NA_character_,
67-
reporter = NA_character_,
68-
trade_responsible = NA_character_,
69-
trade_attended_1 = NA_character_,
70-
trade_attended_2 = NA_character_,
71-
staff_called_1 = NA_character_,
72-
staff_attended_1 = NA_character_,
73-
staff_called_2 = NA_character_,
74-
staff_attended_2 = NA_character_,
75-
contractor_1 = NA_character_,
76-
contractor_2 = NA_character_,
77-
id = 1
78-
) |>
79-
relocate(trade_attended_2, .after = staff_attended_1) |>
80-
rename_with(\(x) x |> str_replace_all("_", " ") |> str_to_title()) |>
81-
rename("am/pm" = "Am Pm") |>
82-
add_rows(2)

app/logic/hot_format.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ hot_format <- function(.data) {
2727
hot_col("Issue", halign = "htLeft") |>
2828
# hot_col(col = "am/pm", type = "dropdown", source = c("am", "pm")) |>
2929
hot_col(
30-
col = c(
31-
"Trade Responsible",
32-
"Trade Attended 1", "Trade Attended 2",
33-
"Staff Attended 1", "Staff Attended 2",
34-
"Staff Called 1", "Staff Called 2"
35-
),
30+
col = c("Trade Responsible", "Trade Attended 1", "Trade Attended 2"),
3631
type = "dropdown", source = str_sort(trade$trade)
3732
) |>
33+
hot_col(
34+
col = c("Staff Attended 1", "Staff Attended 2",
35+
"Staff Called 1", "Staff Called 2"),
36+
type = "dropdown", source = str_sort(employee$name)
37+
) |>
3838
# ,
3939
# "Staff Called 1", "Staff Called 2"
4040
hot_col("Building", type = "dropdown", source = str_sort(building$building)) |>

app/logic/read_table.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ box::use(
66
stringr[...]
77
)
88

9-
read_table <- function() {
10-
dbReadTable(conn, "police_maintenance") |>
9+
read_table <- function(pool) {
10+
dbReadTable(pool, "police_maintenance") |>
1111
rename_with(
1212
\(x) str_replace_all(x, "\\.", " ") |> str_trim(),
1313
everything()

app/main.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ box::use(
55
dm[...],
66
dplyr[...],
77
lubridate[...],
8+
shinylogs[track_usage, store_json],
89
tibble[column_to_rownames, rownames_to_column],
910
app/logic/add_rows[add_rows],
1011
app/logic/constant[pool, conn],
@@ -26,16 +27,17 @@ ui <- function(id) {
2627

2728
#' @export
2829
server <- function(id) {
30+
track_usage(storage_mode = store_json(path = "logs/"))
31+
2932
moduleServer(id, function(input, output, session) {
3033

3134
observe({
3235
if (!is.null(input$hot)) {
33-
x <- input$hot |>
34-
hot_to_r()
36+
x <- input$hot |> hot_to_r()
3537
x <- x |>
3638
mutate(
3739
Date = input$date,
38-
Id = row_number() + as.numeric(Date) * nrow(!!x)
40+
Id = paste0(row_number(), " - ", Date)
3941
)
4042
dm <- dm(police_maintenance = x)
4143
dm <- copy_dm_to(conn, dm, temporary = TRUE)
@@ -46,13 +48,12 @@ server <- function(id) {
4648
})
4749

4850
df_init <- reactive({
49-
x <- read_table() |>
50-
filter(Date == input$date |> as.character()) |>
51-
select(- c(Date, Id))
51+
x <- read_table(pool) |>
52+
filter(Date == input$date |> as.character())
5253
if (nrow(x) == 0) {
53-
x <- x |> add_rows(3)
54+
x <- x |>add_rows(3)
5455
}
55-
return(x)
56+
return(x |> select(- c(Date, Id)))
5657
}) |>
5758
bindEvent(input$date)
5859

dependencies.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# This file allows packrat (used by rsconnect during deployment) to pick up dependencies.
22
library(DBI)
33
library(dbplyr)
4+
library(dm)
5+
library(pool)
46
library(rhandsontable)
57
library(rhino)
68
library(RPostgres)
9+
library(shinylogs)
710
library(usethis)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 09:56:49.936-0500","value":700,"type":"","binding":""},{"name":"HandsontableCopyPaste","timestamp":"2024-02-16 09:56:49.932-0500","value":" ","type":"","binding":"shiny.textareaInput"},{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 09:56:49.935-0500","value":3000,"type":"","binding":""}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 09:56:49.844-0500","sessionid":"1ec20bb7c528dd4dbe9dbbd04c296e61","server_disconnected":"2024-02-16 09:57:16.222-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x363","pixel_ratio":1.25,"browser_connected":"2024-02-16 09:56:49.931-0500"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":"app-date","timestamp":"2024-02-16 14:56:14.007-0500","value":"2024-02-13","type":"shiny.date","binding":"shiny.dateInput"},{"name":"app-date","timestamp":"2024-02-16 14:56:14.007-0500","value":"2024-02-13","type":"shiny.date","binding":"shiny.dateInput"},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:03.987-0500","value":1.25,"type":"","binding":""},{"name":"app-date","timestamp":"2024-02-16 14:56:19.173-0500","value":"2024-02-12","type":"shiny.date","binding":"shiny.dateInput"},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:56:04.657-0500","value":700,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.004-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:56:04.657-0500","value":3000,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.137-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.054-0500","value":1.25,"type":"","binding":""},{"name":"HandsontableCopyPaste","timestamp":"2024-02-16 14:56:03.364-0500","value":" ","type":"","binding":"shiny.textareaInput"},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.091-0500","value":1.25,"type":"","binding":""},{"name":"app-date","timestamp":"2024-02-16 14:56:19.173-0500","value":"2024-02-12","type":"shiny.date","binding":"shiny.dateInput"},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.104-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:56:03.378-0500","value":3000,"type":"","binding":""},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:56:03.379-0500","value":700,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.121-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.154-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.037-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.071-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:04.021-0500","value":1.25,"type":"","binding":""},{"name":".clientdata_pixelratio","timestamp":"2024-02-16 14:56:03.971-0500","value":1.25,"type":"","binding":""}],"outputs":[{"name":"app-hot","timestamp":"2024-02-16 14:56:15.234-0500","binding":"rhandsontable"},{"name":"app-hot","timestamp":"2024-02-16 14:56:20.354-0500","binding":"rhandsontable"}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 14:56:03.178-0500","sessionid":"c8fb2c5053bfdb2d1cc3b315382171bf","server_disconnected":"2024-02-16 14:57:58.932-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x382","pixel_ratio":1.25,"browser_connected":"2024-02-16 14:56:03.361-0500"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:58:00.174-0500","value":766.8,"type":"","binding":""},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:58:00.175-0500","value":0,"type":"","binding":""}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 14:58:00.114-0500","sessionid":"c16aadfa6876f4bef230927a297cb00b","server_disconnected":"2024-02-16 14:58:12.486-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x463","pixel_ratio":1.25,"browser_connected":"2024-02-16 14:58:00.166-0500"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:58:13.737-0500","value":766.8,"type":"","binding":""},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:58:13.737-0500","value":0,"type":"","binding":""}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 14:58:13.692-0500","sessionid":"9ca36f4a4272018caf4395c7c811d423","server_disconnected":"2024-02-16 14:58:26.496-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x463","pixel_ratio":1.25,"browser_connected":"2024-02-16 14:58:13.736-0500"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:58:27.728-0500","value":766.8,"type":"","binding":""},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:58:27.729-0500","value":0,"type":"","binding":""}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 14:58:27.683-0500","sessionid":"70fc5cbf6c874e1ae8d7e0169c7ce4ab","server_disconnected":"2024-02-16 14:58:29.119-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x463","pixel_ratio":1.25,"browser_connected":"2024-02-16 14:58:27.727-0500"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"inputs":[{"name":"app-date","timestamp":"2024-02-16 14:59:23.641-0500","value":"2024-02-15","type":"shiny.date","binding":"shiny.dateInput"},{"name":".clientdata_output_app-hot_width","timestamp":"2024-02-16 14:59:16.704-0500","value":3000,"type":"","binding":""},{"name":"HandsontableCopyPaste","timestamp":"2024-02-16 14:59:16.690-0500","value":" ","type":"","binding":"shiny.textareaInput"},{"name":".clientdata_output_app-hot_height","timestamp":"2024-02-16 14:59:16.704-0500","value":700,"type":"","binding":""},{"name":"app-date","timestamp":"2024-02-16 14:59:23.641-0500","value":"2024-02-15","type":"shiny.date","binding":"shiny.dateInput"}],"outputs":[{"name":"app-hot","timestamp":"2024-02-16 14:59:24.743-0500","binding":"rhandsontable"}],"session":[{"app":"police-maintenance","user":"asadowsk","server_connected":"2024-02-16 14:59:16.572-0500","sessionid":"9da98567248a50aa1486037122875229","server_disconnected":"2024-02-16 14:59:27.756-0500","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36","screen_res":"2560x1440","browser_res":"797x463","pixel_ratio":1.25,"browser_connected":"2024-02-16 14:59:16.687-0500"}]}

0 commit comments

Comments
 (0)