mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Add search feature to SSL Certificates
This commit is contained in:
parent
de84d5d463
commit
29c0fcbad6
@ -3,6 +3,14 @@
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title"><%- i18n('certificates', 'title') %></h3>
|
<h3 class="card-title"><%- i18n('certificates', 'title') %></h3>
|
||||||
<div class="card-options">
|
<div class="card-options">
|
||||||
|
<form class="search-form" role="search">
|
||||||
|
<div class="input-icon">
|
||||||
|
<span class="input-icon-addon">
|
||||||
|
<i class="fe fe-search"></i>
|
||||||
|
</span>
|
||||||
|
<input name="source-query" type="text" value="" class="form-control form-control-sm" placeholder="Search Certificates…" aria-label="Search in SSL Certificates">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<a href="#" class="btn btn-outline-secondary btn-sm ml-2 help"><i class="fe fe-help-circle"></i></a>
|
<a href="#" class="btn btn-outline-secondary btn-sm ml-2 help"><i class="fe fe-help-circle"></i></a>
|
||||||
<% if (showAddButton) { %>
|
<% if (showAddButton) { %>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
|
@ -14,7 +14,44 @@ module.exports = Mn.View.extend({
|
|||||||
list_region: '.list-region',
|
list_region: '.list-region',
|
||||||
add: '.add-item',
|
add: '.add-item',
|
||||||
help: '.help',
|
help: '.help',
|
||||||
dimmer: '.dimmer'
|
dimmer: '.dimmer',
|
||||||
|
search: '.search-form',
|
||||||
|
query: 'input[name="source-query"]'
|
||||||
|
},
|
||||||
|
|
||||||
|
fetch: App.Api.Nginx.Certificates.getAll,
|
||||||
|
|
||||||
|
showData: function(response) {
|
||||||
|
this.showChildView('list_region', new ListView({
|
||||||
|
collection: new CertificateModel.Collection(response)
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
showError: function(err) {
|
||||||
|
this.showChildView('list_region', new ErrorView({
|
||||||
|
code: err.code,
|
||||||
|
message: err.message,
|
||||||
|
retry: function () {
|
||||||
|
App.Controller.showNginxCertificates();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.error(err);
|
||||||
|
},
|
||||||
|
|
||||||
|
showEmpty: function() {
|
||||||
|
let manage = App.Cache.User.canManage('certificates');
|
||||||
|
|
||||||
|
this.showChildView('list_region', new EmptyView({
|
||||||
|
title: App.i18n('certificates', 'empty'),
|
||||||
|
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
|
||||||
|
link: manage ? App.i18n('certificates', 'add') : null,
|
||||||
|
btn_color: 'pink',
|
||||||
|
permission: 'certificates',
|
||||||
|
action: function () {
|
||||||
|
App.Controller.showNginxCertificateForm();
|
||||||
|
}
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
regions: {
|
regions: {
|
||||||
@ -31,6 +68,17 @@ module.exports = Mn.View.extend({
|
|||||||
'click @ui.help': function (e) {
|
'click @ui.help': function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
App.Controller.showHelp(App.i18n('certificates', 'help-title'), App.i18n('certificates', 'help-content'));
|
App.Controller.showHelp(App.i18n('certificates', 'help-title'), App.i18n('certificates', 'help-content'));
|
||||||
|
},
|
||||||
|
|
||||||
|
'submit @ui.search': function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
let query = this.ui.query.val();
|
||||||
|
|
||||||
|
this.fetch(['owner'], query)
|
||||||
|
.then(response => this.showData(response))
|
||||||
|
.catch(err => {
|
||||||
|
this.showError(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -41,39 +89,18 @@ module.exports = Mn.View.extend({
|
|||||||
onRender: function () {
|
onRender: function () {
|
||||||
let view = this;
|
let view = this;
|
||||||
|
|
||||||
App.Api.Nginx.Certificates.getAll(['owner'])
|
view.fetch(['owner'])
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!view.isDestroyed()) {
|
if (!view.isDestroyed()) {
|
||||||
if (response && response.length) {
|
if (response && response.length) {
|
||||||
view.showChildView('list_region', new ListView({
|
view.showData(response);
|
||||||
collection: new CertificateModel.Collection(response)
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
let manage = App.Cache.User.canManage('certificates');
|
view.showEmpty();
|
||||||
|
|
||||||
view.showChildView('list_region', new EmptyView({
|
|
||||||
title: App.i18n('certificates', 'empty'),
|
|
||||||
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
|
|
||||||
link: manage ? App.i18n('certificates', 'add') : null,
|
|
||||||
btn_color: 'pink',
|
|
||||||
permission: 'certificates',
|
|
||||||
action: function () {
|
|
||||||
App.Controller.showNginxCertificateForm();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
view.showChildView('list_region', new ErrorView({
|
view.showError(err);
|
||||||
code: err.code,
|
|
||||||
message: err.message,
|
|
||||||
retry: function () {
|
|
||||||
App.Controller.showNginxCertificates();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
console.error(err);
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
view.ui.dimmer.removeClass('active');
|
view.ui.dimmer.removeClass('active');
|
||||||
|
Loading…
Reference in New Issue
Block a user