自动更新管控端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

428 lines
13 KiB

<!DOCTYPE html>
<html>
<head>
<title>文件更新控制台</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./static/css/bootstrap.css">
<link rel="icon" type="image/x-icon" href="/favicon.ico?v=2">
<script type="text/javascript" src="./static/js/jquery.min.js"></script>
<script type="text/javascript" src="./static/js/bootstrap.min.js"></script>
<style>
.list-group>.list-group-item {
padding: 20px;
}
.optzone {
height: 60px;
}
.stabox {
height: 260px;
overflow: scroll;
}
.flist {
height: 360px;
overflow: auto;
}
.icon {
display: inline-block;
width: 24px;
height: 24px;
}
.hsval {
font-size: 10px;
margin-left: 16px;
}
.hschange {
/* background-color: #dabd16; */
background: linear-gradient(0deg, #dabd16 60%, transparent 20%);
}
.hschange a {
color: #fff !important;
}
.hschange .icon:hover {
cursor: pointer;
background-color: #fff;
}
.folder-icon {
mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyAgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pZFlNaWQgbWVldCcgIHZpZXdCb3g9IjAgMCAyNCAyNCIgPjxwYXRoIGQ9Ik0xMCA0SDRDMi45IDQgMiA0LjkgMiA2VjE4QzIgMTkuMSAyLjkgMjAgNCAyMEgyMEMyMS4xIDIwIDIyIDE5LjEgMjIgMThWOEMyMiA2LjkgMjEuMSA2IDIwIDZIMTJMMTAgNFoiIC8+PC9zdmc+");
-webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyAgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pZFlNaWQgbWVldCcgIHZpZXdCb3g9IjAgMCAyNCAyNCIgPjxwYXRoIGQ9Ik0xMCA0SDRDMi45IDQgMiA0LjkgMiA2VjE4QzIgMTkuMSAyLjkgMjAgNCAyMEgyMEMyMS4xIDIwIDIyIDE5LjEgMjIgMThWOEMyMiA2LjkgMjEuMSA2IDIwIDZIMTJMMTAgNFoiIC8+PC9zdmc+");
background-color: #c1972e;
}
.file-icon {
mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyAgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pZFlNaWQgbWVldCcgIHZpZXdCb3g9IjAgMCAyNCAyNCIgPjxwYXRoIGQ9Ik0xNCAySDZDNC45IDIgNCAyLjkgNCA0VjIwQzQgMjEuMSA0LjkgMjIgNiAyMkgxOEMxOS4xIDIyIDIwIDIxLjEgMjAgMjBWOEwxNCAyTTEzIDlWMy41TDE4LjUgOUgxM1oiIC8+IDwvc3ZnPg==");
-webkit-mask-imagee: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyAgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pZFlNaWQgbWVldCcgIHZpZXdCb3g9IjAgMCAyNCAyNCIgPjxwYXRoIGQ9Ik0xNCAySDZDNC45IDIgNCAyLjkgNCA0VjIwQzQgMjEuMSA0LjkgMjIgNiAyMkgxOEMxOS4xIDIyIDIwIDIxLjEgMjAgMjBWOEwxNCAyTTEzIDlWMy41TDE4LjUgOUgxM1oiIC8+IDwvc3ZnPg==");
background-repeat: no-repeat;
background-color: #0e0b8b;
}
#rstatus {
height: 360px;
overflow-y: auto;
}
.nav {
background-color: #ccc;
padding-top: 12px;
}
.sticky {
position: fixed;
width: 100%;
left: 0;
bottom: 0;
z-index: 9;
border-top: 0;
background-color: #fff !important;
padding: 10px 0px;
border-bottom: none;
box-shadow: 0 10px 30px -10px rgb(0 64 128/20%);
}
</style>
</head>
<body>
<div class="jumbotron">
<div class="container">
<p>文件更新控制台</p>
<p>ver:3.04</p>
</div>
</div>
<!-- 输入服务器ip -->
<div class="container">
<div class="form-group col-md-6" style="display: none;">
<div class="input-group">
<div class="input-group-addon">服务器ip</div>
<input type="text" class="form-control" name="sip" id="scip" value="0.0.0.0"
placeholder="eg:192.168.66.99">
</div>
</div>
<div class="form-group col-md-10">
<div class="input-group">
<div class="input-group-addon">监视目录</div>
<input type="text" class="form-control" name="sdir" placeholder="空白查询根目录.eg :/www/wwwroot/aa_com/" />
</div>
</div>
<div class="form-group col-md-2">
<button type="button" id="scbtn" class="btn btn-primary">查看文件信息</button>
</div>
</div>
<!-- 目标服务器配置信息 -->
<div class="container">
<!-- 目标的服务器信息 -->
<div class="form-group col-md-4">
<div class="input-group">
<div class="input-group-addon">目标ip</div>
<input type="text" class="form-control" name="tsip" id="tcip" placeholder="eg:192.168.66.99">
</div>
</div>
<div class="form-group col-md-4">
<div class="input-group ">
<div class="input-group-addon">目标目录</div>
<input type="text" class="form-control" name="tsdir" id="" placeholder="eg :/www/wwwroot/aa_com/" />
</div>
</div>
<div class="form-group col-md-4">
<div class="input-group">
<div class="input-group-addon">来源ip</div>
<input type="text" class="form-control" name="masterip" readonly id="masteripd" value="" />
</div>
</div>
</div>
<!-- 罗列文件的列表信息 -->
<div class="container" id="scfzone">
<!-- 源服务器 -->
<div class="col-md-12">
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading" id="ssip">源站</div>
<div class="panel-body">
<p>监听目录:<span class="sc01"></span></p>
<p>相对目录: <span class="sc02"></span> </p>
<div class="col-md-12">
<a href="javascript:void(0);" class="btn btn-success btn-sm" id="slall" data-st="ss">全选</a>
</div>
</div>
<!-- List group -->
<form action="/sendZip" method="post" class="ssform">
<ul class="list-group" id="scsc"></ul>
</form>
</div>
</div>
</div>
<!-- 状态信息 -->
<div class="container">
<div class="col-md-12">
<p>1、获取远程服务器的文件信息,2、校验hash值3、枚举出所有hash不同的文件4、勾选文件更新即可5、根据勾选的文件制作更新zip文件,发送到目标服务器。文件的参考HASH值,如何同步到几个平台?</p>
</div>
<div class="panel">
<div class="panel-heading">运行状态</div>
<div class="panel-body">
<ul class="list-group" id="rstatus"></ul>
</div>
</div>
</div>
<!-- 提交按钮 -->
<div class="nav">
<div class="container">
<!-- submit -->
<div class="col-md-12">
<div class="form-group">
<button class="btn btn-info btn-sm" onclick="dosync()">同步选中的文件</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// add sticky 滚动黏贴效果
$(document).ready(function () {
// grab the initial top offset of the navigation
// var stickyNavTop = $('.nav').offset().top;
var stickyNavTop = $('.nav').offset().top;
// console.log(stickyNavTop)
// our function that decides weather the navigation bar should have "fixed" css position or not.
var stickyNav = function () {
var scrollTop = $(window).scrollTop(); // our current vertical position from the top
// if we've scrolled more than the navigation, change its position to fixed to stick to top,
// otherwise change it back to relative
if (scrollTop < stickyNavTop) {
$('.nav').addClass('sticky');
} else {
$('.nav').removeClass('sticky');
}
};
stickyNav();
// and run it again every time you scroll
$(window).scroll(function () {
stickyNav();
});
})
</script>
<script type="text/javascript">
// 控制全选与否
var chkall = true;
var chknum = 0;
var tgip = ""; //目标服务器ip
var masterip = ""; // 主控地址
var urlpath = ".";// 当前的操作目录
var chkarr = new Array; //选中的文件或目录
//var bfsarr = new Array; // base file infomation array
$(function () {
// read sessionStorage 当前
var oscip = sessionStorage.getItem("scip");
if (oscip != "" || otip != '') {
$("input[name='sip']").val(oscip);
}
// 目标服务器的文件信息
// st 源站 或 目标站
var scfs = function (st) {
//
scip = $("input[name='sip']").val();
// ip storage
sessionStorage.setItem("scip", scip);
//监视目录
var jsdir = $("input[name='sdir']").val();
if (jsdir != '') {
urlpath = bsrqst(jsdir)
//urlpath = encodeURIComponent(btoa(jsdir));
} else {
urlpath = bsrqst(".")
}
// 输入框也显示东西
$("input[name='sdir']").val(urlpath);
//
var html = "<li class=\"list-group-item\">输入源服务器" + scip + "</li>";
$("#ssip").text("源站(" + scip + ")");
// 获取信息
gescinfo("#scsc", scip, urlpath, st);
//
$("#rstatus").append(html);
}
// button click function for TARGET SERVER
$("#scbtn").on("click", function () {
$("#mbip").text("目标站(" + scip + ")");
// 检查目标ip 是否已经输入
var ttsip = $("input[name='tsip']").val();
if(ttsip==""){
alert("输入目标ip信息");
return false;
}else{
localStorage.setItem("tgip",ttsip);
tgip = ttsip
scfs("ss");
}
})
// 获取目标服务器的信息
var gescinfo = function (elemnt, scip, upath, st) {
//
upath = upath.replace("/\\/g", "\/");
var url = ""; // 客户端的状态地址
if (scip == '' || scip == "0.0.0.0" || scip == '127.0.0.1' || scip == "localhost") {
url = "./sc?p=" + upath;
} else {
url = "http://" + scip + ":9099/sc?p=" + upath;
}
//
var html = "";
$.getJSON(url, function (res) {
// 主控ip
// masterip = res.hostid
$("#masteripd").val(res.hostip)
//
var chgflag;
$.each(res.data.list, function (k, v) {
// 不存在这个字段的话
if (typeof (v.rehash) != 'undefined') {
chgflag = ""
}
// 判读是否存在 变化
if (!v.dirflag) {
// hash相同,未修改
chgflag = v.rehash == v.hash ? " nochage" : " hschange";
} else {
chgflag = ""
}
//
html += "<li class=\"list-group-item optzone " + chgflag + "\"><div class=\"col-md-10\">";
html += "<input type=\"checkbox\" class=" + st + 'mfile' + " name=\"sfiles\" value=" + v.fname + " />";
if (v.dirflag) { //如果是文件夹
html += "<span class=\"icon folder-icon\"></span>";
html += v.fname
// html += "<a href=\"javascript:void(0);\" onclick='"+getDirList(elemnt, scip,v.fname)+"'>"+v.fname +"</a>";
html += "</div>";
} else {
html += "<span class=\"icon file-icon\"></span>" +
"<a href=\"javascript:void(0);\" hsval='" + v.hash + "' bhasval='"
+ v.rehash + "'>"
+ v.fname + "</a></div>";
}
html += "</li>";
})
// append to html
html += "<input type='hidden' name='curpath' value='" + upath + "'>";
html += "<input type='hidden' name='serverip' value='" + tgip + "'>";
// if (st == "tg") {
// html += "<input type='hidden' name='serverip' value='" + scip + "'>";
// } else {
// html += "<input type='hidden' name='serverip' value='" + masterip + "'>";
// }
// $("#tgsc").html(html)
$(elemnt).html(html);
writelog(scip + "获取数据:" + res.data.list.length + "条数据")
// 客户端监控目录
$(elemnt).parent().find(".sc01").text(res.workdir)
$(elemnt).parent().find(".sc02").text(dbsresp(res.curdir))
});
}
// write log
var writelog = function (html) {
var hprex = "<li class=\"list-group-item\">" + html + "</li>";
$("#rstatus").append(hprex);
}
//全选按钮设置点击事件
$("#slall").click(function () {
let st = $(this).data("st");
//1、循环设置其它多选框选中状态,跟标识用的变量一样
$("." + st + "mfile").prop("checked", chkall);
// down button toggle
if (chkall || chknum > 2) {
chknum += 1
} else {
chknum -= 1
}
//2、标识的变量取反
chkall = !chkall;
})
//base64 编码防止请求错误
var bsrqst = function (path) {
return encodeURIComponent(btoa(path));
}
//解码base64
var dbsresp = function (bsStr) {
// console.log("respone base64 string ", bsStr)
if (bsStr == ".") {
return "."
} else {
return decodeURIComponent(atob(bsStr))
}
}
// 另外的base64的解码
function safeAtob(base64Str) {
// 检查输入字符串是否是有效的Base64编码
const base64Regex = /^[A-Za-z0-9+/]+={0,2}$/;
if (!base64Regex.test(base64Str)) {
throw new Error('The string to be decoded is not correctly encoded.');
}
// 如果输入字符串长度不是4的倍数,添加等号'='
while (base64Str.length % 4 !== 0) {
base64Str += '=';
}
return atob(base64Str);
}
});
//同步操作
var dosync = function () {
// var ttsip = $("input[name='tsip']").val();
if (tgip == "") {
alert("老天鹅,你还没填写目标服务器地址。");
} else {
// 提交表单
$(".ssform").submit();
}
}
</script>
</body>
</html>