mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Mooooar buttons (firewall view)
This commit is contained in:
parent
7ac8f61cdb
commit
4b5d64f8ef
2 changed files with 51 additions and 54 deletions
|
@ -30,23 +30,53 @@
|
||||||
// Get UPnP status
|
// Get UPnP status
|
||||||
firewall.upnp = data.uPnP.enabled;
|
firewall.upnp = data.uPnP.enabled;
|
||||||
|
|
||||||
c.view('tools/tools_firewall', firewall);
|
c.view('tools/tools_firewall', firewall, function() {
|
||||||
|
|
||||||
|
// Buttons in the 'ports' panel to open/close specific ports
|
||||||
|
$("button[data-port]").on("click", function() {
|
||||||
|
|
||||||
|
var port = $(this).data("port");
|
||||||
|
var action = $(this).data("action");
|
||||||
|
var protocol = $(this).data("protocol");
|
||||||
|
var connection = $(this).data("connection");
|
||||||
|
c.confirm(
|
||||||
|
y18n.t('firewall'),
|
||||||
|
// confirm_firewall_open and confirm_firewall_close
|
||||||
|
y18n.t('confirm_firewall_' + action, [ port, y18n.t(protocol), y18n.t(connection)]),
|
||||||
|
function(){ c.togglePort(port, protocol, connection, action); }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Buttons to enable / disable UPnP
|
||||||
|
$("button[data-upnp]").on("click", function() {
|
||||||
|
var action = $(this).data("upnp");
|
||||||
|
c.confirm(
|
||||||
|
y18n.t('firewall'),
|
||||||
|
// confirm_upnp_enable and confirm_upnp_disable
|
||||||
|
y18n.t('confirm_upnp_' + action),
|
||||||
|
function(){
|
||||||
|
c.api('GET', '/firewall/upnp', {action: action}, function(data) {
|
||||||
|
c.redirect_to('#/tools/firewall');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enable/Disable UPnP
|
// Update port status from form
|
||||||
app.get('#/tools/firewall/upnp/:action', function (c) {
|
app.post('#/tools/firewall/port', function (c) {
|
||||||
c.confirm(
|
c.confirm(
|
||||||
y18n.t('firewall'),
|
y18n.t('firewall'),
|
||||||
// confirm_upnp_enable and confirm_upnp_disable
|
y18n.t('confirm_firewall_' + c.params['action'].toLowerCase(), [ c.params['port'], y18n.t(c.params['protocol']), y18n.t(c.params['connection']) ]),
|
||||||
y18n.t('confirm_upnp_' + c.params['action'].toLowerCase()),
|
|
||||||
function(){
|
function(){
|
||||||
var params = {
|
c.togglePort(
|
||||||
action : c.params['action']
|
c.params['port'],
|
||||||
};
|
c.params['protocol'],
|
||||||
c.api('GET', '/firewall/upnp', params, function(data) {
|
c.params['connection'],
|
||||||
c.redirect_to('#/tools/firewall');
|
c.params['action']
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -118,38 +148,5 @@
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update port status from direct link
|
|
||||||
// #/firewall/port/{{@key}}/tcp/ipv4/close
|
|
||||||
app.get('#/tools/firewall/port/:port/:protocol/:connection/:action', function (c) {
|
|
||||||
c.confirm(
|
|
||||||
y18n.t('firewall'),
|
|
||||||
// confirm_firewall_open and confirm_firewall_close
|
|
||||||
y18n.t( 'confirm_firewall_' + c.params['action'].toLowerCase(), [ c.params['port'], y18n.t(c.params['protocol']), y18n.t(c.params['connection'])]),
|
|
||||||
function(){
|
|
||||||
c.togglePort(
|
|
||||||
c.params['port'],
|
|
||||||
c.params['protocol'],
|
|
||||||
c.params['connection'],
|
|
||||||
c.params['action']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update port status from form
|
|
||||||
app.post('#/tools/firewall/port', function (c) {
|
|
||||||
c.confirm(
|
|
||||||
y18n.t('firewall'),
|
|
||||||
y18n.t('confirm_firewall_' + c.params['action'].toLowerCase(), [ c.params['port'], y18n.t(c.params['protocol']), y18n.t(c.params['connection']) ]),
|
|
||||||
function(){
|
|
||||||
c.togglePort(
|
|
||||||
c.params['port'],
|
|
||||||
c.params['protocol'],
|
|
||||||
c.params['connection'],
|
|
||||||
c.params['action']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -29,20 +29,20 @@
|
||||||
<td>
|
<td>
|
||||||
{{#if this.ipv4}}
|
{{#if this.ipv4}}
|
||||||
<span class="fa-check"></span>
|
<span class="fa-check"></span>
|
||||||
<a class="btn btn-xs btn-danger" href="#/tools/firewall/port/{{@key}}/tcp/ipv4/close">{{t 'close'}}</a>
|
<button class="btn btn-xs btn-danger" data-action="close" data-port="{{@key}}" data-protocol="tcp" data-connection="ipv4">{{t 'close'}}</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span></span>
|
<span></span>
|
||||||
<span class="fa-times"></span>
|
<span class="fa-times"></span>
|
||||||
<a class="btn btn-xs btn-success" href="#/tools/firewall/port/{{@key}}/tcp/ipv4/open">{{t 'open'}}</a>
|
<button class="btn btn-xs btn-success" data-action="open" data-port="{{@key}}" data-protocol="tcp" data-connection="ipv4">{{t 'open'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{#if this.ipv6}}
|
{{#if this.ipv6}}
|
||||||
<span class="fa-check"></span>
|
<span class="fa-check"></span>
|
||||||
<a class="btn btn-xs btn-danger" href="#/tools/firewall/port/{{@key}}/tcp/ipv6/close">{{t 'close'}}</a>
|
<button class="btn btn-xs btn-danger" data-action="close" data-port="{{@key}}" data-protocol="tcp" data-connection="ipv6">{{t 'close'}}</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="fa-times"></span>
|
<span class="fa-times"></span>
|
||||||
<a class="btn btn-xs btn-success" href="#/tools/firewall/port/{{@key}}/tcp/ipv6/open">{{t 'open'}}</a>
|
<button class="btn btn-xs btn-success" data-action="open" data-port="{{@key}}" data-protocol="tcp" data-connection="ipv6">{{t 'open'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -75,20 +75,20 @@
|
||||||
<td>
|
<td>
|
||||||
{{#if this.ipv4}}
|
{{#if this.ipv4}}
|
||||||
<span class="fa-check"></span>
|
<span class="fa-check"></span>
|
||||||
<a class="btn btn-xs btn-danger" href="#/tools/firewall/port/{{@key}}/udp/ipv4/close">{{t 'close'}}</a>
|
<button class="btn btn-xs btn-danger" data-action="close" data-port="{{@key}}" data-protocol="udp" data-connection="ipv4">{{t 'close'}}</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span></span>
|
<span></span>
|
||||||
<span class="fa-times"></span>
|
<span class="fa-times"></span>
|
||||||
<a class="btn btn-xs btn-success" href="#/tools/firewall/port/{{@key}}/udp/ipv4/open">{{t 'open'}}</a>
|
<button class="btn btn-xs btn-success" data-action="open" data-port="{{@key}}" data-protocol="udp" data-connection="ipv4">{{t 'open'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{#if this.ipv6}}
|
{{#if this.ipv6}}
|
||||||
<span class="fa-check"></span>
|
<span class="fa-check"></span>
|
||||||
<a class="btn btn-xs btn-danger" href="#/tools/firewall/port/{{@key}}/udp/ipv6/close">{{t 'close'}}</a>
|
<button class="btn btn-xs btn-danger" data-action="close" data-port="{{@key}}" data-protocol="udp" data-connection="ipv6">{{t 'close'}}</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="fa-times"></span>
|
<span class="fa-times"></span>
|
||||||
<a class="btn btn-xs btn-success" href="#/tools/firewall/port/{{@key}}/udp/ipv6/open">{{t 'open'}}</a>
|
<button class="btn btn-xs btn-success" data-action="open" data-port="{{@key}}" data-protocol="udp" data-connection="ipv6">{{t 'open'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -168,10 +168,10 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{#if upnp}}
|
{{#if upnp}}
|
||||||
<p class="text-success">{{t 'upnp_enabled'}}</p>
|
<p class="text-success">{{t 'upnp_enabled'}}</p>
|
||||||
<a role="button" href="#/tools/firewall/upnp/disable" class="btn btn-danger">{{t 'disable'}}</a>
|
<button class="btn btn-danger" data-upnp="disable">{{t 'disable'}}</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p class="text-danger">{{t 'upnp_disabled'}}</p>
|
<p class="text-danger">{{t 'upnp_disabled'}}</p>
|
||||||
<a role="button" href="#/tools/firewall/upnp/enable" class="btn btn-success">{{t 'enable'}}</a>
|
<button class="btn btn-success" data-upnp="enable">{{t 'enable'}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue