mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-21 01:01:05 -05:00
enabling jsp for fast admin screens that won't clutter the BattlBuilder development
This commit is contained in:
15
pom.xml
15
pom.xml
@@ -131,6 +131,21 @@
|
|||||||
<version>0.11.5</version>
|
<version>0.11.5</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JSP Support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
|
<artifactId>tomcat-embed-jasper</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet.jsp.jstl</groupId>
|
||||||
|
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.web</groupId>
|
||||||
|
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Configurations for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Configurations for the Battl.Builder application.
|
||||||
* This package includes Configurations for Spring-Boot application
|
* This package includes Configurations for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package group.goforward.battlbuilder.controllers;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/platforms")
|
||||||
|
public class PlatformViewController {
|
||||||
|
|
||||||
|
@GetMapping("/manage")
|
||||||
|
public String managePlatforms() {
|
||||||
|
return "platform-manager";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Provides the classes necessary for the public api endpoints for the Battl.Builder
|
||||||
|
* application Spring Controllers.
|
||||||
|
* This package includes Controllers for Spring-Boot application
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>The main entry point for managing the inventory is the
|
||||||
|
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @author Don Strawsburg
|
||||||
|
* @version 1.1
|
||||||
|
*/
|
||||||
|
package group.goforward.battlbuilder.controllers.api;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Controllers for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Controllers for the Battl.Builder application.
|
||||||
* This package includes Controllers for Spring-Boot application
|
* This package includes Controllers for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Provides the classes necessary for the utility controllers for the Battl.Builder
|
||||||
|
* application Spring Controllers.
|
||||||
|
* This package includes Controllers for Spring-Boot application
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>The main entry point for managing the inventory is the
|
||||||
|
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
|
||||||
|
*
|
||||||
|
* @since 1.0
|
||||||
|
* @author Don Strawsburg
|
||||||
|
* @version 1.1
|
||||||
|
*/
|
||||||
|
package group.goforward.battlbuilder.controllers.utils;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Data Transfer Objects for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Data Transfer Objects for the Battl.Builder application.
|
||||||
* This package includes DTO for Spring-Boot application
|
* This package includes DTO for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Repository for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Repository for the Battl.Builder application.
|
||||||
* This package includes Repository for Spring-Boot application
|
* This package includes Repository for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Services implementations for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Services implementations for the Battl.Builder application.
|
||||||
* This package includes Services implementations for Spring-Boot application
|
* This package includes Services implementations for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Provides the classes necessary for the Spring Services implementations for the ballistic -Builder application.
|
* Provides the classes necessary for the Spring Services implementations for the Battl.Builder application.
|
||||||
* This package includes Services implementations for Spring-Boot application
|
* This package includes Services implementations for Spring-Boot application
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -19,4 +19,8 @@ spring.jpa.show-sql=true
|
|||||||
logging.level.org.hibernate.SQL=INFO
|
logging.level.org.hibernate.SQL=INFO
|
||||||
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=warn
|
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=warn
|
||||||
|
|
||||||
|
# JSP Configuration
|
||||||
|
spring.mvc.view.prefix=/WEB-INF/views/
|
||||||
|
spring.mvc.view.suffix=.jsp
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
292
src/main/webapp/WEB-INF/views/platform-manager.jsp
Normal file
292
src/main/webapp/WEB-INF/views/platform-manager.jsp
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Platform Manager</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.form-section {
|
||||||
|
background: #f5f5f5;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background: #007bff;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
background: #0056b3;
|
||||||
|
}
|
||||||
|
button.delete {
|
||||||
|
background: #dc3545;
|
||||||
|
}
|
||||||
|
button.delete:hover {
|
||||||
|
background: #c82333;
|
||||||
|
}
|
||||||
|
button.edit {
|
||||||
|
background: #28a745;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
button.edit:hover {
|
||||||
|
background: #218838;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
padding: 12px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: #007bff;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
tr:hover {
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
.actions {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.success {
|
||||||
|
background: #d4edda;
|
||||||
|
color: #155724;
|
||||||
|
border: 1px solid #c3e6cb;
|
||||||
|
}
|
||||||
|
.error {
|
||||||
|
background: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
border: 1px solid #f5c6cb;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Platform Manager</h1>
|
||||||
|
|
||||||
|
<div id="message"></div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<h2 id="formTitle">Add New Platform</h2>
|
||||||
|
<form id="platformForm">
|
||||||
|
<input type="hidden" id="platformId" name="id">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="key">Key:</label>
|
||||||
|
<input type="text" id="key" name="key" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="label">Label:</label>
|
||||||
|
<input type="text" id="label" name="label" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" id="submitBtn">Add Platform</button>
|
||||||
|
<button type="button" id="cancelBtn" onclick="resetForm()" style="display:none; background:#6c757d;">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h2>Existing Platforms</h2>
|
||||||
|
<table id="platformTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Key</th>
|
||||||
|
<th>Label</th>
|
||||||
|
<th>Created At</th>
|
||||||
|
<th>Updated At</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="platformList">
|
||||||
|
<!-- Platforms will be loaded here -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const API_BASE = '/api/platforms';
|
||||||
|
|
||||||
|
// Load platforms on page load
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
loadPlatforms();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Form submission
|
||||||
|
document.getElementById('platformForm').addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const id = document.getElementById('platformId').value;
|
||||||
|
const platform = {
|
||||||
|
key: document.getElementById('key').value,
|
||||||
|
label: document.getElementById('label').value
|
||||||
|
};
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
updatePlatform(id, platform);
|
||||||
|
} else {
|
||||||
|
addPlatform(platform);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadPlatforms() {
|
||||||
|
fetch(API_BASE)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(platforms => {
|
||||||
|
const tbody = document.getElementById('platformList');
|
||||||
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
|
platforms.forEach(platform => {
|
||||||
|
const row = document.createElement('tr');
|
||||||
|
row.innerHTML = `
|
||||||
|
<td>\${platform.id}</td>
|
||||||
|
<td>\${platform.key}</td>
|
||||||
|
<td>\${platform.label}</td>
|
||||||
|
<td>\${formatDate(platform.createdAt)}</td>
|
||||||
|
<td>\${formatDate(platform.updatedAt)}</td>
|
||||||
|
<td class="actions">
|
||||||
|
<button class="edit" onclick="editPlatform(\${platform.id}, '\${escapeHtml(platform.key)}', '\${escapeHtml(platform.label)}')">Edit</button>
|
||||||
|
<button class="delete" onclick="deletePlatform(\${platform.id})">Delete</button>
|
||||||
|
</td>
|
||||||
|
`;
|
||||||
|
tbody.appendChild(row);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => showMessage('Error loading platforms: ' + error, 'error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPlatform(platform) {
|
||||||
|
fetch(API_BASE + '/add', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(platform)
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('Platform added successfully!', 'success');
|
||||||
|
resetForm();
|
||||||
|
loadPlatforms();
|
||||||
|
} else {
|
||||||
|
showMessage('Error adding platform', 'error');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => showMessage('Error: ' + error, 'error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function editPlatform(id, key, label) {
|
||||||
|
document.getElementById('platformId').value = id;
|
||||||
|
document.getElementById('key').value = key;
|
||||||
|
document.getElementById('label').value = label;
|
||||||
|
document.getElementById('formTitle').textContent = 'Edit Platform';
|
||||||
|
document.getElementById('submitBtn').textContent = 'Update Platform';
|
||||||
|
document.getElementById('cancelBtn').style.display = 'inline-block';
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePlatform(id, platform) {
|
||||||
|
platform.id = parseInt(id);
|
||||||
|
|
||||||
|
fetch(API_BASE + '/add', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(platform)
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('Platform updated successfully!', 'success');
|
||||||
|
resetForm();
|
||||||
|
loadPlatforms();
|
||||||
|
} else {
|
||||||
|
showMessage('Error updating platform', 'error');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => showMessage('Error: ' + error, 'error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePlatform(id) {
|
||||||
|
if (confirm('Are you sure you want to delete this platform?')) {
|
||||||
|
fetch(API_BASE + '/delete/' + id, {
|
||||||
|
method: 'DELETE'
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('Platform deleted successfully!', 'success');
|
||||||
|
loadPlatforms();
|
||||||
|
} else {
|
||||||
|
showMessage('Error deleting platform', 'error');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => showMessage('Error: ' + error, 'error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
document.getElementById('platformForm').reset();
|
||||||
|
document.getElementById('platformId').value = '';
|
||||||
|
document.getElementById('formTitle').textContent = 'Add New Platform';
|
||||||
|
document.getElementById('submitBtn').textContent = 'Add Platform';
|
||||||
|
document.getElementById('cancelBtn').style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMessage(message, type) {
|
||||||
|
const messageDiv = document.getElementById('message');
|
||||||
|
messageDiv.className = 'message ' + type;
|
||||||
|
messageDiv.textContent = message;
|
||||||
|
messageDiv.style.display = 'block';
|
||||||
|
setTimeout(() => {
|
||||||
|
messageDiv.style.display = 'none';
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(dateString) {
|
||||||
|
if (!dateString) return '';
|
||||||
|
const date = new Date(dateString);
|
||||||
|
return date.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHtml(text) {
|
||||||
|
return text.replace(/'/g, "\\'");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user