Added a page for memory stats
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				ci/woodpecker/push/woodpecker Pipeline was successful
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	ci/woodpecker/push/woodpecker Pipeline was successful
				
			This commit is contained in:
		
							
								
								
									
										24
									
								
								assets/coffee/memory.coffee
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								assets/coffee/memory.coffee
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| si = require('systeminformation') | ||||
|  | ||||
| window.onload = () -> | ||||
|   # Grab the static CPU information | ||||
|   si.mem() | ||||
|     .then((data) -> | ||||
|       document.getElementById('memoryTotal').innerText = @formatBytes(data.total) | ||||
|     ).catch((error) -> | ||||
|       console.error(error) | ||||
|     ) | ||||
|  | ||||
|   # Start the CPU temperature loop | ||||
|   getMemoryUsage() | ||||
|  | ||||
| getMemoryUsage = () -> | ||||
|   si.mem() | ||||
|     .then((data) -> | ||||
|       document.getElementById('memoryFree').innerText = @formatBytes(data.free) | ||||
|       document.getElementById('memoryActive').innerText = @formatBytes(data.active) | ||||
|       document.getElementById('memoryBuffCache').innerText = @formatBytes(data.buffcache) | ||||
|     ).catch((error) -> | ||||
|       console.error(error) | ||||
|     ) | ||||
|   setTimeout(getMemoryUsage, 2000) | ||||
| @@ -1,2 +1,21 @@ | ||||
| @loadPage = (pagePath) -> | ||||
|   window.location.href = pagePath + '.html' | ||||
|  | ||||
| @formatBytes = (bytes, decimals = 2) -> | ||||
|   if bytes == 0 | ||||
|     return '0 Bytes' | ||||
|   k = 1024 | ||||
|   dm = if decimals < 0 then 0 else decimals | ||||
|   sizes = [ | ||||
|     'Bytes' | ||||
|     'KB' | ||||
|     'MB' | ||||
|     'GB' | ||||
|     'TB' | ||||
|     'PB' | ||||
|     'EB' | ||||
|     'ZB' | ||||
|     'YB' | ||||
|   ] | ||||
|   i = Math.floor(Math.log(bytes) / Math.log(k)) | ||||
|   parseFloat((bytes / k ** i).toFixed(dm)) + ' ' + sizes[i] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user