diff --git a/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java b/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java index 9ed82d8..2ca7dde 100644 --- a/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java +++ b/src/main/java/tech/ailef/dbadmin/external/controller/DefaultDbAdminController.java @@ -264,9 +264,15 @@ public class DefaultDbAdminController { @GetMapping("/model/{className}/create") - public String create(Model model, @PathVariable String className) { + public String create(Model model, @PathVariable String className, RedirectAttributes attr) { DbObjectSchema schema = dbAdmin.findSchemaByClassName(className); + if (!schema.isCreateEnabled()) { + attr.addFlashAttribute("errorTitle", "Unauthorized"); + attr.addFlashAttribute("error", "CREATE operations have been disabled on this type (" + schema.getJavaClass().getSimpleName() + ")."); + return "redirect:/" + properties.getBaseUrl() + "/model/" + className; + } + model.addAttribute("className", className); model.addAttribute("schema", schema); model.addAttribute("title", "Entities | " + schema.getJavaClass().getSimpleName() + " | Create"); @@ -411,6 +417,12 @@ public class DefaultDbAdminController { boolean create = Boolean.parseBoolean(c); DbObjectSchema schema = dbAdmin.findSchemaByClassName(className); + + if (!schema.isCreateEnabled() && create) { + attr.addFlashAttribute("errorTitle", "Unauthorized"); + attr.addFlashAttribute("error", "CREATE operations have been disabled on this type (" + schema.getJavaClass().getSimpleName() + ")."); + return "redirect:/" + properties.getBaseUrl() + "/model/" + className; + } String pkValue = params.get(schema.getPrimaryKey().getName()); if (pkValue == null || pkValue.isBlank()) { diff --git a/src/main/resources/static/css/dbadmin.css b/src/main/resources/static/css/dbadmin.css index ef79218..adc1cfd 100644 --- a/src/main/resources/static/css/dbadmin.css +++ b/src/main/resources/static/css/dbadmin.css @@ -27,9 +27,16 @@ a { .disable { pointer-events: none; +} + +input.disable { background: #EDECEF; } +a.disable .bi { + color: #9298A0 !important; +} + .btn-secondary.disable { background-color: #A8ADB3; border: 1px solid #A8ADB3; diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 926e47b..ee4ab85 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -50,7 +50,10 @@ - + + diff --git a/src/main/resources/templates/model/list.html b/src/main/resources/templates/model/list.html index 44258aa..7a82801 100644 --- a/src/main/resources/templates/model/list.html +++ b/src/main/resources/templates/model/list.html @@ -62,7 +62,8 @@

-

diff --git a/src/main/resources/templates/model/schema.html b/src/main/resources/templates/model/schema.html index 7508fb1..625b406 100644 --- a/src/main/resources/templates/model/schema.html +++ b/src/main/resources/templates/model/schema.html @@ -39,8 +39,9 @@ [[ ${schema.getTableName()} ]] -

+