Skip to content

Commit

Permalink
✨ : new stack
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Jul 5, 2019
1 parent 5e2e310 commit c444026
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/main/java/io/codeka/gaia/config/RepositoryConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import io.codeka.gaia.bo.Job;
import io.codeka.gaia.bo.Stack;
import io.codeka.gaia.repository.StackRepositoryEventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;

Expand All @@ -12,6 +14,10 @@ public class RepositoryConfig {
@Autowired
public void configureRest(RepositoryRestConfiguration repositoryRestConfiguration){
repositoryRestConfiguration.exposeIdsFor(Stack.class, Job.class);
}

@Bean
StackRepositoryEventHandler stackRepositoryEventHandler(){
return new StackRepositoryEventHandler();
}
}
6 changes: 6 additions & 0 deletions src/main/java/io/codeka/gaia/controller/StackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public StackController(StackRepository stackRepository, StackRunner stackRunner,
this.jobRepository = jobRepository;
}

@GetMapping("/modules/{moduleId}/run")
public String newStack(@PathVariable String moduleId, Model model){
model.addAttribute("moduleId", moduleId);
return "new_stack";
}

@GetMapping("/stacks")
public String listStacks(){
return "stacks";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.web.bind.annotation.PostMapping;

@Controller
@Secured("ROLE_ADMIN")
public class TerraformModuleController {

private TerraformModuleRepository terraformModuleRepository;
Expand All @@ -29,12 +28,14 @@ public String modulesList(Model model){
return "modules";
}

@Secured("ROLE_ADMIN")
@GetMapping("/modules/{id}")
public String module(@PathVariable String id, Model model){
model.addAttribute("module", terraformModuleRepository.findById(id).orElseThrow());
return "module";
}

@Secured("ROLE_ADMIN")
@PostMapping("/modules/{id}")
public String saveModule(@ModelAttribute TerraformModule module, Model model){
terraformModuleRepository.save(module);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.codeka.gaia.repository;

import io.codeka.gaia.bo.Stack;
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;

import java.util.UUID;

@RepositoryEventHandler
public class StackRepositoryEventHandler {

@HandleBeforeCreate
public void handleStackCreate(Stack stack){
// generate an id for new stacks
if(stack.getId() == null){
stack.setId(UUID.randomUUID().toString());
}
}
}
153 changes: 153 additions & 0 deletions src/main/resources/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3416,3 +3416,156 @@ code[class*="language-"] b {
margin-top: 0;
margin-left: -1.5rem;
}

/*------------------------------------------------------------------
29. Custom style for wizard
-------------------------------------------------------------------*/

.wizard {
margin: 20px auto;
background: #fff;
width:100%;
}

.wizard .nav-tabs {
position: relative;
margin-bottom: 0;
border-bottom-color: #e0e0e0;
}

.wizard > div.wizard-inner {
position: relative;
}

.connecting-line {
height: 2px;
background: #e0e0e0;
position: absolute;
width: 66%;
margin: 0 auto;
left: 0;
right: 0;
top: 50%;
z-index: 1;
}

.wizard .nav-tabs > li.active > a,
.wizard .nav-tabs > li.active > a:hover,
.wizard .nav-tabs > li.active > a:focus {
color: #555555;
cursor: default;
border: 0;
border-bottom-color: transparent;
}

span.round-tab {
width: 70px;
height: 70px;
line-height: 70px;
display: inline-block;
border-radius: 100px;
background: #fff;
border: 2px solid #e0e0e0;
z-index: 2;
position: absolute;
left: 0;
text-align: center;
font-size: 25px;
}

span.round-tab i {
color: #555555;
}

.wizard li a.active span.round-tab {
background: #fff;
border: 2px solid #5bc0de;

}

.wizard li a.active span.round-tab i {
color: #5bc0de;
}

span.round-tab:hover {
color: #333;
border: 2px solid #333;
}

.wizard .nav-tabs > li {
width: 33%;
}

.wizard li a:after {
content: " ";
position: relative;
left: 46%;
top: -20px;
opacity: 0;
margin: 0 auto;
bottom: 0px;
border: 5px solid transparent;
border-bottom-color: #5bc0de;
transition: 0.1s ease-in-out;
}

.wizard li.active.nav-item:after {
content: " ";
position: relative;
left: 46%;
top: -20px;
opacity: 1;
margin: 0 auto;
bottom: 0px;
border: 10px solid transparent;
border-bottom-color: #5bc0de;
}

.wizard .nav-tabs > li a {
width: 70px;
height: 70px;
margin: 20px auto;
border-radius: 100%;
padding: 0;
position: relative;
display: block;
}

.wizard .nav-tabs > li a:hover {
background: transparent;
}

.wizard .tab-pane {
position: relative;
}

.wizard h3 {
margin-top: 0;
}

@media( max-width: 585px) {

.wizard {
width: 90%;
height: auto !important;
}

span.round-tab {
font-size: 16px;
width: 50px;
height: 50px;
line-height: 50px;
}

.wizard .nav-tabs > li a {
width: 50px;
height: 50px;
line-height: 50px;
}

.wizard li.active:after {
content: " ";
position: absolute;
left: 35%;
}
}
9 changes: 7 additions & 2 deletions src/main/resources/templates/layout/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<html xmlns:th="http://www.thymeleaf.org/"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<!-- Sidebar -->
<nav id="sidebar">
<div class="sidebar_blog_1">
Expand All @@ -21,10 +24,12 @@ <h6>Gaia</h6>
<h4>Menu</h4>
<ul class="list-unstyled components">
<li class="active"><a href="/" ><i class="fas fa-tachometer-alt yellow_color"></i> <span>Dashboard</span></a></li>
<li sec:authorize="hasRole('ADMIN')"><a href="/modules"><i class="fa fa-object-group blue1_color"></i> <span>Modules</span></a></li>
<li><a href="/modules"><i class="fa fa-object-group blue1_color"></i> <span>Modules</span></a></li>
<li><a href="/stacks"><i class="fas fa-layer-group blue2_color"></i> <span>Stacks</span></a></li>
<li sec:authorize="hasRole('ADMIN')"><a href="/settings"><i class="fa fa-cog yellow_color"></i> <span>Settings</span></a></li>
</ul>
</div>
</nav>
<!-- end sidebar -->
<!-- end sidebar -->

</html>
6 changes: 3 additions & 3 deletions src/main/resources/templates/modules.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head th:replace="layout/header :: header(~{::title})">

<title>Gaia - Modules</title>
Expand Down Expand Up @@ -33,8 +33,8 @@ <h2>Modules</h2>
<div class="card-body">
<h5 class="card-title" th:text="${module.name}">Card title</h5>
<p class="card-text" th:text="${module.description}">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" th:href="@{/modules/{moduleId}(moduleId=${module.id})}" data-toggle="tooltip" title="Edit this module" class="btn btn-primary"><i class="far fa-edit"></i></a>
<a href="#" th:href="@{/modules/{moduleId}/instanciate(moduleId=${module.id})}" class="btn btn-primary"><i class="fas fa-rocket"></i></a>
<a href="#" sec:authorize="hasRole('ADMIN')" th:href="@{/modules/{moduleId}(moduleId=${module.id})}" data-toggle="tooltip" title="Edit this module" class="btn btn-primary"><i class="far fa-edit"></i></a>
<a href="#" th:href="@{/modules/{moduleId}/run(moduleId=${module.id})}" data-toggle="tooltip" title="Run this module" class="btn btn-primary"><i class="fas fa-rocket"></i></a>
</div>
</div>

Expand Down
Loading

0 comments on commit c444026

Please sign in to comment.