Commit 308a4ed5b838befa3278e325ee3cb58ab7d79bdf

Authored by Paul Brodner
1 parent 7fa6e71b7c
Exists in master

added environment files

src/main/java/org/alfresco/tasenvironment/AppRoutes.java
... ... @@ -35,6 +35,10 @@ public class AppRoutes
35 35 return indexController.addNew().toLayout();
36 36 }, new FreeMarkerEngine());
37 37  
  38 + get("/environment/delete/:id", (request, response) ->{
  39 + return indexController.deleteEnv(request).toLayout();
  40 + }, new FreeMarkerEngine());
  41 +
38 42 post("/environment/new", (request, response) -> {
39 43 ViewContainerHelper mv = indexController.create(request);
40 44 mv.addAttribute("response", response);
... ...
src/main/java/org/alfresco/tasenvironment/controller/IndexController.java
... ... @@ -33,10 +33,20 @@ public class IndexController
33 33  
34 34 public ViewContainerHelper create(Request request)
35 35 {
36   - Environment newEnv = environmentRepo.save(new Environment(request.queryParams("envName"), request.queryParams("envIP"), request.queryParams("envPort")));
  36 + Environment newEnv = environmentRepo
  37 + .save(new Environment(request.queryParams("envName"), request.queryParams("envIP"), request.queryParams("envPort")));
37 38  
38 39 ViewContainerHelper vc = new ViewContainerHelper("New Environment", "environment/response.ftl");
39 40 vc.addAttribute("object", newEnv);
40 41 return vc;
41 42 }
  43 +
  44 + public ViewContainerHelper deleteEnv(Request request)
  45 + {
  46 + Environment env =environmentRepo.findOne(request.params(":id"));
  47 + environmentRepo.delete(env);
  48 + ViewContainerHelper vc = new ViewContainerHelper("Delete Environment", "environment/delete.ftl");
  49 + vc.addAttribute("object", env);
  50 + return vc;
  51 + }
42 52 }
... ...
src/main/java/org/alfresco/tasenvironment/models/Environment.java
... ... @@ -10,7 +10,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
10 10 */
11 11 @Document(collection = "environments")
12 12 public class Environment
13   -{
  13 +{
14 14 @Id
15 15 private String id;
16 16  
... ... @@ -87,10 +87,10 @@ public class Environment
87 87 boolean isOnline = false;
88 88 try
89 89 {
90   - ServerHealth serverHealth = new ServerHealth();
91   - isOnline = serverHealth.isServerReachable(getIp(), Integer.valueOf(getPort()));
  90 + ServerHealth serverHealth = new ServerHealth();
  91 + isOnline = serverHealth.isServerReachable(getIp(), Integer.valueOf(getPort()));
92 92 }
93   - catch (Exception e)
  93 + catch (Exception e)
94 94 {
95 95 e.printStackTrace();
96 96 }
... ... @@ -103,11 +103,11 @@ public class Environment
103 103  
104 104 public String getOnlineIcon()
105 105 {
106   - return "<span class=\"glyphicon glyphicon-upload btn-success\" style=\"float:right\"></span>";
  106 + return "<span class=\"label label-success\"> Online</span>";
107 107 }
108 108  
109 109 public String getOfflineIcon()
110 110 {
111   - return "<span class=\"glyphicon glyphicon-download btn-danger\" style=\"float:right\"></span>";
  111 + return "<span class=\"label label-danger\"> Offline</span>";
112 112 }
113 113 }
114 114 \ No newline at end of file
... ...
src/main/java/org/alfresco/tasenvironment/models/EnvironmentRepository.java
... ... @@ -7,6 +7,7 @@ import org.springframework.stereotype.Repository;
7 7 * @author pbrodner
8 8 */
9 9 @Repository
10   -public interface EnvironmentRepository extends PagingAndSortingRepository<Environment, Long>
  10 +public interface EnvironmentRepository extends PagingAndSortingRepository<Environment, String>
11 11 {
  12 +
12 13 }
... ...
src/main/resources/public/js/npm.js
... ... @@ -1,13 +0,0 @@
1   -// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2   -require('../../js/transition.js')
3   -require('../../js/alert.js')
4   -require('../../js/button.js')
5   -require('../../js/carousel.js')
6   -require('../../js/collapse.js')
7   -require('../../js/dropdown.js')
8   -require('../../js/modal.js')
9   -require('../../js/tooltip.js')
10   -require('../../js/popover.js')
11   -require('../../js/scrollspy.js')
12   -require('../../js/tab.js')
13   -require('../../js/affix.js')
14 0 \ No newline at end of file
src/main/resources/spark/template/freemarker/environment/delete.ftl
... ... @@ -0,0 +1,2 @@
  1 +Object Deleted: ${object.toString()}
  2 +
... ...
src/main/resources/spark/template/freemarker/environment/index.ftl
1 1 <a href="/environment/new" data-toggle="tooltip" title="Add a new Environment!">Add New</a>
2   -
3   - <table class="table table-striped">
  2 +<table class="table table-striped table-bordered table-condensed">
4 3 <thead>
5 4 <tr>
6 5 <th>Name</th>
7 6 <th>IP</th>
8   - <th>Alfresco Path</th>
9   - <th>Share Path</th>
  7 + <th>Alfresco Path</th>
10 8 <th>Status</th>
  9 + <th></th>
11 10 </tr>
12 11 </thead>
13 12 <tbody>
... ... @@ -15,10 +14,17 @@
15 14 <tr>
16 15 <td>${env.getName()}</td>
17 16 <td>${env.getIp()}</td>
18   - <td><a href="${env.getAlfrescoPath()}" target="_blank">${env.getAlfrescoPath()}</a></td>
19   - <td><a href="${env.getSharePath()}" target="_blank">${env.getSharePath()}</a></td>
20   - <td>${env.getStatus()}</td>
  17 + <td><a href="${env.getAlfrescoPath()}" target="_blank">${env.getAlfrescoPath()}</a></td>
  18 + <td align="center">${env.getStatus()}</td>
  19 + <td>
  20 +
  21 + <form method="DELETE" action="/environment/delete/${env.getId()}">
  22 + <button type="submit" class="btn btn-small">Delete</button>
  23 + </form>
  24 +
  25 + </td>
21 26 </tr>
22 27 </#list>
23 28 </tbody>
24   - </table>
25 29 \ No newline at end of file
  30 + </table>
  31 +
26 32 \ No newline at end of file
... ...
src/main/resources/spark/template/freemarker/environment/new.ftl
1   -
2   - <form method="POST" action="/environment/new">
  1 +<form method="POST" action="/environment/new">
3 2 <div class="form-group">
4 3 <label for="inputdefault">Name</label>
5 4 <input class="form-control" id="inputdefault" type="text" name="envName">
... ... @@ -15,4 +14,4 @@
15 14 <div class="form-group">
16 15 <button id="inputsm" type="submit" class="btn btn-small">Add</button>
17 16 </div>
18   - </form>
  17 +</form>
... ...