fix 重新同步节点项目、节点脚本缓存交互

This commit is contained in:
bwcx_jzy 2024-01-02 17:46:04 +08:00
parent 6c75c23830
commit 59402b19dd
No known key found for this signature in database
GPG Key ID: E187D6E9DDDE8C53
8 changed files with 28 additions and 88 deletions

View File

@ -5,6 +5,7 @@
### 🐞 解决BUG、优化功能
1. 【server】修复 工作空间菜单配置无法使用(感谢@新)
2. 【server】优化 重新同步节点项目、节点脚本缓存交互
------

View File

@ -24,7 +24,6 @@ package org.dromara.jpom.controller.node;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import cn.keepbx.jpom.IJsonMessage;
import cn.keepbx.jpom.model.JsonMessage;
import lombok.extern.slf4j.Slf4j;
@ -40,7 +39,6 @@ import org.dromara.jpom.model.user.UserModel;
import org.dromara.jpom.permission.ClassFeature;
import org.dromara.jpom.permission.Feature;
import org.dromara.jpom.permission.MethodFeature;
import org.dromara.jpom.permission.SystemPermission;
import org.dromara.jpom.service.node.ProjectInfoCacheService;
import org.dromara.jpom.service.user.TriggerTokenLogServer;
import org.springframework.http.MediaType;
@ -127,21 +125,6 @@ public class NodeProjectInfoController extends BaseServerController {
return JsonMessage.success("主动清除:" + count + StrUtil.SPACE + msg);
}
/**
* 删除节点缓存的所有项目
*
* @return json
*/
@GetMapping(value = "clear_all_project", produces = MediaType.APPLICATION_JSON_VALUE)
@SystemPermission(superUser = true)
@Feature(cls = ClassFeature.PROJECT, method = MethodFeature.DEL)
public IJsonMessage<Object> clearAll() {
Entity where = Entity.create();
where.set("id", " <> id");
int del = projectInfoCacheService.del(where);
return JsonMessage.success("成功删除" + del + "条项目缓存");
}
/**
* 排序
*

View File

@ -24,7 +24,6 @@ package org.dromara.jpom.controller.node.script;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import cn.keepbx.jpom.IJsonMessage;
import cn.keepbx.jpom.model.JsonMessage;
import org.dromara.jpom.common.BaseServerController;
@ -138,21 +137,6 @@ public class NodeScriptController extends BaseServerController {
return JsonMessage.success("主动清除 " + cache + StrUtil.SPACE + msg);
}
/**
* 删除节点缓存的所有脚本模版
*
* @return json
*/
@GetMapping(value = "clear_all", produces = MediaType.APPLICATION_JSON_VALUE)
@SystemPermission(superUser = true)
@Feature(method = MethodFeature.DEL)
public IJsonMessage<Object> clearAll() {
Entity where = Entity.create();
where.set("id", " <> id");
int del = nodeScriptServer.del(where);
return JsonMessage.success("成功删除" + del + "条脚本模版缓存");
}
/**
* 释放脚本关联的节点
*

View File

@ -292,7 +292,6 @@ public class WorkspaceController extends BaseServerController {
//"classpath:/menus/index.json"
//"classpath:/menus/node-index.json"
config.put("serverMenus", this.readMenusJson("classpath:/menus/index.json"));
config.put("nodeMenus", this.readMenusJson("classpath:/menus/node-index.json"));
return JsonMessage.success("", config);
}

View File

@ -107,15 +107,6 @@ export function deleteScript(params) {
});
}
// 删除节点脚本模版缓存
export function delAllCache() {
return axios({
url: "/node/script/clear_all",
method: "get",
params: {},
});
}
/**
* 解绑 Script
* @param {id} params

View File

@ -94,15 +94,6 @@ export function sortItem(params) {
});
}
// 删除节点项目缓存
export function delAllProjectCache() {
return axios({
url: "/node/clear_all_project",
method: "get",
params: {},
});
}
// 项目排序
export function sortItemProject(params) {
return axios({

View File

@ -15,12 +15,16 @@
<a-button type="primary" @click="handleEdit()">新增</a-button>
<a-tooltip v-if="nodeId" placement="topLeft" title="清除服务端缓存节点所有的脚步模版信息并重新同步">
<a-button type="danger" @click="sync()" icon="sync"> 重新同步 </a-button>
</a-tooltip>
<a-tooltip v-else placement="topLeft" title="清除服务端缓存节点所有的脚步模版信息, 需要重新同步">
<a-button type="danger" @click="delAll()" icon="delete"> 删除缓存 </a-button>
</a-tooltip>
<a-dropdown v-if="!nodeId">
<a-button type="danger"> 同步缓存 <a-icon type="down" /></a-button>
<a-menu slot="overlay">
<a-menu-item v-for="(nodeName, key) in nodeMap" :key="key" @click="sync(key)">
<a href="javascript:;">{{ nodeName }} <a-icon type="sync" /></a>
</a-menu-item>
</a-menu>
</a-dropdown>
<a-button v-else type="danger" @click="sync(nodeId)" icon="sync"> 同步缓存 </a-button>
<a-tooltip>
<template slot="title">
<div>节点脚本模版是存储在节点中的命令脚本用于在线管理一些脚本命令如初始化软件环境管理应用程序等</div>
@ -191,7 +195,7 @@
</div>
</template>
<script>
import { delAllCache, deleteScript, getScriptListAll, getTriggerUrl, unbindScript, syncScript } from "@/api/node-other";
import { deleteScript, getScriptListAll, getTriggerUrl, unbindScript, syncScript } from "@/api/node-other";
import { getNodeListAll } from "@/api/node";
import ScriptConsole from "@/pages/node/node-layout/other/script-console";
@ -338,25 +342,7 @@ export default {
// onConsoleClose() {
// this.drawerConsoleVisible = false;
// },
delAll() {
this.$confirm({
title: "系统提示",
content: "确定要清除服务端所有的脚步模版缓存信息吗?",
okText: "确认",
cancelText: "取消",
onOk: () => {
//
delAllCache().then((res) => {
if (res.code == 200) {
this.$notification.success({
message: res.msg,
});
this.loadData();
}
});
},
});
},
//
changePage(pagination, filters, sorter) {
this.listQuery = CHANGE_PAGE(this.listQuery, { pagination, sorter });
@ -428,9 +414,9 @@ export default {
},
});
},
sync() {
sync(nodeId) {
syncScript({
nodeId: this.listQuery.nodeId,
nodeId: nodeId,
}).then((res) => {
if (res.code == 200) {
this.$notification.success({

View File

@ -37,11 +37,16 @@
</a-dropdown>
<a-button v-else type="primary" :disabled="true"> 批量操作 <a-icon type="down" /> </a-button>
<a-tooltip placement="topLeft" title="清除服务端缓存节点所有的项目信息, 需要重新同步:可以通过节点列表逐个同步">
<a-button type="danger" @click="delAll()" icon="delete"> 删除缓存 </a-button>
</a-tooltip>
<a-button type="primary" @click="openAdd">创建项目</a-button>
<a-dropdown v-if="!nodeId">
<a-button type="danger"> 同步缓存 <a-icon type="down" /></a-button>
<a-menu slot="overlay">
<a-menu-item v-for="(nodeName, key) in nodeMap" :key="key" @click="reSyncProject(key)">
<a href="javascript:;">{{ nodeName }} <a-icon type="sync" /></a>
</a-menu-item>
</a-menu>
</a-dropdown>
<a-button v-else type="danger" @click="reSyncProject(nodeId)" icon="sync"> 同步缓存 </a-button>
<a-button v-if="nodeId" icon="download" type="primary" @click="handlerExportData()">导出</a-button>
<a-dropdown v-if="nodeId">
@ -370,7 +375,7 @@
</div>
</template>
<script>
import { delAllProjectCache, getNodeListAll, getProjectList, sortItemProject } from "@/api/node";
import { getNodeListAll, getProjectList, sortItemProject, syncProject } from "@/api/node";
import {
getRuningProjectInfo,
noFileModes,
@ -806,15 +811,15 @@ export default {
this.listQuery = CHANGE_PAGE(this.listQuery, { pagination, sorter });
this.getNodeProjectData();
},
delAll() {
reSyncProject(nodeId) {
this.$confirm({
title: "系统提示",
content: "确定要清除服务端所有的项目缓存信息吗?清除后需要重新同步节点项目才能正常使用项目相关功能",
content: "确定要重新同步当前节点项目缓存信息吗?",
okText: "确认",
cancelText: "取消",
onOk: () => {
//
delAllProjectCache().then((res) => {
syncProject(nodeId).then((res) => {
if (res.code == 200) {
this.$notification.success({
message: res.msg,