Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
de3eed6
update:后端apscheduler使用自定义scheduler
4linuxfun Jul 19, 2024
a2352c2
update:后端增加job相关接口
4linuxfun Jul 19, 2024
86d82ec
update:前端增加job页面
4linuxfun Jul 19, 2024
23d1d91
update:后端CRUD增加通过ID查询
4linuxfun Jul 19, 2024
253076b
update:其他配置更新
4linuxfun Jul 19, 2024
0c7eb3f
后端:修复hosts inventory错误
4linuxfun Jul 22, 2024
9e2cbf0
前端:更新ConfirmDel函数
4linuxfun Jul 22, 2024
0cbe6e9
前端:任务管理-更新实现
4linuxfun Jul 22, 2024
0001783
后端:rpyc执行日志写入redis和数据库
4linuxfun Jul 31, 2024
0ae3e14
后端:rpyc修改任务逻辑调整
4linuxfun Jul 31, 2024
80c38f3
alembic排除部分表
4linuxfun Jul 31, 2024
cda5580
后端:增加任务管理接口
4linuxfun Jul 31, 2024
c338dd1
后端:增加主机管理接口
4linuxfun Jul 31, 2024
f0c6d3b
前端:任务管理界面实现
4linuxfun Jul 31, 2024
f1773c3
后端:rpyc自定义jobstore
4linuxfun Jul 31, 2024
72c00f7
后端:主机管理、任务管理CRUD部分修改
4linuxfun Jul 31, 2024
c0de28e
前端:增加主机管理相关API
4linuxfun Jul 31, 2024
c8c8e78
前端:独立terminal组件,用于日志展示
4linuxfun Jul 31, 2024
9a426bd
前端:主机管理实现
4linuxfun Jul 31, 2024
0ddd9be
后端:更新统计值方式
4linuxfun Aug 1, 2024
1872ca3
后端:实现主机管理查询功能
4linuxfun Aug 1, 2024
81ed345
后端:修复主机管理分组查找逻辑
4linuxfun Aug 2, 2024
97d94db
前端:增加common函数
4linuxfun Aug 6, 2024
1f94a59
前端:主机管理相关页面功能实现
4linuxfun Aug 6, 2024
c1e7406
前端:增加更新主机分组接口
4linuxfun Aug 6, 2024
6adcc11
后端:更新host、user接口
4linuxfun Aug 6, 2024
1cb2281
前端:主机管理-分页点击查询位置调整
4linuxfun Aug 6, 2024
3eb2a87
后端:主机管理接口实现
4linuxfun Aug 6, 2024
a348e06
前端:任务管理-主机选择对话框功能实现
4linuxfun Aug 8, 2024
1bde445
前端:任务管理-主机选择列表功能实现
4linuxfun Aug 8, 2024
0229736
前端:hosts接口调整
4linuxfun Aug 8, 2024
d4cdd91
后端:主机管理增加多主机信息查询接口
4linuxfun Aug 8, 2024
4bc5ab7
前端:update package.json
4linuxfun Aug 8, 2024
9f4491e
前端:任务管理-用户手动输入模板名称
4linuxfun Aug 8, 2024
190cf9f
前端:任务管理-执行方式使用radio实现
4linuxfun Aug 8, 2024
0b2b127
前端:update
4linuxfun Aug 8, 2024
3a15622
后端:pydantic语法更新
4linuxfun Aug 8, 2024
3b310c8
前端:任务管理-任务日志:修复stats为null时异常报错
4linuxfun Aug 12, 2024
1df1880
scheduler:增加playbook业务逻辑实现
4linuxfun Aug 14, 2024
1c6d460
scheduler:增加注释
4linuxfun Aug 14, 2024
deb50aa
后端:增加playbook管理后端接口
4linuxfun Aug 14, 2024
9d8fe9a
后端:update
4linuxfun Aug 14, 2024
05723cc
前端:任务管理,修订module或playbook为null
4linuxfun Aug 14, 2024
42a5bae
前端:任务管理-脚本管理页面功能实现
4linuxfun Aug 14, 2024
98c5193
scheduler:修复ansible playbook传值为id
4linuxfun Aug 14, 2024
bd9a763
后端:playbook增加部分接口
4linuxfun Aug 14, 2024
4fc8a24
前端:任务管理页面调整,playbook传值改为id
4linuxfun Aug 14, 2024
d175f26
update README.md
4linuxfun Aug 14, 2024
ae12682
update:README.md
4linuxfun Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
前端:主机管理相关页面功能实现
  • Loading branch information
