-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
173 lines (149 loc) · 7.79 KB
/
app.R
File metadata and controls
173 lines (149 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
################################################################################
# 4Ever-Bock-Dashboard #
# The "4Ever-Bock-Dashboard" is an interactive R-Shiny-Dashboard that displays #
# the current standings of the "4ever Bock" Doppelkopf community. Data is #
# updated in real-time via a connected Google Sheet, allowing all members to #
# stay up-to-date with the latest scores and statistics. #
# # # #
# Author: Felix Aust #
# E-mail: felix.aust@posteo.de #
################################################################################
# Preparation ------------------------------------------------------------------
# Clean up workspace ----
rm(list = ls(all.names = TRUE))
# setwd is only required on local machine
# setwd(dirname(rstudioapi::getSourceEditorContext()$path))
# Load packages ----
pacman::p_load(tidyverse,
janitor,
shiny,
bslib,
bsicons,
fontawesome,
googledrive,
googlesheets4,
plotly,
reactablefmtr,
toastui)
# Define input data ----
# URL's from Google Drive and Google Sheet
input_data <-
list(google_url_folder_images = "https://drive.google.com/drive/folders/1a7Rn8z1eSw-xZPczU5vioYJh0eftK5dj",
google_id_folder_images = "1a7Rn8z1eSw-xZPczU5vioYJh0eftK5dj",
google_url_sheet_data = "https://docs.google.com/spreadsheets/d/1rZDkXF7CPSkXcMSGHUp-KRwgnoBsgN-xqQqRO-GyGs8")
# Load config files ----
# Custom values
source(file="./global/custom_values.R", local = TRUE)
# Custom functions
source(file="./global/custom_functions.R", local = TRUE)
# Google authentication ----
# Get json from Google Service Account
value_name_service_account_token <- list.files(path = "./.secrets",
pattern = "\\.json$")[1]
# Authentication
drive_auth(path = paste0("./.secrets/",
value_name_service_account_token))
gs4_auth(token = drive_token())
# Load data -----
script_load_data <- parse(file = "./global/load_data.R")
for (i in seq_along(script_load_data)) {
tryCatch(eval(script_load_data[[i]]),
error = function(e) message("Oops! Error in chunk: ",
script_load_data[[i]],
"; error message: ",
as.character(e)))
}
# APP --------------------------------------------------------------------------
# Load ui ----
source("./ui/ui_page_overview.R", local = TRUE)
source("./ui/ui_page_player.R", local = TRUE)
source("./ui/ui_page_matches.R", local = TRUE)
# Create ui object
ui <- page_navbar(theme = bslib_theme_default,
tags$head(
tags$link(rel = "stylesheet",
type = "text/css",
href = "styles.css"),
tags$link(rel = "shortcut icon",
type = "image/x-icon",
href = "favicon.ico")),
title = tags$div(class = "navbar-brand",
tags$img(src = "logo.png",
height = "48px",
style = "margin-right: 10px;"),
"4ever Bock Dashboard"),
sidebar = sidebar(open = "closed",
selectInput("season",
label = "Select season",
choices = options_season,
multiple = T,
selected = max(options_season))),
nav_panel("Overview",
icon = fa("users-viewfinder"),
page_ui_overview),
nav_panel("Player",
icon = bs_icon("person-bounding-box"),
page_ui_player),
nav_panel("Matches",
icon = fa("dice"),
page_ui_matches),
nav_panel("Rules",
icon = fa("section"),
page_fluid(card(tags$iframe(
src = "rules.pdf",
width = "100%",
height = "1300px",
style = "border: none;",
allow = "fullscreen; autoplay")))),
nav_panel("Hall Of Fame",
icon = fa("place-of-worship"),
page_fluid(
navset_card_tab(full_screen = TRUE,
title = "Hall of Fame",
height = 800,
nav_panel(title = "2024",
tags$iframe(
src = "season_2024_4ever_bock.pdf",
width = "100%",
height = "700px",
style = "border: none;",
allow = "fullscreen; autoplay")
),
nav_panel(title = "2023",
tags$iframe(
src = "season_2023_4ever_bock.pdf",
width = "100%",
height = "700px",
style = "border: none;",
allow = "fullscreen; autoplay")
)
)
)
),
nav_spacer(),
nav_item(tags$a(tags$span(fa("google-drive"),
"Data"),
href = input_data$google_url_sheet_data,
target = "_blank")
),
nav_item(tags$a(tags$span(fa("images"),
"Pictures"),
href = input_data$google_url_folder_images,
target = "_blank")
),
nav_item(tags$a(tags$span(bs_icon("github"),
"Source Code"),
href = "https://github.com/faust-x/4ever_bock_dashboard",
target = "_blank"))
)
# Load server ----
server <- function(session,input, output) {
# Data
source("./server/server_data.R", local = TRUE)
# Pages
source("./server/server_page_overview.R", local = TRUE)
source("./server/server_page_player.R", local = TRUE)
source("./server/server_page_matches.R", local = TRUE)
}
# Start App -------------------------------------------------------------------
shinyApp(ui, server)