parent
343e95d161
commit
55491c9979
|
@ -95,33 +95,77 @@ var ClientModel = Backbone.Model.extend({
|
||||||
urlRoot:"api/clients",
|
urlRoot:"api/clients",
|
||||||
|
|
||||||
matches:function(term) {
|
matches:function(term) {
|
||||||
|
|
||||||
|
var matches = [];
|
||||||
|
|
||||||
if (term) {
|
if (term) {
|
||||||
if (this.get('clientId').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
if (this.get('clientId').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
return true;
|
matches.push('id');
|
||||||
} else if (this.get('clientName') != null && this.get('clientName').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
|
||||||
return true;
|
|
||||||
} else if (this.get('clientDescription') != null && this.get('clientDescription').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
|
||||||
return true;
|
|
||||||
} else if (this.get('clientUri') != null && this.get('clientUri').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (this.get('contacts') != null) {
|
|
||||||
var f = _.filter(this.get('contacts'), function(item) {
|
|
||||||
return item.toLowerCase().indexOf(term.toLowerCase()) != -1;
|
|
||||||
});
|
|
||||||
if (f.length > 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (this.get('clientName') != null && this.get('clientName').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('name');
|
||||||
|
}
|
||||||
|
if (this.get('clientDescription') != null && this.get('clientDescription').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('description');
|
||||||
|
}
|
||||||
|
if (this.get('clientUri') != null && this.get('clientUri').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('homepage');
|
||||||
|
}
|
||||||
|
if (this.get('policyUri') != null && this.get('policyUri').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('policy');
|
||||||
|
}
|
||||||
|
if (this.get('tosUri') != null && this.get('tosUri').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('terms of service');
|
||||||
|
}
|
||||||
|
if (this.get('logoUri') != null && this.get('logoUri').toLowerCase().indexOf(term.toLowerCase()) != -1) {
|
||||||
|
matches.push('logo');
|
||||||
|
}
|
||||||
|
if (this.get('contacts') != null) {
|
||||||
|
var f = _.filter(this.get('contacts'), function(item) {
|
||||||
|
return item.toLowerCase().indexOf(term.toLowerCase()) != -1;
|
||||||
|
});
|
||||||
|
if (f.length > 0) {
|
||||||
|
matches.push('contacts');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.get('redirectUris') != null) {
|
||||||
|
var f = _.filter(this.get('redirectUris'), function (item) {
|
||||||
|
return item.toLowerCase().indexOf(term.toLowerCase()) != -1;
|
||||||
|
});
|
||||||
|
if (f.length > 0) {
|
||||||
|
matches.push('redirect uri');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.get('scope') != null) {
|
||||||
|
var f = _.filter(this.get('scope'), function (item) {
|
||||||
|
return item.toLowerCase().indexOf(term.toLowerCase()) != -1;
|
||||||
|
});
|
||||||
|
if (f.length > 0) {
|
||||||
|
matches.push('scope');
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
// there's no search term, we always match
|
||||||
|
|
||||||
|
this.unset('matches', {silent: true});
|
||||||
|
console.log('no term');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var matchString = matches.join(' | ');
|
||||||
|
|
||||||
|
if (matches.length > 0) {
|
||||||
|
this.set({
|
||||||
|
matches: matchString
|
||||||
|
}, {silent: true});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.unset('matches', {silent: true});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -200,9 +244,23 @@ var ClientView = Backbone.View.extend({
|
||||||
this.$('.dynamically-registered').tooltip({title: 'This client was dynamically registered'});
|
this.$('.dynamically-registered').tooltip({title: 'This client was dynamically registered'});
|
||||||
this.$('.allow-introspection').tooltip({title: 'This client can perform token introspection'});
|
this.$('.allow-introspection').tooltip({title: 'This client can perform token introspection'});
|
||||||
|
|
||||||
|
this.updateMatched();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateMatched:function() {
|
||||||
|
|
||||||
|
console.log(this.model.get('matches'));
|
||||||
|
|
||||||
|
if (this.model.get('matches')) {
|
||||||
|
$('.matched', this.el).show();
|
||||||
|
$('.matched span', this.el).html(this.model.get('matches'));
|
||||||
|
} else {
|
||||||
|
$('.matched', this.el).hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
"click .btn-edit":"editClient",
|
"click .btn-edit":"editClient",
|
||||||
"click .btn-delete":"deleteClient",
|
"click .btn-delete":"deleteClient",
|
||||||
|
@ -444,13 +502,9 @@ var ClientListView = Backbone.View.extend({
|
||||||
searchTable:function(e) {
|
searchTable:function(e) {
|
||||||
var term = $('.search-query', this.el).val();
|
var term = $('.search-query', this.el).val();
|
||||||
|
|
||||||
if (term) {
|
this.filteredModel = new ClientCollection(this.model.filter(function(client) {
|
||||||
this.filteredModel = new ClientCollection(this.model.filter(function(client) {
|
return client.matches(term);
|
||||||
return client.matches(term);
|
}));
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
this.filteredModel = this.model;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear out the table
|
// clear out the table
|
||||||
$('tbody', this.el).html('');
|
$('tbody', this.el).html('');
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
<small class="muted" title="<%= hoverCreationDate %>">Registered <%= displayCreationDate %></small>
|
<small class="muted" title="<%= hoverCreationDate %>">Registered <%= displayCreationDate %></small>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="matched text-info">
|
||||||
|
<small><i>Matched: <span class="label"></span></i></small>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
Loading…
Reference in New Issue