access list config feature done

This commit is contained in:
idiotalex@163.com 2020-12-08 16:20:30 +08:00
parent 3b845a5a07
commit ae900698da
10 changed files with 129 additions and 18 deletions

View File

@ -1,5 +1,6 @@
package io.jpom.controller.node.system;
import cn.jiangzeyin.common.JsonMessage;
import io.jpom.common.BaseServerController;
import io.jpom.common.forward.NodeForward;
import io.jpom.common.forward.NodeUrl;
@ -15,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* 白名单目录
@ -45,6 +48,32 @@ public class WhitelistDirectoryController extends BaseServerController {
return "node/system/whitelistDirectory";
}
/**
* @author Hotstrip
* get whiteList data
* 白名单数据接口
* @return
*/
@RequestMapping(value = "white-list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@SystemPermission
@ResponseBody
public String whiteList() {
AgentWhitelist agentWhitelist = whitelistDirectoryService.getData(getNode());
Map<String, String> map = new HashMap();
if (agentWhitelist != null) {
/**
* put key and value into map
* 赋值给 map 对象返回
*/
map.put("project", AgentWhitelist.convertToLine(agentWhitelist.getProject()));
map.put("certificate", AgentWhitelist.convertToLine(agentWhitelist.getCertificate()));
map.put("nginx", AgentWhitelist.convertToLine(agentWhitelist.getNginx()));
}
return JsonMessage.getString(200, "ok", map);
}
/**
* 保存接口
*

View File

@ -0,0 +1,30 @@
import axios from './config';
/**
* white list data
* @param {nodeId} nodeId
*/
export function getWhiteList(nodeId) {
return axios({
url: '/node/system/white-list',
method: 'post',
data: {nodeId}
})
}
/**
* edit white list data
* @param {
* nodeId: 节点 ID,
* project: 项目目录,
* certificate: 证书目录,
* nginx: Nginx 目录
* } params
*/
export function editWhiteList(params) {
return axios({
url: '/node/system/whitelistDirectory_submit',
method: 'post',
data: params
})
}

View File

@ -1,12 +0,0 @@
<template>
<div>
White List Page
</div>
</template>
<script>
export default {
data() {
return {}
}
}
</script>

View File

@ -47,11 +47,11 @@ import Tomcat from './other/tomcat';
import ScriptTemplate from './other/script-template';
import NginxList from './nginx/list';
import Cert from './nginx/cert';
import WhiteList from './config/white-list.vue';
import Cache from './config/cache';
import Log from './config/log.vue';
import Upgrade from './config/upgrade.vue';
import ConfigFile from './config/config-file.vue';
import WhiteList from './system/white-list.vue';
import Cache from './system/cache';
import Log from './system/log.vue';
import Upgrade from './system/upgrade.vue';
import ConfigFile from './system/config-file.vue';
export default {
components: {
Welcome,

View File

@ -0,0 +1,64 @@
<template>
<div>
<a-form-model ref="editForm" :model="temp" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-model-item label="项目路径" prop="id">
<a-input v-model="temp.project" type="textarea" :rows="5" style="resize: none" placeholder="请输入项目存放路径白名单,回车支持输入多个路径,系统会自动过滤 ../ 路径、不允许输入根路径"/>
</a-form-model-item>
<a-form-model-item label="证书路径" prop="name">
<a-input v-model="temp.certificate" type="textarea" :rows="5" style="resize: none" placeholder="请输入证书存放路径白名单,回车支持输入多个路径,系统会自动过滤 ../ 路径、不允许输入根路径"/>
</a-form-model-item>
<a-form-model-item label="Nginx 路径" prop="name">
<a-input v-model="temp.nginx" type="textarea" :rows="5" style="resize: none" placeholder="请输入 nginx 存放路径白名单,回车支持输入多个路径,系统会自动过滤 ../ 路径、不允许输入根路径"/>
</a-form-model-item>
<a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" :disabled="submitAble" @click="onSubmit">提交</a-button>
</a-form-model-item>
</a-form-model>
</div>
</template>
<script>
import { getWhiteList, editWhiteList } from '../../../../api/node-system';
export default {
props: {
node: {
type: Object
}
},
data() {
return {
temp: {},
submitAble: false
}
},
mounted() {
this.loadData();
},
methods: {
// load data
loadData() {
getWhiteList(this.node.id).then(res => {
if (res.code === 200) {
this.temp = res.data;
}
})
},
// submit
onSubmit() {
// disabled submit button
this.submitAble = true;
this.temp.nodeId = this.node.id;
editWhiteList(this.temp).then(res => {
if (res.code === 200) {
//
this.$notification.success({
message: res.msg,
duration: 2
});
}
// button recover
this.submitAble = false;
})
}
}
}
</script>

View File

@ -1,7 +1,7 @@
<template>
<div>
<!-- 历史监控数据 -->
<a-button type="primary" @click="handleHistory">历史监控图表</a-button>
<a-button v-show="node.cycle && node.cycle !== 0" type="primary" @click="handleHistory">历史监控图表</a-button>
<a-divider>图表</a-divider>
<!-- top 图表 -->
<div id="top-chart">loading...</div>