Authored by jack

修改nginxsync页面

... ... @@ -3,8 +3,6 @@ package com.ui.model.req;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yoho on 2016/8/24.
... ... @@ -13,7 +11,7 @@ import java.util.List;
public class NginxSyncLog {
String taskId = StringUtils.EMPTY;
int isFinished = 1;
int isFinished;
List<String> msgList = new ArrayList<>();
String log;
}
... ...
... ... @@ -84,63 +84,47 @@
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-6" style="width: 90%">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#nginx" data-toggle="tab"><strong>Nginx</strong></a></li>
<li><a href="#dns_nginx" data-toggle="tab"><strong>DNS-Nginx</strong></a></li>
<li><a href="#h5_nginx" data-toggle="tab"><strong>H5-Nginx</strong></a></li>
<%--<li><a href="#aws_time" data-toggle="tab"><strong>Request TimeRank</strong></a></li>--%>
</ul>
<!-- Tab panes -->
<div class="tab-content mb30">
<div class="tab-pane active" id="nginx">
<div class="section section-visible" style="margin-bottom: 10px;margin-top: 10px">
<textarea id="resultArea" rows="30" cols="120"
style="background-color: black; color: white;resize: none"
readonly="readonly"></textarea>
<div class="form-group">
<label class="col-sm-1 control-label">任务选择</label>
<div class="col-sm-8">
<div class="rdio rdio-default">
<input type="radio" name="operate" id="nginx" value="nginx_val" checked="checked"
onclick="operateChange(1)"/>
<label for="nginx">nginx 同步</label>
</div>
<button id="nginx_btn" class="btn btn-success btn-rounded"
style="margin-top: 10px; margin-bottom: 10px;margin-left: 50%"
onclick="btn_click('nginx_btn','resultArea')">Run
</button>
</div><!-- tab-pane -->
<div class="tab-pane" id="dns_nginx">
<div class="section section-visible" style="margin-bottom: 10px;margin-top: 10px">
<textarea id="dns_resultArea" rows="30" cols="120"
style="background-color: black; color: white;resize: none"
readonly="readonly"></textarea>
<div class="rdio rdio-default">
<input type="radio" name="operate" value="dns_nginx_val" id="dns_nginx"
onclick="operateChange(3)"/>
<label for="dns_nginx">DNS_nginx 同步</label>
</div>
<button id="dns_btn" class="btn btn-success btn-rounded"
style="margin-top: 10px; margin-bottom: 10px;margin-left: 50%"
onclick="btn_click('dns_btn','dns_resultArea')">Run
<div class="rdio rdio-default">
<input type="radio" name="operate" value="h5_nginx_val" id="h5_nginx"
onclick="operateChange(2)"/>
<label for="h5_nginx">H5_nginx 同步</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-8" style="margin-bottom: 10px;margin-top: 10px">
<button id="exe_btn" class="btn btn-success btn-rounded"
onclick="btn_click()">Run
</button>
</div><!-- tab-pane -->
<div class="tab-pane" id="h5_nginx">
<div class="section section-visible" style="margin-bottom: 10px;margin-top: 10px">
</div>
</div>
<div class="form-group" style="margin-top: 40px">
<div class="col-sm-8">
<textarea id="textArea" rows="30" cols="120"
style="background-color: black; color: white;resize: none"
readonly="readonly"></textarea>
</div>
</div>
<textarea id="h5_resultArea" rows="30" cols="120"
style="background-color: black; color: white;resize: none"
readonly="readonly"></textarea>
</div>
<button id="h5_btn" class="btn btn-success btn-rounded"
style="margin-top: 10px; margin-bottom: 10px; margin-left: 50%"
onclick="btn_click('h5_btn','h5_resultArea')">Run
</button>
</div><!-- tab-pane -->
</div><!-- tab-content -->
</div><!-- col-md-6 -->
</div>
</div>
</div>
... ... @@ -156,37 +140,46 @@
);
function btn_click(btnId, txtId) {
console.log(btnId);
var id = 0;
if (btnId === "nginx_btn") {
id = 1;
}
else if (btnId === "h5_btn") {
id = 2;
}
else if (btnId === "dns_btn") {
id = 3;
}
else {
return;
}
var btn = document.getElementById(btnId);
document.getElementById(txtId).innerText ="";
var type = 1;
function operateChange(id) {
type = id;
}
function disableSelect() {
var select = document.getElementById("nginx");
select.disabled = true;
select = document.getElementById("dns_nginx");
select.disabled = true;
select = document.getElementById("h5_nginx");
select.disabled = true;
var btn = document.getElementById("exe_btn");
btn.disabled = true;
console.log("id: " + id);
}
function ableSelect() {
var select = document.getElementById("nginx");
select.disabled = false;
select = document.getElementById("dns_nginx");
select.disabled = false;
select = document.getElementById("h5_nginx");
select.disabled = false;
var btn = document.getElementById("exe_btn");
btn.disabled = false;
}
function btn_click() {
disableSelect();
document.getElementById("textArea").innerText = "";
$.ajax({
url: getUrlBasePath() + "/nginxSync/pushTask",
type: "post",
dataType: "json",
data: {
type: id
type: type
},
success: function (response) {
var logView = document.getElementById(txtId).innerText;
var txtId = "textArea";
var interval = setInterval(function () {
$.ajax({
url: "/nginxSync/getTaskLog",
... ... @@ -198,29 +191,24 @@
success: function (data3) {
console.log(data3);
var messagedata = data3.data;
var logList = messagedata.msgList;
console.log(logList)
console.log(logList.length)
if (logList.length != 0) {
var str = "";
for (var i = 0; i < logList.length; i++) {
str = str + '\n' + logList[i];
}
var logList = messagedata.log;
if (logList != "") {
var d = document.getElementById(txtId).innerHTML;
document.getElementById(txtId).innerText = d + str;
document.getElementById(txtId).scrollTop=document.getElementById(txtId).scrollHeight;
document.getElementById(txtId).innerText = d + logList;
console.log("textarea: " + document.getElementById(txtId).innerHTML);
document.getElementById(txtId).scrollTop = document.getElementById(txtId).scrollHeight;
}
//code为2 ,则结束
var code = messagedata.isFinished;
if (code == 1) {
clearInterval(interval);
alert("Success to execute job...");
btn.disabled = false;
ableSelect();
}
},
error: function (e) {
alert("从后台获取数据出错");
ableSelect();
}
});
... ... @@ -228,7 +216,7 @@
},
error: function (e) {
alert("Failed to execute job...");
btn.disabled = false;
ableSelect();
}
});
}
... ...