Skip to content

Commit

Permalink
chore: add Clean unavailable nodes and Clean deleted indices to a…
Browse files Browse the repository at this point in the history
…ctions in cluster list (#44)

Co-authored-by: yaojiping <[email protected]>
  • Loading branch information
yaojp123 and yaojiping authored Dec 17, 2024
1 parent 4218d42 commit 01c0bda
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 43 deletions.
4 changes: 4 additions & 0 deletions web/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export default {
"form.button.verify": "Verify",
"form.button.clean": "Clean",
"form.button.clean.confim.desc": "Are you sure to clean data that is {status}?",
"form.button.clean.unavailable.nodes": "Clean unavailable nodes",
"form.button.clean.unavailable.nodes.desc": "Are you sure to clean nodes that are unavailable within seven days?",
"form.button.clean.deleted.indices": "Clean deleted indices",
"form.button.clean.deleted.indices.desc": "Are you sure to clean indices that are deleted?",
"component.refreshGroup.label.title": "Auto Refresh",
"component.refreshGroup.label.every": "Every",

Expand Down
4 changes: 4 additions & 0 deletions web/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export default {
"form.button.verify": "校验",
"form.button.clean": "清除",
"form.button.clean.confim.desc": "确定删除状态为 {status} 的数据吗?",
"form.button.clean.unavailable.nodes": "清除不可用节点",
"form.button.clean.unavailable.nodes.desc": "确定清除7天内不可用的节点吗?",
"form.button.clean.deleted.indices": "清除已删除索引",
"form.button.clean.deleted.indices.desc": "确定清除已删除的索引吗?",
"component.refreshGroup.label.title": "自动刷新",
"component.refreshGroup.label.every": "每隔",

Expand Down
6 changes: 0 additions & 6 deletions web/src/pages/Platform/Overview/Indices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Infos from "./Detail/Infos";
import Card from "./Card";
import Table from "./Table";
import Overview from "@/components/Overview";
import CleanData from "../components/CleanData";

const facetLabels = {
"metadata.cluster_name": "cluster",
Expand Down Expand Up @@ -75,11 +74,6 @@ export default () => {
getStatus: (item) =>
item._source?.metadata?.labels.health_status || "unavailable",
}}
headerConfig={{
getExtra: (props) => [
<CleanData status="deleted" type="index" onSuccess={props.onCleanSuccess}/>,
],
}}
/>
);
};
6 changes: 0 additions & 6 deletions web/src/pages/Platform/Overview/Node/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Card from "./Card";
import Table from "./Table";
import Overview from "@/components/Overview";
import Logs from "./Detail/Logs";
import CleanData from "../components/CleanData";

const facetLabels = {
"metadata.cluster_name": "cluster",
Expand Down Expand Up @@ -85,11 +84,6 @@ export default () => {
getStatus: (item) =>
item._source?.metadata?.labels?.status || "unavailable",
}}
headerConfig={{
getExtra: (props) => [
<CleanData status="unavailable" type="node" onSuccess={props.onCleanSuccess}/>,
],
}}
/>
);
};
31 changes: 0 additions & 31 deletions web/src/pages/Platform/Overview/components/CleanData/index.jsx

This file was deleted.

41 changes: 41 additions & 0 deletions web/src/pages/System/Cluster/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Link from "umi/link";
import request from "@/utils/request";
import { hasAuthority } from "@/utils/authority";
import { useGlobal } from "@/layouts/GlobalContext";
import { ESPrefix } from "@/services/common";

export default (props) => {
const ref = useRef(null);
Expand Down Expand Up @@ -92,6 +93,32 @@ export default (props) => {
});
}, []);

const onClean = async (type) => {
setIsLoading(true)
const res = await request(`${ESPrefix}/metadata/${type}`, {
method: 'DELETE'
})
if (res?.acknowledged) {
message.success(formatMessage({ id: "app.message.operate.success"}))
}
setIsLoading(false)
}

const showCleanConfirm = (type) => {
let title
if (type === 'node') {
title = formatMessage({ id: "form.button.clean.unavailable.nodes.desc" })
} else if (type === 'index') {
title = formatMessage({ id: "form.button.clean.unavailable.indices.desc" })
}
Modal.confirm({
title,
onOk() {
onClean(type)
},
});
};

const formatTableData = async (value) => {
let dataNew = formatESSearchResult(value);
//更新扩展数据
Expand Down Expand Up @@ -212,6 +239,12 @@ export default (props) => {
render: (text, record) => {
const onMenuClick = ({ key }) => {
switch (key) {
case "clean_nodes":
showCleanConfirm('node');
break;
case "clean_indices":
showCleanConfirm('index');
break;
case "delete":
showDeleteConfirm(record);
break;
Expand All @@ -233,6 +266,14 @@ export default (props) => {
</Link>
),
});
menuItems.push({
key: "clean_nodes",
content: formatMessage({ id: "form.button.clean.unavailable.nodes" }),
});
menuItems.push({
key: "clean_indices",
content: formatMessage({ id: "form.button.clean.deleted.indices" }),
});
if (!record.reserved) {
menuItems.push({
key: "delete",
Expand Down

0 comments on commit 01c0bda

Please sign in to comment.