Commits

liefeld  committed c230eba

revised display of search result tags and added search on server

  • Participants
  • Parent commits 0b27afd

Comments (0)

Files changed (3)

File jsui/src/main/webapp/css/TedsStyles.css

 }
 
 #asdToolSearchResults, #asdToolSearchResults ul {
-	list-style: none;
-	list-style-type: none;
+
+	 list-style-type: none; 
 }
 
 #asdToolSearchResults li {
 	margin-left: -20px;
 }
 
-.asdSearchResultTag {
-	padding-left: 5px;
+.asdToolSearchResultsHeader {
+	
+	margin-top: 12px;
 }
 .asdMatchTag {
 	font-size: 14px !important;
 	font-weight: bold !important;
+	margin-top: 2px;
 }
+
+.asdNonMatchTag {
+	
+}
+
 .asdSearchResultTag {
+	border: 1px solid #7295d1;
+	border-width: 1px 1px 1px 0px;
+	color: #7295d1;
+	padding-left: 2px;
+	padding-right: 3px;
+	margin-right: 10px;
 	
-	color: #7295d1;
-	padding-left: 1px;
+	float: left;
+	z-index: 2;
+	position: relative;
+	height: 16px !important;
+}
+
+.lefttriangle{
+    border: 1px solid #7295d1;
+    border-width: 1px 0 0 1px;
+    width:12px;
+    height:12px;
+    /* for firefox, safari, chrome, etc. */
+    -webkit-transform: rotate(-45deg);
+    -moz-transform: rotate(-45deg);
+    -o-transform:rotate(-45deg);
+    z-index: 1;
+    bottom: -2px;
+    background: #fff;
+    float: left;
+    margin-right: -6px;
+    position: relative;
+   
+}
+
+
+.asdSearchResultTagNomatch {
+	border: 1px solid #AAA;
+	border-width: 1px 1px 1px 0px;
+	color: #AAA;
+	padding-left: 2px;
+	padding-right: 3px;
 	margin-right: 10px;
+	
+	float: left;
+	z-index: 2;
+	position: relative;
+	height: 16px !important;
 }
+
+.lefttriangleNomatch {
+    border: 1px solid #AAA;
+    border-width: 1px 0 0 1px;
+    width:12px;
+    height:12px;
+    /* for firefox, safari, chrome, etc. */
+    -webkit-transform: rotate(-45deg);
+    -moz-transform: rotate(-45deg);
+    -o-transform:rotate(-45deg);
+    z-index: 1;
+    bottom: -2px;
+    background: #fff;
+    float: left;
+    margin-right: -6px;
+    position: relative;
+   
+}
+.asdSearchResultTagDrawing div {
+	
+	background-color: #ffffff;
+}
+
+

File jsui/src/main/webapp/js/atm.js

 }
 
 
+function atmSearchTools(searchTerms, callback){
+	var termJson = JSON.stringify(searchTerms);
+	$.ajax({
+		  url: atmUrlBase + "/webtool/search",
+		  type: 'post',
+		  context: document.body,
+		  async: true,
+		  data: termJson,
+		  contentType: 'application/json',
+		  dataType: 'json',
+		  success: function(data) {
+				if (callback != null) callback(data, searchTerms);
+			},
+		  error: gsErrorFunction
+		});
+}
 
 
-

File jsui/src/main/webapp/js/search.js

 }
 
 function clearSearchResults(){
-	toolSearchAreas = [];
 	
 	$('#asdToolSearchResults').hide();
 	$('#asdToolSearchResults').html('');
 	var byToolDescription =$("#asdToolDescriptionCB").prop('checked');
 	var byToolTag =$("#asdToolTagCB").prop('checked') ;
 	
-	var seperateTerms = terms.toLowerCase().split(" ");
+	var seperateTerms =getSeperateTerms(terms);
 	
 	if (byToolName) searchToolProperties(seperateTerms, 'name');
 	if (byToolDescription) searchToolProperties(seperateTerms, 'description');
-	if (byToolTag) searchToolTags(seperateTerms);
+	addToolTagsToTools();
+	performRemoteSearch(seperateTerms);
 	
 	$('#asdSearchResultsHeader').show();
 	
 	// $('#asdFileSearchResults').show();
 }
 
