admin.html 8.1 KB
Newer Older
H
hjdhnx 已提交
1 2 3
<!DOCTYPE html>
<html lang="en">
<head>
H
hjdhnx 已提交
4
    <meta charset="utf-8">
H
hjdhnx 已提交
5
  <title>管理员操作中心-{{rules.count}}条规则</title>
H
hjdhnx 已提交
6 7 8
  <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">
H
hjdhnx 已提交
9
<!--    <link rel="stylesheet" media="screen" href="/static/css/admin.css">-->
H
hjdhnx 已提交
10
    <link rel="stylesheet" media="screen" href="/static/css/admin.css">
H
hjdhnx 已提交
11
  <link rel="icon" href="/static/img/logo.png" type="image/x-icon">
H
hjdhnx 已提交
12
    <script src="/static/js/jquery.min.js"></script>
H
hjdhnx 已提交
13
    <script src="/static/js/common.js"></script>
H
hjdhnx 已提交
14 15
</head>
<body>
H
hjdhnx 已提交
16 17 18 19 20 21 22
<script>
    $(document).ready(function(){
        $(".view").click(function(){
            let rule = this.innerText.trim();
            location.href = '/admin/view/'+rule+'.js';
        });

H
hjdhnx 已提交
23 24 25 26 27
        $(".view_home").click(function(){
            let rule = this.getAttribute('value').trim();
            location.href = '/vod?rule='+rule;
        });

H
hjdhnx 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41
        $("#checkUpdate").click(function(){
            console.log('开始检查升级...');
            $.get("/admin/get_ver",function(data,status){
                console.log("数据: " + data + "\n状态: " + status);
                if(data.msg){
                    alert(data.msg);
                    return false
                }else{
                    if(data.local_ver && data.online_ver){
                        if(data.local_ver !== data.online_ver){
                            msg = `本地版本:${data.local_ver}\n线上版本:${data.online_ver}\n是否立即执行升级?`;
                            if(confirm(msg)){
                               $.get("/admin/update_ver",function(data,status){
                                   console.log(data);
H
hjdhnx 已提交
42 43 44 45 46
                                   if(data.code === 200){
                                       alert(data.msg+'\n除主程序app.py需要自行检测替换升级外,其他关键文件全部更新完毕');
                                      location.reload();
                                   }else{
                                       alert(data.msg||'未知数据,具体到数据控制台查看');
H
hjdhnx 已提交
47 48 49
                                       console.log('升级失败了...');
                                       return false
                                   }
H
hjdhnx 已提交
50 51 52 53 54 55 56 57 58 59 60 61
                               });
                            }
                        }else{
                            alert('已经是最新版,无需升级!')
                        }
                    }else{
                        alert('已经是最新版,无需升级!')
                    }
                }
            });
        });

H
hjdhnx 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        $(".clear").click(function(){
            let rule = this.getAttribute('value').trim();
            if(confirm('确认删除内置规则:'+rule+'?')){
            let code = $.ajax({url:'/admin/clear/'+rule+'.js',async:false}).responseText;
            code = typeof(code) === "object"?code:JSON.parse(code);
            if(code.code === 200){
                alert('操作成功!\n'+code.msg);
                location.reload()
            }else{
                alert('操作失败!\n'+code.msg);
            }
            }
        });

        $('#upload').click(function(){
            var file_data = $("input[name='file']").prop("files")[0];
H
hjdhnx 已提交
78
            // console.log(file_data);
H
hjdhnx 已提交
79 80
            if(!file_data){
                alert('文件必选');
81 82 83 84 85 86
                return false
            }
            var name = file_data.name;
            if(!name.endsWith('.js')){
                alert('仅支持上传js文件');
                return false
H
hjdhnx 已提交
87 88 89 90
            }
            var form_data = new FormData();
            // 把所有表单信息
            form_data.append("id", "001");
91
            form_data.append("name", name);
H
hjdhnx 已提交
92 93 94
            form_data.append("file", file_data);
            $.ajax({
                type: "POST",
H
hjdhnx 已提交
95
                url: "/admin/upload",
H
hjdhnx 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108
                dataType : "json",
                processData: false,  // 注意:让jQuery不要处理数据
                contentType: false,  // 注意:让jQuery不要设置contentType
                data: form_data
            }).success(function(ret) {
                console.log(ret);
                alert(ret.msg);
                location.reload();
            }).fail(function(ret) {
                console.log(ret);
                alert(ret.msg);
            });
        });
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 137 138 139 140 141 142 143

        $('#update_lives').click(function(){
            let live_url = $('#live_url').val();
            // console.log(live_url);
            let new_live_url = prompt('输入临时同步远程直播源地址(自动获取当前配置)',live_url);
            if(new_live_url.startsWith('http')){
                $.get("/admin/update_lives?url="+new_live_url,function(data,status){
                console.log("数据: " + data + "\n状态: " + status);
                if(data.code === 200){
                    alert('操作成功!\n'+data.msg);
                    // location.reload();
                }else{
                    alert('操作失败!\n'+data.msg);
                }
             });
            }
        });

        $('#write_lives').click(function(){
            let live_url = $('#live_url').val();
            let new_live_url = prompt('请修改默认的远程直播源地址',live_url);
            if(new_live_url){
                console.log('修改直播源地址为:'+new_live_url);
                $.get("/admin/write_live_url?url="+new_live_url,function(data,status){
                console.log("数据: " + data + "\n状态: " + status);
                if(data.code === 200){
                    alert('操作成功!\n'+data.msg);
                    location.reload();
                }else{
                    alert('操作失败!\n'+data.msg);
                }
             });
            }
        });

H
hjdhnx 已提交
144
});
H
hjdhnx 已提交
145 146
function getFileSize(fileObj) {
   $('#file_size').text('文件大小为:'+fileObj.files[0].size/1024+'kb');
H
hjdhnx 已提交
147
}
H
hjdhnx 已提交
148
</script>
H
hjdhnx 已提交
149 150 151
<h2 class="title">欢迎使用DR-PY管理界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
                class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div>