4linuxfun committed Aug 6, 2024
commit 1f94a59fda49e77e597845f917862d658915b5e9
115 changes: 115 additions & 0 deletions www/src/views/host/AddGroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!--
新增、编辑分组对话框
-->
<template>
<el-dialog v-model="visible" width="500px" :title="title" destroy-on-close>
<el-form ref="addRootFormRef" :model="addRootForm" label-width="100px">
<el-form-item label="父级:">
<el-tree-select v-model="addRootForm.parent_id" :data="allGroups" :props="{label:'name'}" value-key="id"
check-strictly
:render-after-expand="false"
check-on-click-node
@change="handleChangeAncestors">
<template #label="{label,value}">
<span>{{ getHierarchyLabel(allGroups, value, {label: 'name'}) }}</span>
</template>
</el-tree-select>
</el-form-item>
<el-form-item label="分组名:" prop="name" :rules="[{required:true,message:'请输入分组名'}]">
<el-input v-model="addRootForm.name"/>
</el-form-item>
</el-form>
<el-row justify="end">
<el-button type="primary" @click="handleAddRoot">提交</el-button>
<el-button type="danger" @click="visible=false">取消</el-button>
</el-row>
</el-dialog>
</template>

<script setup>
import {reactive, ref} from 'vue'
import {PostNewGroup, PutGroup, GetAllGroup} from '@/api/host.js'
import {findNodeById, getHierarchyLabel} from '@/utils/common.js'

const emit = defineEmits(['close'])
const addRootFormRef = ref(null)
const visible = ref(false)
const title = ref('')
const addRootForm = reactive({})
const allGroups = ref([])
let RequestAPI = ref(null)

const initRootForm = {id: null, name: null, parent_id: null, ancestors: null}


/**
* 下拉框选择父组件后,对应的ancestors属性值也需要修改
* @param id
*/
function handleChangeAncestors(id) {
let selectNode = findNodeById(allGroups.value, id)
console.log(selectNode)
if (selectNode.ancestors === null || selectNode.ancestors === undefined || selectNode.ancestors === '') {
// 为空,则为根节点
addRootForm.ancestors = selectNode.id.toString()
} else {
// 父节点存在ancestors,继承拼接
addRootForm.ancestors = selectNode.ancestors + ',' + selectNode.id.toString()
}
console.log(addRootForm)
}

/**
* 添加根分组的函数
*/
async function handleAddRoot() {
console.log('添加根分组')
// treeData.value.push({label: '', children: []})
try {
await addRootFormRef.value.validate()
console.log('submit')
await RequestAPI(addRootForm)
} catch (err) {
console.log('error submit', err)
}
visible.value = false
emit('close')
}


async function add() {
console.log('start to get all groups')
try {
allGroups.value = await GetAllGroup()
} catch (err) {
console.log('获取组失败。。。')
return false
}
Object.assign(addRootForm, initRootForm)
console.log('start to visible')
console.log(allGroups.value)
RequestAPI = PostNewGroup
title.value = '新增分组'
visible.value = true
}

async function edit(data) {
try {
allGroups.value = await GetAllGroup()
} catch (err) {
console.log('获取组失败。。。')
return false
}
Object.assign(addRootForm, data)
RequestAPI = PutGroup
title.value = '编辑分组'
visible.value = true
}

