review code.

This commit is contained in:
lijiahang
2022-08-12 19:09:26 +08:00
parent 5444bb7818
commit 9aef52bc47
5 changed files with 63 additions and 61 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ RUN sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config &&
ssh-keygen -t ed25519 -P '' -f /etc/ssh/ssh_host_ed25519_key && \
echo 'root:orionadmin' | chpasswd
WORKDIR /app
COPY orion-ops-api/target/orion-ops-api-1.2.0.jar /app/app.jar
COPY orion-ops-api/orion-ops-web/target/orion-ops-web-1.2.0.jar /app/app.jar
COPY orion-ops-vue/dist/index.html /usr/share/nginx/html/
COPY orion-ops-vue/dist /usr/share/nginx/html/ops
ADD docker/orion-ops/entrypoint.sh /app/entrypoint.sh
+18
View File
@@ -2427,6 +2427,24 @@ const $api = {
})
},
/**
* 安装机器监控插件
*/
installMachineMonitorAgent: param => {
return $http.$post('/monitor/install', param, {
loading: '正在安装/启动...'
})
},
/**
* 升级机器监控插件
*/
upgradeMachineMonitorAgent: param => {
return $http.$post('/monitor/upgrade', param, {
loading: '正在升级...'
})
},
/**
* 查询机器监控指标
*/
+15 -20
View File
@@ -191,14 +191,14 @@ export const MACHINE_PROXY_TYPE = {
label: 'http',
color: '#228BE6'
},
SOCKET4: {
SOCKS4: {
value: 2,
label: 'socket4',
label: 'socks4',
color: '#1098AD'
},
SOCKET5: {
SOCKS5: {
value: 3,
label: 'socket5',
label: 'socks5',
color: '#0CA678'
}
}
@@ -2459,25 +2459,20 @@ export const IMPORT_TYPE = {
* 监控状态
*/
export const MONITOR_STATUS = {
NOT_INSTALL: {
value: 1,
label: '未安装',
color: ''
},
INSTALLING: {
value: 2,
label: '安装中',
color: 'green'
},
NOT_START: {
value: 3,
label: '未运行',
color: ''
value: 1,
label: '未启动',
status: 'default'
},
STARTED: {
value: 4,
STARTING: {
value: 2,
label: '启动中',
status: 'success'
},
RUNNING: {
value: 3,
label: '运行中',
color: 'blue'
status: 'processing'
}
}
@@ -53,9 +53,8 @@
</template>
<!-- 状态 -->
<template #status="record">
<a-tag :color="record.status | formatStatus('color')">
{{ record.status | formatStatus('label') }}
</a-tag>
<a-badge :status="record.status | formatStatus('status')"
:text="record.status | formatStatus('label')"/>
</template>
<!-- version -->
<template #version="record">
@@ -69,43 +68,30 @@
<template #title>
最新版本: V{{ record.latestVersion }} 点击进行升级
</template>
<a-tag class="ml4 pointer usn" @click="upgradeVersion(record.machineId)">
<a-tag class="ml4 pointer usn" @click="upgradeVersion(record)">
升级
</a-tag>
</a-tooltip>
</template>
<!-- 操作 -->
<template #action="record">
<!-- 监控 -->
<!-- 安装 -->
<a-button class="p0"
v-if="MONITOR_STATUS.NOT_START.value === record.status"
type="link"
style="height: 22px"
:disabled="MONITOR_STATUS.STARTED.value !== record.status">
@click="installMonitor(record)">
安装
</a-button>
<!-- 监控 -->
<a-button class="p0"
v-else
type="link"
style="height: 22px"
:disabled="MONITOR_STATUS.RUNNING.value !== record.status">
<a :href="`#/machine/monitor/metrics/${record.machineId}`">监控</a>
</a-button>
<a-divider type="vertical"/>
<!-- 安装 -->
<span v-if="MONITOR_STATUS.NOT_INSTALL.value === record.status"
class="span-blue pointer"
@click="installMonitor(record.machineId)">
安装
</span>
<!-- 启动 -->
<a-button v-if="MONITOR_STATUS.INSTALLING.value === record.status ||
MONITOR_STATUS.NOT_START.value === record.status"
type="link"
style="height: 22px; padding: 0 3px"
:disabled="MONITOR_STATUS.INSTALLING.value === record.status"
@click="installMonitor(record.machineId)">
启动
</a-button>
<!-- 同步 -->
<span v-if="MONITOR_STATUS.STARTED.value === record.status"
class="span-blue pointer"
@click="syncMonitor(record.machineId)">
同步
</span>
<a-divider type="vertical"/>
<a @click="openAgentSetting(record.machineId)">插件配置</a>
<a-divider type="vertical"/>
<a :href="`#/machine/monitor/metrics/${record.machineId}?tab=3`">报警配置</a>
@@ -226,17 +212,21 @@ export default {
this.getList({})
}
},
toMonitor(machineId) {
this.$message.success(machineId)
installMonitor(record) {
record.status = MONITOR_STATUS.STARTING.value
this.$api.installMachineMonitorAgent({
machineId: record.machineId
}).then(({ data }) => {
record.status = data
})
},
installMonitor(machineId) {
this.$message.success(machineId)
},
upgradeVersion(machineId) {
this.$message.success(machineId)
},
syncMonitor(machineId) {
this.$message.success(machineId)
upgradeVersion(record) {
record.status = MONITOR_STATUS.STARTING.value
this.$api.upgradeMachineMonitorAgent({
machineId: record.machineId
}).then(({ data }) => {
record.status = data
})
},
openAgentSetting(machineId) {
this.$refs.configModal.open(machineId)
@@ -244,7 +234,6 @@ export default {
resetForm() {
this.$refs.query.resetFields()
this.$refs.machineSelector.reset()
this.$refs.userSelector && this.$refs.userSelector.reset()
this.query.machineId = undefined
this.query.machineName = undefined
this.query.status = undefined
@@ -124,7 +124,7 @@ export default {
machineId: this.machineId
}).then(({ data }) => {
this.config = data
this.monitorStarted = MONITOR_STATUS.STARTED.value === data.status
this.monitorStarted = MONITOR_STATUS.RUNNING.value === data.status
if (!this.monitorStarted && (this.active === 1 || this.active === 2)) {
this.$message.warning('监控插件未运行')
}