Skip to content

Commit

Permalink
For #240.
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Mar 24, 2017
1 parent aa20349 commit 0244951
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 167 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="index-content">
<section class="content-header">
<h4>事件追踪数据源配置</h4>
<h4>事件追踪数据源配置总览</h4>
</section>
<section class="content">
<table id="data-sources" data-pagination="true" data-page-list="[10, 20, 50, 100]"></table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="index-content">
<section class="content-header">
<h4>注册中心配置</h4>
<h4>注册中心配置总览</h4>
</section>
<section class="content">
<table id="reg-centers" data-pagination="true" data-page-list="[10, 20, 50, 100]"></table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="index-content">
<section class="content">
<h4>作业总览</h4>
<h4>作业配置总览</h4>
<table id="jobs-overview-tbl" data-pagination="true" data-page-list="[10, 20, 50, 100]"></table>
</section>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="index-content">
<section class="content">
<h4>服务器IP地址:<span id="server-ip"></span></h4><br/>
<h4>服务器IP地址:<span id="server-ip"></span></h4>&nbsp;&nbsp;
<h4>服务器实例ID:<span id="server-instance-id"></span></h4>
<table id="jobs"></table>
<span id="chosen-job-name" class="hide"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ function renderDataSources() {
$("#data-sources").bootstrapTable({
url: "api/data-source",
cache: false,
search: true,
showRefresh: true,
showColumns: true,
columns:
[{
field: "name",
title: "数据源名称"
title: "数据源名称",
sortable: true
}, {
field: "driver",
title: "数据库驱动"
}, {
field: "url",
title: "数据库连接地址"
title: "数据库连接地址",
sortable: true
}, {
field: "username",
title: "数据库用户名"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ function renderRegCenters() {
$("#reg-centers").bootstrapTable({
url: "api/registry-center",
cache: false,
search: true,
showRefresh: true,
showColumns: true,
columns:
[{
field: "name",
title: "注册中心名称"
title: "注册中心名称",
sortable: true
}, {
field: "zkAddressList",
title: "连接地址"
title: "连接地址",
sortable: true
}, {
field: "namespace",
title: "命名空间"
title: "命名空间",
sortable: true
}, {
field: "digest",
title: "登录凭证"
Expand Down Expand Up @@ -140,7 +146,7 @@ function submitRegCenter() {
var namespace = $("#namespace").val();
var digest = $("#digest").val();
$.ajax({
url: "api/registry_center",
url: "api/registry-center",
type: "POST",
data: JSON.stringify({"name": name, "zkAddressList": zkAddressList, "namespace": namespace, "digest": digest}),
contentType: "application/json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
$(function() {
var jobName = getCurrentUrl("jobName");
var serverIp = getCurrentUrl("serverIp");
var statusPage = getCurrentUrl("statusPage");
var jobName = getCurrentUrl("job-name");
var serverIp = getCurrentUrl("server-ip");
var statusPage = getCurrentUrl("status-page");
if (null !== statusPage) {
$("#content").load("html/status/job/job_status_detail.html");
$("#job").addClass("active");
$("#server").addClass("active");
$("#job-status").parent().addClass("active");
} else if (null !== serverIp) {
$("#content").load("html/status/server/server_status_detail.html");
$("#server").addClass("active");
$("#server-status").parent().addClass("active");
} else if (null !== jobName) {
$("#content").load("html/job/jobs_overview.html");
$("#job").addClass("active");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function bindSubmitJobSettingsForm() {
dataType: "json",
success: function() {
showSuccessDialog();
window.location = "index.html?jobName=" + jobName;
window.location = "index.html";
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
$(function() {
renderJobsOverview();
bindModifyButtons();
bindTriggerButtons();
bindPauseButtons();
bindResumeButtons();
bindRemoveButtons();
bindModifyButton();
});

function renderJobsOverview() {
$("#jobs-overview-tbl").bootstrapTable({
url: "/api/jobs",
cache: false,
search: true,
showRefresh: true,
showColumns: true,
columns:
[{
field: "jobName",
title: "作业名",
sortable: true
}, {
field: "jobType",
title: "作业类型",
sortable: true
}, {
field: "cron",
title: "cron表达式"
}, {
field: "description",
title: "描述"
}, {
field: "status",
title: "状态",
sortable: true,
formatter: "statusFormatter"
}, {
field: "operation",
title: "操作",
Expand All @@ -35,44 +33,13 @@ function renderJobsOverview() {
});
}

function statusFormatter(value, row) {
switch(value) {
case "OK":
return "<span class='label label-success'>全部可用</span>";
break;
case "DISABLED":
return "<span class='label label-info'>被禁用</span>";
break;
case "PARTIAL_ALIVE":
return "<span class='label label-warning'>部分可用</span>";
break;
case "ALL_CRASHED":
return "<span class='label label-danger'>全部宕机</span>";
break;
}
}

function generateOperationButtons(val, row) {
var modifyButton = "<button operation='modifyJob' class='btn-xs btn-warning' jobName='" + row.jobName + "'>修改</button>";
var removeButton = "<button operation='removeJob' class='btn-xs btn-danger' jobName='" + row.jobName + "'>删除</button>";
var pauseButton = "<button operation='pauseJob' class='btn-xs btn-warning' jobName='" + row.jobName + "'>暂停</button>";
var resumeButton = "<button operation='resumeJob' class='btn-xs btn-info' jobName='" + row.jobName + "'>恢复</button>";
var triggerButton = "<button operation='triggerJob' class='btn-xs btn-success' jobName='" + row.jobName + "'>触发</button>";
var operationTd = modifyButton + "&nbsp;" + removeButton + "&nbsp;" + triggerButton + "&nbsp;";
if ("PAUSED" === row.status) {
operationTd = operationTd + resumeButton + "&nbsp;";
} else if ("DISABLED" !== row.status && "CRASHED" !== row.status && "SHUTDOWN" !== row.status) {
operationTd = operationTd + pauseButton + "&nbsp;";
}
if ("SHUTDOWN" === row.status || "CRASHED" === row.status) {
operationTd = removeButton + "&nbsp;";
}
return operationTd;
return "<button operation='modify-job' class='btn-xs btn-info' job-name='" + row.jobName + "'>修改</button>";
}

function bindModifyButtons() {
$(document).on("click", "button[operation='modifyJob'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("jobName");
function bindModifyButton() {
$(document).on("click", "button[operation='modify-job'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("job-name");
$.ajax({
url: "/api/jobs/settings/" + jobName,
success: function(data) {
Expand All @@ -88,79 +55,6 @@ function bindModifyButtons() {
});
}

function bindRemoveButtons() {
$(document).on("click", "button[operation='removeJob'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("jobName");
$.ajax({
url: "/api/jobs/remove",
type: "POST",
data: JSON.stringify({jobName : jobName}),
contentType: "application/json",
dataType: "json",
success: function(data) {
if (data.length > 0) {
showFailureDialog("remove-job-failure-dialog");
} else {
showSuccessDialog();
}
$("#jobs-overview-tbl").bootstrapTable("refresh");
getJobNavTag();
}
});
});
}

function bindTriggerButtons() {
$(document).on("click", "button[operation='triggerJob'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("jobName");
$.ajax({
url: "/api/jobs/triggerAll/name",
type: "POST",
data: JSON.stringify({jobName : jobName}),
contentType: "application/json",
dataType: "json",
success: function() {
$("#jobs-overview-tbl").bootstrapTable("refresh");
showSuccessDialog();
}
});
});
}

function bindPauseButtons() {
$(document).on("click", "button[operation='pauseJob'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("jobName");
$.ajax({
url: "/api/jobs/pauseAll/name",
type: "POST",
data: JSON.stringify({jobName : jobName}),
contentType: "application/json",
dataType: "json",
success: function() {
$("#jobs-overview-tbl").bootstrapTable("refresh");
showSuccessDialog();
}
});
});
}

function bindResumeButtons() {
$(document).on("click", "button[operation='resumeJob'][data-toggle!='modal']", function(event) {
var jobName = $(event.currentTarget).attr("jobName");
$.ajax({
url: "/api/jobs/resumeAll/name",
type: "POST",
data: JSON.stringify({jobName : jobName}),
contentType: "application/json",
dataType: "json",
success: function() {
$("#jobs-overview-tbl").bootstrapTable("refresh");
showSuccessDialog();
}
});
});
}

function renderJob(data) {
$("#job-name").attr("value", data.jobName);
$("#job-type").attr("value", data.jobType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
$(function() {
$("#job-name").text(getCurrentUrl("jobName"));
$("#job-name").text(getCurrentUrl("job-name"));
renderServers();
$('[href="#servers"]').click(function() {
renderServers();
});
$('[href="#execution-info"]').click(function() {
renderExecution();
});
bindTriggerButtons();
bindPauseButtons();
bindResumeButtons();
bindShutdownButtons();
bindRemoveButtons();
bindDisableButtons();
bindEnableButtons();
bindButtons();
});

function renderServers() {
Expand Down Expand Up @@ -94,7 +88,17 @@ function generateOperationButtons(val, row) {
return operationTd;
}

function bindTriggerButtons() {
function bindButtons() {
bindTriggerButton();
bindPauseButton();
bindResumeButton();
bindShutdownButton();
bindRemoveButton();
bindDisableButton();
bindEnableButton();
}

function bindTriggerButton() {
$(document).on("click", "button[operation='trigger'][data-toggle!='modal']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -111,7 +115,7 @@ function bindTriggerButtons() {
});
}

function bindPauseButtons() {
function bindPauseButton() {
$(document).on("click", "button[operation='pause'][data-toggle!='modal']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -128,7 +132,7 @@ function bindPauseButtons() {
});
}

function bindResumeButtons() {
function bindResumeButton() {
$(document).on("click", "button[operation='resume']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -145,7 +149,7 @@ function bindResumeButtons() {
});
}

function bindShutdownButtons() {
function bindShutdownButton() {
$(document).on("click", "button[operation='shutdown']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -162,7 +166,7 @@ function bindShutdownButtons() {
});
}

function bindRemoveButtons() {
function bindRemoveButton() {
$(document).on("click", "button[operation='remove']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -183,7 +187,7 @@ function bindRemoveButtons() {
});
}

function bindDisableButtons() {
function bindDisableButton() {
$(document).on("click", "button[operation='disable']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand All @@ -200,7 +204,7 @@ function bindDisableButtons() {
});
}

function bindEnableButtons() {
function bindEnableButton() {
$(document).on("click", "button[operation='enable']", function(event) {
var jobName = $("#job-name").text();
$.ajax({
Expand Down
Loading

0 comments on commit 0244951

Please sign in to comment.