-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integración de cambios en ixplorer.es
- Loading branch information
Showing
56 changed files
with
5,520 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
Meta | ||
doc | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Session Data files | ||
.RData | ||
# Example code in package build process | ||
*-Ex.R | ||
# Output files from R CMD build | ||
/*.tar.gz | ||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
# RStudio files | ||
.Rproj.user/ | ||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
# knitr and R markdown default cache directories | ||
/*_cache/ | ||
/cache/ | ||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
.Rproj.user | ||
inst/doc | ||
.Renviron | ||
.gitignore | ||
.gitignore | ||
.ixplorer* | ||
Meta | ||
doc | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Session Data files | ||
.RData | ||
# Example code in package build process | ||
*-Ex.R | ||
# Output files from R CMD build | ||
/*.tar.gz | ||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
# RStudio files | ||
.Rproj.user/ | ||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
# knitr and R markdown default cache directories | ||
/*_cache/ | ||
/cache/ | ||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
.Rproj.user | ||
inst/doc | ||
.Renviron | ||
.gitignore | ||
|
||
.ixplorer* | ||
.ixplorer | ||
|
||
|
||
temp.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,100 @@ | ||
#' @import shiny | ||
#' @import miniUI | ||
NULL | ||
|
||
#' Authenticate to ixplorer | ||
#' | ||
#' Make the connection to your repository through the ixplorer gadget and be | ||
#' able to create tickets, review tickets without re-writing your credentials | ||
#' | ||
#' @export | ||
add_token <- function() { | ||
|
||
ui <- miniPage( | ||
gadgetTitleBar("ixplorer authentication", | ||
left = miniTitleBarCancelButton(inputId = "cancel", | ||
label = "Cancel", | ||
primary = FALSE), | ||
right = miniTitleBarButton(inputId = "done", | ||
label = "Done", | ||
primary = TRUE)), | ||
|
||
miniContentPanel( | ||
|
||
textInput(inputId = "ixplorer_token", | ||
label = "API token", | ||
width = "100%", | ||
placeholder = "Paste your ixplorer token here"), | ||
|
||
textInput(inputId = "ixplorer_url", | ||
label = "ixplorer url", | ||
width = "100%", | ||
placeholder = "Paste your ixplorer url here"), | ||
|
||
textInput(inputId = "ixplorer_project_name", | ||
label = "Name of the upstream project", | ||
width = "100%", | ||
placeholder = "Paste your ixplorer upstream project name here"), | ||
|
||
textInput(inputId = "ixplorer_repo_name", | ||
label = "ixplorer repository name", | ||
width = "100%", | ||
placeholder = "Paste your ixplorer repository name here"), | ||
|
||
textInput(inputId = "ixplorer_user_name", | ||
label = "Your ixplorer user name", | ||
width = "100%", | ||
placeholder = "Paste your ixplorer user name here"), | ||
|
||
checkboxInput(inputId = "token_persist", | ||
value = 0, | ||
label = "Persist token? (do no use on shared computer)", | ||
width = "100%" | ||
) | ||
|
||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
|
||
observeEvent(input$done, { | ||
|
||
Sys.setenv("IXTOKEN" = input$ixplorer_token) | ||
Sys.setenv("IXURL" = input$ixplorer_url) | ||
Sys.setenv("IXPROJECT" = input$ixplorer_project_name) | ||
Sys.setenv("IXREPO" = input$ixplorer_repo_name) | ||
Sys.setenv("IXUSER" = input$ixplorer_user_name) | ||
|
||
token <- paste0("IXTOKEN=", input$ixplorer_token) | ||
url <- paste0("IXURL=", input$ixplorer_url) | ||
project <- paste0("IXPROJECT=", input$ixplorer_project_name) | ||
repo <- paste0("IXREPO=", input$ixplorer_repo_name) | ||
user <- paste0("IXUSER=", input$ixplorer_user_name) | ||
|
||
access_data <- c(token, url, project, repo, user) | ||
|
||
if (input$token_persist == 1) { | ||
working_directory <- rstudioapi::getActiveProject() | ||
ixplorer_file <- paste0(working_directory, "/.ixplorer") | ||
conn <- file(ixplorer_file, open = "w") | ||
writeLines(access_data, con = conn, sep = "\n", useBytes = FALSE) | ||
close(conn) | ||
|
||
gitignore <- paste0(working_directory, "/.gitignore") | ||
if (file.exists(gitignore)) { | ||
conn <- file(gitignore) | ||
archivos_ignorados <- readLines(conn) | ||
writeLines(c(archivos_ignorados,".ixplorer"), conn) #lo sobre escribe | ||
close(conn) | ||
} else { | ||
conn <- file(gitignore, open = "w") | ||
writeLines(".ixplorer", con = conn, sep = "\n", useBytes = FALSE) | ||
close(conn) | ||
} | ||
|
||
} | ||
stopApp(NULL) | ||
}) | ||
|
||
observeEvent(input$cancel, { | ||
# do nothing | ||
stopApp(NULL) | ||
}) | ||
} | ||
|
||
runGadget(ui, server, viewer = dialogViewer("ixplorer")) | ||
} | ||
#' @import shiny | ||
#' @import miniUI | ||
NULL | ||
|
||
#' @title Autentificación en ixplorer | ||
#' @description Guarda en su computadora por medio del sistema de | ||
#' autentificación del OS de su computadora. | ||
#' | ||
#' @details En caso de que los credenciales ya existan solo se ingresa el url | ||
#' y se confirma si quiere conservar los credenciales en su computador o quiere | ||
#' borrarlos luego de la siguiente consulta. | ||
#' | ||
#' @export | ||
add_token <- function() { | ||
|
||
ui <- miniPage( | ||
gadgetTitleBar("Autentificación en ixplorer", | ||
left = miniTitleBarCancelButton(inputId = "cancel", | ||
label = "Cancelar", | ||
primary = FALSE), | ||
right = miniTitleBarButton(inputId = "done", | ||
label = "Listo", | ||
primary = TRUE)), | ||
miniContentPanel( | ||
textInput(inputId = "ixplorer_url", | ||
label = "URL de ixplorer", | ||
width = "100%", | ||
placeholder = "Copie su ixplorer URl aquí."), | ||
uiOutput("token_user"), | ||
checkboxInput(inputId = "token_persist", | ||
value = 1, | ||
label = "Persistencia de las credenciales en este computador. (No usar en computadoras compartidas)", | ||
width = "100%" | ||
) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
|
||
output$token_user <- renderUI({ | ||
req(input$ixplorer_url) | ||
|
||
instancia <- sub("\\..*", "", input$ixplorer_url) | ||
|
||
verifica_cred <- tryCatch( | ||
keyring::key_get(paste0("token_", instancia)), | ||
error = function(cond) "no_credenciales") | ||
|
||
if(verifica_cred == "no_credenciales") { | ||
div(textInput(inputId = "ixplorer_token", | ||
label = "Token de acceso", | ||
width = "100%", | ||
placeholder = "Ingrese su Token de acceso aquí"), | ||
textInput(inputId = "ixplorer_user_name", | ||
label = "Su nombre de usuario.", | ||
width = "100%", | ||
placeholder = "Ingrese su nombre de usuario aquí.")) | ||
} | ||
|
||
}) | ||
|
||
observeEvent(input$done, { | ||
|
||
instancia <- sub("\\..*", "", input$ixplorer_url) | ||
|
||
verifica_cred <- tryCatch( | ||
keyring::key_get(paste0("token_", instancia)), | ||
error = function(cond) "no_credenciales") | ||
|
||
|
||
if(verifica_cred == "no_credenciales") { | ||
|
||
if(is.null(input$ixplorer_url) == FALSE | | ||
is.null(input$ixplorer_token) == FALSE | | ||
is.null(input$ixplorer_user_name) == FALSE) { | ||
|
||
keyring::key_set_with_value( | ||
service = paste0("token_", instancia), | ||
password = paste(input$ixplorer_url, | ||
input$ixplorer_token, | ||
input$ixplorer_user_name, | ||
input$token_persist, | ||
sep = "/")) | ||
} | ||
|
||
} else { | ||
|
||
} | ||
|
||
stopApp(TRUE) | ||
}) | ||
|
||
observeEvent(input$cancel, { | ||
# do nothing | ||
stopApp(TRUE) | ||
}) | ||
} | ||
|
||
runGadget(ui, server, viewer = dialogViewer("ixplorer")) | ||
} |
Oops, something went wrong.