ProcessDistributionCard.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <script setup lang="ts">
  2. import type { NginxPerformanceInfo } from '@/api/ngx'
  3. import { InfoCircleOutlined } from '@ant-design/icons-vue'
  4. const props = defineProps<{
  5. nginxInfo: NginxPerformanceInfo
  6. }>()
  7. // Process composition data
  8. const processTypeData = computed(() => {
  9. return [
  10. { type: $gettext('Worker Processes'), value: props.nginxInfo.workers, color: '#1890ff' },
  11. { type: $gettext('Master Process'), value: props.nginxInfo.master, color: '#52c41a' },
  12. { type: $gettext('Cache Processes'), value: props.nginxInfo.cache, color: '#faad14' },
  13. { type: $gettext('Other Processes'), value: props.nginxInfo.other, color: '#f5222d' },
  14. ]
  15. })
  16. // Total processes
  17. const totalProcesses = computed(() => {
  18. return props.nginxInfo.workers + props.nginxInfo.master + props.nginxInfo.cache + props.nginxInfo.other
  19. })
  20. </script>
  21. <template>
  22. <ACard :title="$gettext('Process Distribution')" :bordered="false" class="h-full" :body-style="{ height: 'calc(100% - 58px)' }">
  23. <div class="process-distribution h-full flex flex-col justify-between">
  24. <div>
  25. <div v-for="(item, index) in processTypeData" :key="index" class="mb-3">
  26. <div class="flex items-center">
  27. <div class="w-3 h-3 rounded-full mr-2" :style="{ backgroundColor: item.color }" />
  28. <div class="flex-grow truncate">
  29. {{ item.type }}
  30. </div>
  31. <div class="font-medium w-8 text-right">
  32. {{ item.value }}
  33. </div>
  34. </div>
  35. <AProgress
  36. :percent="totalProcesses === 0 ? 0 : (item.value / totalProcesses) * 100"
  37. :stroke-color="item.color"
  38. size="small"
  39. :show-info="false"
  40. />
  41. </div>
  42. </div>
  43. <div class="mt-auto text-xs text-gray-500 truncate">
  44. {{ $gettext('Actual worker to configured ratio') }}:
  45. <span class="font-medium">{{ nginxInfo.workers }} / {{ nginxInfo.worker_processes }}</span>
  46. </div>
  47. <div class="mt-2 text-xs text-gray-500 overflow-hidden text-ellipsis">
  48. {{ $gettext('Total Nginx processes') }}: {{ nginxInfo.workers + nginxInfo.master + nginxInfo.cache + nginxInfo.other }}
  49. <ATooltip :title="$gettext('Includes master process, worker processes, cache processes, and other Nginx processes')">
  50. <InfoCircleOutlined class="ml-1" />
  51. </ATooltip>
  52. </div>
  53. </div>
  54. </ACard>
  55. </template>