-var toolSearchAreas = [];
-function recordToolSubSearchComplete(searchType){
-	toolSearchAreas.push(searchType);
-	if (toolSearchAreas.length == 3){
-		recordToolSearchComplete();
-	}
+// split the tring, remove blanks and duplicates
+function getSeperateTerms(terms){
+	 var rawTerms = terms.toLowerCase().split(" ");
+	 var cleanTerms = new Array();
+	 $.each(rawTerms, function(k,term){
+		 if (term.length > 0){
+			if ($.inArray(term, cleanTerms) == -1) {
+				cleanTerms.push(term);
+			} 
+		 }
+	 });
+	 return cleanTerms;
 }
 
+
+function performRemoteSearch(seperateTerms){
+	atmSearchTools(seperateTerms, function(results, terms){
+	  // alert('Search done ' + results + "  " + terms);
+	   
+	   $.each(results, function(k,searchResult){
+		   var tool = toolsByIds[searchResult.toolId];
+		   
+		   if (tool != null) { // may have a tag we can see on a tool we cannot
+			   if (searchResult.tag != null) {
+				   addTagToTool(tool, searchResult.tag);
+				   var match = new Object();
+				   match.name = "tag";
+				   match.object = searchResult.tag;
+				   recordToolSearchResult(tool, searchResult.attributeName, match);
+			   } else {
+				   var match = new Object();
+				   match.name = searchResult.attributeName;
+				   match.matchString = tool[searchResult.attributeName];			
+				   recordToolSearchResult(tool, searchResult.attributeName, match);
+			   }
+			}
+		   
+	   });
+	   // once 
+	   recordToolSearchComplete();
+	   
+	});
+}
+
+
+function addToolTagsToTools(){
+	atmGetAllTags(function(tags){
+		$.each(tags, function(k, tag){
+			$.each(tag.toolInternalId, function(kt, toolId){
+				var tool = toolsByIds[toolId];
+				if (tool != null) { // may have a tag we can see on a tool we cannot
+					addTagToTool(tool, tag);
+				}
+			});
+		});
+	});
+}
+
+
 function recordToolSearchComplete(){
 	var header = $('#asdSearchResultsHeader').html();
 	header = header.replace(asdStatusRunning, "");
 }
 
 function createTagHtml(tag, tool, boldit){
-	var tagSpan =  $('<span class="'+uniqueTagClass(tool, tag)+'"  title="'+tag.description+'">'+tag.value+'</span>');
-	tagSpan.addClass('asdSearchResultTag');
-	if (boldit == true) tagSpan.addClass("asdMatchTag");
-	tagSpan.addClass("asdSearchResultTag");
+	 //<img height="14" width="14" src="./images/tag-blue.png"/>
+	
+	var tagSpan =  $('<span class="'+uniqueTagClass(tool, tag)+'"  title="'+tag.description+'"></span>');
+	
+	var triangle = $('<div></div>');
+	var nameSpan =  $('<div style="display:inline">'+tag.value+'</div>');
+	tagSpan.append(triangle);
+	tagSpan.append(nameSpan);
+
+	tagSpan.addClass("asdSearchResultTagDrawing");
+	if (boldit == true){
+		tagSpan.addClass("asdMatchTag");
+		nameSpan.addClass('asdSearchResultTag');
+		
+		$(triangle).addClass("lefttriangle");
+	} else {
+		tagSpan.addClass("asdNonMatchTag");
+		nameSpan.addClass('asdSearchResultTagNomatch');
+		
+		$(triangle).addClass("lefttriangleNomatch");
+		
+	}
 	
 	$(tagSpan).click(function(e){
 		e.preventDefault();
 			}
 		});
 	});
-	recordToolSubSearchComplete(property);
-}
-
-
-
-function searchToolTags(terms){
-	atmGetAllTags(function(tags){
-		$.each(terms, function(key, term){
-			$.each(tags, function(k, tag){
-				$.each(tag.toolInternalId, function(kt, toolId){
-					var tool = toolsByIds[toolId];
-					if (tool != null) { // may have a tag we can see on a tool we cannot
-						addTagToTool(tool, tag);
-						if ( (tag.value.toLowerCase().indexOf(term) > -1)){
-							var match = new Object();
-							match.name = "tag";
-							match.object = tag;
-							recordToolSearchResult(tool, "tag", match);
-						}
-						if (  (tag.description.toLowerCase().indexOf(term) > -1)){
-							var match = new Object();
-							match.name = "tag";
-							match.object = tag;
-							recordToolSearchResult(tool, "tag", match);
-						}
-					}
-				});
-			});
-		});
-		// once 
-		recordToolSubSearchComplete("tags");
-	});
 }
 
 // save the tags for the tool to facilitate later use
 	if (existingRow.length == 0){
 		var toolRow = $('<li class="asdToolSearchResult" id="'+searchResultId+'"></li>');
 		$(toolRow).data('tool',tool);
-		var part1 = $('<div></div>');
+		var part1 = $('<div class="asdToolSearchResultsHeader"></div>');
 		var part2 = $('<ul></ul>');
 		
 		toolRow.append(part1).append(part2);
 		part1.append(enhanceMatchingTerms(tool.name));
 		part2.append('<li>'+enhanceMatchingTerms(tool.description)+'</li>');
 		var tagSpan = formatTagMatchString(tool, match, true);
-		var tagLi = $('<li><img height="14" width="14" src="./images/tag-blue.png"/> </li>');
-		tagLi.append(tagSpan);
+		var tagLi = $('<li> </li>');
+		
 		part2.append(tagLi);
+		if (tagSpan != null){
+			$(tagLi).append(tagSpan);
+		} else {
+			$(tagLi).hide();
+		}
 		
 		var launch = $('<img  class="asdLaunchIcnButton" alt="launch" src="images/XXXstart.jpg" title="Launch '+tool.name+'"/>');
 		launch.addClass('asdlaunchIcon');
 		else if (count > 1) $('#asdSearchResultsHeader').html(asdFoundString_part1 + count + asdToolFoundString_part2_plural+ asdStatusRunning);
 	} else {
 		var col3 = $('#'+searchResultId + ' li:nth-child(2)');
-		var existingTag = null
+		var existingTag = null;
 		if (match.name == 'tag'){
 			var tag = match.object;
 			existingTag = col3.find("."+uniqueTagClass(tool, tag));
 		}
 		// if there is already a tag of this name, add a count and a popover with
 		// the descriptions from all variants of tags of this name
-		if (existingTag.length == 0){
-			col3.append(  formatTagMatchString(tool, match, true));
+		
+		if ((existingTag == null) || (existingTag.length == 0)){
+			var tagSpan = formatTagMatchString(tool, match, true);
+			if (tagSpan != null) {
+				col3.append(tagSpan);
+				col3.show();
+			}
 		}
+	
+			
 	}
 	
 	
 		var tag = createTagHtml(match.object, tool, boldit);
 		return tag;
 	} else {
-		return ""; // leave blank for name/descrop matches
+		return null; // leave blank for name/descrop matches
 	}
 }