diff --git a/inst/application/src/server/01_set_read_data.R b/inst/application/src/server/01_set_read_data.R index a5551bf..4323498 100644 --- a/inst/application/src/server/01_set_read_data.R +++ b/inst/application/src/server/01_set_read_data.R @@ -43,7 +43,7 @@ rdsData <- reactive({ output$directory_message <- renderText({ if(length(input$directory) > 0){ if(input$directory == 0){ - antaresViz:::.getLabelLanguage("Or choose a folder with antares output", current_language$language) + antaresViz:::.getLabelLanguage("Choose a folder with antares output", current_language$language) } else { antaresViz:::.getLabelLanguage("No antares output found in directory", current_language$language) } @@ -110,7 +110,9 @@ observe({ }) # init opts after validation -opts <- reactive({ +opts <- reactiveVal(NULL) + +observe({ if(input$init_sim > 0){ opts <- tryCatch({ @@ -120,7 +122,7 @@ opts <- reactive({ title = "Error setting file", easyClose = TRUE, footer = NULL, - paste("Directory/file is not an Antares study : ", e, sep = "\n") + paste("Directory/file is not an Antares study : ", e$message, sep = "\n") )) NULL }) @@ -140,9 +142,37 @@ opts <- reactive({ } } } - opts + opts(opts) } else { - NULL + opts(NULL) + } +}) + +observe({ + if(input$init_sim_api > 0){ + opts <- + tryCatch({ + setSimulationPathAPI( + host = isolate(input$api_host), + study_id = isolate(input$api_study_id), + token = isolate(input$api_token), + simulation = isolate(input$api_simulation) + ) + }, error = function(e){ + showModal(modalDialog( + title = "Error reading API", + easyClose = TRUE, + footer = NULL, + e$message + )) + NULL + }) + if(!is.null(opts)){ + opts$h5 <- FALSE + } + opts(opts) + } else { + opts(NULL) } }) diff --git a/inst/application/src/server/08_language.R b/inst/application/src/server/08_language.R index ab5ee88..4c7e53b 100644 --- a/inst/application/src/server/08_language.R +++ b/inst/application/src/server/08_language.R @@ -118,6 +118,18 @@ observe({ # params updateCheckboxInput(session, "is_shared_input", antaresViz:::.getLabelLanguage("Share inputs between modules ?", current_language$language)) + # import type + cur_type_import <- isolate({input$type_import}) + choice <- c("local", "RDS", "API") + sel <- which(choice %in% cur_type_import) + names(choice) <- c( + antaresViz:::.getLabelLanguage("Local Antares Study", current_language$language), + antaresViz:::.getLabelLanguage("R file .RDS", current_language$language), + antaresViz:::.getLabelLanguage("API Antares", current_language$language) + ) + updateSelectInput(session, "type_import", + label = , + choices = choice, selected = choice[sel]) }) output$current_opts <- renderText({ diff --git a/inst/application/src/ui/01_ui_import_data.R b/inst/application/src/ui/01_ui_import_data.R index e53e54e..7018603 100644 --- a/inst/application/src/ui/01_ui_import_data.R +++ b/inst/application/src/ui/01_ui_import_data.R @@ -1,38 +1,74 @@ tabPanel(textOutput("label_tab_import_data"), - h3(textOutput("title_import_data")), fluidRow( - column(4, - fileInput("fileRDS", - label = NULL, - # antaresViz:::.getLabelLanguage("Choose rds File who contains antares data"), - accept = ".rds", width = "100%")), - column(8, - h3(textOutput("directory_message2"), style = "color : red;margin-top:0px") + column(6, h3(textOutput("title_import_data"))), + column(6, + selectInput("type_import", "", + choices = c("Etude Antares locale" = "local", "Fichier R .RDS" = "RDS", "API Antares" = "API"), width = "100%") ) ), - fluidRow( - column(4, - directoryInput('directory', label = '', value = 'C:\\Users\\Datastorm\\Documents\\git\\bpNumerique2018\\inst\\application_bp\\data') - ), - conditionalPanel(condition = "output.ctrl_is_antares_study | output.ctrl_is_antares_h5", - column(1, - div(br(), h4("Simulation : "), align = "center") + + conditionalPanel(condition = "input.type_import === 'RDS'", + fluidRow( + column(4, + fileInput("fileRDS", + label = NULL, + # antaresViz:::.getLabelLanguage("Choose rds File who contains antares data"), + accept = ".rds", width = "100%")), + column(8, + h3(textOutput("directory_message2"), style = "color : red;margin-top:0px") + ) + ) + ), + + conditionalPanel(condition = "input.type_import === 'local'", + fluidRow( + column(4, + directoryInput('directory', label = '', value = 'C:\\Users\\Datastorm\\Documents\\git\\bpNumerique2018\\inst\\application_bp\\data') + ), + conditionalPanel(condition = "output.ctrl_is_antares_study | output.ctrl_is_antares_h5", + column(1, + div(br(), h4("Simulation : "), align = "center") + ), + column(4, + selectInput("study_path", "", choices = NULL, selected = NULL, width = "100%") + ), + column(2, + div(br(), + actionButton("init_sim", "Set simulation", icon = icon("check-circle")), + align = "center" + ) + ) + ), + conditionalPanel(condition = "output.ctrl_is_antares_study === false & output.ctrl_is_antares_h5 === false", + column(8, + h3(textOutput("directory_message"), style = "color : red") + ) + ) + ) + ), + + conditionalPanel(condition = "input.type_import === 'API'", + fluidRow( + column(3, + textInput('api_host', label = 'Host :', value = '') + ), + column(3, + textInput('api_study_id', label = 'Study id :', value = '') ), column(4, - selectInput("study_path", "", choices = NULL, selected = NULL, width = "100%") + textInput('api_token', label = 'Token :', value = '', width = "100%") + ), + column(1, + numericInput('api_simulation', label = 'simulation :', value = 1, min = 1, step = 1) ), - column(2, + column(1, div(br(), - actionButton("init_sim", "Set simulation", icon = icon("check-circle")), + actionButton("init_sim_api", "Go!", + icon = icon("check-circle"), style = "margin-top:5px"), align = "center" ) ) - ), - conditionalPanel(condition = "output.ctrl_is_antares_study === false & output.ctrl_is_antares_h5 === false", - column(8, - h3(textOutput("directory_message"), style = "color : red") - ) - ) + ) ), conditionalPanel(condition = "output.have_study", @@ -136,14 +172,14 @@ tabPanel(textOutput("label_tab_import_data"), ) ), - fluidRow( - column(3, - h4(textOutput("title_hvdc")) - - ), - - - column(9, selectInput("hvdc", "hvdc", choices = NULL, selected = NULL, multiple = TRUE))), + fluidRow( + column(3, + h4(textOutput("title_hvdc")) + + ), + + + column(9, selectInput("hvdc", "hvdc", choices = NULL, selected = NULL, multiple = TRUE))), div(actionButton("import_data", "Validate & import data", icon = icon("upload")), align = "center"), # convert h5 @@ -248,7 +284,7 @@ tabPanel(textOutput("label_tab_import_data"), ), - + fluidRow( column(12, div(actionButton("write_h5", "Convert study to h5", icon = icon("floppy-o")), align = "center") ) diff --git a/inst/language_labels.csv b/inst/language_labels.csv index f1d3e19..1d8815a 100644 --- a/inst/language_labels.csv +++ b/inst/language_labels.csv @@ -132,7 +132,7 @@ No data imported;Pas de données importées No areas imported;Pas noeuds importés No links imported;Pas de liens importés No antares output found in directory;Pas d'étude(s) antares trouvée(s) dans le répertoire -Or choose a folder with antares output; Ou sélectionner un répertoire contenant des études antares +Choose a folder with antares output; Sélectionner un répertoire contenant des études antares Please set or import a map layout before;Editer ou importer le positionnement des points Download Layout;Télécharger le positionnement Import a layout;Importer un positionnement @@ -157,3 +157,6 @@ Choose rds File who contains antares data;Choisir un fichier .RDS avec des donn Hvdc areas;Zones Hvdc updateLegendOnMouseOver;Maj légende par survol closePopupOnClick;Fermer les popups à chaque clic +Local Antares Study;Etude Antares locale +R file .RDS;Fichier R .RDS +API Antares;API Antares \ No newline at end of file