diff --git a/src/js/yunohost/controllers/domains.js b/src/js/yunohost/controllers/domains.js index bfd41e2f..17df4f75 100644 --- a/src/js/yunohost/controllers/domains.js +++ b/src/js/yunohost/controllers/domains.js @@ -97,14 +97,52 @@ } }); - var domain = { name: c.params['domain'], main: (c.params['domain'] == dataMain.current_main_domain) ? true : false, url: "https://"+c.params['domain'], enable_cert_management: enable_cert_management_ }; - c.view('domain/domain_info', domain); + c.view('domain/domain_info', domain, function() { + + // Configure "set default" button + $('button[data-action="set_default"]').on("click", function() { + var domain = $(this).data("domain"); + c.confirm( + y18n.t('domains'), + y18n.t('confirm_change_maindomain'), + function() { + var params = { + new_domain: c.params['domain'] + }; + c.api('PUT', '/domains/main', params, function(data) { + c.redirect_to('#/domains'); + }); + + // WTF ... why is this hack needed v_v + + // Wait 15s and refresh the page + var refreshDomain = window.setTimeout(function(){ + c.redirect_to('#/domains'); + }, 15000); + } + ); + }); + + // Configure delete button + $('button[data-action="delete"]').on("click", function() { + var domain = $(this).data("domain"); + c.confirm( + y18n.t('domains'), + y18n.t('confirm_delete', [domain]), + function(){ + c.api('DELETE', '/domains/'+ domain, {}, function(data) { + c.redirect_to('#/domains'); + }); + } + ); + }); + }); }); }); }); @@ -241,46 +279,4 @@ }); }); - - // Remove existing domain - app.get('#/domains/:domain/delete', function (c) { - c.confirm( - y18n.t('domains'), - y18n.t('confirm_delete', [c.params['domain']]), - function(){ - c.api('DELETE', '/domains/'+ c.params['domain'], {}, function(data) { - c.redirect_to('#/domains'); - }); - } - ); - }); - - // Set default domain - app.post('#/domains', function (c) { - if (c.params['domain'] === '') { - c.flash('fail', y18n.t('error_select_domain')); - c.redirect_to('#/domains', {slide:false}); - } else { - c.confirm( - y18n.t('domains'), - y18n.t('confirm_change_maindomain'), - function(){ - var params = { - new_domain: c.params['domain'] - }; - c.api('PUT', '/domains/main', params, function(data) { - c.redirect_to('#/domains'); - }); - - // WTF ... why is this hack needed v_v - - // Wait 15s and refresh the page - var refreshDomain = window.setTimeout(function(){ - c.redirect_to('#/domains'); - }, 15000); - } - ); - } - }); - })(); diff --git a/src/views/domain/domain_info.ms b/src/views/domain/domain_info.ms index 6eed7627..f22bd3c0 100644 --- a/src/views/domain/domain_info.ms +++ b/src/views/domain/domain_info.ms @@ -40,12 +40,9 @@
{{t 'domain_default_desc'}}
- +{{t 'domain_delete_longdesc' name}}
- + +