defineExpose({add, edit})
</script>


<style scoped>

</style>
7 changes: 6 additions & 1 deletion www/src/views/host/HostDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<el-tree-select v-model="hostForm.groups" :data="allGroups" :props="{label:'name'}" value-key="id" multiple
check-strictly
:render-after-expand="false"
check-on-click-node/>
check-on-click-node>
<template #label="{label,value}">
<span>{{ getHierarchyLabel(allGroups, value, {label: 'name'}) }}</span>
</template>
</el-tree-select>
</el-form-item>
<el-form-item label="主机名称" prop="name">
<el-input v-model="hostForm.name" placeholder="请输入主机名称"/>
Expand Down Expand Up @@ -49,6 +53,7 @@
import {ref, reactive} from 'vue'
import {GetAllGroup, GetHostById, PostNewHost, PutHost, PingHost} from '@/api/host.js'
import {ElNotification} from 'element-plus'
import {getHierarchyLabel} from '@/utils/common.js'

const initForm = {
id: null,
Expand Down
144 changes: 43 additions & 101 deletions www/src/views/host/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@
<el-col :span="6" style="height: 100%">
<div class="col-style">
<span style="padding: 10px">分组列表</span>
<el-button type="primary" @click="addRootDialog=true">新建根分组</el-button>
<el-button type="primary" @click="handleAddChild">新建分组</el-button>
<el-divider style="margin-bottom: 0"/>
<div style="height: 90%;overflow-y: scroll;">
<el-tree ref="elTreeRef" :data="treeData" :props="{label:'name'}"
style="padding: 10px" highlight-current default-expand-all
:expand-on-click-node="false"
@node-drop="handleDrop"
@node-contextmenu="handleContextMenu">
:expand-on-click-node="false">
<template #default="{node,data}">
<el-row style="flex: 1" justify="space-between" @click="handleSearchHost(data.id)">
<el-col :span="6"><span>{{ node.label }}</span></el-col>
<el-row style="flex: 1" justify="space-between" >
<el-col :span="18"><span @click="handleSearchHost(data)">{{ node.label }}</span></el-col>
<el-col :span="6" style="text-align: right">
<el-link v-if="data.hasOwnProperty('children')" :underline="false" @click="handleAddChild(data.id)">
<el-icon>
<Plus/>
</el-icon>
</el-link>
<el-link :underline="false" style="margin-left: 10px">
<el-link :underline="false" style="margin-left: 10px" @click="handleEditGroup(data)">
<el-icon>
<Edit/>
</el-icon>
Expand Down Expand Up @@ -87,45 +80,32 @@
</el-col>
</el-row>

<el-dialog v-model="addRootDialog" width="500px" title="新增分组" destroy-on-close
@close="handleFreshGroups">
<el-form ref="addRootFormRef" :model="addRootForm">
<el-form-item label="分组名:" prop="name" :rules="[{required:true,message:'请输入分组名'}]">
<el-input v-model="addRootForm.name"/>
</el-form-item>
</el-form>
<el-row justify="end">
<el-button type="primary" @click="handleAddRoot">提交</el-button>
<el-button type="danger" @click="addRootDialog=false">取消</el-button>
</el-row>
</el-dialog>

<add-group ref="addGroupRef" @close="handleFreshAll"/>
<host-dialog ref="hostDialogRef" @close="freshCurrentPage"/>

</template>

<script setup>
import {ref, reactive, onMounted} from 'vue'
import {Contextmenu, ContextmenuItem} from 'v-contextmenu'
import {Close, Delete, DocumentAdd, Edit, Folder, FolderAdd, Switch} from '@element-plus/icons-vue'
import {PostNewGroup, GetAllGroup, DelHost, DelGroup, PingHost} from '@/api/host.js'
import {ref, onMounted} from 'vue'
import {Delete, Edit} from '@element-plus/icons-vue'
import {GetAllGroup, DelHost, DelGroup, PingHost} from '@/api/host.js'
import HostDialog from '@/views/host/HostDialog.vue'
import usePagination from '@/composables/usePagination.js'
import AddGroup from '@/views/host/AddGroup.vue'
import {ConfirmDel} from '@/utils/request.js'

const treeData = ref([])
const elTreeRef = ref(null)
const addRootFormRef = ref(null)
const addGroupRef = ref(null)
const hostDialogRef = ref(null)
const inputRef = ref(null)
const selectTreeNodeData = ref(null)
const editTreeNodeId = ref(null)
const newNodeName = ref(null)
const addRootDialog = ref(false)
const addRootForm = reactive({name: null, parent_id: null})

const searchForm = {
name: null,
ansible_host: null,
group_id: null
group_id: null,
ancestors: null
}

// 首次打开页面先进行初始化
Expand All @@ -142,64 +122,46 @@
} = usePagination('/api/host/search', searchForm)


