feat 机器管理新增查看关联节点功能

This commit is contained in:
bwcx_jzy 2023-02-21 18:30:27 +08:00
parent 127a38c509
commit c444890507
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
6 changed files with 95 additions and 17 deletions

View File

@ -8,6 +8,7 @@
2. 【server】新增 容器构建缓存插件支持缓存 node_modules `mode: copy` (避免出现:[https://github.com/npm/cli/issues/3669](https://github.com/npm/cli/issues/3669))
3. 【server】新增 构建列表新增批量构建
(感谢 [@爱笑的眼睛](https://gitee.com/175cm75kg18cm) [Gitee issues I6GNV2](https://gitee.com/dromara/Jpom/issues/I6GNV2)
4. 【server】新增 机器管理新增查看关联节点功能
### 🐞 解决BUG、优化功能

View File

@ -28,6 +28,7 @@ import io.jpom.common.BaseServerController;
import io.jpom.common.JsonMessage;
import io.jpom.common.validator.ValidatorItem;
import io.jpom.func.assets.model.MachineNodeModel;
import io.jpom.model.data.NodeModel;
import io.jpom.model.data.WorkspaceModel;
import io.jpom.permission.ClassFeature;
import io.jpom.permission.Feature;
@ -43,11 +44,15 @@ import org.springframework.web.bind.annotation.RestController;
import top.jpom.model.PageResultDto;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 机器节点
*
* @author bwcx_jzy
* @since 2023/2/18
*/
@ -103,6 +108,13 @@ public class MachineNodeController extends BaseServerController {
return JsonMessage.success("操作成功");
}
/**
* 将机器分配到指定工作空间
*
* @param id 机器id
* @param workspaceId 工作空间id
* @return json
*/
@PostMapping(value = "distribute", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public JsonMessage<String> distribute(@ValidatorItem String id, @ValidatorItem String workspaceId) {
@ -117,4 +129,19 @@ public class MachineNodeController extends BaseServerController {
machineNodeServer.insertNode(machineNodeModel, workspaceId);
return JsonMessage.success("操作成功");
}
@GetMapping(value = "list-node", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public JsonMessage<List<NodeModel>> listData(@ValidatorItem String id) {
MachineNodeModel machineNodeModel = machineNodeServer.getByKey(id);
Assert.notNull(machineNodeModel, "没有对应的机器");
NodeModel nodeModel = new NodeModel();
nodeModel.setMachineId(id);
List<NodeModel> modelList = nodeService.listByBean(nodeModel);
modelList = Optional.ofNullable(modelList).orElseGet(ArrayList::new);
for (NodeModel model : modelList) {
model.setWorkspace(workspaceService.getByKey(model.getWorkspaceId()));
}
return JsonMessage.success("", modelList);
}
}

View File

@ -87,6 +87,9 @@ public class NodeModel extends BaseMachineModel {
@PropIgnore
private MachineNodeModel machineNodeData;
@PropIgnore
private WorkspaceModel workspace;
public boolean isOpenStatus() {
return openStatus != null && openStatus == 1;
}
@ -99,9 +102,4 @@ public class NodeModel extends BaseMachineModel {
this.setId(id);
this.setWorkspaceId(workspaceId);
}
// public String getRealUrl(NodeUrl nodeUrl) {
// return StrUtil.format("{}://{}{}", getProtocol().toLowerCase(), getUrl(), nodeUrl.getUrl());
// }
}

View File

@ -50,3 +50,12 @@ export const statusMap = {
2: "授权信息错误",
3: "状态码错误",
};
// 查看机器关联节点
export function machineListNode(params) {
return axios({
url: "/system/assets/machine/list-node",
method: "get",
params: params,
});
}

View File

@ -1394,11 +1394,11 @@ export default {
});
});
},
//
handleFilter() {
this.loadData();
// this.loadRepositoryList();
},
// //
// handleFilter() {
// this.loadData();
// // this.loadRepositoryList();
// },
//
changeRepositpry(value) {
this.repositoryList.forEach((element) => {
@ -1555,7 +1555,7 @@ export default {
});
//this.$refs["editBuildForm"].resetFields();
this.editBuildVisible = false;
this.handleFilter();
this.loadData();
this.loadGroupList();
}
});
@ -1676,7 +1676,7 @@ export default {
this.$notification.success({
message: res.msg,
});
this.handleFilter();
this.loadData();
if (openLog) {
//
this.handleBuildLog({
@ -1703,7 +1703,7 @@ export default {
this.$notification.success({
message: res.msg,
});
this.handleFilter();
this.loadData();
}
});
},
@ -1719,7 +1719,7 @@ export default {
},
//
closeBuildLogModel() {
this.handleFilter();
this.loadData();
},
//
changePage(pagination, filters, sorter) {
@ -1767,7 +1767,7 @@ export default {
method: method,
compareId: compareId,
}).then((res) => {
if (res.code == 200) {
if (res.code === 200) {
this.$notification.success({
message: res.msg,
});
@ -1801,7 +1801,8 @@ export default {
}
});
});
this.handleFilter();
this.tableSelections = [];
this.loadData();
},
},
};

