Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

Edit contents of Modal popup in R shiny

I would like to edit the contents of a modal popup in R shiny. Below is my code with which I'm able to print the values in the modal popup but I'm not able to edit it.

Server.R

modelnetlist <- function(failed = FALSE){
    netlistdata <- readLines('run.scs')
    splitText1 <- stringi::stri_split(str = netlistdata, regex = '\n')
    
    # wrap a paragraph tag around each element in the list
    replacedText1 <- lapply(splitText1, p)
    modalDialog(
      title = "Netlist File",
      replacedText1,
      easyClose = FALSE,
      footer = tagList(
        modalButton("Close"),
        actionButton("save", "Save")
      )
    )

  }
  
  observeEvent(input$gennet, {
    
    showModal(modelnetlist())
  })

ui.R

options(shiny.maxRequestSize=100*1024^2)
ui <- dashboardPage(skin = "yellow",
                    dashboardHeader(title = "Modelling Automation"), 
                    dashboardSidebar(
                      sidebarMenu(
                        # Setting id makes input$tabs give the tabName of currently-selected tab
                        id = "tabs",
                        
                        menuItem("Data Processing", tabName = "DP", icon = icon("database"), startExpanded = TRUE,
                                 menuSubItem("Merge", tabName= "Merge"),
                                 menuSubItem("Data", tabName = "Data"),
                                 menuSubItem("Plot", tabName = "Plot", selected = TRUE),
                                 menuSubItem("Parameters", tabName = "Parameters")),
                        menuItem("Parameter Extraction", icon = icon("book-open"), tabName = "PE"),
                                  menuSubItem("Data Conversion", tabName = "DC"),
                                  menuSubItem("IPL Upload", tabName = "IPL"),
                                  menuSubItem("Netlist Spectre", tabName = "netlist"),
                                  menuSubItem("Spectre logs", tabName = "mylog"),
                                  menuSubItem("Parameter Fitting", tabName = "PF"),
                        
                        
                        menuItem("Model QA", tabName = "QA", icon = icon("angellist"))
                      ),
                      
                      textOutput("res")
                    ),
                    
                    dashboardBody(
                      tabItems(
                        tabItem("DP", "Dashboard tab content"),
                        #tabItem("PE", "Widgets tab content"),
                        tabItem("Merge", fileInput("mergefiles", "choose the files", accept = c(".txt"), multiple = TRUE), downloadButton("Download", label = "Merged File")),
                        tabItem("Data",
                                
                                mainPanel(div(style='overflow-x:scroll',tableOutput("txt"),tableOutput("filetable"),tableOutput("filetable1")))
                        ),
                        
                        tabItem("Plot",sidebarLayout(sidebarPanel(width=3,
                                                                  fileInput("datasets", "choose the files", accept = c(".txt",".esd"), multiple = TRUE),
                                                                  uiOutput("plotdata"),uiOutput("devicetype"), uiOutput("chip"),
                                                                  uiOutput("macro"),
                                                                  uiOutput("device"),fluidRow(column(5,uiOutput("minIT2")),column(5,uiOutput("maxIT2"))),
                                                                  fluidRow(column(5,uiOutput("temperature")), column(5,uiOutput("DCleakage"))),
                                                                  fluidRow(column(5,uiOutput("varx")),column(5,uiOutput("vary")))
                        ),
                        mainPanel(width=9,
                                  plotlyOutput("PLOT")))),
                        
                        tabItem("Parameters",tags$style(type="text/css",
                                  ".shiny-output-error { visibility: hidden; }",
                                 ".shiny-output-error:before { visibility: hidden; }"),
                                div(style="display:inline-block;width:32%;text-align: center;",actionButton("action", label = "Normalize")),
                                tabsetPanel(type="tabs",
                                            tabPanel("CV Table",div(style='overflow-x:scroll',dataTableOutput('DiodeCVTable')),fluidRow(column(5, actionButton("perimeterCV", label="Change Perimeter")),column(5, actionButton("changeCV", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicCV")),column(5,uiOutput("goldenchipCV"))),plotlyOutput("cvplot")),
                                            tabPanel("DC Table",div(style='overflow-x:scroll',dataTableOutput('DiodeDCTable')),fluidRow(column(5, actionButton("perimeterDC", label="Change Perimeter")),column(5, actionButton("changeDC", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicDC")),column(5,uiOutput("goldenchipDC"))),plotlyOutput("dcplot")),
                                            tabPanel("TLP Table",div(style='overflow-x:scroll',dataTableOutput('TLPTable')), fluidRow(column(5, actionButton("perimeterTLP", label="Change Perimeter")),column(5, actionButton("changeTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicTLP")),column(5,uiOutput("goldenchipTLP"))),plotlyOutput("tlpplot")),
                                            tabPanel("VFTLP Table",div(style='overflow-x:scroll',dataTableOutput('VFTLPTable')), fluidRow(column(5, actionButton("perimeterVFTLP", label="Change Perimeter")),column(5, actionButton("changeVFTLP", label = "Change Goldenchip"))),fluidRow(column(5, uiOutput("dynamicVFTLP")),column(5,uiOutput("goldenchipVFTLP"))), plotlyOutput("vftlpplot")))),
                        
                        tabItem("PE","Parameter Extraction Content"),
                        tabItem("DC",uiOutput("onedevice"),uiOutput('tabs'), 
                               
                                   conditionalPanel(condition="input.layer=='CV'", plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
                                #conditionalPanel(condition="input.layer=='CV 2'", plotlyOutput("plotcv2"),br(), tableOutput("device2cv")),
                               # conditionalPanel(condition="input.layer=='CV 3'", plotlyOutput("plotcv3"),br(), tableOutput("device2cv")),
                                conditionalPanel(condition="input.layer=='DC @ 25'", plotlyOutput("plotdc125"),br(), tableOutput("device1dc25")),
                                conditionalPanel(condition="input.layer=='DC @ -40'", plotlyOutput("plotdc140"),br(), tableOutput("device1dc40")),
                                conditionalPanel(condition="input.layer=='DC @ 125'", plotlyOutput("plotdc1125"),br(), tableOutput("device1dc125")),
                                conditionalPanel(condition="input.layer=='DC @ 150'", plotlyOutput("plotdc1150"),br(), tableOutput("device1dc150")),
                                conditionalPanel(condition="input.layer=='TLP'",fluidRow(column(3,uiOutput("stepcountTLP")), column(3, uiOutput("maxvoltageTLP")), column(3, uiOutput("VholdTLP")), downloadButton("DownloadTLP",label = "Download converted data")), plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
                               #conditionalPanel(condition="input.layer=='TLP 2'", plotlyOutput("plottlp2"),br(), tableOutput("device2tlp")),
                               
                                 conditionalPanel(condition="input.layer=='VFTLP'",fluidRow(column(3,uiOutput("stepcountVFTLP")), column(3, uiOutput("maxvoltageVFTLP")), column(3, uiOutput("VholdVFTLP"))), plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
                                
                                ),
                        tabItem("PF",  uiOutput('modelingtabs'),
                                conditionalPanel(condition="input.modtab=='CV'",tableOutput("modelingdevice1CV")),
                                conditionalPanel(condition= "input.modtab=='DC @ 25'", tableOutput("modelingdevice1DC25")),
                                conditionalPanel(condition= "input.modtab=='DC @ 40'", tableOutput("modelingdevice1DC40")),
                                conditionalPanel(condition= "input.modtab=='DC @ 125'", tableOutput("modelingdevice1DC125")),
                                conditionalPanel(condition= "input.modtab=='DC @ 150'", tableOutput("modelingdevice1DC150")),# plotlyOutput("plotcv1"),br(), tableOutput("device1cv")),
                                conditionalPanel(condition="input.modtab=='TLP'",tableOutput("modelingdevice1TLP")),# plotlyOutput("plottlp1"),br(), tableOutput("device1tlp")),
                                conditionalPanel(condition="input.modtab=='VFTLP'",tableOutput("modelingdevice1VFTLP"))#, plotlyOutput("plotvftlp1"),br(), tableOutput("device1vftlp"))
                        ),
                        tabItem("IPL", 
                                fluidRow(box(title = "Model Inputs", width = 8,
                                         fileInput("iplfile", "choose the IPL file", accept = c(".xlsx"), multiple = TRUE),
                                         column(3, uiOutput("modeltype")),
                                         column(3,uiOutput("modeldevtype")),
                                         column(3,uiOutput("modelpath")), 
                                         column(3, uiOutput("wrapperfile")),
                                         column(3,uiOutput("zapcon")), 
                                         column(3,uiOutput("polarity")),
                                         column(3,uiOutput("sectiontype")),
                                         column(3,uiOutput("designfile")), 
                                         column(3, uiOutput(&quo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In modalDialog function you can use almost any UI elements (see ... parameter)

modelnetlist <- function(failed = FALSE){
  netlistdata <- paste(readLines('run.scs'),collapse="
")
  modalDialog(
    title = "Netlist File",
    textAreaInput("theScript", value=netlistdata),
    easyClose = FALSE,
    footer = tagList(
      modalButton("Close"),
      actionButton("save", "Save")
    )
  )
}

and to get new script in the save button listener use input$theScript

observeEvent(input$save, {
  # do whatever you want with input$theScript
  if(isTruthy(input$theScript))
    writeLines(input$theScript, "run.scs")
})

Note: the path where you save file must be writeable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...