diff --git a/config/env/torrents.js b/config/env/torrents.js index 2a9ddbf7..b4e4b847 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -1228,7 +1228,7 @@ module.exports = { /**------------------------------------------------------------------------------------------------ * !IMPORTANT - * MEANTORRENT CONFIG START + * MEANTORRENT CONFIG END * PLEASE DO NOT MODIFY THE FOLLOWING LINES !!! --------------------------------------------------------------------------------------------------*/ }; diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 5cb09e1f..710e206e 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -6,11 +6,13 @@ .module(app.applicationModuleName) .config(transConfig); - // ************************************************** - // English Strings - // -------------------------------------------------- - // Don`t change other code - // ************************************************** + /**------------------------------------------------------------------------------------------------ + * !IMPORTANT + * MEANTORRENT CONFIG START + * PLEASE DO NOT MODIFY THE ABOVE LINES !!! + * + * English strings + --------------------------------------------------------------------------------------------------*/ var string_en = { COMINGSOON: 'coming soon...', @@ -1258,17 +1260,21 @@ //systems control panel SYSTEMS: { - TORRENTS_CONFIG: 'System configure', + ASSETS_CONFIG: 'System assets configure', + ENV_CONFIG: 'System env configure', TEMPLATES_EDIT: 'Templates editor', - STRINGS_EDIT: 'Translate strings editor', + TRANS_EDIT: 'Translate strings editor', COMMANDS_EXECUTE: 'Server commands execute', + SELECT_FILE: 'Select file, please', - CONFIG_BLUR_CONFIRM_CANCEL: 'Cancel', - CONFIG_BLUR_CONFIRM_SAVE: 'Save', - CONFIG_BLUR_HEADER_TEXT: 'Configure was changed', - CONFIG_BLUR_BODY_TEXT: 'Configure was changed, are you sure to quit and don`t save it?', + CONFIG_CHANGED_CONFIRM_CANCEL: 'Cancel', + CONFIG_CHANGED_CONFIRM_SAVE: 'Save', + CONFIG_CHANGED_HEADER_TEXT: 'Configure was changed', + CONFIG_CHANGED_BODY_TEXT: 'Configure was changed, are you sure to quit and don`t save it?', CONFIG_SAVE_SUCCESSFULLY: 'Configure save successfully', - CONFIG_SAVE_FAILED: 'Configure save failed' + CONFIG_SAVE_FAILED: 'Configure save failed', + + DESC_CONFIG: ':warning: This is the system configuration file of **meanTorrent**. If you know what you are doing, you can modify them. Otherwise, don\'t change it arbitrarily. Incorrect settings may cause the system to not work properly. You can also consult the related system maintenance personnel before modification.' }, /////////////////////////resources tag fields/////////////////////////////////// @@ -1548,9 +1554,13 @@ } }; - // ************************************************** - // English Strings end - // ************************************************** + /**------------------------------------------------------------------------------------------------ + * !IMPORTANT + * MEANTORRENT CONFIG END + * PLEASE DO NOT MODIFY THE FOLLOWING LINES !!! + * + * English strings + --------------------------------------------------------------------------------------------------*/ // config $translateProvider transConfig.$inject = ['$translateProvider']; diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 070ee233..c6107828 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -6,11 +6,13 @@ .module(app.applicationModuleName) .config(transConfig); - // ************************************************** - // 中 文 翻 译 - // -------------------------------------------------- - // 请不要修改翻译部分之外的代码 - // ************************************************** + /**------------------------------------------------------------------------------------------------ + * !重要提示 + * MEANTORRENT 配置开始 + * 请不要修改在这之前的任何代码 !!! + * + * 中文字符串 + --------------------------------------------------------------------------------------------------*/ var string_zh = { COMINGSOON: '开发中,请稍候...', @@ -1258,17 +1260,21 @@ //systems control panel SYSTEMS: { - TORRENTS_CONFIG: '系统配置调整', + ASSETS_CONFIG: 'Assets 资源配置调整', + ENV_CONFIG: 'Env 环境配置调整', TEMPLATES_EDIT: '模板在线编辑', - STRINGS_EDIT: '多语言字符串在线编辑', + TRANS_EDIT: '多语言字符串在线编辑', COMMANDS_EXECUTE: '服务器命令在线执行', + SELECT_FILE: '请选择文件', - CONFIG_BLUR_CONFIRM_CANCEL: '取消', - CONFIG_BLUR_CONFIRM_SAVE: '保存', - CONFIG_BLUR_HEADER_TEXT: '系统配置已更改', - CONFIG_BLUR_BODY_TEXT: '系统配置已被修改, 您确定要退出并放弃保存吗?', + CONFIG_CHANGED_CONFIRM_CANCEL: '取消', + CONFIG_CHANGED_CONFIRM_SAVE: '保存', + CONFIG_CHANGED_HEADER_TEXT: '系统配置已更改', + CONFIG_CHANGED_BODY_TEXT: '系统配置已被修改, 您确定要退出并放弃保存吗?', CONFIG_SAVE_SUCCESSFULLY: '系统配置保存成功', - CONFIG_SAVE_FAILED: '系统配置保存失败' + CONFIG_SAVE_FAILED: '系统配置保存失败', + + DESC_CONFIG: ':warning: 这是 **meantorrent** 的系统配置文件, 如果您知道你在干什么, 您可以修改它们, 否则不要随便改动, 不正确的设置可能会导致系统不能正常工作. 您也可以在修改前咨询相关系统维护人员.' }, /////////////////////////resources tag fields/////////////////////////////////// @@ -1546,12 +1552,15 @@ SITE_NOTICE: { GLOBAL_SALES_NOTICE: '### 重要通知! \n :radio: **新年快乐 2018**, **{{site_name}}** 新年促销活动已准备就绪, 促销活动类型为 **{{sale_value}}** , 活动将开始于 **{{sale_start_at | date: "yyyy-MM-dd HH:mm"}}** 并持续 **{{sale_days}}** 天, 结束于 **{{sale_end_at | date: "yyyy-MM-dd HH:mm"}}**, 并感谢所有会员用户一直以来给予我们的帮助与支持!' } - }; - // ************************************************** - // 中文翻译结束 - // ************************************************** + /**------------------------------------------------------------------------------------------------ + * !重要提示 + * MEANTORRENT 配置结束 + * 请不要修改在这之前的任何代码 !!! + * + * 中文字符串 + --------------------------------------------------------------------------------------------------*/ // config $translateProvider transConfig.$inject = ['$translateProvider']; diff --git a/modules/requests/client/controllers/requests-list.client.controller.js b/modules/requests/client/controllers/requests-list.client.controller.js index b5f95428..2c2a0eb8 100644 --- a/modules/requests/client/controllers/requests-list.client.controller.js +++ b/modules/requests/client/controllers/requests-list.client.controller.js @@ -9,7 +9,7 @@ 'NotifycationService', 'uibButtonConfig', 'marked', 'localStorageService']; function RequestsListController($scope, $rootScope, $state, $timeout, $translate, Authentication, RequestsService, ScoreLevelService, MeanTorrentConfig, mtDebug, - NotifycationService, uibButtonConfig, marked, localStorageService) { + NotifycationService, uibButtonConfig, marked, localStorageService) { var vm = this; vm.user = Authentication.user; vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage; diff --git a/modules/requests/client/controllers/requests-res.client.controller.js b/modules/requests/client/controllers/requests-res.client.controller.js index c5ae8fb0..c9688413 100644 --- a/modules/requests/client/controllers/requests-res.client.controller.js +++ b/modules/requests/client/controllers/requests-res.client.controller.js @@ -9,7 +9,7 @@ 'NotifycationService', 'uibButtonConfig', 'marked', 'localStorageService']; function RequestsResController($scope, $rootScope, $state, $timeout, $translate, Authentication, RequestsService, ScoreLevelService, MeanTorrentConfig, mtDebug, - NotifycationService, uibButtonConfig, marked, localStorageService) { + NotifycationService, uibButtonConfig, marked, localStorageService) { var vm = this; vm.user = Authentication.user; vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage; diff --git a/modules/systems/client/config/systems-admin.client.menu.js b/modules/systems/client/config/systems-admin.client.menu.js index 18c8429f..2d417dff 100644 --- a/modules/systems/client/config/systems-admin.client.menu.js +++ b/modules/systems/client/config/systems-admin.client.menu.js @@ -11,7 +11,7 @@ function menuConfig(menuService) { menuService.addSubMenuItem('topbar', 'admin', { title: 'MENU_ADMIN_SYSTEMS', - state: 'admin.systems.config', + state: 'admin.systems.env', position: 1000, roles: ['admin'], divider: true diff --git a/modules/systems/client/config/systems-admin.client.routes.js b/modules/systems/client/config/systems-admin.client.routes.js index e6bf05b8..85d8ba4f 100644 --- a/modules/systems/client/config/systems-admin.client.routes.js +++ b/modules/systems/client/config/systems-admin.client.routes.js @@ -19,17 +19,21 @@ roles: ['admin'] } }) - .state('admin.systems.config', { - url: '/config', - templateUrl: '/modules/systems/client/views/config.client.view.html' + .state('admin.systems.assets', { + url: '/assets', + templateUrl: '/modules/systems/client/views/assets.client.view.html' + }) + .state('admin.systems.env', { + 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.strings', { - url: '/strings', - templateUrl: '/modules/systems/client/views/strings.client.view.html' + .state('admin.systems.trans', { + url: '/trans', + templateUrl: '/modules/systems/client/views/trans.client.view.html' }) .state('admin.systems.commands', { url: '/commands', diff --git a/modules/systems/client/controllers/ststems-config.client.controller.js b/modules/systems/client/controllers/ststems-config.client.controller.js index 3408da36..abdc34aa 100644 --- a/modules/systems/client/controllers/ststems-config.client.controller.js +++ b/modules/systems/client/controllers/ststems-config.client.controller.js @@ -5,22 +5,65 @@ .module('systems') .controller('SystemConfigController', SystemConfigController); - SystemConfigController.$inject = ['$scope', '$state', '$timeout', '$translate', 'Authentication', 'SystemsService', 'ModalConfirmService', 'NotifycationService']; + SystemConfigController.$inject = ['$scope', '$state', '$timeout', '$translate', 'Authentication', 'SystemsService', 'ModalConfirmService', 'NotifycationService', 'marked', + 'DebugConsoleService']; - function SystemConfigController($scope, $state, $timeout, $translate, Authentication, SystemsService, ModalConfirmService, NotifycationService) { + function SystemConfigController($scope, $state, $timeout, $translate, Authentication, SystemsService, ModalConfirmService, NotifycationService, marked, + mtDebug) { var vm = this; vm.user = Authentication.user; + vm.selectedFilename = 'null'; vm.cmOption = { lineNumbers: true, mode: {name: 'javascript', json: true}, tabSize: 2, onLoad: function (_cm) { + /** + * initConfigContent + * @param value + */ vm.initConfigContent = function (value) { _cm.setOption('value', value); vm.contentChanged = false; }; + /** + * onSelectedFileChanged + */ + vm.onSelectedFileChanged = function () { + if (vm.contentChanged) { + var modalOptions = { + closeButtonText: $translate.instant('SYSTEMS.CONFIG_CHANGED_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') + }; + + ModalConfirmService.showModal({}, modalOptions) + .then(function (result) { + vm.saveConfigFileContent(function () { + loadNewFile(); + }); + }, function (result) { + loadNewFile(); + }); + + } else { + loadNewFile(); + } + }; + + function loadNewFile() { + _cm.setOption('value', ''); + SystemsService.getSystemConfigContent({ + filename: vm.selectedFilename + }, function (res) { + vm.loadedFilename = vm.selectedFilename; + vm.initConfigContent(res.configContent); + }); + } + _cm.on('change', function () { vm.contentChanged = true; }); @@ -33,41 +76,70 @@ $scope.$on('$stateChangeStart', function () { if (vm.contentChanged) { var modalOptions = { - closeButtonText: $translate.instant('SYSTEMS.CONFIG_BLUR_CONFIRM_CANCEL'), - actionButtonText: $translate.instant('SYSTEMS.CONFIG_BLUR_CONFIRM_SAVE'), - headerText: $translate.instant('SYSTEMS.CONFIG_BLUR_HEADER_TEXT'), - bodyText: $translate.instant('SYSTEMS.CONFIG_BLUR_BODY_TEXT') + closeButtonText: $translate.instant('SYSTEMS.CONFIG_CHANGED_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') }; ModalConfirmService.showModal({}, modalOptions) .then(function (result) { - vm.saveConfigContent(); + vm.saveConfigFileContent(); }); } }); /** - * getConfigFile + * getDescConfig + * @returns {*} */ - vm.getConfigFile = function () { - SystemsService.getSystemConfig(function (res) { - vm.initConfigContent(res.configContent); - // vm.systemConfigContent = res.configContent; - }, function (err) { + vm.getDescConfig = function () { + var ts = $translate.instant('SYSTEMS.DESC_CONFIG'); + return marked(ts, {sanitize: true}); + }; + + /** + * getEnvConfigFiles + */ + vm.getEnvConfigFiles = function () { + SystemsService.getSystemEnvConfigFiles(function (res) { + vm.envConfigFiles = res; }); }; /** - * saveConfigContent + * getTransConfigFiles */ - vm.saveConfigContent = function () { - var sc = new SystemsService({ - content: vm.systemConfigContent + vm.getTransConfigFiles = function () { + SystemsService.getSystemTransConfigFiles(function (res) { + vm.transConfigFiles = res; }); - sc.$setSystemConfig(function (res) { + }; + + /** + * getAssetsConfigFiles + */ + vm.getAssetsConfigFiles = function () { + SystemsService.getSystemAssetsConfigFiles(function (res) { + vm.assetsConfigFiles = res; + }); + }; + + /** + * saveConfigFileContent + */ + vm.saveConfigFileContent = function (callback) { + mtDebug.info('save content to config file: ' + vm.loadedFilename); + var sc = new SystemsService({ + filename: vm.loadedFilename, + content: vm.systemConfigContentValue + }); + sc.$setSystemConfigContent(function (res) { NotifycationService.showSuccessNotify('SYSTEMS.CONFIG_SAVE_SUCCESSFULLY'); vm.contentChanged = false; + if (callback) + callback(); }); }; } diff --git a/modules/systems/client/less/systems.less b/modules/systems/client/less/systems.less index 284d6492..52408d96 100644 --- a/modules/systems/client/less/systems.less +++ b/modules/systems/client/less/systems.less @@ -11,13 +11,18 @@ } .panel-desc { border-bottom: solid 1px #ddd; + padding: 10px 15px 5px; + background-color: @alert-warning-bg; + } + .panel-filelist { + border-bottom: solid 1px #ddd; + padding: 10px 15px; background-color: #fafbfc; - height: 100px; } .panel-body { padding: 0; .CodeMirror { - min-height: 500px; + min-height: 450px; } } } \ No newline at end of file diff --git a/modules/systems/client/services/systems.client.service.js b/modules/systems/client/services/systems.client.service.js index adc57c80..d52f95ab 100644 --- a/modules/systems/client/services/systems.client.service.js +++ b/modules/systems/client/services/systems.client.service.js @@ -14,13 +14,25 @@ update: { method: 'PUT' }, - getSystemConfig: { + getSystemEnvConfigFiles: { method: 'GET', - url: '/api/systems/systemConfig' + url: '/api/systems/systemEnvConfigFiles' }, - setSystemConfig: { + getSystemAssetsConfigFiles: { + method: 'GET', + url: '/api/systems/systemAssetsConfigFiles' + }, + getSystemTransConfigFiles: { + method: 'GET', + url: '/api/systems/systemTransConfigFiles' + }, + getSystemConfigContent: { + method: 'GET', + url: '/api/systems/systemConfigContent' + }, + setSystemConfigContent: { method: 'PUT', - url: '/api/systems/systemConfig' + url: '/api/systems/systemConfigContent' } }); } diff --git a/modules/systems/client/views/assets.client.view.html b/modules/systems/client/views/assets.client.view.html new file mode 100644 index 00000000..725b4269 --- /dev/null +++ b/modules/systems/client/views/assets.client.view.html @@ -0,0 +1,26 @@ +
...
-