View File

@ -98,6 +98,7 @@
<a-button @click="handleEdit(item)" type="primary" size="small"> 编辑 </a-button>
<a-button @click="showMachineInfo(item)" type="primary" size="small">详情</a-button>
<a-button @click="syncToWorkspaceShow(item)" type="primary" size="small">分配</a-button>
<a-button @click="viewMachineNode(item)" type="primary" size="small">节点</a-button>
<a-button @click="deleteMachineInfo(item)" size="small">删除</a-button>
</a-button-group>
</a-row>
@ -230,6 +231,7 @@
</a-form-model-item>
</a-form-model>
</a-modal>
<!-- 机器在线升级相关信息 -->
<a-drawer
destroyOnClose
:title="`${temp.name} 插件版本信息`"
@ -245,11 +247,23 @@
<!-- 在线升级 -->
<upgrade v-if="drawerUpgradeVisible" :machineId="temp.id" />
</a-drawer>
<!-- 查看机器关联节点 -->
<a-modal destroyOnClose v-model="viewLinkNode" width="50%" title="关联节点" :footer="null" :maskClosable="false">
<a-list bordered :data-source="nodeList">
<a-list-item slot="renderItem" slot-scope="item" style="display: block">
<a-row>
<a-col :span="10">节点名称{{ item.name }}</a-col>
<a-col :span="10">所属工作空间 {{ item.workspace && item.workspace.name }}</a-col>
<a-col :span="4"> <a-button type="link" icon="login" @click="toNode(item.id, item.workspace && item.workspace.id)"> </a-button></a-col>
</a-row>
</a-list-item>
</a-list>
</a-modal>
</div>
</template>
<script>
import { machineListData, machineListGroup, statusMap, machineEdit, machineDelete, machineDistribute } from "@/api/system/assets-machine";
import { machineListData, machineListGroup, statusMap, machineEdit, machineDelete, machineDistribute, machineListNode } from "@/api/system/assets-machine";
import { CHANGE_PAGE, COMPUTED_PAGINATION, PAGE_DEFAULT_LIST_QUERY, PAGE_DEFAULT_SHOW_TOTAL, formatDuration, parseTime } from "@/utils/const";
import CustomSelect from "@/components/customSelect";
import { mapGetters } from "vuex";
@ -281,6 +295,8 @@ export default {
drawerVisible: false,
drawerUpgradeVisible: false,
workspaceList: [],
viewLinkNode: false,
nodeList: [],
};
},
computed: {
@ -413,10 +429,36 @@ export default {
}
});
},
//
showMachineUpgrade(item) {
this.temp = { ...item };
this.drawerUpgradeVisible = true;
},
//
viewMachineNode(item) {
machineListNode({
id: item.id,
}).then((res) => {
if (res.code === 200) {
this.viewLinkNode = true;
this.nodeList = res.data;
}
});
},
toNode(nodeId, wid) {
const newpage = this.$router.resolve({
name: "node_" + nodeId,
path: "/node/list",
query: {
...this.$route.query,
nodeId: nodeId,
pId: "manage",
id: "manageList",
wid: wid,
},
});
window.open(newpage.href, "_blank");
},
},
};
</script>