mirror of
				https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
				synced 2025-11-03 19:57:46 +00:00 
			
		
		
		
	Version 2.5.19: new memory display
This commit is contained in:
		
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,12 +1,12 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "ucentral-client",
 | 
					  "name": "ucentral-client",
 | 
				
			||||||
  "version": "2.5.18",
 | 
					  "version": "2.5.19",
 | 
				
			||||||
  "lockfileVersion": 2,
 | 
					  "lockfileVersion": 2,
 | 
				
			||||||
  "requires": true,
 | 
					  "requires": true,
 | 
				
			||||||
  "packages": {
 | 
					  "packages": {
 | 
				
			||||||
    "": {
 | 
					    "": {
 | 
				
			||||||
      "name": "ucentral-client",
 | 
					      "name": "ucentral-client",
 | 
				
			||||||
      "version": "2.5.18",
 | 
					      "version": "2.5.19",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "@coreui/coreui": "^3.4.0",
 | 
					        "@coreui/coreui": "^3.4.0",
 | 
				
			||||||
        "@coreui/icons": "^2.0.1",
 | 
					        "@coreui/icons": "^2.0.1",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "ucentral-client",
 | 
					  "name": "ucentral-client",
 | 
				
			||||||
  "version": "2.5.18",
 | 
					  "version": "2.5.19",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "@coreui/coreui": "^3.4.0",
 | 
					    "@coreui/coreui": "^3.4.0",
 | 
				
			||||||
    "@coreui/icons": "^2.0.1",
 | 
					    "@coreui/icons": "^2.0.1",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,6 +671,7 @@
 | 
				
			|||||||
		"percentage_free": "{{percentage}}% von {{total}} kostenlos",
 | 
							"percentage_free": "{{percentage}}% von {{total}} kostenlos",
 | 
				
			||||||
		"percentage_used": "{{percentage}}% von {{total}} verwendet",
 | 
							"percentage_used": "{{percentage}}% von {{total}} verwendet",
 | 
				
			||||||
		"title": "#{{serialNumber}} Status",
 | 
							"title": "#{{serialNumber}} Status",
 | 
				
			||||||
 | 
							"total_memory": "Gesamtspeicher",
 | 
				
			||||||
		"uptime": "Betriebszeit",
 | 
							"uptime": "Betriebszeit",
 | 
				
			||||||
		"used_total_memory": "{{used}} verwendet / {{total}} insgesamt"
 | 
							"used_total_memory": "{{used}} verwendet / {{total}} insgesamt"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,6 +671,7 @@
 | 
				
			|||||||
		"percentage_free": "{{percentage}}% of {{total}} free",
 | 
							"percentage_free": "{{percentage}}% of {{total}} free",
 | 
				
			||||||
		"percentage_used": "{{percentage}}% of {{total}} used",
 | 
							"percentage_used": "{{percentage}}% of {{total}} used",
 | 
				
			||||||
		"title": "#{{serialNumber}} Status",
 | 
							"title": "#{{serialNumber}} Status",
 | 
				
			||||||
 | 
							"total_memory": "Total Memory",
 | 
				
			||||||
		"uptime": "Uptime",
 | 
							"uptime": "Uptime",
 | 
				
			||||||
		"used_total_memory": "{{used}} used / {{total}} total "
 | 
							"used_total_memory": "{{used}} used / {{total}} total "
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,6 +671,7 @@
 | 
				
			|||||||
		"percentage_free": "{{percentage}}% de {{total}} gratis",
 | 
							"percentage_free": "{{percentage}}% de {{total}} gratis",
 | 
				
			||||||
		"percentage_used": "{{percentage}}% de {{total}} utilizado",
 | 
							"percentage_used": "{{percentage}}% de {{total}} utilizado",
 | 
				
			||||||
		"title": "#{{serialNumber}} Estado",
 | 
							"title": "#{{serialNumber}} Estado",
 | 
				
			||||||
 | 
							"total_memory": "Memoria total",
 | 
				
			||||||
		"uptime": "Tiempo de actividad",
 | 
							"uptime": "Tiempo de actividad",
 | 
				
			||||||
		"used_total_memory": "{{used}} usado / {{total}} total"
 | 
							"used_total_memory": "{{used}} usado / {{total}} total"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,6 +671,7 @@
 | 
				
			|||||||
		"percentage_free": "{{percentage}}% de {{total}} gratuit",
 | 
							"percentage_free": "{{percentage}}% de {{total}} gratuit",
 | 
				
			||||||
		"percentage_used": "{{percentage}}% de {{total}} utilisé",
 | 
							"percentage_used": "{{percentage}}% de {{total}} utilisé",
 | 
				
			||||||
		"title": "#{{serialNumber}} état",
 | 
							"title": "#{{serialNumber}} état",
 | 
				
			||||||
 | 
							"total_memory": "Mémoire totale",
 | 
				
			||||||
		"uptime": "La disponibilité",
 | 
							"uptime": "La disponibilité",
 | 
				
			||||||
		"used_total_memory": "{{used}} utilisé / {{total}} total"
 | 
							"used_total_memory": "{{used}} utilisé / {{total}} total"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,6 +671,7 @@
 | 
				
			|||||||
		"percentage_free": "{{percentage}}% de {{total}} grátis",
 | 
							"percentage_free": "{{percentage}}% de {{total}} grátis",
 | 
				
			||||||
		"percentage_used": "{{percentage}}% de {{total}} usado",
 | 
							"percentage_used": "{{percentage}}% de {{total}} usado",
 | 
				
			||||||
		"title": "#{{serialNumber}} status",
 | 
							"title": "#{{serialNumber}} status",
 | 
				
			||||||
 | 
							"total_memory": "Memória total",
 | 
				
			||||||
		"uptime": "Tempo de atividade",
 | 
							"uptime": "Tempo de atividade",
 | 
				
			||||||
		"used_total_memory": "{{used}} usado / {{total}} total"
 | 
							"used_total_memory": "{{used}} usado / {{total}} total"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,13 +2,13 @@
 | 
				
			|||||||
import React from 'react';
 | 
					import React from 'react';
 | 
				
			||||||
import PropTypes from 'prop-types';
 | 
					import PropTypes from 'prop-types';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
 | 
					  CAlert,
 | 
				
			||||||
  CCard,
 | 
					  CCard,
 | 
				
			||||||
  CCardHeader,
 | 
					  CCardHeader,
 | 
				
			||||||
  CRow,
 | 
					  CRow,
 | 
				
			||||||
  CCol,
 | 
					  CCol,
 | 
				
			||||||
  CCardBody,
 | 
					  CCardBody,
 | 
				
			||||||
  CBadge,
 | 
					  CBadge,
 | 
				
			||||||
  CAlert,
 | 
					 | 
				
			||||||
  CPopover,
 | 
					  CPopover,
 | 
				
			||||||
  CButton,
 | 
					  CButton,
 | 
				
			||||||
  CSpinner,
 | 
					  CSpinner,
 | 
				
			||||||
@@ -16,8 +16,7 @@ import {
 | 
				
			|||||||
} from '@coreui/react';
 | 
					} from '@coreui/react';
 | 
				
			||||||
import CIcon from '@coreui/icons-react';
 | 
					import CIcon from '@coreui/icons-react';
 | 
				
			||||||
import { cilSync } from '@coreui/icons';
 | 
					import { cilSync } from '@coreui/icons';
 | 
				
			||||||
import { prettyDate, compactSecondsToDetailed } from 'utils/helper';
 | 
					import { prettyDate, compactSecondsToDetailed, cleanBytesString } from 'utils/helper';
 | 
				
			||||||
import MemoryBar from './MemoryBar';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import styles from './index.module.scss';
 | 
					import styles from './index.module.scss';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -27,6 +26,20 @@ const errorField = (t) => (
 | 
				
			|||||||
  </CAlert>
 | 
					  </CAlert>
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getMemoryColor = (memTotal, memFree) => {
 | 
				
			||||||
 | 
					  let memoryUsed = 0;
 | 
				
			||||||
 | 
					  if (memTotal > 0) memoryUsed = Math.floor(((memTotal - memFree) / memTotal) * 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (memoryUsed < 60) return 'success';
 | 
				
			||||||
 | 
					  if (memoryUsed <= 85) return 'warning';
 | 
				
			||||||
 | 
					  return 'danger';
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getMemoryPercentage = (memTotal, memFree) => {
 | 
				
			||||||
 | 
					  if (memTotal <= 0) return `0%`;
 | 
				
			||||||
 | 
					  return `${Math.floor(((memTotal - memFree) / memTotal) * 100)}%`;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DeviceStatusCard = ({
 | 
					const DeviceStatusCard = ({
 | 
				
			||||||
  t,
 | 
					  t,
 | 
				
			||||||
  loading,
 | 
					  loading,
 | 
				
			||||||
@@ -156,6 +169,12 @@ const DeviceStatusCard = ({
 | 
				
			|||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                  )}
 | 
					                  )}
 | 
				
			||||||
                </CCol>
 | 
					                </CCol>
 | 
				
			||||||
 | 
					                <CCol className="mb-1" md="4" xl="4">
 | 
				
			||||||
 | 
					                  {t('status.total_memory')}:
 | 
				
			||||||
 | 
					                </CCol>
 | 
				
			||||||
 | 
					                <CCol className="mb-1" md="8" xl="8" style={{ paddingTop: '5px' }}>
 | 
				
			||||||
 | 
					                  {error ? errorField(t) : cleanBytesString(lastStats?.unit?.memory?.total)}
 | 
				
			||||||
 | 
					                </CCol>
 | 
				
			||||||
                <CCol className="mb-1" md="4" xl="4">
 | 
					                <CCol className="mb-1" md="4" xl="4">
 | 
				
			||||||
                  {t('status.memory')}:
 | 
					                  {t('status.memory')}:
 | 
				
			||||||
                </CCol>
 | 
					                </CCol>
 | 
				
			||||||
@@ -163,15 +182,19 @@ const DeviceStatusCard = ({
 | 
				
			|||||||
                  {error ? (
 | 
					                  {error ? (
 | 
				
			||||||
                    errorField(t)
 | 
					                    errorField(t)
 | 
				
			||||||
                  ) : (
 | 
					                  ) : (
 | 
				
			||||||
                    <MemoryBar
 | 
					                    <CAlert
 | 
				
			||||||
                      t={t}
 | 
					                      style={{ width: '40px' }}
 | 
				
			||||||
                      usedBytes={
 | 
					                      className="p-0 text-center"
 | 
				
			||||||
                        lastStats?.unit?.memory?.total && lastStats?.unit?.memory?.free
 | 
					                      color={getMemoryColor(
 | 
				
			||||||
                          ? lastStats?.unit?.memory?.total - lastStats?.unit?.memory?.free
 | 
					                        lastStats?.unit?.memory?.total ?? 0,
 | 
				
			||||||
                          : 0
 | 
					                        lastStats?.unit?.memory?.free ?? 0,
 | 
				
			||||||
                      }
 | 
					                      )}
 | 
				
			||||||
                      totalBytes={lastStats?.unit?.memory?.total ?? 0}
 | 
					                    >
 | 
				
			||||||
                    />
 | 
					                      {getMemoryPercentage(
 | 
				
			||||||
 | 
					                        lastStats?.unit?.memory?.total ?? 0,
 | 
				
			||||||
 | 
					                        lastStats?.unit?.memory?.free ?? 0,
 | 
				
			||||||
 | 
					                      )}
 | 
				
			||||||
 | 
					                    </CAlert>
 | 
				
			||||||
                  )}
 | 
					                  )}
 | 
				
			||||||
                </CCol>
 | 
					                </CCol>
 | 
				
			||||||
              </CRow>
 | 
					              </CRow>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user