瀏覽代碼

Bug fix around folder handling from various sources

Steve L. Nyemba 8 年之前
父節點
當前提交
267e11e47b
共有 5 個文件被更改,包括 25 次插入11 次删除
  1. 11 2
      src/api/index.py
  2. 4 4
      src/api/static/js/dashboard.js
  3. 2 2
      src/api/templates/dashboard.html
  4. 6 2
      src/monitor.py
  5. 2 1
      src/utils/agents/data-collector.py

+ 11 - 2
src/api/index.py

@@ -253,8 +253,17 @@ def get_folders():
 	d =  gReader.read()
 	if 'folders' in d:
 		d = d['folders']
-		index = len(d) - 1
-		d = d[index]
+		hosts = set([row[0]['id'] for row in d])
+		m = {}
+		for id in hosts:
+			for row in d:				
+				if id == row[0]['id'] :
+					m[id] = row
+		d = m.values()
+		for row in d:
+			print row[0]['id']
+		# index = len(d) - 1
+		# d = d[index]
 		
 			
 		# m = {}

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

@@ -408,7 +408,7 @@ monitor.folders.search.init = function(){
 	term = term.replace(/\x32/g,'')
 	if (term.length == 0) {
 		monitor.folders.render.summary(data)
-	} else if (term.length > 3) {
+	} else if (term.length > 0) {
 		
 		data = jx.utils.patterns.visitor(data, function (row) {
 			if (row.id.match(term)) {
@@ -517,9 +517,9 @@ monitor.folders.render.summary = function (data) {
 	}
 	options.paging = true
 	options.pageSize = 4
-	options.pageIndex = 1
+	options.pageIndex = 2
 	options.pageButtonCount = 4
-	options.pagerContainer = '#latest_process_pager'
+	options.pagerContainer = '#folderspager'
     	options.pagerFormat= "{prev} Page {pageIndex} of {pageCount} {next}"
     	options.pagePrevText= '<i class="fa fa-chevron-left"></i>'
     	options.pageNextText= "<i class='fa fa-chevron-right small' title='Next'> </i>"
@@ -546,7 +546,7 @@ monitor.folders.render.summary = function (data) {
 	options.autoload  = true
 	options.fields = [
 		{ name: 'id', type: 'text', title: "Host", headercss: "small bold", css: "small"},
-		{ name: 'label', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
+		{ name: 'name', type: 'text', title: "Folder Name", headercss: "small bold", css: "small"},
 		
 		{ name: "size", type: "number", title: "Folder Size", type: "number", headercss: "small bold" },
 		{ name: "count", type: "number", title: "File Count", type: "number", headercss: "small bold" }

+ 2 - 2
src/api/templates/dashboard.html

@@ -114,9 +114,9 @@
 						<input id="folder_search" type="text" class="small left" placeholder="hostname" style="width:87%; padding-left:4px;" onkeyup="monitor.folders.search.init()"/>
 						<i class="fa fa-trash right action right" style="margin:4px; padding:4px; color:maroon" onclick="monitor.folders.search.reset()"></i>
 					</div>
-					<div style="margin-top:10px; height:150px">
+					<div style="margin-top:10px; height:170px">
 						<div id="gridfolders"></div>
-						<div id="folderspager"></div>
+						<div id="folderspager" class="small" style="height:22px"></div>
 					</div>
 				</div>
 			</div>

+ 6 - 2
src/monitor.py

@@ -293,9 +293,13 @@ class FileWatch(Analysis):
 				xo = np.array(ML.Extract(['size','age'],xo_raw))
 				if len(xo) == 0:
 					continue
-				name = re.findall("([a-z,A-Z,0-9]+$)",folder)
-				if len(name) == 0:
+				name = re.findall("([a-z,A-Z,0-9]+)",folder)
+				name = folder.split(os.sep)
+				if len(name) == 1:
 					name = [folder]
+				else:
+					i = len(name) -1
+					name = [name[i-1]+' '+name[i]]
 
 				name = name[0]
 				size = round(np.sum(xo[:,0]),2)

+ 2 - 1
src/utils/agents/data-collector.py

@@ -79,7 +79,8 @@ class ICollector(Thread) :
 				label	= thread.getName()
 				row	= {}
 				if label == 'folders':
-					row = [ dict({"id":self.id}, **_row) for _row in data]
+					row = [ dict({"id":self.id}, **_row) for _row in data]					
+					
 				else:
 					label = id
 					row = data