diff --git a/config/assets/default.js b/config/assets/default.js index 3439a2b5..dfb54420 100644 --- a/config/assets/default.js +++ b/config/assets/default.js @@ -86,6 +86,7 @@ module.exports = { 'public/lib/angular-ui-codemirror/ui-codemirror.js', 'public/lib/codemirror/mode/javascript/javascript.js', 'public/lib/codemirror/mode/markdown/markdown.js', + 'public/lib/codemirror/mode/xml/xml.js', //angular-lazy-img 'public/lib/angular-lazy-img/release/angular-lazy-img.js' diff --git a/config/assets/production.js b/config/assets/production.js index 0768f09a..41bb4298 100644 --- a/config/assets/production.js +++ b/config/assets/production.js @@ -86,6 +86,7 @@ module.exports = { 'public/lib/angular-ui-codemirror/ui-codemirror.min.js', 'public/lib/codemirror/mode/javascript/javascript.js', 'public/lib/codemirror/mode/markdown/markdown.js', + 'public/lib/codemirror/mode/xml/xml.js', //angular-lazy-img 'public/lib/angular-lazy-img/release/angular-lazy-img.min.js' diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 48adf1ed..2504ebfd 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -1274,7 +1274,8 @@ SYSTEMS: { ASSETS_CONFIG: 'System assets configure', ENV_CONFIG: 'System env configure', - TEMPLATES_EDIT: 'Templates editor', + TEMPLATES_EDIT_FRONTEND: 'Front-end templates editor', + TEMPLATES_EDIT_BACKEND: 'Back-end templates editor', DATABASE_BACKUP: 'Database backup files', TRANS_EDIT: 'Translate strings editor', COMMANDS_EXECUTE: 'Server commands execute', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index c9eb7385..f7f0dedb 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -1274,7 +1274,8 @@ SYSTEMS: { ASSETS_CONFIG: 'Assets 资源配置调整', ENV_CONFIG: 'Env 环境配置调整', - TEMPLATES_EDIT: '模板在线编辑', + TEMPLATES_EDIT_FRONTEND: '前端模板在线编辑', + TEMPLATES_EDIT_BACKEND: '后端模板在线编辑', DATABASE_BACKUP: '数据库备份文件', TRANS_EDIT: '多语言字符串在线编辑', COMMANDS_EXECUTE: '服务器命令在线执行', diff --git a/modules/systems/client/config/systems-admin.client.routes.js b/modules/systems/client/config/systems-admin.client.routes.js index e96c5b4f..45d57894 100644 --- a/modules/systems/client/config/systems-admin.client.routes.js +++ b/modules/systems/client/config/systems-admin.client.routes.js @@ -27,9 +27,13 @@ url: '/env', templateUrl: '/modules/systems/client/views/env.client.view.html' }) - .state('admin.systems.templates', { - url: '/templates', - templateUrl: '/modules/systems/client/views/templates.client.view.html' + .state('admin.systems.templatesFront', { + url: '/templatesFront', + templateUrl: '/modules/systems/client/views/templatesFront.client.view.html' + }) + .state('admin.systems.templatesBack', { + url: '/templatesBack', + templateUrl: '/modules/systems/client/views/templatesBack.client.view.html' }) .state('admin.systems.trans', { url: '/trans', diff --git a/modules/systems/client/controllers/systems-config.client.controller.js b/modules/systems/client/controllers/systems-config.client.controller.js index a21c57ef..b7daf264 100644 --- a/modules/systems/client/controllers/systems-config.client.controller.js +++ b/modules/systems/client/controllers/systems-config.client.controller.js @@ -80,6 +80,10 @@ case 'md': _cm.setOption('mode', 'markdown'); break; + case 'html': + _cm.setOption('mode', 'xml'); + _cm.setOption('htmlMode', true); + break; default: _cm.setOption('mode', {name: 'javascript', json: true}); } @@ -126,10 +130,10 @@ $scope.$on('$stateChangeStart', function () { if (vm.contentChanged) { var modalOptions = { - closeButtonText: $translate.instant('SYSTEMS.CONFIG_CHANGED_CONFIRM_CANCEL'), + closeButtonText: $translate.instant('SYSTEMS.CONFIRM_CANCEL'), actionButtonText: $translate.instant('SYSTEMS.CONFIG_CHANGED_CONFIRM_SAVE'), - headerText: $translate.instant('SYSTEMS.CONFIG_CHANGED_HEADER_TEXT'), - bodyText: $translate.instant('SYSTEMS.CONFIG_CHANGED_BODY_TEXT') + headerText: $translate.instant('SYSTEMS.CONFIG_CHANGED_CONFIRM_HEADER_TEXT'), + bodyText: $translate.instant('SYSTEMS.CONFIG_CHANGED_CONFIRM_BODY_TEXT') }; ModalConfirmService.showModal({}, modalOptions) @@ -187,11 +191,20 @@ }; /** - * getTemplateConfigFiles + * getTemplateFrontConfigFiles */ - vm.getTemplateConfigFiles = function () { - SystemsService.getSystemTemplateConfigFiles(function (res) { - vm.templateConfigFiles = res; + vm.getTemplateFrontConfigFiles = function () { + SystemsService.getSystemTemplateFrontConfigFiles(function (res) { + vm.templateFrontConfigFiles = res; + }); + }; + + /** + * getTemplateBackConfigFiles + */ + vm.getTemplateBackConfigFiles = function () { + SystemsService.getSystemTemplateBackConfigFiles(function (res) { + vm.templateBackConfigFiles = res; }); }; diff --git a/modules/systems/client/services/systems.client.service.js b/modules/systems/client/services/systems.client.service.js index 87a8973d..0d1caef5 100644 --- a/modules/systems/client/services/systems.client.service.js +++ b/modules/systems/client/services/systems.client.service.js @@ -26,9 +26,13 @@ method: 'GET', url: '/api/systems/systemTransConfigFiles' }, - getSystemTemplateConfigFiles: { + getSystemTemplateFrontConfigFiles: { method: 'GET', - url: '/api/systems/systemTemplateConfigFiles' + url: '/api/systems/systemTemplateFrontConfigFiles' + }, + getSystemTemplateBackConfigFiles: { + method: 'GET', + url: '/api/systems/systemTemplateBackConfigFiles' }, getSystemConfigContent: { method: 'GET', diff --git a/modules/systems/client/views/panel.client.view.html b/modules/systems/client/views/panel.client.view.html index e41c401e..42efd221 100644 --- a/modules/systems/client/views/panel.client.view.html +++ b/modules/systems/client/views/panel.client.view.html @@ -8,8 +8,10 @@ ui-sref-active="active">{{'SYSTEMS.ASSETS_CONFIG' | translate}} {{'SYSTEMS.TRANS_EDIT' | translate}} - {{'SYSTEMS.TEMPLATES_EDIT' | translate}} + {{'SYSTEMS.TEMPLATES_EDIT_FRONTEND' | translate}} + {{'SYSTEMS.TEMPLATES_EDIT_BACKEND' | translate}} {{'SYSTEMS.EXAMINATION_MANAGE' | translate}} +
{{'SYSTEMS.TEMPLATES_EDIT_BACKEND' | translate}} + - {{vm.loadedFilename}} +
+
+
+ +
+
+
+ +
+ + diff --git a/modules/systems/client/views/templates.client.view.html b/modules/systems/client/views/templatesFront.client.view.html similarity index 87% rename from modules/systems/client/views/templates.client.view.html rename to modules/systems/client/views/templatesFront.client.view.html index 5d10720f..4a791aaa 100644 --- a/modules/systems/client/views/templates.client.view.html +++ b/modules/systems/client/views/templatesFront.client.view.html @@ -1,5 +1,5 @@ -
-
{{'SYSTEMS.TEMPLATES_EDIT' | translate}} +
+
{{'SYSTEMS.TEMPLATES_EDIT_FRONTEND' | translate}} - {{vm.loadedFilename}}
@@ -7,7 +7,7 @@ diff --git a/modules/systems/server/controllers/systems.server.controller.js b/modules/systems/server/controllers/systems.server.controller.js index 14b09015..4d19c904 100644 --- a/modules/systems/server/controllers/systems.server.controller.js +++ b/modules/systems/server/controllers/systems.server.controller.js @@ -78,11 +78,11 @@ exports.getSystemTransConfigFiles = function (req, res) { }; /** - * getSystemTemplateConfigFiles + * getSystemTemplateFrontConfigFiles * @param req * @param res */ -exports.getSystemTemplateConfigFiles = function (req, res) { +exports.getSystemTemplateFrontConfigFiles = function (req, res) { var files = shell.ls('./modules/*/client/templates/*.md'); if (req.user.isAdmin) { @@ -96,6 +96,25 @@ exports.getSystemTemplateConfigFiles = function (req, res) { } }; +/** + * getSystemTemplateBackConfigFiles + * @param req + * @param res + */ +exports.getSystemTemplateBackConfigFiles = function (req, res) { + var files = shell.ls('./modules/*/server/templates/*'); + + if (req.user.isAdmin) { + res.json({ + files: files + }); + } else { + return res.status(403).json({ + message: 'SERVER.USER_IS_NOT_AUTHORIZED' + }); + } +}; + /** * getSystemConfigContent * @param req diff --git a/modules/systems/server/policies/systems.server.policy.js b/modules/systems/server/policies/systems.server.policy.js index 38eade03..c1eeed99 100644 --- a/modules/systems/server/policies/systems.server.policy.js +++ b/modules/systems/server/policies/systems.server.policy.js @@ -19,7 +19,8 @@ exports.invokeRolesPolicies = function () { {resources: '/api/systems/systemEnvConfigFiles', permissions: '*'}, {resources: '/api/systems/systemAssetsConfigFiles', permissions: '*'}, {resources: '/api/systems/systemTransConfigFiles', permissions: '*'}, - {resources: '/api/systems/systemTemplateConfigFiles', permissions: '*'}, + {resources: '/api/systems/systemTemplateFrontConfigFiles', permissions: '*'}, + {resources: '/api/systems/systemTemplateBackConfigFiles', permissions: '*'}, {resources: '/api/systems/shellCommand', permissions: '*'}, {resources: '/api/systems/initExaminationData', permissions: '*'}, {resources: '/api/systems/getExaminationStatus', permissions: '*'}, diff --git a/modules/systems/server/routes/systems.server.routes.js b/modules/systems/server/routes/systems.server.routes.js index 43f1496b..c7c3d75f 100644 --- a/modules/systems/server/routes/systems.server.routes.js +++ b/modules/systems/server/routes/systems.server.routes.js @@ -16,8 +16,11 @@ module.exports = function (app) { app.route('/api/systems/systemTransConfigFiles').all(systemsPolicy.isAllowed) .get(systems.getSystemTransConfigFiles); - app.route('/api/systems/systemTemplateConfigFiles').all(systemsPolicy.isAllowed) - .get(systems.getSystemTemplateConfigFiles); + app.route('/api/systems/systemTemplateFrontConfigFiles').all(systemsPolicy.isAllowed) + .get(systems.getSystemTemplateFrontConfigFiles); + + app.route('/api/systems/systemTemplateBackConfigFiles').all(systemsPolicy.isAllowed) + .get(systems.getSystemTemplateBackConfigFiles); app.route('/api/systems/systemConfigContent').all(systemsPolicy.isAllowed) .get(systems.getSystemConfigContent)