awsasrconf.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('亚马逊ASR参数配置')" />
  5. <th:block th:include="include :: layout-latest-css" />
  6. <th:block th:include="include :: ztree-css" />
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <div class="main-content">
  12. <div class="h4 form-header" th:text="#{switchconf.asr.aws.header}"></div>
  13. <div id="baseConfigs"></div>
  14. <!-- 保存按钮 -->
  15. <div class="row" ></div>
  16. <div class="row" >
  17. <div class="col-sm-offset-5 col-sm-10">
  18. <button id="saveConfig" type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i><span th:text="#{switchconf.btn.save}"></span></button>&nbsp;
  19. </div>
  20. </div>
  21. </div>
  22. <th:block th:include="include :: footer" />
  23. <th:block th:include="include :: layout-latest-js" />
  24. <script>
  25. // 页面加载完成后,发送AJAX请求获取配置数据
  26. var prefix = ctx + "cc/fsconf";
  27. $(function() {
  28. $.ajax({
  29. url: prefix + '/getAwsAsrConf',
  30. type: 'GET',
  31. success: function(_data) {
  32. // 假设后端返回的数据格式为 [{"aliasName":"xxx", "name":"xxx", "value":"xxx"},{}]
  33. var baseConfigsHtml = '';
  34. var data = _data.data;
  35. // 渲染基础配置
  36. $.each(data, function(index, config) {
  37. baseConfigsHtml += '<div className="row">';
  38. baseConfigsHtml += '<div class="col-sm-12">';
  39. baseConfigsHtml += '<label class="col-sm-2 control-label">' + config.aliasName + '</label><div class="col-sm-10"><input class="config-value form-control" type="text" id="' + config.name + '" value="' + config.value + '" /></div>';
  40. baseConfigsHtml += '</div>';
  41. baseConfigsHtml += '</div>';
  42. });
  43. $('#baseConfigs').html(baseConfigsHtml);
  44. },
  45. error: function(error) {
  46. console.error('Error fetching configuration:', error);
  47. }
  48. });
  49. });
  50. // 保存配置
  51. $('#saveConfig').click(function() {
  52. var configs = [];
  53. $('input.config-value').each(function() {
  54. var config = {
  55. name: $(this).attr('id'),
  56. value: $(this).val().trim()
  57. };
  58. configs.push(config);
  59. });
  60. $.ajax({
  61. url: prefix + '/setAwsAsrConf', // 假设后端保存配置的接口是 /setConfig
  62. type: 'POST',
  63. contentType: 'application/json',
  64. data: JSON.stringify(configs),
  65. beforeSend: function () {
  66. $.modal.loading(i18n("common.tip.loading"));
  67. $.modal.disable();
  68. },
  69. success: function(response) {
  70. processAjaxReponseJson(response);
  71. },
  72. error: function(error) {
  73. }
  74. });
  75. });
  76. </script>
  77. </body>
  78. </html>