Simplify RAM management
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -154,7 +154,7 @@ function VMListWidget(p: {
 | 
			
		||||
                        {row.name}
 | 
			
		||||
                      </TableCell>
 | 
			
		||||
                      <TableCell>{row.description ?? ""}</TableCell>
 | 
			
		||||
                      <TableCell>{vmMemoryToHuman(row.memory)}</TableCell>
 | 
			
		||||
                      <TableCell>{filesize(row.memory)}</TableCell>
 | 
			
		||||
                      <TableCell>{row.number_vcpu}</TableCell>
 | 
			
		||||
                      <TableCell>
 | 
			
		||||
                        <VMStatusWidget
 | 
			
		||||
@@ -183,13 +183,13 @@ function VMListWidget(p: {
 | 
			
		||||
            <TableCell></TableCell>
 | 
			
		||||
            <TableCell></TableCell>
 | 
			
		||||
            <TableCell>
 | 
			
		||||
              {vmMemoryToHuman(
 | 
			
		||||
              {filesize(
 | 
			
		||||
                p.list
 | 
			
		||||
                  .filter((v) => runningVMs.has(v.name))
 | 
			
		||||
                  .reduce((s, v) => s + v.memory, 0)
 | 
			
		||||
              )}
 | 
			
		||||
              {" / "}
 | 
			
		||||
              {vmMemoryToHuman(p.list.reduce((s, v) => s + v.memory, 0))}
 | 
			
		||||
              {filesize(p.list.reduce((s, v) => s + v.memory, 0))}
 | 
			
		||||
            </TableCell>
 | 
			
		||||
            <TableCell>
 | 
			
		||||
              {p.list
 | 
			
		||||
@@ -206,7 +206,3 @@ function VMListWidget(p: {
 | 
			
		||||
    </TableContainer>
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function vmMemoryToHuman(size: number): string {
 | 
			
		||||
  return filesize(size * 1000 * 1000);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -279,14 +279,16 @@ function VMDetailsTabGeneral(p: DetailsInnerProps): React.ReactElement {
 | 
			
		||||
          label="Memory (MB)"
 | 
			
		||||
          editable={p.editable}
 | 
			
		||||
          type="number"
 | 
			
		||||
          value={p.vm.memory.toString()}
 | 
			
		||||
          value={Math.floor(p.vm.memory / (1000 * 1000)).toString()}
 | 
			
		||||
          onValueChange={(v) => {
 | 
			
		||||
            p.vm.memory = Number(v ?? "0");
 | 
			
		||||
            p.vm.memory = Number(v ?? "0") * 1000 * 1000;
 | 
			
		||||
            p.onChange?.();
 | 
			
		||||
          }}
 | 
			
		||||
          checkValue={(v) =>
 | 
			
		||||
            Number(v) > ServerApi.Config.constraints.memory_size.min &&
 | 
			
		||||
            Number(v) < ServerApi.Config.constraints.memory_size.max
 | 
			
		||||
            Number(v) >
 | 
			
		||||
              ServerApi.Config.constraints.memory_size.min / (1000 * 1000) &&
 | 
			
		||||
            Number(v) <
 | 
			
		||||
              ServerApi.Config.constraints.memory_size.max / (1000 * 1000)
 | 
			
		||||
          }
 | 
			
		||||
        />
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user