瀏覽代碼

修改首页

zs 5 月之前
父節點
當前提交
4f4e8942b7
共有 3 個文件被更改,包括 268 次插入7 次删除
  1. 54 1
      src/controller/core/statistics.controller.ts
  2. 143 0
      src/data/site.ts
  3. 71 6
      src/service/core/statistics.service.ts

+ 54 - 1
src/controller/core/statistics.controller.ts

@@ -14,7 +14,6 @@ export class StatisticsController {
     const result = await this.service.resource(query, page);
     return RF.success(result);
   }
-
   //   作业统计
   @Get('/work')
   async work(@Query() query, @Page() page) {
@@ -27,4 +26,58 @@ export class StatisticsController {
     const result = await this.service.user(query, page);
     return RF.success(result);
   }
+  //   资源管理
+  @Get('/natural')
+  async natural() {
+    const result = await this.service.natural();
+    return RF.success(result);
+  }
+  //   监控作业
+  @Get('/task')
+  async task() {
+    const result = await this.service.task();
+    return RF.success(result);
+  }
+  //   首页统计
+  @Get('/total')
+  async total() {
+    const result = await this.service.total();
+    return RF.success(result);
+  }
+  //   首页echarts
+  @Get('/echarts1')
+  async echarts1() {
+    const result = await this.service.echarts1();
+    return RF.success(result);
+  }
+  @Get('/echarts2')
+  async echarts2() {
+    const result = await this.service.echarts2();
+    return RF.success(result);
+  }
+  @Get('/echarts3')
+  async echarts3() {
+    const result = await this.service.echarts3();
+    return RF.success(result);
+  }
+  @Get('/echarts4')
+  async echarts4() {
+    const result = await this.service.echarts4();
+    return RF.success(result);
+  }
+  @Get('/echarts5')
+  async echarts5() {
+    const result = await this.service.echarts5();
+    return RF.success(result);
+  }
+  @Get('/echarts6')
+  async echarts6() {
+    const result = await this.service.echarts6();
+    return RF.success(result);
+  }
+  @Get('/echarts7')
+  async echarts7() {
+    const result = await this.service.echarts7();
+    return RF.success(result);
+  }
 }

+ 143 - 0
src/data/site.ts

