mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-03 18:30:24 +08:00
增加节点同步状态提示和任务列表
This commit is contained in:
@@ -27,12 +27,24 @@
|
||||
</a>
|
||||
|
||||
<div class="right menu">
|
||||
<!-- 集群同步 -->
|
||||
<a href="" class="item" v-if="teaCheckClusterTask && doingNodeTasks.isUpdated" @click.prevent="showNodeTasks()">
|
||||
<span v-if="!doingNodeTasks.isDoing && !doingNodeTasks.hasError"><i class="icon sync"></i>已同步</span>
|
||||
<span v-if="doingNodeTasks.isDoing && !doingNodeTasks.hasError"><i class="icon sync"></i>正在同步...</span>
|
||||
<span v-if="doingNodeTasks.hasError" class="red"><i class="icon sync"></i>同步失败</span>
|
||||
</a>
|
||||
|
||||
<!-- 消息 -->
|
||||
<a href="/messages" class="item" :class="{active:teaMenu == 'message'}"><span :class="{'blink':globalMessageBadge > 0}"><i class="icon bell"></i>消息({{globalMessageBadge}}) </span></a>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<a href="/settings/profile" class="item">
|
||||
<i class="icon user" v-if="teaUserAvatar.length == 0"></i>
|
||||
<img class="avatar" alt="" :src="teaUserAvatar" v-if="teaUserAvatar.length > 0"/>
|
||||
{{teaUsername}}
|
||||
</a>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<a :href="Tea.url('logout')" class="item" title="安全退出登录"><i class="icon sign out"></i>退出</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,119 +1,152 @@
|
||||
Tea.context(function () {
|
||||
this.moreOptionsVisible = false
|
||||
this.globalMessageBadge = 0
|
||||
this.moreOptionsVisible = false
|
||||
this.globalMessageBadge = 0
|
||||
|
||||
if (typeof this.leftMenuItemIsDisabled == "undefined") {
|
||||
this.leftMenuItemIsDisabled = false
|
||||
}
|
||||
if (typeof this.leftMenuItemIsDisabled == "undefined") {
|
||||
this.leftMenuItemIsDisabled = false
|
||||
}
|
||||
|
||||
this.$delay(function () {
|
||||
if (this.$refs.focus != null) {
|
||||
this.$refs.focus.focus()
|
||||
}
|
||||
this.$delay(function () {
|
||||
if (this.$refs.focus != null) {
|
||||
this.$refs.focus.focus()
|
||||
}
|
||||
|
||||
// 检查消息
|
||||
this.checkMessages()
|
||||
})
|
||||
// 检查消息
|
||||
this.checkMessages()
|
||||
|
||||
/**
|
||||
* 左侧子菜单
|
||||
*/
|
||||
this.showSubMenu = function (menu) {
|
||||
if (menu.alwaysActive) {
|
||||
return
|
||||
}
|
||||
if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
|
||||
this.teaSubMenus.menus.$each(function (k, v) {
|
||||
if (menu.id == v.id) {
|
||||
return
|
||||
}
|
||||
v.isActive = false
|
||||
})
|
||||
}
|
||||
menu.isActive = !menu.isActive
|
||||
};
|
||||
// 检查集群节点同步
|
||||
this.loadNodeTasks();
|
||||
})
|
||||
|
||||
/**
|
||||
* 检查消息
|
||||
*/
|
||||
this.checkMessages = function () {
|
||||
this.$post("/messages/badge")
|
||||
.params({})
|
||||
.success(function (resp) {
|
||||
this.globalMessageBadge = resp.data.count
|
||||
})
|
||||
.done(function () {
|
||||
let delay = 6000
|
||||
if (this.globalMessageBadge > 0) {
|
||||
delay = 30000
|
||||
}
|
||||
this.$delay(function () {
|
||||
this.checkMessages()
|
||||
}, delay)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 左侧子菜单
|
||||
*/
|
||||
this.showSubMenu = function (menu) {
|
||||
if (menu.alwaysActive) {
|
||||
return
|
||||
}
|
||||
if (this.teaSubMenus.menus != null && this.teaSubMenus.menus.length > 0) {
|
||||
this.teaSubMenus.menus.$each(function (k, v) {
|
||||
if (menu.id == v.id) {
|
||||
return
|
||||
}
|
||||
v.isActive = false
|
||||
})
|
||||
}
|
||||
menu.isActive = !menu.isActive
|
||||
};
|
||||
|
||||
/**
|
||||
* 底部伸展框
|
||||
*/
|
||||
this.showQQGroupQrcode = function () {
|
||||
teaweb.popup("/about/qq", {
|
||||
width: "21em",
|
||||
height: "24em"
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 检查消息
|
||||
*/
|
||||
this.checkMessages = function () {
|
||||
this.$post("/messages/badge")
|
||||
.params({})
|
||||
.success(function (resp) {
|
||||
this.globalMessageBadge = resp.data.count
|
||||
})
|
||||
.done(function () {
|
||||
let delay = 6000
|
||||
if (this.globalMessageBadge > 0) {
|
||||
delay = 30000
|
||||
}
|
||||
this.$delay(function () {
|
||||
this.checkMessages()
|
||||
}, delay)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹窗中默认成功回调
|
||||
*/
|
||||
if (window.IS_POPUP === true) {
|
||||
this.success = window.NotifyPopup
|
||||
}
|
||||
/**
|
||||
* 底部伸展框
|
||||
*/
|
||||
this.showQQGroupQrcode = function () {
|
||||
teaweb.popup("/about/qq", {
|
||||
width: "21em",
|
||||
height: "24em"
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹窗中默认成功回调
|
||||
*/
|
||||
if (window.IS_POPUP === true) {
|
||||
this.success = window.NotifyPopup
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点同步任务
|
||||
*/
|
||||
this.doingNodeTasks = {
|
||||
isDoing: false,
|
||||
hasError: false,
|
||||
isUpdated: false
|
||||
}
|
||||
|
||||
this.loadNodeTasks = function () {
|
||||
this.$post("/clusters/tasks/check")
|
||||
.success(function (resp) {
|
||||
this.doingNodeTasks.isDoing = resp.data.isDoing
|
||||
this.doingNodeTasks.hasError = resp.data.hasError
|
||||
this.doingNodeTasks.isUpdated = true
|
||||
})
|
||||
.done(function () {
|
||||
this.$delay(function () {
|
||||
this.loadNodeTasks()
|
||||
}, 5000)
|
||||
})
|
||||
}
|
||||
|
||||
this.showNodeTasks = function () {
|
||||
teaweb.popup("/clusters/tasks/listPopup", {
|
||||
height: "24em",
|
||||
width: "50em"
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
window.NotifySuccess = function (message, url, params) {
|
||||
if (typeof (url) == "string" && url.length > 0) {
|
||||
if (url[0] != "/") {
|
||||
url = Tea.url(url, params);
|
||||
}
|
||||
}
|
||||
return function () {
|
||||
teaweb.success(message, function () {
|
||||
window.location = url;
|
||||
});
|
||||
};
|
||||
if (typeof (url) == "string" && url.length > 0) {
|
||||
if (url[0] != "/") {
|
||||
url = Tea.url(url, params);
|
||||
}
|
||||
}
|
||||
return function () {
|
||||
teaweb.success(message, function () {
|
||||
window.location = url;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
window.NotifyReloadSuccess = function (message) {
|
||||
return function () {
|
||||
teaweb.success(message, function () {
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
return function () {
|
||||
teaweb.success(message, function () {
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
window.NotifyDelete = function (message, url, params) {
|
||||
teaweb.confirm(message, function () {
|
||||
Tea.Vue.$post(url)
|
||||
.params(params)
|
||||
.refresh();
|
||||
});
|
||||
teaweb.confirm(message, function () {
|
||||
Tea.Vue.$post(url)
|
||||
.params(params)
|
||||
.refresh();
|
||||
});
|
||||
};
|
||||
|
||||
window.NotifyPopup = function (resp) {
|
||||
window.parent.teaweb.popupFinish(resp);
|
||||
window.parent.teaweb.popupFinish(resp);
|
||||
};
|
||||
|
||||
window.ChangePageSize = function (size) {
|
||||
let url = window.location.toString();
|
||||
if (url.indexOf("pageSize") > 0) {
|
||||
url = url.replace(/pageSize=\d+/g, "pageSize=" + size);
|
||||
} else {
|
||||
if (url.indexOf("?") > 0) {
|
||||
url += "&pageSize=" + size;
|
||||
} else {
|
||||
url += "?pageSize=" + size;
|
||||
}
|
||||
}
|
||||
window.location = url;
|
||||
let url = window.location.toString();
|
||||
if (url.indexOf("pageSize") > 0) {
|
||||
url = url.replace(/pageSize=\d+/g, "pageSize=" + size);
|
||||
} else {
|
||||
if (url.indexOf("?") > 0) {
|
||||
url += "&pageSize=" + size;
|
||||
} else {
|
||||
url += "?pageSize=" + size;
|
||||
}
|
||||
}
|
||||
window.location = url;
|
||||
};
|
||||
6
web/views/@default/clusters/tasks/listPopup.css
Normal file
6
web/views/@default/clusters/tasks/listPopup.css
Normal file
@@ -0,0 +1,6 @@
|
||||
h3 span {
|
||||
margin-left: 0.5em;
|
||||
color: grey;
|
||||
font-size: 0.6em !important;
|
||||
}
|
||||
/*# sourceMappingURL=listPopup.css.map */
|
||||
1
web/views/@default/clusters/tasks/listPopup.css.map
Normal file
1
web/views/@default/clusters/tasks/listPopup.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["listPopup.less"],"names":[],"mappings":"AAAA,EAAG;EACF,kBAAA;EACA,WAAA;EACA,2BAAA","file":"listPopup.css"}
|
||||
38
web/views/@default/clusters/tasks/listPopup.html
Normal file
38
web/views/@default/clusters/tasks/listPopup.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>正在同步的任务<span v-if="countTasks > 0">(共{{countTasks}}个)</span></h3>
|
||||
<p class="comment" v-if="clusters.length == 0">暂时没有同步的集群。</p>
|
||||
<div v-if="clusters.length > 0">
|
||||
<table class="ui table selectable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>集群</th>
|
||||
<th>节点</th>
|
||||
<th>任务</th>
|
||||
<th>状态</th>
|
||||
<th>触发时间</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-for="cluster in clusters">
|
||||
<tr v-for="task in cluster.tasks">
|
||||
<td>{{cluster.name}}</td>
|
||||
<td>
|
||||
{{task.node.name}} <a :href="'/clusters/cluster/node?clusterId=' + cluster.id + '&nodeId=' + task.node.id" target="_blank"><i class="icon linkify small grey"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="task.type == 'configChanged'">同步配置</span>
|
||||
<span v-if="task.type == 'ipItemChanged'">同步IP名单</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="task.isDone" class="red">{{task.error}}</span>
|
||||
<span v-else>正在同步...</span>
|
||||
</td>
|
||||
<td>{{task.updatedTime}}</td>
|
||||
<td>
|
||||
<a href="" title="删除" class="remove-btn" @click.prevent="deleteTask(task.id)"><i class="icon remove small grey"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
31
web/views/@default/clusters/tasks/listPopup.js
Normal file
31
web/views/@default/clusters/tasks/listPopup.js
Normal file
@@ -0,0 +1,31 @@
|
||||
Tea.context(function () {
|
||||
this.$delay(function () {
|
||||
this.reload()
|
||||
})
|
||||
|
||||
this.reload = function () {
|
||||
this.$post("$")
|
||||
.success(function (resp) {
|
||||
this.countTasks = resp.data.countTasks
|
||||
this.clusters = resp.data.clusters
|
||||
})
|
||||
.done(function () {
|
||||
this.$delay(function () {
|
||||
this.reload()
|
||||
}, 5000)
|
||||
})
|
||||
}
|
||||
|
||||
this.deleteTask = function (taskId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除这个任务吗?", function () {
|
||||
that.$post(".delete")
|
||||
.params({
|
||||
taskId: taskId
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
5
web/views/@default/clusters/tasks/listPopup.less
Normal file
5
web/views/@default/clusters/tasks/listPopup.less
Normal file
@@ -0,0 +1,5 @@
|
||||
h3 span {
|
||||
margin-left: 0.5em;
|
||||
color: grey;
|
||||
font-size: 0.6em !important;
|
||||
}
|
||||
Reference in New Issue
Block a user