mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Moaaaar buttons (certificate management view)
This commit is contained in:
parent
266e349d1f
commit
3f8aff1a99
2 changed files with 48 additions and 61 deletions
|
@ -198,62 +198,49 @@
|
|||
status: status_,
|
||||
actions_enabled : actions_enabled
|
||||
};
|
||||
c.view('domain/domain_cert', data_);
|
||||
c.view('domain/domain_cert', data_, function() {
|
||||
// Configure install / renew buttons behavior
|
||||
$("button[data-action]").on("click", function () {
|
||||
var action = $(this).data("action"),
|
||||
domain = $(this).data("domain"),
|
||||
confirm_key = "",
|
||||
api_url = "";
|
||||
|
||||
switch (action) {
|
||||
case 'install-LE':
|
||||
confirm_key = 'confirm_cert_install_LE';
|
||||
api_url = '/domains/cert-install/' + domain;
|
||||
break;
|
||||
case 'regen-selfsigned':
|
||||
confirm_key = 'confirm_cert_regen_selfsigned';
|
||||
api_url = '/domains/cert-install/' + domain + "?self_signed";
|
||||
break;
|
||||
case 'renew-letsencrypt':
|
||||
confirm_key = 'confirm_cert_manual_renew_LE';
|
||||
api_url = '/domains/cert-renew/' + domain + "?force";
|
||||
break;
|
||||
case 'replace-with-selfsigned':
|
||||
confirm_key = 'confirm_cert_revert_to_selfsigned';
|
||||
api_url = '/domains/cert-install/' + domain + "?self_signed&force";
|
||||
break;
|
||||
default:
|
||||
c.flash('fail', y18n.t('unknown_action', [action]));
|
||||
return
|
||||
}
|
||||
|
||||
c.confirm(
|
||||
y18n.t('certificate'),
|
||||
y18n.t(confirm_key, [domain]),
|
||||
function(){
|
||||
c.api('POST', api_url, {}, function(data) {
|
||||
c.redirect_to('#/domains/'+domain+'/cert-management', {slide:false});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Install let's encrypt certificate on domain
|
||||
app.get('#/domains/:domain/cert-install-LE', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('certificate'),
|
||||
y18n.t('confirm_cert_install_LE', [c.params['domain']]),
|
||||
function(){
|
||||
c.api('POST', '/domains/cert-install/' + c.params['domain'], {}, function(data) {
|
||||
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Regenerate a self-signed certificate
|
||||
app.get('#/domains/:domain/cert-regen-selfsigned', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('certificate'),
|
||||
y18n.t('confirm_cert_regen_selfsigned', [c.params['domain']]),
|
||||
function(){
|
||||
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed", {}, function(data) {
|
||||
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Manually renew a Let's Encrypt certificate
|
||||
app.get('#/domains/:domain/cert-renew-letsencrypt', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('certificate'),
|
||||
y18n.t('confirm_cert_manual_renew_LE', [c.params['domain']]),
|
||||
function(){
|
||||
c.api('POST', '/domains/cert-renew/' + c.params['domain'] + "?force", {}, function(data) {
|
||||
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Replace valid cert with self-signed
|
||||
app.get('#/domains/:domain/cert-replace-with-selfsigned', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('certificate'),
|
||||
y18n.t('confirm_cert_revert_to_selfsigned', [c.params['domain']]),
|
||||
function(){
|
||||
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed&force", {}, function(data) {
|
||||
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// Remove existing domain
|
||||
app.get('#/domains/:domain/delete', function (c) {
|
||||
|
|
|
@ -46,36 +46,36 @@
|
|||
<p><span class="fa-fw fa-meh-o"></span>
|
||||
{{t 'domain_not_eligible_for_ACME'}}</p>
|
||||
{{/if}}
|
||||
<a role="button" href="#/domains/{{name}}/cert-install-LE" class="btn btn-success {{#unless status.ACME_eligible}}disabled{{/unless}}">
|
||||
<button class="btn btn-success {{#unless status.ACME_eligible}}disabled{{/unless}}" data-domain="{{name}}" data-action="install-LE" >
|
||||
<span class="fa-star"></span> {{t 'install_letsencrypt_cert'}}
|
||||
</a>
|
||||
</button>
|
||||
<hr>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if actions_enabled.manual_renew_letsencrpt}}
|
||||
<div class="container">
|
||||
<p>{{t 'manually_renew_letsencrypt_message'}}</p>
|
||||
<a role="button" href="#/domains/{{name}}/cert-renew-letsencrypt" class="btn btn-warning">
|
||||
<button class="btn btn-warning" data-domain="{{name}}" data-action="renew-letsencrypt">
|
||||
<span class="fa-refresh"></span> {{t 'manually_renew_letsencrypt'}}
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{#if actions_enabled.regen_selfsigned}}
|
||||
<div class="container">
|
||||
<p>{{t 'regenerate_selfsigned_cert_message'}}</p>
|
||||
<a href="#/domains/{{name}}/cert-regen-selfsigned" role="button" class="btn btn-warning">
|
||||
<button class="btn btn-warning" data-domain="{{name}}" data-action="regen-selfsigned">
|
||||
<span class="fa-refresh"></span> {{t 'regenerate_selfsigned_cert'}}
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{#if actions_enabled.replace_with_selfsigned}}
|
||||
<div class="container">
|
||||
<p>{{t 'revert_to_selfsigned_cert_message'}}</p>
|
||||
<a href="#/domains/{{name}}/cert-replace-with-selfsigned" role="button" class="btn btn-danger">
|
||||
<button class="btn btn-danger" data-domain="{{name}}" data-action="replace-with-selfsigned">
|
||||
<span class="fa-exclamation-triangle"></span> {{t 'revert_to_selfsigned_cert'}}
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue