124 lines
4.0 KiB
JavaScript
124 lines
4.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.ContainerView = void 0;
|
|
// src/panels/views/ContainerView.ts
|
|
const BaseView_1 = require("./BaseView");
|
|
class ContainerView extends BaseView_1.BaseView {
|
|
render(data) {
|
|
const project = data?.project;
|
|
const aircraft = data?.aircraft;
|
|
const containers = data?.containers || [];
|
|
const containersHtml = containers.map((container) => `
|
|
<tr>
|
|
<td>
|
|
<span class="editable" onclick="editContainerName('${container.id}', '${container.name}')">📦 ${container.name}</span>
|
|
</td>
|
|
<td>
|
|
<span class="clickable" onclick="openContainerConfig('${container.id}')">配置文件</span>
|
|
</td>
|
|
<td>
|
|
<button class="btn-delete" onclick="deleteContainer('${container.id}')">删除</button>
|
|
</td>
|
|
</tr>
|
|
`).join('');
|
|
return `<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>容器管理</title>
|
|
${this.getStyles()}
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${aircraft?.name || '未知飞行器'}</span></h2>
|
|
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
|
</div>
|
|
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th width="40%">容器</th>
|
|
<th width="40%">配置文件</th>
|
|
<th width="20%">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
${containersHtml}
|
|
<tr>
|
|
<td colspan="3" style="text-align: center; padding: 20px;">
|
|
<button class="btn-new" onclick="createNewContainer()">+ 新建容器</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<script>
|
|
const vscode = acquireVsCodeApi();
|
|
|
|
function editContainerName(containerId, currentName) {
|
|
showPromptDialog(
|
|
'修改容器名称',
|
|
'请输入新的容器名称:',
|
|
currentName,
|
|
function(newName) {
|
|
if (newName && newName !== currentName) {
|
|
vscode.postMessage({
|
|
type: 'updateContainerName',
|
|
containerId: containerId,
|
|
name: newName
|
|
});
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
function openContainerConfig(containerId) {
|
|
vscode.postMessage({
|
|
type: 'openContainerConfig',
|
|
containerId: containerId
|
|
});
|
|
}
|
|
|
|
function createNewContainer() {
|
|
showPromptDialog(
|
|
'新建容器',
|
|
'请输入容器名称:',
|
|
'',
|
|
function(name) {
|
|
if (name) {
|
|
vscode.postMessage({
|
|
type: 'createContainer',
|
|
name: name
|
|
});
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
function goBackToAircrafts() {
|
|
vscode.postMessage({ type: 'goBackToAircrafts' });
|
|
}
|
|
|
|
function deleteContainer(containerId) {
|
|
showConfirmDialog(
|
|
'确认删除',
|
|
'确定删除这个容器吗?',
|
|
function() {
|
|
vscode.postMessage({
|
|
type: 'deleteContainer',
|
|
containerId: containerId
|
|
});
|
|
},
|
|
function() {
|
|
// 用户取消删除
|
|
}
|
|
);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>`;
|
|
}
|
|
}
|
|
exports.ContainerView = ContainerView;
|
|
//# sourceMappingURL=ContainerView.js.map
|