135 lines
4.2 KiB
R
135 lines
4.2 KiB
R
library(shiny)
|
|
library(shiny.router)
|
|
library(magrittr)
|
|
library(ggplot2)
|
|
library(plotly)
|
|
library(DT)
|
|
library(shinyjs)
|
|
|
|
#source(".R/home_module.R",encoding="utf-8")
|
|
#source(".R/about_module.R",encoding="utf-8")
|
|
#source(".R/profil_module.R",encoding="utf-8")
|
|
|
|
source("routing_module.R",encoding="utf-8")
|
|
|
|
|
|
ui <- fluidPage(
|
|
useShinyjs(),
|
|
tags$head(
|
|
tags$script(src="js.cookie.js"),
|
|
|
|
tags$script('var cookie = Cookies.get(\'token\');
|
|
$(document).on("shiny:sessioninitialized",function(event){
|
|
Shiny.onInputChange("token", cookie);});'),
|
|
tags$script('Shiny.addCustomMessageHandler("tokenHandler",
|
|
function(token) {
|
|
var cookie = Cookies.set(\'token\', token, { expires: 7 });
|
|
Shiny.onInputChange("token", cookie);
|
|
|
|
}
|
|
);')
|
|
),
|
|
uiOutput("logged"),
|
|
|
|
|
|
router$ui)
|
|
|
|
|
|
|
|
server <- shinyServer(function(input, output, session){
|
|
|
|
output$logged<-renderUI({
|
|
|
|
|
|
if(is.null(input$token)){
|
|
fluidRow(
|
|
|
|
inlineCSS(list(.clicked = "background-color: #008375 !important")),
|
|
column(12,
|
|
navbarPage("",
|
|
tabPanel(a("TakeCareApp",id='takeCareApp',class = "tab-link", href = route_link("home"))),
|
|
tabPanel(a("Firmy",id="tab1",class = "tab-link", href = route_link("profil"))),
|
|
tabPanel(a("O nas",id="tab2",class = "tab-link", href = route_link("about"))),
|
|
tabPanel(a("Zaloguj",id="tab3",class="tab-link", href = route_link("login"))),
|
|
tabPanel(a("Rejestracja",id="tab4",class="tab-link", href = route_link("register"))))
|
|
|
|
|
|
|
|
)
|
|
)
|
|
}else{
|
|
fluidRow(
|
|
|
|
inlineCSS(list(.clicked = "background-color: #008375 !important")),
|
|
column(12,
|
|
navbarPage("",
|
|
tabPanel(a("TakeCareApp",id='takeCareApp',class = "tab-link", href = route_link("home"))),
|
|
tabPanel(a("Firmy",id="tab1",class = "tab-link", href = route_link("profil"))),
|
|
tabPanel(a("O nas",id="tab2",class = "tab-link", href = route_link("about"))),
|
|
tabPanel(a("Wyloguj",id="tab3",class = "tab-link")),
|
|
tabPanel(a("Profil",id="tab4",class="tab-link", href = route_link("profil"))))
|
|
|
|
|
|
|
|
)
|
|
)
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
shinyjs::onclick(id="takeCareApp",expr = {
|
|
shinyjs::removeCssClass(id="tab1",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab2",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab3",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab4",class = "clicked")
|
|
})
|
|
|
|
shinyjs::onclick(id="tab1",expr = {
|
|
shinyjs::addCssClass(id="tab1",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab2",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab3",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab4",class = "clicked")
|
|
})
|
|
|
|
shinyjs::onclick(id="tab2",expr = {
|
|
shinyjs::addCssClass(id="tab2",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab1",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab3",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab4",class = "clicked")
|
|
})
|
|
|
|
shinyjs::onclick(id="tab3",expr = {
|
|
if(is.null(input$token)){
|
|
|
|
shinyjs::addCssClass(id="tab3",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab2",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab1",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab4",class = "clicked")
|
|
}else{
|
|
shinyjs::runjs( 'Cookies.remove(\'token\');
|
|
|
|
Shiny.onInputChange("token", null);
|
|
window.location.replace(\'/#!/login\');')
|
|
}
|
|
})
|
|
|
|
shinyjs::onclick(id="tab4",expr = {
|
|
shinyjs::addCssClass(id="tab4",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab2",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab1",class = "clicked")
|
|
shinyjs::removeCssClass(id="tab3",class = "clicked")
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router$server(input, output, session)
|
|
})
|
|
|
|
shinyApp(ui=ui,server=server) |