瀏覽代碼

bug fix with units and UI

Steve L. Nyemba 8 年之前
父節點
當前提交
9f24f177db
共有 2 個文件被更改,包括 24 次插入2 次删除
  1. 1 1
      src/api/static/js/dashboard.js
  2. 23 1
      src/monitor.py

+ 1 - 1
src/api/static/js/dashboard.js

@@ -496,7 +496,7 @@ monitor.folders.render.summary = function (data) {
 		{ name: 'id', type: 'text', title: "Context", headercss: "small bold", css: "small"},
 		{ name: 'name', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
 		
-		{ name: "summary.size", type: "number", title: "Size (MB)", type: "number", headercss: "small bold" },
+		{ name: "summary.size", type: "number", title: "Folder Size", type: "number", headercss: "small bold" },
 		{ name: "summary.count", type: "number", title: "File Count", type: "number", headercss: "small bold" }
 	]
 	var grid = $('#gridfolders').jsGrid(options) ;

+ 23 - 1
src/monitor.py

@@ -287,7 +287,29 @@ class FileWatch(Analysis):
 				xo = np.array(ML.Extract(['size','age'],xo_raw))
 				name = re.findall("([a-z,A-Z,0-9]+$)",folder)
 				name = name[0]
-				xo = {"label":folder,"details":xo_raw,"summary":{"size":round(np.sum(xo[:,0]),2),"age":round(np.mean(xo[:,1]),2),"count":len(xo[:,1])}}
+				size = round(np.sum(xo[:,0]),2)
+				if size > 1000 :
+					size = round(size/1000,2)
+					units = ' GB'
+				elif size > 1000000:
+					size = round(size/1000000,2)
+					units = ' TB'
+				else:
+					size = size 
+					units = ' MB'
+				size = str(size)+ units
+				age = round(np.mean(xo[:,1]),2)
+				if age > 30 and age <= 365 :
+					age = round(age/30,2)
+					units = ' Months'
+				elif age > 365 :
+					age = round(age/365,2) 
+					units = ' Years'
+				else:
+					age = age
+					units = ' Days'
+				age = str(age)+units
+				xo = {"label":folder,"details":xo_raw,"summary":{"size":size,"age":age,"count":len(xo[:,1])}}
 				xo["name"] = name
 				xo['day'] = now.day
 				xo['month'] = now.month