function handleDrop() {
console.log('end drag')
}

/**
* el-tree右键菜单处理
* 添加分组
*/
function handleContextMenu(e, data, node,) {
console.log('右键菜单', e, data, node)
selectTreeNodeData.value = node
}

function showContextMenu(node) {
console.log('显示右键菜单', node)
async function handleAddChild() {
await addGroupRef.value.add()
}

/**
* 添加子分组
* 编辑分组
* @param data
* @return {Promise<void>}
*/
function handleAddChild(parentId) {
Object.assign(addRootForm, {name: null, parent_id: parentId})
addRootDialog.value = true
async function handleEditGroup(data) {
console.log(data)
await addGroupRef.value.edit(data)
}

function handleSearchHost(groupId) {
function handleSearchHost(groupInfo) {
console.log('点击')
console.log(groupId)
search.group_id = groupId
console.log(groupInfo)
search.group_id = groupInfo.id
search.ancestors = groupInfo.ancestors
handleSearch()
}

/**
* 添加根分组的函数
*/
async function handleAddRoot() {
console.log('添加根分组')
// treeData.value.push({label: '', children: []})

async function handleFreshGroups() {
try {
await addRootFormRef.value.validate()
console.log('submit')
await PostNewGroup(addRootForm)
addRootDialog.value = false
} catch (err) {
console.log('error submit', err)
treeData.value = await GetAllGroup()
} catch (e) {
console.log(e)
}
}

function handleFreshGroups() {
Object.assign(addRootForm, {name: null, parent_id: null})
GetAllGroup().then((data) => {
treeData.value = data
})
}

function handleEdit(node, data) {
console.log('双击编辑事件', node, data)
editTreeNodeId.value = node.id
newNodeName.value = data.label
/**
* 刷新group和host列表
* */
function handleFreshAll() {
handleFreshGroups()
freshCurrentPage()
}

function handleEditHost(hostId) {
Expand All @@ -215,33 +177,13 @@
freshCurrentPage()
}

function handleUpdateNodeName(node, data) {
console.log(node)
if (data.hasOwnProperty('id')) {
console.log('更新节点信息')
} else {
console.log('新增节点信息')
console.log('parentID:', node.parent.id)
data.label = newNodeName.value
PostNewGroup({name: newNodeName.value, parent_id: node.parent.id})
// data.id = data.$treeNodeId
editTreeNodeId.value = null
newNodeName.value = null

}
console.log(treeData.value)

// PostNewGroup({name:data.label,parent_id:})
}

async function handleDelGroup(groupId) {
console.log('删除节点:' + groupId)
try {
await DelGroup(groupId)
} catch (err) {
console.log(err)
await ConfirmDel('删除分组', DelGroup, groupId)
} catch (e) {
console.log(e)
}
handleFreshGroups()
await handleFreshGroups()
}

onMounted(() => {
Expand Down