main
youys 4 days ago
commit 55bb278159

@ -43,6 +43,14 @@ class pollApi {
}); });
} }
remove(data) {
return request({
url: apiPrefix + '/v1/resource/pool/removeNode',
method: 'POST',
data,
});
}
getDetailNodeList(data) { getDetailNodeList(data) {
return { return {
url: apiPrefix + '/v1/resource/pool/detail', url: apiPrefix + '/v1/resource/pool/detail',

@ -2,6 +2,9 @@ import { timeParse } from '@/utils';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import nodeApi from '~/vgpu/api/node'; import nodeApi from '~/vgpu/api/node';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import useParentAction from '~/vgpu/hooks/useParentAction';
const { sendRouteChange } = useParentAction();
export const getResourceStatus = (statusConfig) => { export const getResourceStatus = (statusConfig) => {
return { return {
@ -278,7 +281,7 @@ export const handleChartClick = async (params, router) => {
if (node) { if (node) {
const uuid = node.uid; const uuid = node.uid;
router.push(`/admin/vgpu/node/admin/${uuid}?nodeName=${name}`); sendRouteChange(`/admin/vgpu/node/admin/${uuid}?nodeName=${name}`);
} else { } else {
ElMessage.error('节点未找到'); ElMessage.error('节点未找到');
} }

@ -172,11 +172,6 @@ const columns = [
dataIndex: 'diskSize', dataIndex: 'diskSize',
render: ({ diskSize }) => `${bytesToGB(diskSize)}GiB`, render: ({ diskSize }) => `${bytesToGB(diskSize)}GiB`,
}, },
{
title: '所属资源池',
dataIndex: 'resourcePools',
render: ({ resourcePools }) => `${resourcePools.join('、')}`,
},
{ {
title: '显卡数量', title: '显卡数量',
dataIndex: 'cardCnt', dataIndex: 'cardCnt',
@ -221,57 +216,23 @@ const rowAction = [
}, },
}, },
{ {
title: '禁用', title: '移除',
hidden: (row) => !row.isSchedulable,
onClick: async (row) => { onClick: async (row) => {
ElMessageBox.confirm(`认对该节点进行禁用操作`, '操作确认', { ElMessageBox.confirm(`定要移除当前节点吗`, '操作确认', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}) })
.then(async () => { .then(async () => {
try { try {
await nodeApi.stop( await pollApi.remove(
{ {
nodeName: row.name, node_id: row.nodeId,
status: 'DISABLED'
} }
).then( ).then(
() => { () => {
setTimeout(() => { setTimeout(() => {
ElMessage.success('节点禁用成功'); ElMessage.success('节点移除成功');
table.value.fetchData();
}, 500);
}
)
} catch (error) {
ElMessage.error(error.message);
}
})
.catch(() => { });
},
},
{
title: '开启',
hidden: (row) => row.isSchedulable,
disabled: (row) => row.isExternal,
onClick: async (row) => {
ElMessageBox.confirm(`确认对该节点进行开启调度操作?`, '操作确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
try {
await nodeApi.stop(
{
nodeName: row.name,
status: 'ENABLE'
}
).then(
() => {
setTimeout(() => {
ElMessage.success('节点开启调度成功');
table.value.fetchData(); table.value.fetchData();
}, 500); }, 500);
} }
@ -523,7 +484,6 @@ onMounted(async () => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.card-gauges { .card-gauges {
margin: 0; margin: 0;
padding: 0; padding: 0;

@ -64,7 +64,7 @@ import { onMounted, ref, watch, watchEffect } from 'vue';
import useInstantVector from '~/vgpu/hooks/useInstantVector'; import useInstantVector from '~/vgpu/hooks/useInstantVector';
import cardApi from '~/vgpu/api/card'; import cardApi from '~/vgpu/api/card';
import { QuestionFilled } from '@element-plus/icons-vue'; import { QuestionFilled } from '@element-plus/icons-vue';
import { roundToDecimal, timeParse, calculateDuration } from '@/utils'; import { roundToDecimal, timeParse, calculateDuration, bytesToGB } from '@/utils';
import taskApi from '~/vgpu/api/task'; import taskApi from '~/vgpu/api/task';
import BlockBox from '@/components/BlockBox.vue'; import BlockBox from '@/components/BlockBox.vue';
import Gauge from '~/vgpu/components/gauge.vue'; import Gauge from '~/vgpu/components/gauge.vue';
@ -164,11 +164,23 @@ const columns = [
value: 'type', value: 'type',
}, },
{ {
label: '可分配算力', label: '分配CPU',
value: 'requestedCpuCores',
render: ({ requestedCpuCores }) => <span>{requestedCpuCores} </span>,
},
{
label: '分配内存',
value: 'requestedMemory',
render: ({ requestedMemory }) => <span>{bytesToGB(requestedMemory)} </span>,
},
{
label: '分配算力',
value: 'allocatedCores', value: 'allocatedCores',
}, },
{ {
label: '可分配显存', label: '分配显存',
value: 'allocatedMem', value: 'allocatedMem',
render: ({ allocatedMem }) => render: ({ allocatedMem }) =>
allocatedMem ? ( allocatedMem ? (

@ -9,7 +9,9 @@ import TabTop from '~/vgpu/components/TabTop.vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import nodeApi from '~/vgpu/api/node'; import nodeApi from '~/vgpu/api/node';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import useParentAction from '~/vgpu/hooks/useParentAction';
const { sendRouteChange } = useParentAction();
const router = useRouter(); const router = useRouter();
const handleChartClick = async (params) => { const handleChartClick = async (params) => {
@ -20,23 +22,15 @@ const handleChartClick = async (params) => {
const node = list.find(node => node.name === name); const node = list.find(node => node.name === name);
if (node) { if (node) {
const uuid = node.uid; const uuid = node.uid;
router.push(`/admin/vgpu/node/admin/${uuid}?nodeName=${name}`); sendRouteChange(`/admin/vgpu/node/admin/${uuid}?nodeName=${name}`);
} else { } else {
ElMessage.error('节点未找到'); ElMessage.error('节点未找到');
} }
} else if (activeTabKey === 'deviceuuid') { } else if (activeTabKey === 'deviceuuid') {
router.push({ sendRouteChange(`/admin/vgpu/card/admin/${name}`);
path: `/admin/vgpu/card/admin/${name}`,
});
} else { } else {
const [containerName, podUid] = name.split(':'); const [containerName, podUid] = name.split(':');
router.push({ sendRouteChange(`/admin/vgpu/task/admin/detail?name=${containerName}&podUid=${podUid}`);
path: '/admin/vgpu/task/admin/detail',
query: {
name: containerName,
podUid: podUid,
},
});
} }
}; };

@ -10,7 +10,9 @@
<script setup> <script setup>
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import useParentAction from '~/vgpu/hooks/useParentAction';
const { sendRouteChange } = useParentAction();
const router = useRouter(); const router = useRouter();
const props = defineProps({ const props = defineProps({
@ -32,7 +34,7 @@ const handleCopy = () => {
const handleClick = () => { const handleClick = () => {
if (props.to) { if (props.to) {
router.push(props.to); sendRouteChange(props.to);
} }
}; };
</script> </script>

@ -41,7 +41,7 @@
'side-menus-item-children-item', 'side-menus-item-children-item',
{ 'is-active': route.path.includes(child.path) }, { 'is-active': route.path.includes(child.path) },
]" ]"
@click="router.push(child.path)" @click="sendRouteChange(child.path)"
> >
<svg-icon :icon="child.meta?.icon" /> <svg-icon :icon="child.meta?.icon" />
<span v-if="sideWidth >= 200"> {{ child.meta?.title }}</span> <span v-if="sideWidth >= 200"> {{ child.meta?.title }}</span>
@ -62,6 +62,9 @@
import { computed, onMounted, ref, nextTick, onBeforeUnmount } from 'vue'; import { computed, onMounted, ref, nextTick, onBeforeUnmount } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import useParentAction from '~/vgpu/hooks/useParentAction';
const { sendRouteChange } = useParentAction();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();

@ -50,11 +50,6 @@ export default {
const messageData = JSON.parse(event.data); const messageData = JSON.parse(event.data);
if (messageData.type === "ChangeTheRoute") { if (messageData.type === "ChangeTheRoute") {
// const { pathname, query } = parseUrl(messageData.data) // const { pathname, query } = parseUrl(messageData.data)
// console.log(messageData.data, 'messageData.data')
// this.router.push({
// path: pathname,
// query
// });
this.router.replace(messageData.data) this.router.replace(messageData.data)
} }
} catch (e) { } } catch (e) { }

@ -569,8 +569,11 @@ export const clearEdges = (items) =>
// 字节转GB // 字节转GB
export const bytesToGB = (bytes) => { export const bytesToGB = (bytes) => {
if (bytes === '' || bytes === undefined || bytes === null) {
return '';
}
return Math.round(bytes / (1024 * 1024 * 1024)); return Math.round(bytes / (1024 * 1024 * 1024));
} };
export function parseUrl(url) { export function parseUrl(url) {
const [pathname, queryString] = url.split('?'); const [pathname, queryString] = url.split('?');

Loading…
Cancel
Save