</h2>
H
hjdhnx 已提交
152
<h4>
H
hjdhnx 已提交
153 154 155 156 157 158 159 160 161 162 163
    <button type="button" class="yongyin"><a href="/index">返回首页</a></button>
    <button type="button" class="yongyin1"><a href="javascript:void(0);" class="funcbtn"
            id="checkUpdate">检测升级</a></button>
    <button type="button" class="yongyin2"><a href="javascript:copy('cp ./tmp/dr_py-master/app.py ./app.py');"
            class="funcbtn" id="update_by_self">升级指令</a></button>
    <button type="button" class="yongyin3"><a href="javascript:void(0);" class="funcbtn"
            id="write_lives">修改直播源</a></button>
    <button type="button" class="yongyin4"><a href="javascript:void(0);" class="funcbtn"
            id="update_lives">同步直播源</a></button>
    <input id="live_url" value="{{live_url}}" style="display: none">
    <p class="box">你可以在此界面在线管理JS目录里规则文件的上传/删除</p>
H
hjdhnx 已提交
164
</h4>
H
hjdhnx 已提交
165
 <form action = "/admin/upload" method = "POST" enctype = "multipart/form-data">
166 167
<!--     <input type = "file" name = "file" class="btn" accept=".js"  onchange="getFileSize(this)"/>-->
     <input type = "file" name = "file" class="btn" onchange="getFileSize(this)"/>
H
hjdhnx 已提交
168 169
<!--     <input type = "submit" value="上传" class="btn"/>-->
     <input type="button" id="upload" value="上传" class="btn"/>
H
hjdhnx 已提交
170
</form>
H
hjdhnx 已提交
171
<p id="file_size"></p>
H
hjdhnx 已提交
172
<h2>规则列表数据-共{{rules.count}}条</h2>
H
hjdhnx 已提交
173 174 175
{% if rules.count < 1 %}
<h3>暂无内置的规则</h3>
{% endif %}
H
hjdhnx 已提交
176
<div class="zt">
H
hjdhnx 已提交
177
{% for rule in rules.list %}
H
hjdhnx 已提交
178 179 180 181 182
    <div class="red">
         <div class="mz"><a class="view" href="javascript:void(0);">{{ rule.name }}</a></div>
        <div class="sj"><a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a></div>
        <div class="sc"><a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a></div>
    </div>
H
hjdhnx 已提交
183
 {% endfor %}
H
hjdhnx 已提交
184
</div>
H
hjdhnx 已提交
185 186
</body>
</html>