-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
140 lines (87 loc) · 4.09 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
options(shiny.maxRequestSize = 15*1024^2)
##UI for Comparision Tool
source("InstallRequiredPackages.R")
library(shiny)
library(leaflet)
##source tab files relavant to UI here
source("AppControlTab.R")
source("AppLocationDetailsTab.R")
source("AppSummaryTab.R")
# Define UI for data upload app ----
ui <- fluidPage(
# App title ----
titlePanel("YoY or Pre-Post Comparision Tool"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Select a prequote file ----
fileInput("PreFileID_Inp", "Choose MSTR export Pre File (.xlsx)",
multiple = FALSE,
accept = c(".xlsx")),
# Input: Select a prequote file ----
fileInput("PostFileID_Inp", "Choose MSTR export Post File (.xlsx)",
multiple = FALSE,
accept = c(".xlsx")),
##----
tags$hr(),
h5 ("Version : Beta"),
h5 ("Dev : Nithish"),
tags$hr()
),
# Main panel for other inputs
mainPanel(
tabsetPanel( ## Match percentage slider
ControlTab,
LocationDetailsTab,
SummaryTab
)
)
)
)
server <- function(input, output) {
runandmessage <- eventReactive(input$Run_Inp, ({
## all the global Control variables set them here
assign("MSTRExcelWbPathPre",input$PreFileID_Inp$datapath,envir = .GlobalEnv)
assign("MSTRExcelWbPathPost",input$PostFileID_Inp$datapath,envir =.GlobalEnv)
assign("MatchThreshold",input$MatchPctThreshhold_Inp,envir =.GlobalEnv)
assign("OutputDirectory",gsub("\\\\","/",input$FolderPath_Inp),envir = .GlobalEnv)
###source all the scripts here
withProgress( message = "Status:", value = 0,{
incProgress(1/6, detail = "Running Location Matching Engine")
source("LocationMatchingAlgo.R")
incProgress(1/6, detail = "Running Location Comparision")
source("LocationComparision.R")
incProgress(1/6, detail = "Reading Policy terms")
source("ReadingFromExcel.R")
incProgress(1/6, detail = "Comparing Policies")
source("PolicyLevelComparision.R")
source("AllGraphics.R")
incProgress(1/6, detail = "Generating Report")
source("GenerateReport.R")
}
)
##place all the ouputs here with the IDs
output$LocationComparisionPlot = LocationComparisionPlot_Out ##refer Location comparision
output$AIGParticipationPlot = AIGParticipationPlot_Out ##refer AllGraphics.R
output$PolicyLimitPlot = PolicyLimitPlot_Out
output$NoOfLocationsPlot = NoOfLocationsPlot_Out
paste0("Ran successfully and generated the report")
})
)
output$message <- renderText ({
# execute reactive expression defined above
runandmessage()
})
output$finalReportDownload.xlsx = downloadHandler(
filename = function() {
return("FinalOutput.xlsx")
},
content = function(outputFile) {
# file.copy("FinalReport.xlsx", outputFile)
saveWorkbook(FinalReportWb,file = outputFile,overwrite = TRUE)
}
)
}
# Create Shiny app ----
shinyApp(ui, server)