2016-11-17 7 views
0

光沢のあるアプリケーションを作成しますが、ユーザーがログインしてアプリケーションにアクセスするようにします。次に、これによってログインページを作成する方法を見つける: Starting Shiny app after password input。しかし、私はAPPがパッケージ「shinydashboard」を使用しているという問題があり、ログイン後にページが変わってしまいます。私はHTMLのことに慣れていない。どのようにこの問題を解決するか知っていますか? コードは以下の通りです:ログイン後Shiny App(shinydashboardを使用):ログイン後にページが奇妙になる

library(shiny) 
library(shinydashboard) 
Logged = FALSE; 
my_username <- "test" 
my_password <- "test" 

ui1 <- function(){ 
tagList(
div(id = "login", 
    wellPanel(textInput("userName", "Username"), 
       passwordInput("passwd", "Password"), 
       br(),actionButton("Login", "Log in"))), 
tags$style(type="text/css", "#login {font-size:10px; text-align: left;position:absolute;top: 40%;left: 50%;margin-top: -100px;margin-left: -150px;}") 
)} 

ui2 <- function(){ 
tagList(
dashboardPage(
    dashboardHeader(title = "MY Web APP"), 
    dashboardSidebar( 
    sidebarMenu(
     menuItem("menu1", tabName = "menu1", icon = icon("bank"), 
       badgeColor = "blue"), 
     menuItem("menu2", tabName = "menu2", icon = icon("bar-chart")) 
    )), 
    dashboardBody(
    tabItems(
     # First tab content 
     tabItem(tabName = "menu1", 
       fluidRow(
       sidebarLayout(
        sidebarPanel(
        selectInput("pet1","PET:",c("dog","cat","pig"),selected = "dog"), 
        fileInput(inputId = "iFile", label = "Upload Excel:", 
           accept="application/vnd.ms-excel"), 
        actionButton("go","Go!"), 
        downloadButton('downloadData', 'Download') 
       ), 

        # Show a plot of the generated distribution 
        mainPanel(
        tabsetPanel(
         tabPanel("summary", tableOutput("summary1")), 
         tabPanel("Curve", plotlyOutput("curve1")) 
        ) 
       ) 
       ) 
      ) 
    ), 

     # Second tab content 
     tabItem(tabName = "menu2", 
       fluidRow(
       sidebarLayout(
        sidebarPanel(
        selectInput("pet1","PET:",c("dog","cat","pig"),selected = "dog"), 
        fileInput(inputId = "iFile", label = "Upload Excel:", 
           accept="application/vnd.ms-excel"), 
        actionButton("go","Go!"), 
        downloadButton('downloadData', 'Download') 
       ), 

        # Show a plot of the generated distribution 
        mainPanel(
        tabsetPanel(
         tabPanel("summary", tableOutput("summary1")), 
         tabPanel("Curve", plotlyOutput("curve1")) 
        ) 
       ) 
       ) 
      ) 
    ) 
    ) 
), 
    skin = "purple" 
) 
) 
} 

ui = (htmlOutput("page")) 
server = (function(input, output,session) { 

USER <- reactiveValues(Logged = Logged) 

observe({ 
if (USER$Logged == FALSE) { 
    if (!is.null(input$Login)) { 
    if (input$Login > 0) { 
     Username <- isolate(input$userName) 
     Password <- isolate(input$passwd) 
     Id.username <- which(my_username == Username) 
     Id.password <- which(my_password == Password) 
     if (length(Id.username) > 0 & length(Id.password) > 0) { 
     if (Id.username == Id.password) { 
      USER$Logged <- TRUE 
     } 
     } 
    } 
    } 
}  
}) 
observe({ 
if (USER$Logged == FALSE) { 

    output$page <- renderUI({ 
    div(class="outer",do.call(bootstrapPage,c("",ui1()))) 
    }) 
} 
if (USER$Logged == TRUE) 
{ 
    output$page <- renderUI({ 
    div(class="outer",do.call(navbarPage,c(inverse=TRUE,ui2()))) 
    }) 
} 
}) 
}) 

runApp(list(ui = ui, server = server)) 

ページは次のようにする必要があります: enter image description here

このような未: enter image description here

答えて

0

navbarPage機能を使用するので、最初の引数としてtitleを期待します2つの引数しかなく、1つの引数がすでに識別されている場合、navbarPageui2()という関数をタイトルとして取ります。

だけ

div(class="outer",do.call(navbarPage,c(title = "MY Web APP", inverse=TRUE,ui2())))

+0

div(class="outer",do.call(navbarPage,c(inverse=TRUE,ui2())))

を変更するには、あなたにたくさんありがとうございました。それは動作しますが、ページの色はアップロードした最初のイメージとは異なります。なぜなのかご存知ですか? – ghoost2010

+0

問題は、そのメソッドを使用してダッシュボードページを読み込むと、本体に 'class =" skin-purple "属性がないことです。別のログインオプションを使用することを検討する必要があります。 – Geovany

+0

別のログインオプションの使用についてご提案ありますか? – ghoost2010

関連する問題