节点在线、应用在线、配置在线使用令牌查询
大石头 authored at 2021-12-16 19:49:30
4.17 KiB
Stardust
import NodeFormDrawer from './NodeFormDrawer.vue';
import type { BuildNodeForm, DeployNodeForm } from './deploy.logic.ts';

const deployInitial: DeployNodeForm = {
  nodeId: 2,
  enable: true,
  port: 8080,
  fileName: '',
  arguments: '--urls http://*:8080',
  workingDirectory: '/opt/star',
  userName: '',
  environments: 'ENV=prod',
  maxMemory: 1024,
  delay: 5,
  healthCheck: 'http://*/health',
  remark: '内网节点',
  logDirectory: 'logs',
  logFilePattern: 'app-*.log',
};

const buildInitial: BuildNodeForm = {
  nodeId: 3,
  enable: true,
  sourcePath: '/src/MindHub.Api',
  pullCode: true,
  buildProject: true,
  packageOutput: true,
  uploadPackage: true,
  outputPath: './publish',
  remark: '',
};

// task-91:212 旧构建真身映射(Cube 投影只发 nodeName 缺关联键 nodeId → toDeployNodeForm 回填 0)
const missingNodeInitial: DeployNodeForm = {
  nodeId: 0,
  enable: true,
  port: 0,
  fileName: '',
  arguments: '',
  workingDirectory: '',
  userName: '',
  environments: '',
  maxMemory: 0,
  delay: 0,
  healthCheck: '',
  remark: '',
  logDirectory: '',
  logFilePattern: '*.log',
};

export const stories = [
  // F07 新增部署节点:空表单 + 节点选择器(加载完成)
  {
    id: 'NodeFormDrawer/DeployCreate',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'deploy',
      initial: null,
      title: '新增部署节点',
      sub: '部署集 IoC容器',
      nodeOptions: [
        { id: 1, name: 'node-a', ip: '10.0.0.1' },
        { id: 2, name: 'node-b', ip: '10.0.0.2' },
      ],
      nodesLoading: false,
      busy: false,
    },
  },

  // F07 编辑部署节点:初值回填
  {
    id: 'NodeFormDrawer/DeployEdit',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'deploy',
      initial: deployInitial,
      title: '编辑部署节点 · node-b',
      sub: 'IP 10.0.0.2 · 编号 12',
      nodeOptions: [
        { id: 1, name: 'node-a', ip: '10.0.0.1' },
        { id: 2, name: 'node-b', ip: '10.0.0.2' },
      ],
      nodesLoading: false,
      busy: false,
    },
  },

  // F07 节点选择器加载中:选择器位置显示「节点列表加载中…」
  {
    id: 'NodeFormDrawer/NodesLoading',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'deploy',
      initial: null,
      title: '新增部署节点',
      sub: '部署集 IoC容器',
      nodeOptions: [],
      nodesLoading: true,
      busy: false,
    },
  },

  // F08 编辑编译节点:源代码目录、四个阶段开关
  {
    id: 'NodeFormDrawer/BuildEdit',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'build',
      initial: buildInitial,
      title: '编辑编译节点 · node-build-a',
      sub: 'IP 10.0.0.11 · 编号 21',
      nodeOptions: [{ id: 3, name: 'node-build-a', ip: '10.0.0.11' }],
      nodesLoading: false,
      busy: false,
    },
  },

  // F08 保存中:提交按钮禁用写「保存中…」(AGENTS.md §11)
  {
    id: 'NodeFormDrawer/Busy',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'build',
      initial: buildInitial,
      title: '编辑编译节点 · node-build-a',
      sub: 'IP 10.0.0.11 · 编号 21',
      nodeOptions: [{ id: 3, name: 'node-build-a', ip: '10.0.0.11' }],
      nodesLoading: false,
      busy: true,
    },
  },

  // task-91 节点回显警示:编辑打开但详情缺 nodeId(212 旧构建投影缺关联键)→ 选择器旁可见提示;
  // ct.spec 用 setStoryProps 驱动 missing → unavailable(绑定节点不在可选项)→ 选项补齐后消失 三态转换
  {
    id: 'NodeFormDrawer/DeployEditMissingNode',
    component: NodeFormDrawer,
    props: {
      open: true,
      kind: 'deploy',
      initial: missingNodeInitial,
      title: '编辑部署节点 · 212-cwiocap01',
      sub: 'IP 10.188.32.212 · 编号 76',
      nodeOptions: [
        { id: 1, name: 'node-a', ip: '10.0.0.1' },
        { id: 2, name: 'node-b', ip: '10.0.0.2' },
      ],
      nodesLoading: false,
      busy: false,
    },
  },
];