@@ -0,0 +1,143 @@
+// 资源统计
+export const resource = () => {
+  return [
+    {
+      time: '2024-10-27',
+      cpu_total: '1198.33/5645',
+      gpu_total: '0.0/0',
+      cpu_average: '21.93/26.65',
+      gpu_average: '0.0/0.0',
+      memory_num: '0.0',
+      node_num: '36',
+      partition_num: '2',
+      storage_total: '5130.56/258065.3',
+      storage_num: '2.0',
+    },
+  ];
+};
+// 作业统计
+export const work = () => {
+  return [
+    {
+      work_id: '48404',
+      work_name: 'vasap',
+      user_name: 'juhuangr',
+      organization: 'inpur',
+      submit_time: '2024-10-28 09:20:20',
+      create_time: '2024-10-28 09:20:20',
+      end_time: '2024-10-28 09:22:20',
+      time: '00:20:38',
+      status: 'COMPLETED',
+    },
+  ];
+};
+// 用户统计
+export const user = () => {
+  return [
+    {
+      time: '2024-10-27',
+      user_num: '0',
+      active_num: '0',
+      total: '22',
+    },
+  ];
+};
+// 资源管理
+export const natural = () => {
+  return {
+    cpu: { total: 5464, yes: 1224, n0: 0 },
+    gpu: { total: 0, yes: 0, n0: 0 },
+    statusList: [
+      { id: 1, total: 11, name: '满载', type: 'danger' },
+      { id: 2, total: 5, name: '半载', type: 'warning' },
+      { id: 3, total: 33, name: '空闲', type: 'primary' },
+      { id: 4, total: 0, name: '其他', type: 'info' },
+    ],
+    list: [
+      {
+        id: 1,
+        name: 'cu-amd',
+        cpu: '616/1568',
+        gpu: '0/0',
+        data: [
+          { value: 5, name: '满载' },
+          { value: 24, name: '空闲' },
+        ],
+      },
+      {
+        id: 2,
+        name: 'computerPartion',
+        cpu: '608/3840',
+        gpu: '0/0',
+        data: [
+          { value: 10, name: '满载' },
+          { value: 24, name: '空闲' },
+        ],
+      },
+    ],
+  };
+};
+// 监控作业
+export const task = () => {
+  return {
+    data1: [23, 5, 0, 0],
+    nameList1: ['运行', '排队', '挂起', '其他'],
+    xdata2: [10, 11, 12, 13, 50],
+    ydata2: ['warp', 'warp', 'warp', 'warp', 'qe-250'],
+    data3: ['分区1', '分区2', '分区3', '分区4', '分区5'],
+    rawData3: [
+      [100, 302, 301, 334, 390, 330, 320],
+      [320, 132, 101, 134, 90, 230, 210],
+      [0, 0, 0, 0, 0, 0, 0],
+      [0, 0, 0, 0, 0, 0, 0],
+    ],
+    nameList3: ['运行', '排队', '挂起', '其他'],
+  };
+};
+
+// 首页统计
+export const total = () => {
+  return {
+    nodeList: [
+      { name: '节点总数', num: 49 },
+      { name: '开机总数', num: 0 },
+      { name: '关机总数', num: 49 },
+    ],
+    cpuList: [
+      { name: 'CPU总数', num: 5464 },
+      { name: '已用总数', num: 1280 },
+      { name: '未用总数', num: 4184 },
+    ],
+    userList: [
+      { name: '用户总数', num: 22 },
+      { name: '在线人数', num: 1 },
+    ],
+    work_total: 29,
+  };
+};
+export const echarts1 = () => {
+  return { data: [28, 20], nameList: ['computerPartiton', 'cu-amd'] };
+};
+export const echarts2 = () => {
+  return {
+    data: [
+      { value: 5, name: 'PENDING' },
+      { value: 24, name: 'RUNNING' },
+    ],
+  };
+};
+export const echarts3 = () => {
+  return { data: [148, 108, 96, 95, 84, 69, 123, 160, 190, 123, 251, 220], nameList: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'] };
+};
+export const echarts4 = () => {
+  return { data: [148, 108, 96, 95, 84, 69, 123, 160, 190, 123, 251, 220], nameList: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'] };
+};
+export const echarts5 = () => {
+  return { data: [148, 108, 96, 95, 84, 69, 123, 160, 190, 123, 251, 220], nameList: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'] };
+};
+export const echarts6 = () => {
+  return { xdata: [12, 13], ydata: ['liuxiao', 'zhangs'] };
+};
+export const echarts7 = () => {
+  return { xdata: [12, 13, 14, 15, 16], ydata: ['liuxioa', 'chusod', 'cusnsn', 'quanq', 'iuysk'] };
+};

+ 71 - 6
src/service/core/statistics.service.ts

@@ -1,17 +1,82 @@
 import { Provide } from '@midwayjs/core';
+import {
+  resource,
+  work,
+  user,
+  natural,
+  task,
+  total,
+  echarts1,
+  echarts2,
+  echarts3,
+  echarts4,
+  echarts5,
+  echarts6,
+  echarts7,
+} from '../../data/site';
 
 @Provide()
 export class StatisticsService {
   // 资源统计
-  async resource(query, page) {
-    console.log(query, page);
+  async resource(query, { skip = '0', limit = '10' }) {
+    const data = resource().slice(parseInt(skip), parseInt(limit));
+    const total = data.length || 0;
+    return { data, total };
   }
   // 作业统计
-  async work(query, page) {
-    console.log(query, page);
+  async work(query, { skip = '0', limit = '10' }) {
+    const data = work().slice(parseInt(skip), parseInt(limit));
+    const total = data.length || 0;
+    return { data, total };
   }
   // 用户统计
-  async user(query, page) {
-    console.log(query, page);
+  async user(query, { skip = '0', limit = '10' }) {
+    const data = user().slice(parseInt(skip), parseInt(limit));
+    const total = data.length || 0;
+    return { data, total };
+  }
+  // 资源管理
+  async natural() {
+    const data = natural();
+    return data;
+  }
+  // 监控作业
+  async task() {
+    const data = task();
+    return data;
+  }
+  // 首页统计
+  async total() {
+    const data = total();
+    return data;
+  }
+  // 首页echarts
+  async echarts1() {
+    const data = echarts1();
+    return data;
+  }
+  async echarts2() {
+    const data = echarts2();
+    return data;
+  }
+  async echarts3() {
+    const data = echarts3();
+    return data;
+  }
+  async echarts4() {
+    const data = echarts4();
+    return data;
+  }
+  async echarts5() {
+    const data = echarts5();
+    return data;
+  }
+  async echarts6() {
+    const data = echarts6();
+    return data;
+  }
+  async echarts7() {
+    const data = echarts7();
+    return data;
   }
 }