mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
251 lines
11 KiB
HTML
251 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css" integrity="sha384-b6lVK+yci+bfDmaY1u0zE8YYJt0TZxLEAFyYSLHId4xoVvsrQu3INevFKo+Xir8e" crossorigin="anonymous">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.min.js" integrity="sha512-1/RvZTcCDEUjY/CypiMz+iqqtaoQfAITmNSJY17Myp4Ms5mdxPS5UV7iOfdZoxcGhzFbOm6sntTKJppjvuhg4g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
<title>Documentation | Spring Boot DB Admin Panel</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/java.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/xml.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/properties.min.js"></script>
|
|
<script type="text/javascript">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.querySelectorAll('h2, h3, h4, h5').forEach(heading => {
|
|
let tag = heading.tagName.replace('H', '');
|
|
|
|
document.getElementById('toc').innerHTML +=
|
|
`<li class="ms-${tag}"><a href="#${heading.id}">${heading.innerHTML}</li>`;
|
|
});
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="bg-light">
|
|
<div class="container">
|
|
<nav class="navbar navbar-expand-lg bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand fw-bold" href="#">Spring Boot Database Admin Docs</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="https://github.com/aileftech/spring-boot-database-admin" target="_blank">Github</a>
|
|
</li>
|
|
</ul>
|
|
<!--
|
|
<form class="d-flex" role="search">
|
|
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
</form>
|
|
-->
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
<!-- End nav -->
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-3 pt-3">
|
|
<ol id="toc" class="toc" style="position: fixed">
|
|
|
|
</ol>
|
|
</div>
|
|
<div class="col-9 main-content pt-3 ps-4">
|
|
|
|
<h1>Spring Boot Database Admin documentation</h1>
|
|
|
|
<h2 id="introduction">1. Introduction</h2>
|
|
|
|
<p>The following documentation outlines how to install, configure and customize Spring Boot Database Admin panel. Refer to this document for troubleshooting and if you still encounter problems, please <a href="https://github.com/aileftech/spring-boot-database-admin/issues" target="_blank">report it as an issue on Github</a>.</p>
|
|
<div class="separator"></div>
|
|
<h2 id="getting-started">2. Getting started</h2>
|
|
<p>Getting started with Spring Boot Database Admin requires including it as a dependency and then performing a simple configuration step.</p>
|
|
|
|
<h3 id="installation">2.1 Installation</h3>
|
|
<p>Since Spring Boot Database Admin is distributed on Maven, the easiest way to start is to include this dependency in your <code>pom.xml</code>:</p>
|
|
|
|
<pre>
|
|
<code class="language-xml"><dependency>
|
|
<groupId>tech.ailef</groupId>
|
|
<artifactId>spring-boot-db-admin</artifactId>
|
|
<version>0.1.2</version>
|
|
</dependency>
|
|
</code>
|
|
</pre>
|
|
<p class="tip"><span class="title"><i class="bi bi-info-circle"></i> TIP</span> Go to the <a href="https://mvnrepository.com/artifact/tech.ailef/spring-boot-db-admin" target="_blank">Maven repository</a> to retrieve the exact snippet for the latest stable release.</p>
|
|
|
|
<p>If you want the latest unstable release, you can clone the <code>main</code> branch of the Github repo and execute <code>mvn install -D skipTests</code> in the project's directory. This will install the library in your local repository, which you can then include using the same snippet as above, but replacing the version number with the one contained in the <code>pom.xml</code> file of the code you pulled from Github.</p>
|
|
|
|
<h3 id="configuration">2.2 Configuration</h3>
|
|
<p>After including the dependency, a few configuration steps are required on your end in order to integrate the library into your project. </p>
|
|
<p>The first one is configuring your <code>application.properties</code> file:</p>
|
|
|
|
<pre>
|
|
<code class="language-properties"># The first-level part of the URL path: http://localhost:8080/${baseUrl}/
|
|
dbadmin.baseUrl=admin
|
|
|
|
# The package(s) that contain your @Entity classes
|
|
# accepts multiple comma separated values
|
|
dbadmin.modelsPackage=your.models.package,your.second.models.package
|
|
|
|
# OPTIONAL PARAMETERS
|
|
# Whether to enable to web interface
|
|
# dbadmin.enabled=true
|
|
#
|
|
# Set to true if you need to run the tests, as it will customize
|
|
# the database configuration for the internal DataSource
|
|
# dbadmin.testMode=false
|
|
</code>
|
|
</pre>
|
|
|
|
<p>After this, you must tell Spring to import the Spring Boot Database Admin configuration. To do this, annotate your <code>@SpringBootApplication</code> class containing the <code>main</code> method with the following:</p>
|
|
|
|
<pre>
|
|
<code class="language-java">@ImportAutoConfiguration(DbAdminAutoConfiguration.class)
|
|
</code>
|
|
</pre>
|
|
|
|
<p>This will autoconfigure the various Spring Boot Database Admin components when your application starts.</p>
|
|
<p>If everything is setup correctly, you will see Spring Boot Database Admin confirming it in the log messages that appear when you start your application. Keep in mind that if you specify the wrong models package, it will still work but provide you an empty interface. To check, visit <a target="_blank" href="http://localhost:8080/admin">http://localhost:8080/admin</a>.</p>
|
|
<div class="separator"></div>
|
|
<h2 id="customization">3. Customization</h2>
|
|
<p>There are two ways to customize the appearance and behaviour of Spring Boot Database Admin:</p>
|
|
<ol>
|
|
<li>Applying annotations on your <code>@Entity</code> classes, fields and methods</li>
|
|
<li>Using the Settings panel through the web interface</li>
|
|
</ol>
|
|
<p>Annotations are used primarily to customize behaviour and add custom logic to your classes. If, instead, you're looking to customize appearance of the web UI, it's most likley through the Settings panel.</p>
|
|
|
|
<h3 id="supported-annotations">3.1 Supported annotations</h3>
|
|
|
|
<h4 id="display-name">3.1.1 @DisplayName</h4>
|
|
<pre>
|
|
<code class="language-java">@DisplayName
|
|
public String getFullName() {
|
|
return firstName + " " + lastName;
|
|
}
|
|
</code>
|
|
</pre>
|
|
|
|
<p>When displaying a reference to an item, by default we show its primary key. If a class has a <code>@DisplayName</code>, this method will be used in addition to the primary key whenever possible, giving the user a more readable option. <p>
|
|
|
|
|
|
<h4 id="display-format">3.1.2 @DisplayFormat</h4>
|
|
<pre>
|
|
<code class="language-java">@DisplayFormat(format = "$%.2f")
|
|
private Double price;
|
|
</code>
|
|
</pre>
|
|
|
|
<p>Specify a format string to apply when displaying the field.</p>
|
|
|
|
|
|
<h4 id="computed-column">3.1.3 @ComputedColumn</h4>
|
|
<h6>Supported parameters</h6>
|
|
<table class="table table-striped">
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Type</th>
|
|
<th>Required</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">name</td>
|
|
<td>String</td>
|
|
<td>false</td>
|
|
<td>The name of this column in the web interface. The method's name is used if this value is not specified.</td>
|
|
</tr>
|
|
</table>
|
|
<h6>Code example</h6>
|
|
<pre>
|
|
<code class="language-java">@ComputedColumn
|
|
public double totalSpent() {
|
|
double total = 0;
|
|
for (Order o : orders) {
|
|
total += o.total();
|
|
}
|
|
return total;
|
|
}
|
|
</code>
|
|
</pre>
|
|
|
|
<p>This annotation can be used to add values computed at runtime that are shown like additional columns.</p>
|
|
|
|
<h4 id="filterable">3.1.4 @Filterable</h4>
|
|
<h6>Supported parameters</h6>
|
|
<table class="table table-striped">
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Required</th>
|
|
<th>Type</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">type</td>
|
|
<td>false</td>
|
|
<td>Enum (<code>DEFAULT</code>, <code>CATEGORICAL</code>)</td>
|
|
<td>If <code>CATEGORICAL</code>, this changes the filter in the UI to shows all the possible values directly instead of providing a autocomplete form.</td>
|
|
</tr>
|
|
</table>
|
|
<h6>Code example</h6>
|
|
<pre>
|
|
<code class="language-java">@Filterable
|
|
private LocalDate createdAt;
|
|
|
|
@Filterable(type=FilterableType.CATEGORICAL)
|
|
@ManyToOne
|
|
private User user;
|
|
</code>
|
|
</pre>
|
|
|
|
|
|
|
|
<p>Place on one or more fields in a class to activate the faceted search feature. This will allow you to easily combine all these filters when operating on the table. Can only be placed on fields that correspond to physical columns on the table (e.g. no <code>@ManyToMany</code>/<code>@OneToMany</code>) and that are not binary (<code>byte[]</code>).</p>
|
|
|
|
<h4 id="display-image">3.1.5 @DisplayImage</h4>
|
|
|
|
<pre>
|
|
<code class="language-java">@DisplayImage
|
|
@Lob
|
|
private byte[] image;
|
|
</code>
|
|
</pre>
|
|
|
|
<p>This annotation can be placed on binary fields to declare they are storing an image and that we want it displayed when possible. The image will be shown as a small thumbnail.</p>
|
|
|
|
<h4 id="hidde-column">3.1.6 @HiddenColumn</h4>
|
|
<h6>Code example</h6>
|
|
<pre>
|
|
<code>
|
|
@HiddenColumn
|
|
private String cardNumber;
|
|
</code>
|
|
</pre>
|
|
<p>Marks a column as hidden. This column and its values will not be shown in the list and detail view for objects of this type. If the column is nullable, it will be hidden in the create and edit forms as well (and this will result in the column always being NULL when creating/editing objects). If, instead, it's not nullable column, it will be included in the create and edit forms as it would otherwise prevent the creation of items.</p>
|
|
<p><strong>Please note that this is not meant as a security feature, </strong> but rather to hide uninformative columns that clutter the interface. In fact, since the create and edit form come pre-filled with all the information, these views <b>will</b> show the value of the hidden column (if it's not nullable).</p>
|
|
|
|
<div class="separator"></div>
|
|
|
|
|
|
|
|
<h2>4. Security</h2>
|
|
<p>Spring Boot Database Admin does not implement authentication and/or authorization mechanisms. However, you can use a standard Spring security configuration in order to limit access to the web UI or specific parts of it.</p>
|
|
<p>All Spring Boot Database Admin routes start with the value of <code>dbadmin.baseUrl</code> property, and all write operations (edit, create, delete) are implemented as <code>POST</code> calls.</p>
|
|
<div class="separator"></div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<script>hljs.highlightAll();</script>
|
|
</body>
|
|
</html> |