<commit_before>angular.module('bulk_tag_app', ['slugifier', 'ui.sortable', 'ui.tinymce', 'ngSanitize', 'ui.bootstrap', 'ui.utils']).
	factory('search_factory', function($http){
		return{
			search: function(filters){
				return promise = $http.post(real_base_url+'registry/services/registry/post_solr_search', {'filters':filters}).then(function(response){ return response.data; });
			},
			tags_get_solr: function(filters){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/solr/get', {'filters':filters}).then(function(response){ return response.data; });
			},
			tags_action_solr: function(filters, action, tag, tagType){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/solr/'+action, {'filters':filters, 'tag':tag, 'tag_type':tagType}).then(function(response){ return response.data; });
			},
			tags_get_keys: function(keys){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/keys/get', {'keys':keys}).then(function(response){ return response.data; });
			},
			tags_action_keys: function(keys, action, tag, tagType){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/keys/'+action, {'keys':keys, 'tag':tag, 'tag_type':tagType}).then(function(response){ return response.data; });
			},
			tags_get_status: function(tags){
				return promise = $http.post(real_base_url+'registry/services/registry/tags_status/', {'tags':tags}).then(function(response){ return response.data; });	
			}
		}
	}).
	directive('mapwidget', function(){
		return {
			restrict : 'A',
			link: function(scope, element, a){
				$(element).ands_location_widget({
					target:'geoLocation'+scope.f.id,
					return_callback: function(str){
						scope.f.value=str;
						scope.search();
					}
				});
			}
		}
	}).
	config(function($routeProvider){
		$routeProvider
			.when('/',{
				controller:index,
				template:$('#index_template').html()
			})
	});

function index($scope, $http, search_factory){

	$scope.datasources = [];
	$scope.selected_ro = [];
	
	$scope.$watch('selected_ro.length', function(){
		if($scope.selected_ro.length > 0){
			search_factory.tags_get_keys($scope.selected_ro).then(function(data){
				var tags_array = [];
				$.each(data, function(i, k){
					tags_array.push({name:k});
				});
				$scope.tags_result = {data:tags_array};
			});
		}else{
			if($scope.facet_result) $scope.tags_result = {data:$scope.facet_result.tag};
			if($scope.search_result && $scope.search_result.data.result.docs){
				$.each($scope.search_result.data.result.docs, function(){
					this.selected = '';
				});
			}
		}
	});

	$scope.$watch('perPage', function(){
		$scope.search();
	});

	$scope.$watch('tags_result', function(newr, oldr){
		if(newr && newr.data && newr.data.length > 0){
			search_factory.tags_get_status($scope.tags_result).then(function(data){
				$scope.tags_result.data = data;
			});
		}
	}, true);

	$scope.available_filters = [
		{value:'class', title:'Class'},
		{value:'type', title:'Type'},
		{value:'group', title:'Group'},
		{value:'tag', title:'Tag'},
		{value:'subject_vocab_uri', title:'Subject'},
		{value:'subject_value_resolved', title:'Keywords'},
		{value:'data_source_key', title:'Data Source'},
		{value:'originating_source', title:'Originating Source'},
		{value:'spatial', title:'Spatial'},
	];
<commit_msg>fix minor bug with selected record tags<commit_after>angular.module('bulk_tag_app', ['slugifier', 'ui.sortable', 'ui.tinymce', 'ngSanitize', 'ui.bootstrap', 'ui.utils']).
	factory('search_factory', function($http){
		return{
			search: function(filters){
				return promise = $http.post(real_base_url+'registry/services/registry/post_solr_search', {'filters':filters}).then(function(response){ return response.data; });
			},
			tags_get_solr: function(filters){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/solr/get', {'filters':filters}).then(function(response){ return response.data; });
			},
			tags_action_solr: function(filters, action, tag, tagType){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/solr/'+action, {'filters':filters, 'tag':tag, 'tag_type':tagType}).then(function(response){ return response.data; });
			},
			tags_get_keys: function(keys){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/keys/get', {'keys':keys}).then(function(response){ return response.data; });
			},
			tags_action_keys: function(keys, action, tag, tagType){
				return promise = $http.post(real_base_url+'registry/services/registry/tags/keys/'+action, {'keys':keys, 'tag':tag, 'tag_type':tagType}).then(function(response){ return response.data; });
			},
			tags_get_status: function(tags){
				return promise = $http.post(real_base_url+'registry/services/registry/tags_status/', {'tags':tags}).then(function(response){ return response.data; });	
			}
		}
	}).
	directive('mapwidget', function(){
		return {
			restrict : 'A',
			link: function(scope, element, a){
				$(element).ands_location_widget({
					target:'geoLocation'+scope.f.id,
					return_callback: function(str){
						scope.f.value=str;
						scope.search();
					}
				});
			}
		}
	}).
	config(function($routeProvider){
		$routeProvider
			.when('/',{
				controller:index,
				template:$('#index_template').html()
			})
	});

function index($scope, $http, search_factory){

	$scope.datasources = [];
	$scope.selected_ro = [];
	
	$scope.$watch('selected_ro.length', function(){
		if($scope.selected_ro.length > 0){
			search_factory.tags_get_keys($scope.selected_ro).then(function(data){
				var tags_array = [];
				$.each(data, function(i, k){
					tags_array.push(k);
				});
				$scope.tags_result = {data:tags_array};
			});
		}else{
			if($scope.facet_result) $scope.tags_result = {data:$scope.facet_result.tag};
			if($scope.search_result && $scope.search_result.data.result.docs){
				$.each($scope.search_result.data.result.docs, function(){
					this.selected = '';
				});
			}
		}
	});

	$scope.$watch('perPage', function(){
		$scope.search();
	});

	$scope.$watch('tags_result', function(newr, oldr){
		if(newr && newr.data && newr.data.length > 0){
			search_factory.tags_get_status($scope.tags_result).then(function(data){
				console.log(data);
				if(data.status=='OK') {
					$scope.tags_result.data = data.content;
				}
			});
		}
	}, true);

	$scope.available_filters = [
		{value:'class', title:'Class'},
		{value:'type', title:'Type'},
		{value:'group', title:'Group'},
		{value:'tag', title:'Tag'},
		{value:'subject_vocab_uri', title:'Subject'},
		{value:'subject_value_resolved', title:'Keywords'},
		{value:'data_source_key', title:'Data Source'},
		{value:'originating_source', title:'Originating Source'},
		{value:'spatial', title:'Spatial'},
	];

{'fraction_non_alphanumeric': 0.19275511706670592, 'fraction_numerical': 0.0005890148726255338, 'mean_word_length': 5.015943312666076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371517', 'n_tokens_mistral': 2570, 'n_tokens_neox': 2254, 'n_words': 310}