|  |  | @ -2,24 +2,12 @@ package master_ui | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import ( | 
			
		
	
		
			
				
					|  |  |  | 	"fmt" | 
			
		
	
		
			
				
					|  |  |  | 	"github.com/chrislusf/seaweedfs/weed/util" | 
			
		
	
		
			
				
					|  |  |  | 	"html/template" | 
			
		
	
		
			
				
					|  |  |  | 	"strconv" | 
			
		
	
		
			
				
					|  |  |  | 	"strings" | 
			
		
	
		
			
				
					|  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | func bytesToHumanReadble(b uint64) string { | 
			
		
	
		
			
				
					|  |  |  | 	const unit = 1024 | 
			
		
	
		
			
				
					|  |  |  | 	if b < unit { | 
			
		
	
		
			
				
					|  |  |  | 		return fmt.Sprintf("%d B", b) | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	div, exp := uint64(unit), 0 | 
			
		
	
		
			
				
					|  |  |  | 	for n := b / unit; n >= unit; n /= unit { | 
			
		
	
		
			
				
					|  |  |  | 		div *= unit | 
			
		
	
		
			
				
					|  |  |  | 		exp++ | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	return fmt.Sprintf("%.2f %ciB", float64(b)/float64(div), "KMGTPE"[exp]) | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | func percentFrom(total uint64, part_of uint64) string { | 
			
		
	
		
			
				
					|  |  |  | 	return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100) | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | @ -33,9 +21,9 @@ func join(data []int64) string { | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | var funcMap = template.FuncMap{ | 
			
		
	
		
			
				
					|  |  |  | 	"join":                join, | 
			
		
	
		
			
				
					|  |  |  | 	"bytesToHumanReadble": bytesToHumanReadble, | 
			
		
	
		
			
				
					|  |  |  | 	"percentFrom":         percentFrom, | 
			
		
	
		
			
				
					|  |  |  | 	"join":                 join, | 
			
		
	
		
			
				
					|  |  |  | 	"bytesToHumanReadable": util.BytesToHumanReadable, | 
			
		
	
		
			
				
					|  |  |  | 	"percentFrom":          percentFrom, | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html> | 
			
		
	
	
		
			
				
					|  |  | @ -90,8 +78,8 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC | 
			
		
	
		
			
				
					|  |  |  |           {{ range .DiskStatuses }} | 
			
		
	
		
			
				
					|  |  |  |             <tr> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .Dir }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadble .All }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadble .Free  }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadable .All }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadable .Free  }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ percentFrom .All .Used}}%</td> | 
			
		
	
		
			
				
					|  |  |  |             </tr> | 
			
		
	
		
			
				
					|  |  |  |           {{ end }} | 
			
		
	
	
		
			
				
					|  |  | @ -151,9 +139,9 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC | 
			
		
	
		
			
				
					|  |  |  |             <tr> | 
			
		
	
		
			
				
					|  |  |  |               <td><code>{{ .Id }}</code></td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .Collection }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadble .Size }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadable .Size }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .FileCount }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .DeleteCount }} / {{bytesToHumanReadble .DeletedByteCount}}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .Ttl }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .ReadOnly }}</td> | 
			
		
	
		
			
				
					|  |  |  |             </tr> | 
			
		
	
	
		
			
				
					|  |  | @ -181,9 +169,9 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC | 
			
		
	
		
			
				
					|  |  |  |             <tr> | 
			
		
	
		
			
				
					|  |  |  |               <td><code>{{ .Id }}</code></td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .Collection }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadble .Size }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadable .Size }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .FileCount }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .DeleteCount }} / {{bytesToHumanReadble .DeletedByteCount}}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .RemoteStorageName }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .RemoteStorageKey }}</td> | 
			
		
	
		
			
				
					|  |  |  |             </tr> | 
			
		
	
	
		
			
				
					|  |  | @ -209,7 +197,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC | 
			
		
	
		
			
				
					|  |  |  |             <tr> | 
			
		
	
		
			
				
					|  |  |  |               <td><code>{{ .VolumeId }}</code></td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .Collection }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadble .ShardSize }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ bytesToHumanReadable .ShardSize }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .ShardIdList }}</td> | 
			
		
	
		
			
				
					|  |  |  |               <td>{{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}</td> | 
			
		
	
		
			
				
					|  |  |  |             </tr> | 
			
		
	
	
		
			
				
					|  |  | 
 |