Merge pull request #344 from getrebuild/frontapi-base-688

Frontapi base 688
This commit is contained in:
devezhao 2021-05-29 12:34:10 +08:00 committed by GitHub
commit 38b93c1861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 257 additions and 46 deletions

2
@rbv

@ -1 +1 @@
Subproject commit 5cd0278ad08b49508bf278654c8ab4825b868870
Subproject commit fa267c9c6721819f19208a3afd0f6dff6b14f620

View file

@ -207,6 +207,7 @@ public class EntityHelper {
public static final int SmsendLog = 35;
public static final int Language = 36;
public static final int TransformConfig = 37;
public static final int FrontjsCode = 38;
// 动态

View file

@ -75,8 +75,9 @@ public class RebuildWebInterceptor implements AsyncHandlerInterceptor, InstallSt
request.setAttribute(WebConstants.LOCALE, requestEntry.getLocale());
request.setAttribute(WebConstants.$BUNDLE, Application.getLanguage().getBundle(requestEntry.getLocale()));
request.setAttribute(WebConstants.USE_THEME,
!requestEntry.getRequestUri().contains("/admin/") && License.isCommercial());
boolean adminPage = requestEntry.getRequestUri().contains("/admin/")
|| requestEntry.getRequestUri().contains("/admin-");
request.setAttribute(WebConstants.USE_THEME, !adminPage && License.isCommercial());
}
final String requestUri = requestEntry.getRequestUri();
@ -98,8 +99,7 @@ public class RebuildWebInterceptor implements AsyncHandlerInterceptor, InstallSt
else if (!requestUri.contains("/setup/")) {
sendRedirect(response, "/setup/install", null);
return false;
}
else {
} else {
return true;
}
}

View file

