Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added search by tag name #32

Merged
merged 3 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/app/components/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.spacing {
margin-right: 0.25em;
}
.columns {
.sub-results {
margin-left: 36px;
}
</style>
Expand Down Expand Up @@ -38,7 +38,7 @@ <h4 class="a">
<p ng-bind-html="highlight(result.model.description)"></p>
</div>
</div>
<div class="columns" ng-show="query.length > 0">
<div class="sub-results" ng-show="query.length > 0">
<span ng-repeat="column in columnFilter(result.model.columns) | limitTo:limitColumns(result.model.unique_id)">
<span ng-show="$first === true">columns:</span>
<span ng-bind-html="highlight(column + ',')" ng-show="$last === false"></span>
Expand All @@ -48,6 +48,13 @@ <h4 class="a">
ng-show="columnFilter(result.model.columns).length > max_results_columns && !limit_columns[result.model.unique_id]"
ng-click="$event.stopPropagation(); limit_columns[result.model.unique_id] = 100">Show {{ columnFilter(result.model.columns).length - max_results_columns }} more</a>
</div>
<div class="sub-results" ng-show="query.length > 0">
<span ng-repeat="tag in result.model.tags">
<span ng-show="$first === true">tags:</span>
<span ng-bind-html="highlight(tag + ',')" ng-show="$last === false"></span>
<span ng-bind-html="highlight(tag)" ng-show="$last === true"></span>
</span>
</div>
</div>
<a
ng-show="results.length >= max_results && !show_all"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/table_details/table_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h6 class="detail-label">Details</h6>
<dl class='detail' ng-if="model.tags != undefined">
<dt class="detail-label">Tags</dt>
<dd ng-if="model.tags.length > 0" class="detail-value">
<span ng-repeat="tag in model.tags"><code>{{ tag }}</code>&nbsp;</span>
<span ng-repeat="tag in model.tags"><code><a ng-click=queryTag(tag)>{{ tag }}</a></code>&nbsp;</span>
</dd>
<dd ng-if="model.tags.length == 0" class="detail-value">untagged</dd>
</dl>
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/table_details/table_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ angular

scope.show_extended = _.where(scope.extended, {include: true}).length > 0;
});

scope.queryTag = function(tag) {
scope.$emit('query', tag);
}
}
}
}]);
5 changes: 5 additions & 0 deletions src/app/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ angular
$scope.clearSearch();
});

$scope.$on('query', function(event, search) {
$scope.search.is_focused = true;
$scope.search.query = search;
});

$scope.onSearchKeypress = function(e) {
console.log(e);
if (e.key == 'Escape') {
Expand Down
12 changes: 9 additions & 3 deletions src/app/services/project_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ angular

function fuzzySearchObj(val, obj) {
var objects = [];
var search_keys = {'name':'string', 'description':'string', 'columns':'object'};

var search_keys = {'name':'string', 'description':'string', 'columns':'object', 'tags': 'array'};
var search = new RegExp(val, "i")

for (var i in search_keys) {
if (!obj[i]) {
continue;
Expand All @@ -259,6 +259,12 @@ angular
objects.push({key: i, value: val});
}
}
} else if (search_keys[i] === 'array') {
for (var tag of obj[i]) {
if (tag.toLowerCase().indexOf(val.toLowerCase()) != -1) {
objects.push({key: i, value: val});
}
}
}
}

Expand Down