settings.html 5.4 KB
Newer Older
H
hjdhnx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
  <title>管理员操作中心-配置修改</title>
  <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  <meta name="author" content="道长"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" media="screen" href="/static/css/admin.css">
    <link rel="stylesheet" media="screen" href="/static/css/settings.css">
  <link rel="icon" href="/static/img/logo.png" type="image/x-icon">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/common.js"></script>
H
hjdhnx 已提交
14
    <script src="/static/js/grey.js"></script>
H
hjdhnx 已提交
15 16
  <link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
  <script src="/static/plugin/layui/layui.js"></script>
H
hjdhnx 已提交
17
</head>
H
hjdhnx 已提交
18 19
<body style="margin:0 auto">
  <center>
H
hjdhnx 已提交
20
<script>
H
hjdhnx 已提交
21 22 23 24
  function saveConf(key,value){
    // let thisObj=$(obj);//js对象转jquery对象
    // let key = thisObj.attr("value");
    // let value = $('.conf[name="'+key+'"]').val();
H
hjdhnx 已提交
25
    console.log('key:'+key+',value:'+value);
H
hjdhnx 已提交
26 27 28 29
    if(!key||typeof(value)==='undefined'){
      layer.msg('saveConf传参异常',{time:1000});
      return
    }
H
hjdhnx 已提交
30 31 32 33 34 35 36
    let params = {
      key:key,
      value:value
    };
    $.post("/admin/save_conf",params,function(data,status){
                   // console.log(data);
                   if(data.code === 200){
H
hjdhnx 已提交
37 38
                       // alert(data.msg);
                       layer.msg(data.msg,{time:1000});
H
hjdhnx 已提交
39
                       console.log('保存'+key+'成功了...');
H
hjdhnx 已提交
40
                       $(`input.conf[name="${key}"]`).val(value);
H
md  
hjdhnx 已提交
41 42 43
                       if(/UNAME|PWD/.test(params.key)){
                         location.reload();
                         }
H
hjdhnx 已提交
44 45 46 47
                   }else{
                      if(/登录/.test(data.msg)){
                        location.href = '/admin'
                      }else{
H
hjdhnx 已提交
48 49
                        // alert(data.msg);
                        layer.msg(data.msg,{time:1000});
H
hjdhnx 已提交
50 51 52 53 54 55
                       console.log('保存'+key+'失败了...');
                       return false
                      }
                   }
    });
  }
H
hjdhnx 已提交
56 57 58 59 60 61 62 63 64 65 66 67

  function checkValue(key,value){
    if(key==='ENV'){
      try {
        JSON.parse(value);
      }catch (e) {
        layer.msg(`保存失败,变量 ${key}必须为json格式!`);
        return false;
      }
    }
    return true;
  }
H
hjdhnx 已提交
68
    $(document).ready(function() {
H
hjdhnx 已提交
69 70 71
      $(".save_conf").click(function () {
        let key = $(this).attr('value');
        let value = $(`input.conf[name="${key}"]`).val();
H
hjdhnx 已提交
72 73 74
        if(checkValue(key,value)){
            saveConf(key,value);
        }
H
hjdhnx 已提交
75 76 77 78 79 80 81 82 83 84 85
      });
      $('.edit_conf').click(function (){
        let key = $(this).attr('value');
        let value = $(`input.conf[name="${key}"]`).val();
        layer.prompt({
          formType: 2,
          value: value,
          title: '请输入 '+key,
          area: ['320px', '100px'] //自定义文本域宽高
	    }, function(value, index, elem){
	      console.log(value); //得到value
H
hjdhnx 已提交
86 87 88
          if(checkValue(key,value)){
            saveConf(key,value);
          }
H
hjdhnx 已提交
89 90
          layer.close(index);
        });
H
hjdhnx 已提交
91
      });
H
hjdhnx 已提交
92
      $('#update_db').click(function (){
H
hjdhnx 已提交
93
        if(confirm('确定要升级数据库?升级过程可能较长,需要耐心等待提示完成。判断标准为是否正常打开缓存文件列表-查看界面,如果正常就不需要进行此操作。升级数据库后将正常使用未来功能多选操作,可对规则进行多选显示或者隐藏')){
H
hjdhnx 已提交
94
          $.get("/admin/update_db",function(data,status){
H
hjdhnx 已提交
95 96 97 98 99 100 101 102 103 104
                   console.log(data);
                   if(data.code === 200){
                       alert(data.msg);
                      // location.reload();
                   }else{
                       alert(data.msg);
                       console.log('升级失败了...');
                       return false
                   }
           });
H
hjdhnx 已提交
105
        }
H
hjdhnx 已提交
106
      });
H
hjdhnx 已提交
107 108
    });
</script>
H
hjdhnx 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
<div class="title">欢迎使用DR-PY配置界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
                class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div></div>
  <div class="nav">
    <!-- 列表 -->
    <ul>
        <!-- 一级菜单 -->
        <li class="nav-litem">
           <a href="/admin">返回前页</a>
        </li>

        <li class="nav-litem">
          <a href="javascript:void(0);" class="funcbtn" id="update_db">升级数据库</a>
        </li>

        <li class="nav-litem">
          <a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');" class="funcbtn" id="update_by_self">升级指令</a>
        </li>

        <li class="nav-litem">
          <a href="javascript:copy('cp ./tmp/dr_py-master/base/custom.conf base');" class="funcbtn" id="user_custom">用户配置</a>
        </li>

       
    </ul>
</div>

<div class="w">
<form action="#" class="m">
H
hjdhnx 已提交
137
{% for conf in conf_lists %}
H
hjdhnx 已提交
138 139 140

  <span class="label{{conf.name|length}}">
    {{ conf.name }}:
H
hjdhnx 已提交
141 142 143
  </span>
  <input class="conf" type="text" name="{{ conf.key }}"  placeholder="请输入{{ conf.key }}..." value="{{ conf.value }}"/>
  <a class="edit_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">编辑</a>
H
hjdhnx 已提交
144
  <a class="save_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">保存</a>
H
hjdhnx 已提交
145 146
{% if loop.last==False %}</br>{% endif %}{% endfor %}
</form>
H
hjdhnx 已提交
147 148
</div>
</center>
H
hjdhnx 已提交
149 150
</body>
</html>