-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix typo in user msg - set new timeout - fixed upload fcts
- Loading branch information
CIP-RIU
committed
Jan 24, 2019
1 parent
5f48dea
commit 5094439
Showing
5 changed files
with
238 additions
and
176 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
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ check_fbapp <- function(dfr){ | |
|
||
|
||
if(nrow(dfr)==0){ | ||
msg <- paste("There are not changes in the dataset") | ||
msg <- paste("There have been no changes in the dataset") | ||
status <- "error" | ||
} else if(!is.element("plot_id", fb_headers)){ #Check #1 | ||
msg <- paste("The variable 'plot_id' is missing. Must be included in order to upload into the database") | ||
|
@@ -39,18 +39,53 @@ check_fbapp <- function(dfr){ | |
msg <- paste("The variable(s)", non_found, "was (were) not found in the database. Refine your file before processing.") | ||
status <- "error" | ||
} else { #Check #3 | ||
msg <- paste("Dataset successfully uploaded in SweetPotatoBase!") | ||
msg <- paste("Great! Dataset successfully uploaded in SweetPotatoBase. ") | ||
status <- "success" | ||
} | ||
|
||
out<- list(msg= msg, status=status) | ||
|
||
} | ||
|
||
# | ||
# | ||
# check_upload <- function(){ | ||
# | ||
# | ||
# | ||
# } | ||
|
||
|
||
#' Check credentials from sweetpotatobase users. | ||
#' | ||
#' @param dbname character Database name. Currently, it only works with SOL genomics databases. | ||
#' @param user character User name | ||
#' @param password character Password | ||
#' @param urltoken character \code{BRAPI} call URL to login in Sol Genomic databases. | ||
# | ||
#' @description FieldbookApp data is captured by mobiles phones or tablets. After exporting this information, it should be read in R | ||
#' in order to process, check and curate. | ||
#' @author Omar Benites | ||
#' @export | ||
#' | ||
check_credentials <- function(dbname= "sweetpotatobase", user="obenites", password="dasdfsdgs", | ||
urltoken= "sgn:[email protected]/brapi/v1/token"){ | ||
|
||
white_list <- brapi::ba_db() | ||
con <- white_list[[dbname]] #get list | ||
con[["user"]] <- user | ||
con[["password"]] <- password | ||
dat<- data.frame(username = con$user, password = con$password, | ||
grant_type = "password", client_id = "", stringsAsFactors = FALSE) | ||
jsondat <- RJSONIO::toJSON(dat) | ||
callurl <- urltoken | ||
resp <- httr::POST(url = callurl, | ||
body = dat, | ||
encode = ifelse(con$bms == TRUE, "json", "form")) | ||
xout <- httr::content(x = resp) | ||
|
||
code <- xout$metadata$status[[3]]$code %>% as.numeric() | ||
|
||
if(code==200){ | ||
msg <- paste("Login credentials are correct.") | ||
status <- "success" | ||
} else { | ||
msg <- paste("Login credentials are incorrect. Please try again.") | ||
status <- "error" | ||
} | ||
out<- list(msg= msg, status=status) | ||
} | ||
|
Oops, something went wrong.