diff --git a/app/app.R b/app/app.R index 1c9f8b8..991c93e 100644 --- a/app/app.R +++ b/app/app.R @@ -5,6 +5,7 @@ library(ggplot2) library(plotly) library(DT) library(shinyjs) +library(leaflet) #source(".R/home_module.R",encoding="utf-8") #source(".R/about_module.R",encoding="utf-8") diff --git a/app/firmy_module.R b/app/firmy_module.R index d988eb9..91c2796 100644 --- a/app/firmy_module.R +++ b/app/firmy_module.R @@ -27,18 +27,20 @@ firmyUI <- function(id) { fluidRow( column(12, align="center", - h1('Firmy') - ) - ), - - fluidRow(column(4, - div(div("GlaxoSmithKline"),img(src="gsk.png", a("GlaxoSmithKline" ,href= "https://pl.gsk.com/pl/"),height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile'), - column(4, - div(div("Bayer"),img(src="bayer.png", a("Bayer",href="https://www.bayer.com/pl/pl/poland-home"), height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile'), - column(4, - div(div("BioFarm"),img(src="biofarm.png", a("BioFarm",href= "https://www.biofarm.pl"),height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile') - ) %>% tagAppendAttributes(id = 'row-tiles'), + )), + uiOutput("firms"), + + + + # fluidRow(column(4, + # div(div("GlaxoSmithKline"),img(src="gsk.png", a("GlaxoSmithKline" ,href= "https://pl.gsk.com/pl/"),height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile'), + # column(4, + # div(div("Bayer"),img(src="bayer.png", a("Bayer",href="https://www.bayer.com/pl/pl/poland-home"), height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile'), + # column(4, + # div(div("BioFarm"),img(src="biofarm.png", a("BioFarm",href= "https://www.biofarm.pl"),height = 150, width = 150)))%>% tagAppendAttributes(class = 'column-tile') + # + # ) %>% tagAppendAttributes(id = 'row-tiles'), @@ -52,8 +54,81 @@ firmyUI <- function(id) { ) } -firmyServer <- function(input, output) { +firmyServer <- function(input, output,session) { + observe({ + + if(get_page()=="firms"){ + run = paste('Shiny.onInputChange("pageFIRMS","',timestamp(),'");',sep="") + shinyjs::runjs(run) + + }}) + componentFirms<-eventReactive(input$pageFIRMS,{ + + + r<-httr::GET("http://localhost:8080/api/firms/all",encode = 'json') + + r + + }) + + output$firms<-renderUI({ + r<-componentFirms() + # if(length(input$currentPage)!=0 && input$currentPage=="firms"){ + # r<-httr::GET("http://localhost:8080/api/companies/all",add_headers(Authorization=paste("Bearer",input$token,sep=" ")),encode = 'json') + companies = content(r)$companies + # print(content(r)) + for(i in companies){ + print(i) + } + + exampleMap1 = leaflet() %>% + setView(companies[[1]]$companyData$latitude, companies[[1]]$companyData$longitude, zoom = 16) %>% + addTiles() %>% + addMarkers(companies[[1]]$companyData$latitude, companies[[1]]$companyData$longitude, popup = "PoznaÅ„") + + exampleMap2 = leaflet() %>% + setView(companies[[2]]$companyData$latitude, companies[[2]]$companyData$longitude, zoom = 16) %>% + addTiles() %>% + addMarkers(companies[[2]]$companyData$latitude, companies[[2]]$companyData$longitude, popup = "PoznaÅ„") + # + exampleMap3 = leaflet() %>% + setView(companies[[3]]$companyData$latitude, companies[[3]]$companyData$longitude, zoom = 16) %>% + addTiles() %>% + addMarkers(companies[[3]]$companyData$latitude, companies[[3]]$companyData$longitude, popup = "PoznaÅ„") + + fluidRow( + column(12, + + wellPanel(column(2,img(src="gsk.png", height = 150, width = 150)), + column(6, + h2(companies[[1]]$companyData$name), + h3(companies[[1]]$companyData$email), + h3(companies[[1]]$companyData$address)), + column(4,exampleMap1)), + wellPanel(column(2,img(src="bayer.png", height = 150, width = 150)), + column(6, + h2(companies[[2]]$companyData$name), + h3(companies[[2]]$companyData$email), + h3(companies[[2]]$companyData$address)), + column(4,exampleMap2)), + wellPanel(column(2,img(src="biofarm.png", height = 150, width = 150)), + column(6, + h2(companies[[3]]$companyData$name), + h3(companies[[3]]$companyData$email), + h3(companies[[3]]$companyData$address)), + column(4,exampleMap3)), + + + + )%>% tagAppendAttributes(id = 'column-firms') + + ) %>% tagAppendAttributes(id = 'row-firms') + # actionButton("asdasdasd","asd") + + # } + + }) } diff --git a/app/klasyfikator.R b/app/klasyfikator.R index 3b92b26..c5f982b 100644 --- a/app/klasyfikator.R +++ b/app/klasyfikator.R @@ -68,7 +68,7 @@ klasyserver <- function(input, output,session) { g=ggplot(d, aes(x,y,fill=x))+ geom_col()+ - labs(x="",y="Prawdopodobieñstwo [%]") + labs(x="",y="PrawdopodobieÅ„stwo [%]") ggplotly(g) diff --git a/app/routing_module.R b/app/routing_module.R index 450c2b4..37e0a27 100644 --- a/app/routing_module.R +++ b/app/routing_module.R @@ -34,7 +34,7 @@ router <- make_router( route("register", register_page,registerServer), route("calculator", calculator_page, calculatorServer), route("iota", calculatorView_page, calculatorViewServer), - route("firms", firmy_page, firmyServer) + route("firms", firmy_page, firmyServer), route("klasyfikator",klas_page,klasyserver) ) diff --git a/app/www/style.css b/app/www/style.css index 7d1fa78..ba65840 100644 --- a/app/www/style.css +++ b/app/www/style.css @@ -408,6 +408,37 @@ table.dataTable th{ display:none!important; } +#firms{ + background-color: #C7F9CC; +} + +#column-firms > .well{ + + display:flex; + flex-direction:row; + + flex-wrap:wrap; + box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25), -2px -2px 4px rgba(0, 0, 0, 0.25); + #background-color:#00A896!important; +} + +#column-firms > .well >div:nth-child(2){ + #height:100%; + border-right:1.5px dashed #00A896; + border-left:1.5px dashed #00A896; +} +#column-firms > .well >div{ + padding-left:15px; + padding-right:15px; +} +#column-firms > .well div{ + + display:flex!important; + align-items:center; + justify-content:center; + + +} @media only screen and (max-width: 767px) { body >.container-fluid{ diff --git a/backend/src/main/java/project/config/SecurityConfiguration.java b/backend/src/main/java/project/config/SecurityConfiguration.java index 24d3ab6..61a13a6 100644 --- a/backend/src/main/java/project/config/SecurityConfiguration.java +++ b/backend/src/main/java/project/config/SecurityConfiguration.java @@ -60,6 +60,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers("/profile**").hasAnyAuthority("COMP","IND") .antMatchers("/login").anonymous() .antMatchers("/register").anonymous() + .antMatchers("/firms/all").anonymous() .and() .formLogin() .loginPage("/login") diff --git a/backend/src/main/java/project/controllers/CompanyProfileController.java b/backend/src/main/java/project/controllers/CompanyProfileController.java index bd77d72..2c1a654 100644 --- a/backend/src/main/java/project/controllers/CompanyProfileController.java +++ b/backend/src/main/java/project/controllers/CompanyProfileController.java @@ -6,7 +6,9 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; +import project.DTO.CompanyProfileDTO; import project.DTO.PredictionDTO; +import project.model.CompanyProfile; import project.services.CompanyProfileService; import project.services.GeneratorDTO; @@ -14,7 +16,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @RestController @@ -27,15 +31,22 @@ public class CompanyProfileController { private GeneratorDTO generatorDTO; - + @PreAuthorize("isAnonymous()") @RequestMapping(value = "/all",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity> getAllCompanies(HttpServletRequest request, HttpServletResponse httpServletResponse){ Map map = new HashMap<>(); +// map.put("companies",new Integer(1)); +// return new ResponseEntity<>(map, HttpStatus.OK); try{ - map.put("companies",companyProfileService.getAllCompanies()); + List companyProfileDTOS = new ArrayList<>(); + for (CompanyProfile cp:companyProfileService.getAllCompanies()) { + companyProfileDTOS.add(generatorDTO.generateCompanyProfileDTO(cp)); + + } + map.put("companies",companyProfileDTOS); return new ResponseEntity<>(map, HttpStatus.OK); }catch(Exception e){ map.put("companies",null); diff --git a/backend/src/main/java/project/services/CompanyProfileServiceImpl.java b/backend/src/main/java/project/services/CompanyProfileServiceImpl.java index 081ac24..a277b71 100644 --- a/backend/src/main/java/project/services/CompanyProfileServiceImpl.java +++ b/backend/src/main/java/project/services/CompanyProfileServiceImpl.java @@ -44,6 +44,7 @@ public class CompanyProfileServiceImpl implements CompanyProfileService { @Override public List getAllCompanies() { + System.out.println(companyProfileRepository.findAll().size()); return companyProfileRepository.findAll(); } // @Override