-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
147 lines (134 loc) · 6.5 KB
/
app.R
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
#####################
## Reliability App ##
#####################
### Libraries -----
library(shinydashboard)
library(shiny)
library(dplyr)
library(ggplot2)
options(shiny.maxRequestSize=30*1024^2)
ggplot2::theme_set(theme_minimal())
# Source modules
# The code in ui.R is run once, when the Shiny app is started and it generates an HTML
# file which is cached and sent to each web browser that connects.
# This is a candidate to go the global.R
# Caveat: Since I'm using functions to create the UI, functions inside global.R
# will not be available in that enviroment. Need to source
source("./global.R")
source("./R/module_generator.R")
source("./R/module_UploadData.R")
source("./R/module_WeibullCalculate.R")
source("./R/module_Time_testing_complete.R")
source("./R/module_Time_testing_partial.R")
source("./R/module_Failure_forecast_generator.R")
### UI PART ----
## Sidebar content ---------------------------
sidebar <- function(){
dashboardSidebar(
sidebarMenu(id="menu1",
menuItem("Intro", tabName = "intro", icon = icon("info"), selected = F),
menuItem("Weibull generator", tabName = "generator", icon = icon("dashboard"), selected = T),
menuItem("Weibull Modeler", tabName = "modeler", icon = icon("bar-chart"), selected = F,
menuSubItem("Upload data", icon = icon("gears"),tabName = "uploadData", selected = F),
menuSubItem("Calculate", icon = icon("check-circle"), tabName = "calculateModel", selected = F)
),
menuItem("Zero Failure testing", tabName = "Ztest", icon = icon("flash", lib='glyphicon'), selected = F,
menuSubItem("Time testing complete", icon = icon("time", lib = "glyphicon"),tabName = "ttesting" ),
menuSubItem("Time testing partial", icon = icon("gears"), tabName = "Ntesting", selected = F)
),
menuItem("Forecast Modeler", icon = icon("line-chart"),
menuSubItem("Model generator", icon = icon("gears"),tabName = "forecast_generator", selected = F),
menuSubItem("Train Models", icon = icon("gears"),tabName = "trainModels"),
menuSubItem("Compare Models", icon = icon("check-circle"), tabName = "compareModels")
),
menuItem("Help", tabName = "help", icon = icon("question-circle"),
menuSubItem("About", icon = icon("user"),tabName = "helpAbout"),
menuSubItem("Welcome", icon = icon("coffee"),tabName = "helpWelcome")
)
)
)
}
### Body content --------------------------
body <- function(){
dashboardBody(
RdynamicsHeader(),
tabItems(
## Intro tab content ----
tabItem(tabName = "intro", includeMarkdown("./text/intro_text.md") ),
tabItem(tabName = "generator", generator_UI("page_generator") ),
tabItem(tabName = "uploadData", uploadData_UI("page_uploadData") ),
tabItem(tabName = "calculateModel", weibullCalculate_UI("page_calculate") ),
tabItem(tabName = "ttesting", zeroFailure_test_UI("page_ttest")),
tabItem(tabName = "Ntesting", Zerofailure_fix_time_UI("page_Ntest")),
tabItem(tabName = "forecast_generator", FailureForecast_generator_UI("page_forecastGen"))
)
)
}
header <- function(){
dashboardHeader(title = "R dashboard",
dropdownMenu(type = "messages",
messageItem(
from = "Sales Dept",
message = "Sales are steady this month."),
messageItem(
from = "New User",
message = "How do I register?",
icon = icon("question"),
time = "13:45"),
messageItem(
from = "Support",
message = "The new server is ready.",
icon = icon("life-ring"),
time = "2014-12-01")
),
dropdownMenu(type = "notifications",
notificationItem(
text = "5 new users today",
icon("users")
),
notificationItem(
text = "12 items delivered",
icon("truck"),
status = "success"
),
notificationItem(
text = "Server load at 86%",
icon = icon("exclamation-triangle"),
status = "warning"
)
),
dropdownMenu(type = "tasks", badgeStatus = "success",
taskItem(value = 90, color = "green",
"Documentation"
),
taskItem(value = 17, color = "aqua",
"Project X"
),
taskItem(value = 75, color = "yellow",
"Server deployment"
),
taskItem(value = 80, color = "red",
"Overall project"
)
)
)
}
## Bind ui together ----
ui <- dashboardPage(
header(),
sidebar(),
body())
### SERVER PART ----
library(markdown)
# source("./R/foo_make_abrem_plot.R")
## Server foo
server <- function(input, output, session){
callModule(generator_Server, "page_generator")
data <- callModule(uploadData_server, "page_uploadData")
callModule(weibullCalculate_server, "page_calculate", data)
callModule(zeroFailure_test_server, "page_ttest")
callModule(Zerofailure_fix_time_server, "page_Ntest")
callModule(FailureForecast_generator_server, "page_forecastGen")
}
### Bind the app together ----
shinyApp(ui, server)