@ -28,6 +28,7 @@ import com.rebuild.core.support.RebuildConfiguration;
import com.rebuild.core.support.i18n.Language;
import com.rebuild.core.support.task.TaskExecutors;
import com.rebuild.utils.JSONUtils;
import com.rebuild.utils.RbAssert;
import com.rebuild.web.BaseController;
import com.rebuild.web.commons.FileDownloader;
import lombok.extern.slf4j.Slf4j;
@ -97,6 +98,17 @@ public class MetaEntityController extends BaseController {
return mv;
}
@GetMapping("entity/{entity}/frontjs")
public ModelAndView pageFrontJs(@PathVariable String entity, HttpServletRequest request) {
RbAssert.isCommercial(
Language.L("免费版不支持 FrontJS 功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
ModelAndView mv = createModelAndView("/admin/metadata/frontjs");
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
setEntityBase(mv, entity);
return mv;
}
@ResponseBody
@RequestMapping("entity/entity-list")
public Object listEntity(HttpServletRequest request) {

View file

@ -23,7 +23,8 @@ public class ExtformAdminController extends BaseController {
@GetMapping("/admin/extforms")
public ModelAndView pageList() {
RbAssert.isCommercial(Language.L("免费版不支持外部表单功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
RbAssert.isCommercial(
Language.L("免费版不支持外部表单功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
return createModelAndView("/admin/extform/extform-list");
}
}

View file

@ -1681,5 +1681,23 @@
"默认值无效":"默认值无效",
"默认排序":"默认排序",
"默认用户名/密码均为":"默认用户名/密码均为",
"默认语言":"默认语言"
"默认语言":"默认语言",
"管理员将审核你的注册信息,请正确填写":"管理员将审核你的注册信息,请正确填写",
"我的任务":"我的任务",
"保存草稿":"保存草稿",
"免费版不支持 FrontJS 功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)":"免费版不支持 FrontJS 功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)",
"ES5 代码":"ES5 代码",
"仅超级管理员可以发布 FrontJS 代码":"仅超级管理员可以发布 FrontJS 代码",
"审核步骤":"审核步骤",
"应用路径":"应用路径",
"时间":"时间",
"无法完成发布,请检查代码是否有误":"无法完成发布,请检查代码是否有误",
"代码":"代码",
"注册信息已提交,审核结果将通过邮件通知你":"注册信息已提交,审核结果将通过邮件通知你",
"你已完成所有任务":"你已完成所有任务",
"审核流程":"审核流程",
"管理员正在审核你的注册信息":"管理员正在审核你的注册信息",
"FrontJS":"FrontJS",
"审核状态":"审核状态",
"草稿已保存":"草稿已保存"
}

View file

@ -369,6 +369,14 @@
<field name="isDisabled" type="bool" default-value="F" description="是否禁用"/>
</entity>
<entity name="FrontjsCode" type-code="038" description="FrontJS" queryable="false">
<field name="codeId" type="primary"/>
<field name="belongEntity" type="string" max-length="100" nullable="false" updatable="false" description="所属实体"/>
<field name="applyPath" type="string" max-length="200" description="应用路径"/>
<field name="code" type="text" description="代码"/>
<field name="es5Code" type="text" description="ES5 代码"/>
</entity>
<!-- 动态不涉及审计 -->
<entity name="Feeds" type-code="040" description="动态" name-field="content" extra-attrs="{icon:'chart-donut'}">
<field name="feedsId" type="primary"/>

View file

@ -724,6 +724,19 @@ create table if not exists `extform_config` (
primary key (`CONFIG_ID`)
)Engine=InnoDB;
-- ************ Entity [FrontjsCode] DDL ************
create table if not exists `frontjs_code` (
`CODE_ID` char(20) not null,
`BELONG_ENTITY` varchar(100) not null comment '所属实体',
`APPLY_PATH` varchar(200) comment '应用路径',
`CODE` text(21845) comment '代码',
`ES5_CODE` text(21845) comment 'ES5 代码',
`MODIFIED_ON` timestamp not null default current_timestamp comment '修改时间',
`MODIFIED_BY` char(20) not null comment '修改人',
`CREATED_BY` char(20) not null comment '创建人',
`CREATED_ON` timestamp not null default current_timestamp comment '创建时间',
primary key (`CODE_ID`)
)Engine=InnoDB;
-- #3 datas
@ -777,4 +790,4 @@ insert into `project_plan_config` (`CONFIG_ID`, `PROJECT_ID`, `PLAN_NAME`, `SEQ`
-- DB Version (see `db-upgrade.sql`)
insert into `system_config` (`CONFIG_ID`, `ITEM`, `VALUE`)
values ('021-9000000000000001', 'DBVer', 35);
values ('021-9000000000000001', 'DBVer', 36);

View file

@ -1,6 +1,21 @@
-- Database upgrade scripts for rebuild 1.x and 2.x
-- Each upgraded starts with `-- #VERSION`
-- #36 (v2.4)
-- ************ Entity [FrontjsCode] DDL ************
create table if not exists `frontjs_code` (
`CODE_ID` char(20) not null,
`BELONG_ENTITY` varchar(100) not null comment '所属实体',
`APPLY_PATH` varchar(200) comment '应用路径',
`CODE` text(21845) comment '代码',
`ES5_CODE` text(21845) comment 'ES5 代码',
`MODIFIED_ON` timestamp not null default current_timestamp comment '修改时间',
`MODIFIED_BY` char(20) not null comment '修改人',
`CREATED_BY` char(20) not null comment '创建人',
`CREATED_ON` timestamp not null default current_timestamp comment '创建时间',
primary key (`CODE_ID`)
)Engine=InnoDB;
-- #35 (v2.3)
alter table `project_task`
add column `RELATED_RECORD` char(20) comment '相关业务记录',

View file

@ -7,7 +7,7 @@
<title>[[${bundle.L('表单回填')}]]</title>
<style type="text/css">
.dataTables_wrapper .rb-datatable-header {
position: static
position: static;
}
span.badge {
font-size: 1rem;
@ -49,6 +49,7 @@
<li><a href="../../form-design">[[${bundle.L('表单设计')}]]</a></li>
<li class="active"><a href="../../fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="../../advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="../../frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -4,24 +4,6 @@
<th:block th:replace="~{/_include/header}" />
<meta name="page-help" content="https://getrebuild.com/docs/admin/meta-entity" />
<title>[[${bundle.L('高级配置')}]]</title>
<style type="text/css">
a#entityIcon {
display: inline-block;
width: 36px;
height: 36px;
background-color: #e3e3e3;
text-align: center;
border-radius: 2px;
}
a#entityIcon .icon {
font-size: 26px;
color: #555;
line-height: 36px;
}
a#entityIcon:hover {
opacity: 0.8;
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-aside rb-color-header" th:classappend="${sideCollapsedClazz}">
@ -44,6 +26,7 @@
<li><a href="form-design">[[${bundle.L('表单设计')}]]</a></li>
<li><a href="fields">[[${bundle.L('字段管理')}]]</a></li>
<li class="active"><a href="advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -26,6 +26,7 @@
<li><a href="form-design">[[${bundle.L('表单设计')}]]</a></li>
<li><a href="fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -27,6 +27,7 @@
<li><a href="../form-design">[[${bundle.L('表单设计')}]]</a></li>
<li class="active"><a href="../fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="../advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -26,6 +26,7 @@
<li><a href="form-design">[[${bundle.L('表单设计')}]]</a></li>
<li class="active"><a href="fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -27,6 +27,7 @@
<li class="active"><a href="form-design">[[${bundle.L('表单设计')}]]</a></li>
<li><a href="fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="advanced">[[${bundle.L('高级配置')}]]</a></li>
<li><a href="frontjs">FrontJS <sup class="rbv"></sup></a></li>
</ul>
</div>
</div>

View file

@ -0,0 +1,139 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:replace="~{/_include/header}" />
<meta name="page-help" content="https://getrebuild.com/docs/dev/how-use-front-api" />
<title>FrontJS</title>
<style type="text/css">
.CodeMirror {
padding: 0;
border: 0 none;
}
.cm-s-material-darker {
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif !important;
}
.CodeMirror-hints.material-darker {
font-family: Menlo, Monaco, Consolas, 'Courier New', monospace !important;
}
.rb-loading:after {
background-color: transparent;
}
.code-editor-wrapper {
position: relative;
min-height: 300px;
}
body.fullscreen .code-editor-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}
.code-editor-wrapper .code-editor-toolbar {
position: absolute;
right: 10px;
top: 10px;
background-color: rgba(255, 255, 255, 0.2);
z-index: 101;
border-radius: 2px;
overflow: hidden;
}
.code-editor-wrapper .code-editor-toolbar > a {
display: inline-block;
font-size: 1.3rem;
padding: 8px 14px;
color: #fff;
line-height: 1;
transition: all 0.4s;
}
.code-editor-wrapper .code-editor-toolbar > a:hover {
background-color: rgba(255, 255, 255, 0.6);
}
</style>
</head>
<body>
<div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-aside rb-color-header" th:classappend="${sideCollapsedClazz}">
<th:block th:replace="~{/_include/nav-top}" />
<th:block th:replace="~{/_include/nav-left-admin(active='entities')}" />
<div class="rb-content">
<aside class="page-aside">
<div class="rb-scroller-aside rb-scroller">
<div class="aside-content">
<div class="content">
<div class="aside-header">
<button class="navbar-toggle collapsed" type="button"><span class="icon zmdi zmdi-caret-down"></span></button>
<span class="title">[[${entityLabel}]]</span>
<p class="description">[[${comments}]]</p>
</div>
</div>
<div class="aside-nav collapse">
<ul class="nav">
<li><a href="base">[[${bundle.L('基本信息')}]]</a></li>
<li><a href="form-design">[[${bundle.L('表单设计')}]]</a></li>
<li><a href="fields">[[${bundle.L('字段管理')}]]</a></li>
<li><a href="advanced">[[${bundle.L('高级配置')}]]</a></li>
<li class="active">
<a href="frontjs">FrontJS <sup class="rbv"></sup></a>
</li>
</ul>
</div>
</div>
</div>
</aside>
<div class="main-content container-fluid">
<div class="code-toolbar row">
<div class="col">
<ol class="breadcrumb m-0 p-0 bg-transparent" style="height: 37px; line-height: 37px">
<li class="breadcrumb-item">[[${entityLabel}]]</li>
<li class="breadcrumb-item position-relative">
<div class="position-absolute" style="width: 300px; top: 0; left: 20px">
<input class="form-control form-control-sm" id="applyPath" th:placeholder="${bundle.L('应用路径')}" />
</div>
</li>
</ol>
</div>
<div class="col text-right">
<div class="btn-group J_save_group">
<button class="btn btn-primary J_save" type="button" data-spinner="grow">[[${bundle.L('保存')}]]</button>
<button class="btn btn-primary dropdown-toggle auto" type="button" data-toggle="dropdown"><span class="icon zmdi zmdi-chevron-down"></span></button>
<div class="dropdown-menu dropdown-menu-primary dropdown-menu-right">
<a class="dropdown-item J_draft">[[${bundle.L('保存草稿')}]]</a>
</div>
</div>
</div>
</div>
<div class="mt-2">
<div class="code-editor-wrapper rb-loading rb-loading-active">
<div class="code-editor-toolbar">
<a class="J_format" th:title="${bundle.L('格式化')}"><i class="zmdi zmdi-wrap-text"></i></a>
<a class="J_fullscreen" th:title="${bundle.L('全屏')}"><i class="zmdi zmdi-fullscreen"></i></a>
</div>
<textarea id="code-editor" class="hide"></textarea>
<th:block th:replace="~{/_include/spinner}" />
</div>
</div>
</div>
</div>
</div>
<th:block th:replace="~{/_include/footer}" />
<script>
window.__PageConfig = {
id: '[[${entityMetaId}]]',
entity: '[[${entityName}]]',
isSuperAdmin: '[[${isSuperAdmin}]]' === 'true',
}
</script>
<link rel="stylesheet" type="text/css" th:href="@{/assets/lib/codemirror/codemirror.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/assets/lib/codemirror/theme/material-darker.css}" />
<script th:src="@{/assets/lib/codemirror/codemirror.js}"></script>
<script th:src="@{/assets/lib/codemirror/mode/javascript/javascript.js}"></script>
<script th:src="@{/assets/lib/codemirror/mode/xml/xml.js}"></script>
<script th:src="@{/assets/lib/codemirror/mode/jsx/jsx.js}"></script>
<script th:src="@{/assets/lib/codemirror/addon/edit/closebrackets.js}"></script>
<script th:src="@{/assets/lib/codemirror/addon/edit/matchbrackets.js}"></script>
<script th:src="@{/assets/lib/prettier/standalone.js}"></script>
<script th:src="@{/assets/lib/prettier/parser-babel.js}"></script>
<script th:src="@{/assets/js/frontjs/frontjs.js}" type="text/babel"></script>
</body>
</html>

View file

@ -170,19 +170,6 @@ See LICENSE and COMMERCIAL in the project root for license information.
min-width: 0;
}
body.fullscreen .rb-wrapper {
padding: 0 !important;
}
body.fullscreen .rb-wrapper > .rb-top-header,
body.fullscreen .rb-wrapper > .rb-left-sidebar {
display: none !important;
}
body.fullscreen .rb-wrapper > .rb-content {
margin-left: 0 !important;
}
body.fullscreen .J_dash-fullscreen .zmdi-fullscreen::before {
content: '\f16c';
}

View file

@ -11914,7 +11914,7 @@ a.avatar img {
width: 32px;
height: 32px;
border-radius: 50%;
background-color: #ccc;
background-color: #eee;
display: inline-block;
overflow: hidden;
font-size: 12px;

View file

@ -3939,3 +3939,16 @@ a.select-lang:hover {
.admin-danger-list > div + div {
border-top: 1px solid #eee;
}
body.fullscreen .rb-wrapper > .rb-top-header,
body.fullscreen .rb-wrapper > .rb-left-sidebar {
display: none !important;
}
body.fullscreen .rb-wrapper {
padding: 0 !important;
}
body.fullscreen .rb-wrapper > .rb-content {
margin-left: 0 !important;
}

View file

@ -123,5 +123,9 @@
<script th:src="@{/assets/js/rb-advfilter.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-approval.js}" type="text/babel"></script>
<script th:src="@{/assets/js/settings-share2.js}" type="text/babel"></script>
<th:block th:if="${commercial > 0}">
<script th:src="@{/assets/js/frontjs/frontjs-sdk.js}"></script>
<script th:src="@{/commons/frontjs/use-frontjs}"></script>
</th:block>
</body>
</html>

View file

@ -81,5 +81,9 @@
<script th:src="@{/assets/js/rb-forms.append.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-view.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-view.append.js}" type="text/babel"></script>
<th:block th:if="${commercial > 0}">
<script th:src="@{/assets/js/frontjs/frontjs-sdk.js}"></script>
<script th:src="@{/commons/frontjs/use-frontjs}"></script>
</th:block>
</body>
</html>

View file

@ -128,5 +128,9 @@
<script th:src="@{/assets/js/rb-assignshare.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-approval.js}" type="text/babel"></script>
<script th:src="@{/assets/js/settings-share2.js}" type="text/babel"></script>
<th:block th:if="${commercial > 0}">
<script th:src="@{/assets/js/frontjs/frontjs-sdk.js}"></script>
<script th:src="@{/commons/frontjs/use-frontjs}"></script>
</th:block>
</body>
</html>

View file

@ -126,5 +126,9 @@
<script th:src="@{/assets/js/rb-view.append.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-assignshare.js}" type="text/babel"></script>
<script th:src="@{/assets/js/rb-approval.js}" type="text/babel"></script>
<th:block th:if="${commercial > 0}">
<script th:src="@{/assets/js/frontjs/frontjs-sdk.js}"></script>
<script th:src="@{/commons/frontjs/use-frontjs}"></script>
</th:block>
</body>
</html>

View file

@ -2,7 +2,7 @@
Copyright (c) Ruifang Tech <http://ruifang-tech.com/> and/or its owners. All rights reserved.
*/
package com.rebuild;
package com.rebuild.support;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
@ -27,7 +27,7 @@ import java.util.regex.Pattern;
/**
* 多语言提取
* 1 .java 文件提取 `$L(xxx, [args])` `errorl(xxx)` 注意不要换行
* 1 .java 文件提取 `.L(xxx, [args])` `.errorl(xxx)` 注意不要换行
* 2 .js 提取 `$L(xxx, [args])`
* 3 .html 提取 `bundle.L(xxx, [args])`
*
@ -67,7 +67,6 @@ public class I18nGettextParser {
FileUtils.writeStringToFile(target, JSONUtils.prettyPrint(contents));
log.info("File write : {} ({})", target.getAbsolutePath(), contents.size());
System.exit(0);
}
static void parse(File fileOrDir, Set<String> into) throws IOException {

View file

@ -13,6 +13,7 @@ import cn.devezhao.persist4j.metadata.impl.ConfigurationMetadataFactory;
import cn.devezhao.persist4j.util.support.Table;
import com.rebuild.core.Application;
import com.rebuild.core.BootApplication;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.easymeta.EasyMetaFactory;
import org.dom4j.Element;
@ -34,8 +35,8 @@ public class SchemaGenerator {
PMF = Application.getPersistManagerFactory();
// !!! COMMENT DynamicMetadataFactory#appendConfig4Db
generate();
// generate(EntityHelper.ExtformConfig);
// generate();
generate(EntityHelper.FrontjsCode);
System.exit(0);
}